FBX C++ API Reference
fbxcolladaelement.h File Reference
#include <fbxsdk.h>
#include <fbxsdk/fbxsdk_nsbegin.h>
#include <fbxsdk/fbxsdk_nsend.h>

Go to the source code of this file.

Classes

struct  ElementContentAccessor
 A struct for convenient access to the content of common COLLADA element. More...
 
struct  SourceElementContentAccessor< TYPE >
 A struct for convenient access to the content of COLLADA source element. More...
 
class  ElementBase
 Representing a common COLLADA element. More...
 

Functions

template<typename T >
const FbxString TypeToArrayTag ()
 
template<>
const FbxString TypeToArrayTag< bool > ()
 
template<>
const FbxString TypeToArrayTag< int > ()
 
template<>
const FbxString TypeToArrayTag< FbxString > ()
 
template<typename T >
const FbxString TypeToParameterTag ()
 
template<>
const FbxString TypeToParameterTag< bool > ()
 
template<>
const FbxString TypeToParameterTag< int > ()
 
template<>
const FbxString TypeToParameterTag< FbxString > ()
 
const FbxString URL (const FbxString &pID)
 Convert from ID to URL, just add a prefix "#". More...
 
template<typename T >
xmlNode * AddSourceElement (xmlNode *pParentElement, const char *pID, const T *pData, int pCount, int pStride=1)
 Convert the array data to a source element under specific parent element. More...
 
template<typename TYPE >
FbxLayerElementArrayPopulateLayerElementDirectArray (FbxLayerElement *pLayerElement, xmlNode *pSourceElement, int pSize)
 Populate the layer element with direct array and return index array for later use. More...
 

Function Documentation

const FbxString TypeToArrayTag ( )
inline

Definition at line 22 of file fbxcolladaelement.h.

23 {
25 }
#define COLLADA_FLOAT_ARRAY_STRUCTURE
const FbxString TypeToArrayTag< bool > ( )
inline

Definition at line 28 of file fbxcolladaelement.h.

29 {
31 }
#define COLLADA_BOOL_ARRAY_STRUCTURE
const FbxString TypeToArrayTag< int > ( )
inline

Definition at line 34 of file fbxcolladaelement.h.

35 {
37 }
#define COLLADA_INT_ARRAY_STRUCTURE
const FbxString TypeToArrayTag< FbxString > ( )
inline

Definition at line 40 of file fbxcolladaelement.h.

41 {
43 }
#define COLLADA_NAME_ARRAY_STRUCTURE
const FbxString TypeToParameterTag ( )
inline

Definition at line 47 of file fbxcolladaelement.h.

48 {
49  return COLLADA_FLOAT_TYPE;
50 }
#define COLLADA_FLOAT_TYPE
const FbxString TypeToParameterTag< bool > ( )
inline

Definition at line 53 of file fbxcolladaelement.h.

54 {
55  return COLLADA_BOOL_TYPE;
56 }
#define COLLADA_BOOL_TYPE
const FbxString TypeToParameterTag< int > ( )
inline

Definition at line 59 of file fbxcolladaelement.h.

60 {
61  return COLLADA_INT_TYPE;
62 }
#define COLLADA_INT_TYPE
const FbxString TypeToParameterTag< FbxString > ( )
inline

Definition at line 65 of file fbxcolladaelement.h.

66 {
67  return COLLADA_NAME_TYPE;
68 }
#define COLLADA_NAME_TYPE
const FbxString URL ( const FbxString pID)
inline

Convert from ID to URL, just add a prefix "#".

Parameters
pIDThe ID string.
Returns
Return the URL string.

Definition at line 206 of file fbxcolladaelement.h.

207 {
208  return FbxString("#") + pID;
209 }
Utility class to manipulate strings.
Definition: fbxstring.h:66
xmlNode* AddSourceElement ( xmlNode *  pParentElement,
const char *  pID,
const T *  pData,
int  pCount,
int  pStride = 1 
)

Convert the array data to a source element under specific parent element.

Parameters
pParentElementThe parent element.
pIDThe ID of the new source element.
pDataThe array data.
pCountThe length of the array.
pStrideThe stride of each unit in the array. For example, when you export an array of FbxDouble3 of size 10, you convert it to a double array of size 30 with a stride 3 and call this method.
Returns
The new source element.

Definition at line 222 of file fbxcolladaelement.h.

