fbxsdk/fileio/collada/fbxcolladaelement.h File 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

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

196 {
197  return FbxString("#") + pID;
198 }
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 211 of file fbxcolladaelement.h.

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

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

Go to the source code of this file.