- Main Page
- Classes
- Files
- Directories
- Examples

- File List
- File Members

Classes | Defines | Functions

# 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...
## Defines
#define | FBX_COLLADA_NAMESPACE_OPEN namespace FBX_COLLADA {
#define | FBX_COLLADA_NAMESPACE_CLOSE };
## Functions
template<typename T >
FBX_COLLADA_NAMESPACE_OPEN 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 "#".
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.
template<typename TYPE >
FbxLayerElementArray * | PopulateLayerElementDirectArray (FbxLayerElement *pLayerElement, xmlNode *pSourceElement, int pSize)
| Populate the layer element with direct array and return index array for later use.

## Detailed Description

Definition in file fbxcolladaelement.h.

## Define Documentation

#define FBX_COLLADA_NAMESPACE_OPEN namespace FBX_COLLADA {

Search for all occurrences

Definition at line 24 of file fbxcolladaelement.h.

#define FBX_COLLADA_NAMESPACE_CLOSE };

Search for all occurrences

Definition at line 26 of file fbxcolladaelement.h.

## Function Documentation

FBX_COLLADA_NAMESPACE_OPEN const FbxString TypeToArrayTag | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 36 of file fbxcolladaelement.h.

    {
        return COLLADA_FLOAT_ARRAY_STRUCTURE;
    }

const FbxString TypeToArrayTag< bool > | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 42 of file fbxcolladaelement.h.

    {
        return COLLADA_BOOL_ARRAY_STRUCTURE;
    }

const FbxString TypeToArrayTag< int > | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 48 of file fbxcolladaelement.h.

    {
        return COLLADA_INT_ARRAY_STRUCTURE;
    }

const FbxString TypeToArrayTag< FbxString > | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 54 of file fbxcolladaelement.h.

    {
        return COLLADA_NAME_ARRAY_STRUCTURE;
    }

const FbxString TypeToParameterTag | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 61 of file fbxcolladaelement.h.

    {
        return COLLADA_FLOAT_TYPE;
    }

const FbxString TypeToParameterTag< bool > | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 67 of file fbxcolladaelement.h.

    {
        return COLLADA_BOOL_TYPE;
    }

const FbxString TypeToParameterTag< int > | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 73 of file fbxcolladaelement.h.

    {
        return COLLADA_INT_TYPE;
    }

const FbxString TypeToParameterTag< FbxString > | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 79 of file fbxcolladaelement.h.

    {
        return COLLADA_NAME_TYPE;
    }

const FbxString URL | ( | const FbxString & | pID | ) | `[inline]`

Search for all occurrences

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

Parameters:

  The | ID string.

Returns:
  Return the URL string.

Definition at line 209 of file fbxcolladaelement.h.

    {
        return FbxString("#") + pID;
    }

xmlNode* AddSourceElement | ( | xmlNode * | pParentElement,
|  | const char * | pID,
|  | const T * | pData,
|  | int | pCount,
|  | int | pStride = `1`
| ) |  |

Search for all occurrences

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

Parameters:

  pParentElement | The parent element.
  pID | The ID of the new source element.
  pData | The array data.
  pCount | The length of the array.
  pStride | The 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 225 of file fbxcolladaelement.h.

    {
        FBX_ASSERT(pParentElement && pData);
        if (!pParentElement || !pData)
            return NULL;

        xmlNode * lSourceElement = DAE_AddChildElement(pParentElement, COLLADA_SOURCE_STRUCTURE);
        DAE_AddAttribute(lSourceElement, COLLADA_ID_PROPERTY, pID);

        FbxString lContent;
        const int lDataCount = pCount * pStride;
        for (int lIndex = 0; lIndex < lDataCount; ++lIndex)
        {
            lContent += ToString(pData[lIndex]);
            if (lIndex != lDataCount - 1)
                lContent += " ";
        }
        const FbxString lArrayID = FbxString(pID) + "-array";
        xmlNode * lArrayElement = DAE_AddChildElement(lSourceElement, TypeToArrayTag<T>(), lContent);
        DAE_AddAttribute(lArrayElement, COLLADA_ID_PROPERTY, lArrayID);
        DAE_AddAttribute(lArrayElement, COLLADA_COUNT_PROPERTY, lDataCount);

        xmlNode * lTechniqueCommonElement = DAE_AddChildElement(lSourceElement,
            COLLADA_TECHNIQUE_COMMON_ELEMENT);
        xmlNode * lAccessElement = DAE_AddChildElement(lTechniqueCommonElement,
            COLLADA_ACCESSOR_STRUCTURE);
        DAE_AddAttribute(lAccessElement, COLLADA_SOURCE_PROPERTY, URL(lArrayID));
        DAE_AddAttribute(lAccessElement, COLLADA_COUNT_PROPERTY, pCount);
        DAE_AddAttribute(lAccessElement, COLLADA_STRIDE_PROPERTY, pStride);

        for (int lStrideIndex = 0; lStrideIndex < pStride; ++lStrideIndex)
        {
            xmlNode * lParamElement = DAE_AddChildElement(lAccessElement, COLLADA_PARAMETER_STRUCTURE);
            DAE_AddAttribute(lParamElement, COLLADA_TYPE_PROPERTY, TypeToParameterTag<T>());
        }

        return lSourceElement;
    }

FbxLayerElementArray* PopulateLayerElementDirectArray | ( | FbxLayerElement * | pLayerElement,
|  | xmlNode * | pSourceElement,
|  | int | pSize
| ) |  |

Search for all occurrences

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

Parameters:

  pLayerElement | The layer element to be populated.
  pSourceElement | The source element containing the direct array data.
  pSize | The count of double data of direct array element.

Returns:
  Return the index array of the layer element.

Definition at line 271 of file fbxcolladaelement.h.

    {
        SourceElementContentAccessor<TYPE> lSourceElementAccessor(pSourceElement);

        FbxLayerElementTemplate<TYPE> * lLayerElement = (FbxLayerElementTemplate<TYPE> *)pLayerElement;
        lLayerElement->SetMappingMode(FbxLayerElement::eByPolygonVertex);
        lLayerElement->SetReferenceMode(FbxLayerElement::eIndexToDirect);
        lLayerElement->GetDirectArray().SetCount(lSourceElementAccessor.mCount);

        TYPE * lArray = NULL;
        lArray = lLayerElement->GetDirectArray().GetLocked(lArray);
        lSourceElementAccessor.GetArray((double *)lArray, 0, pSize,
            lSourceElementAccessor.mStride, 0, pSize, sizeof(TYPE)/sizeof(double), 1.0);
        lLayerElement->GetDirectArray().Release(&lArray, lArray);

        return &(lLayerElement->GetIndexArray());
    }