224 {
225  FBX_ASSERT(pParentElement && pData);
226  if (!pParentElement || !pData)
227  return NULL;
228 
229  xmlNode * lSourceElement = DAE_AddChildElement(pParentElement, COLLADA_SOURCE_STRUCTURE);
230  DAE_AddAttribute(lSourceElement, COLLADA_ID_PROPERTY, pID);
231 
232  FbxString lContent;
233  const int lDataCount = pCount * pStride;
234  for (int lIndex = 0; lIndex < lDataCount; ++lIndex)
235  {
236  lContent += ToString(pData[lIndex]);
237  if (lIndex != lDataCount - 1)
238  lContent += " ";
239  }
240  const FbxString lArrayID = FbxString(pID) + "-array";
241  xmlNode * lArrayElement = DAE_AddChildElement(lSourceElement, TypeToArrayTag<T>(), lContent);
242  DAE_AddAttribute(lArrayElement, COLLADA_ID_PROPERTY, lArrayID);
243  DAE_AddAttribute(lArrayElement, COLLADA_COUNT_PROPERTY, lDataCount);
244 
245  xmlNode * lTechniqueCommonElement = DAE_AddChildElement(lSourceElement,
247  xmlNode * lAccessElement = DAE_AddChildElement(lTechniqueCommonElement,
249  DAE_AddAttribute(lAccessElement, COLLADA_SOURCE_PROPERTY, URL(lArrayID));
250  DAE_AddAttribute(lAccessElement, COLLADA_COUNT_PROPERTY, pCount);
251  DAE_AddAttribute(lAccessElement, COLLADA_STRIDE_PROPERTY, pStride);
252 
253  for (int lStrideIndex = 0; lStrideIndex < pStride; ++lStrideIndex)
254  {
255  xmlNode * lParamElement = DAE_AddChildElement(lAccessElement, COLLADA_PARAMETER_STRUCTURE);
256  DAE_AddAttribute(lParamElement, COLLADA_TYPE_PROPERTY, TypeToParameterTag<T>());
257  }
258 
259  return lSourceElement;
260 }
#define COLLADA_ACCESSOR_STRUCTURE
const FbxString URL(const FbxString &pID)
Convert from ID to URL, just add a prefix "#".
const FbxString ToString(const T &pValue)
#define COLLADA_COUNT_PROPERTY
#define COLLADA_PARAMETER_STRUCTURE
#define NULL
Definition: fbxarch.h:213
#define COLLADA_STRIDE_PROPERTY
Utility class to manipulate strings.
Definition: fbxstring.h:66
#define COLLADA_SOURCE_STRUCTURE
#define COLLADA_ID_PROPERTY
xmlNode * DAE_AddChildElement(xmlNode *pParentElement, const char *pTag, const T &pContent)
Add a child element with specific content.
#define COLLADA_TYPE_PROPERTY
#define COLLADA_SOURCE_PROPERTY
#define COLLADA_TECHNIQUE_COMMON_ELEMENT
xmlAttr * DAE_AddAttribute(xmlNode *pElement, const FbxString &pAttributeName, const T &pAttributeValue)
Add an attribute for a element.
FbxLayerElementArray* PopulateLayerElementDirectArray ( FbxLayerElement pLayerElement,
xmlNode *  pSourceElement,
int  pSize 
)

Populate the layer element with direct array and return index array for later use.

Parameters
pLayerElementThe layer element to be populated.
pSourceElementThe source element containing the direct array data.
pSizeThe count of double data of direct array element.
Returns
Return the index array of the layer element.

Definition at line 268 of file fbxcolladaelement.h.

269 {
270  SourceElementContentAccessor<TYPE> lSourceElementAccessor(pSourceElement);
271 
272  FbxLayerElementTemplate<TYPE> * lLayerElement = (FbxLayerElementTemplate<TYPE> *)pLayerElement;
275  lLayerElement->GetDirectArray().SetCount(lSourceElementAccessor.mCount);
276 
277  TYPE * lArray = NULL;
278  lArray = lLayerElement->GetDirectArray().GetLocked(lArray);
279  lSourceElementAccessor.GetArray((double *)lArray, lSourceElementAccessor.mCount*pSize, 0, pSize,
280  lSourceElementAccessor.mStride, 0, pSize, sizeof(TYPE)/sizeof(double), 1.0);
281  lLayerElement->GetDirectArray().Release(&lArray, lArray);
282 
283  return &(lLayerElement->GetIndexArray());
284 }
FbxLayerElementArrayTemplate< int > & GetIndexArray() const
Returns the index array of Layer Elements.
Definition: fbxlayer.h:1070
void SetReferenceMode(EReferenceMode pReferenceMode)
Sets the Reference Mode.
Definition: fbxlayer.h:179
A struct for convenient access to the content of COLLADA source element.
#define NULL
Definition: fbxarch.h:213
FbxLayerElementArrayTemplate< Type > & GetDirectArray() const
Returns the direct array of Layer Elements.
Definition: fbxlayer.h:1050
void SetMappingMode(EMappingMode pMappingMode)
Sets the Mapping Mode.
Definition: fbxlayer.h:174
This class complements the FbxLayerElement class.
Definition: fbxlayer.h:1042