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

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

◆ TypeToArrayTag()

const FbxString TypeToArrayTag ( )
inline

Definition at line 22 of file fbxcolladaelement.h.

23 {
25 }
#define COLLADA_FLOAT_ARRAY_STRUCTURE

◆ TypeToArrayTag< bool >()

const FbxString TypeToArrayTag< bool > ( )
inline

Definition at line 28 of file fbxcolladaelement.h.

29 {
31 }
#define COLLADA_BOOL_ARRAY_STRUCTURE

◆ TypeToArrayTag< int >()

const FbxString TypeToArrayTag< int > ( )
inline

Definition at line 34 of file fbxcolladaelement.h.

35 {
37 }
#define COLLADA_INT_ARRAY_STRUCTURE

◆ TypeToArrayTag< FbxString >()

const FbxString TypeToArrayTag< FbxString > ( )
inline

Definition at line 40 of file fbxcolladaelement.h.

41 {
43 }
#define COLLADA_NAME_ARRAY_STRUCTURE

◆ TypeToParameterTag()

const FbxString TypeToParameterTag ( )
inline

Definition at line 47 of file fbxcolladaelement.h.

48 {
49  return COLLADA_FLOAT_TYPE;
50 }
#define COLLADA_FLOAT_TYPE

◆ TypeToParameterTag< bool >()

const FbxString TypeToParameterTag< bool > ( )
inline

Definition at line 53 of file fbxcolladaelement.h.

54 {
55  return COLLADA_BOOL_TYPE;
56 }
#define COLLADA_BOOL_TYPE

◆ TypeToParameterTag< int >()

const FbxString TypeToParameterTag< int > ( )
inline

Definition at line 59 of file fbxcolladaelement.h.

60 {
61  return COLLADA_INT_TYPE;
62 }
#define COLLADA_INT_TYPE

◆ TypeToParameterTag< FbxString >()

const FbxString TypeToParameterTag< FbxString > ( )
inline

Definition at line 65 of file fbxcolladaelement.h.

66 {
67  return COLLADA_NAME_TYPE;
68 }
#define COLLADA_NAME_TYPE

◆ URL()

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 193 of file fbxcolladaelement.h.

194 {
195  return FbxString("#") + pID;
196 }
Utility class to manipulate strings.
Definition: fbxstring.h:66

◆ AddSourceElement()

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 209 of file fbxcolladaelement.h.

211 {
212  FBX_ASSERT(pParentElement && pData);
213  if (!pParentElement || !pData)
214  return NULL;
215 
216  xmlNode * lSourceElement = DAE_AddChildElement(pParentElement, COLLADA_SOURCE_STRUCTURE);
217  DAE_AddAttribute(lSourceElement, COLLADA_ID_PROPERTY, pID);
218 
219  FbxString lContent;
220  const int lDataCount = pCount * pStride;
221  for (int lIndex = 0; lIndex < lDataCount; ++lIndex)
222  {
223  lContent += ToString(pData[lIndex]);
224  if (lIndex != lDataCount - 1)
225  lContent += " ";
226  }
227  const FbxString lArrayID = FbxString(pID) + "-array";
228  xmlNode * lArrayElement = DAE_AddChildElement(lSourceElement, TypeToArrayTag<T>(), lContent);
229  DAE_AddAttribute(lArrayElement, COLLADA_ID_PROPERTY, lArrayID);
230  DAE_AddAttribute(lArrayElement, COLLADA_COUNT_PROPERTY, lDataCount);
231 
232  xmlNode * lTechniqueCommonElement = DAE_AddChildElement(lSourceElement,
234  xmlNode * lAccessElement = DAE_AddChildElement(lTechniqueCommonElement,
236  DAE_AddAttribute(lAccessElement, COLLADA_SOURCE_PROPERTY, URL(lArrayID));
237  DAE_AddAttribute(lAccessElement, COLLADA_COUNT_PROPERTY, pCount);
238  DAE_AddAttribute(lAccessElement, COLLADA_STRIDE_PROPERTY, pStride);
239 
240  for (int lStrideIndex = 0; lStrideIndex < pStride; ++lStrideIndex)
241  {
242  xmlNode * lParamElement = DAE_AddChildElement(lAccessElement, COLLADA_PARAMETER_STRUCTURE);
243  DAE_AddAttribute(lParamElement, COLLADA_TYPE_PROPERTY, TypeToParameterTag<T>());
244  }
245 
246  return lSourceElement;
247 }
#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:210
#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.

◆ PopulateLayerElementDirectArray()

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 255 of file fbxcolladaelement.h.

256 {
257  SourceElementContentAccessor<TYPE> lSourceElementAccessor(pSourceElement);
258 
259  FbxLayerElementTemplate<TYPE> * lLayerElement = (FbxLayerElementTemplate<TYPE> *)pLayerElement;
262  lLayerElement->GetDirectArray().SetCount(lSourceElementAccessor.mCount);
263 
264  TYPE * lArray = NULL;
265  lArray = lLayerElement->GetDirectArray().GetLocked(lArray);
266  lSourceElementAccessor.GetArray((double *)lArray, lSourceElementAccessor.mCount*pSize, 0, pSize,
267  lSourceElementAccessor.mStride, 0, pSize, sizeof(TYPE)/sizeof(double), 1.0);
268  lLayerElement->GetDirectArray().Release(&lArray, lArray);
269 
270  return &(lLayerElement->GetIndexArray());
271 }
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:210
void SetMappingMode(EMappingMode pMappingMode)
Sets the Mapping Mode.
Definition: fbxlayer.h:174
This class complements the FbxLayerElement class.
Definition: fbxlayer.h:1022
FbxLayerElementArrayTemplate< int > & GetIndexArray() const
Returns the index array of Layer Elements.
Definition: fbxlayer.h:1050
FbxLayerElementArrayTemplate< Type > & GetDirectArray() const
Returns the direct array of Layer Elements.
Definition: fbxlayer.h:1030

Go to the source code of this file.