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 "#".
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 >
FbxLayerElementArrayPopulateLayerElementDirectArray (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.


Function Documentation

const FbxString TypeToArrayTag ( ) [inline]
const FbxString TypeToArrayTag< bool > ( ) [inline]
const FbxString TypeToArrayTag< int > ( ) [inline]
const FbxString TypeToArrayTag< FbxString > ( ) [inline]
const FbxString TypeToParameterTag ( ) [inline]

Definition at line 47 of file fbxcolladaelement.h.

{
    return COLLADA_FLOAT_TYPE;
}
const FbxString TypeToParameterTag< bool > ( ) [inline]

Definition at line 53 of file fbxcolladaelement.h.

{
    return COLLADA_BOOL_TYPE;
}
const FbxString TypeToParameterTag< int > ( ) [inline]

Definition at line 59 of file fbxcolladaelement.h.

{
    return COLLADA_INT_TYPE;
}
const FbxString TypeToParameterTag< FbxString > ( ) [inline]

Definition at line 65 of file fbxcolladaelement.h.

{
    return COLLADA_NAME_TYPE;
}
const FbxString URL ( const FbxString pID) [inline]

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

Parameters:
TheID string.
Returns:
Return the URL string.

Definition at line 195 of file fbxcolladaelement.h.

{
    return FbxString("#") + pID;
}
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.

{
    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 
)

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.

{
    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());
}