Public Member Functions | Static Public Member Functions | Protected Member Functions

FbxLayerElementUserData Class Reference

This reference page is linked to from the following overview topics: Customizing the FBX SDK.


Search for all occurrences

Detailed Description

Layer element for mapping custom user data to a geometry.

This layer element is different from the other types of layer elements in that it has multiple direct arrays. There is one array for each user data attribute. Each array is indexed by the index array.

Definition at line 1483 of file fbxlayer.h.

#include <fbxlayer.h>

Inheritance diagram for FbxLayerElementUserData:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 FBXSDK_FRIEND_NEW ()
FbxLayerElementArrayTemplate
< void * > * 
GetDirectArrayVoid (int pIndex, bool *pStatus=NULL)
 Returns the direct array with the specified attribute index.
FbxLayerElementArrayTemplate
< void * > const * 
GetDirectArrayVoid (int pIndex, bool *pStatus=NULL) const
 Returns the direct array with the specified attribute index.
FbxLayerElementArrayTemplate
< void * > * 
GetDirectArrayVoid (const char *pName, bool *pStatus=NULL)
 Returns the direct array with the specified attribute name.
FbxLayerElementArrayTemplate
< void * > const * 
GetDirectArrayVoid (const char *pName, bool *pStatus=NULL) const
 Returns the direct array with the specified attribute name.
FbxDataType GetDataType (int pIndex) const
 Returns the data type for the specified index.
FbxDataType GetDataType (const char *pName) const
 Returns the specified attribute data type.
const char * GetDataName (int pIndex) const
 Returns the attribute name at the specified index.
void ResizeAllDirectArrays (int pSize)
 Resizes all direct arrays to the specified size.
void RemoveFromAllDirectArrays (int pIndex)
 Removes a single element at pIndex from every direct array.
int GetArrayCount (int pIndex) const
 Returns the direct array count for the attribute at pIndex.
int GetId () const
 Queries the this layer element's ID.
int GetDirectArrayCount () const
 Returns this layer element's direct array count.
FbxLayerElementUserDataoperator= (FbxLayerElementUserData const &pOther)
 Assignment operator which performs a deep copy.
bool Clear ()
 Removes all data from this layer element.
virtual int MemorySize () const
 Queries the amount of memory used by this object as well as its content.

Static Public Member Functions

static FbxLayerElementUserDataCreate (FbxLayerContainer *pOwner, char const *pName, int pId, FbxArray< FbxDataType > &pDataTypes, FbxArray< const char * > &pDataNames)
 Allocation method.
static FbxLayerElementUserDataCreate (FbxLayerContainer *pOwner, FbxLayerElementUserData const &pOther)
 Allocation method.

Protected Member Functions

virtual void AllocateArrays ()

Constructor and Destructor.

 FbxLayerElementUserData (int pId, FbxArray< FbxDataType > &pDataTypes, FbxArray< const char * > &pDataNames)
 Constructs a user data layer element.
 FbxLayerElementUserData (FbxLayerElementUserData const &pOther)
 Copy constructor.
 ~FbxLayerElementUserData ()
 Destructor.

Constructor & Destructor Documentation

FbxLayerElementUserData ( int  pId,
FbxArray< FbxDataType > &  pDataTypes,
FbxArray< const char * > &  pDataNames 
) [inline, protected]

Constructs a user data layer element.

Parameters:
pIdAn identifier for this UserData layer element
pDataTypesAttribute data types for this layer element
pDataNamesAttribute names for this layer element

Definition at line 1819 of file fbxlayer.h.

        :
        mId( pId ),
        mDataTypes( pDataTypes )
    {
        FBX_ASSERT( pDataTypes.GetCount() == pDataNames.GetCount() );
        for( int i = 0; i < pDataNames.GetCount(); ++i )
        {
            mDataNames.Add( FbxNew< FbxString >( pDataNames[i] ) );
        }
    }
FbxLayerElementUserData ( FbxLayerElementUserData const &  pOther) [inline, protected]

Copy constructor.

A deep copy is made.

Parameters:
pOtherAnother FbxLayerElementUserData object to be copied.

Definition at line 1834 of file fbxlayer.h.

                                                                     : mId(pOther.mId), mDataTypes(pOther.mDataTypes)
    {
        for (int lIndex = 0; lIndex < pOther.mDataNames.GetCount(); ++lIndex)
        {
            mDataNames.Add(FbxNew<FbxString>(*(pOther.mDataNames[lIndex])));
        }

        SetType(&FbxLayerElementUserDataDT);
        AllocateArrays();

        for(int i = 0; i < pOther.GetDirectArrayCount(); ++i)
        {
            switch (mDataTypes[i].GetType())
            {
            case eFbxBool:
                FbxGetDirectArray<bool>(this, i) = FbxGetDirectArray<bool>(&pOther, i);
                break;

            case eFbxInt:
                FbxGetDirectArray<int>(this, i) = FbxGetDirectArray<int>(&pOther, i);
                break;

            case eFbxFloat:
                FbxGetDirectArray<float>(this, i) = FbxGetDirectArray<float>(&pOther, i);
                break;

            case eFbxDouble:
                FbxGetDirectArray<double>(this, i) = FbxGetDirectArray<double>(&pOther, i);
                break;

            default:
                FBX_ASSERT_NOW("Unknown type" );
                break;
            }
        }

        if ( ( mReferenceMode == FbxLayerElement::eIndex || 
            mReferenceMode == FbxLayerElement::eIndexToDirect) &&
            ( pOther.GetReferenceMode() == FbxLayerElement::eIndex || 
            pOther.GetReferenceMode()  == FbxLayerElement::eIndexToDirect))
        {
            GetIndexArray() = pOther.GetIndexArray();
        }
    }
~FbxLayerElementUserData ( ) [inline, protected]

Destructor.

Definition at line 1880 of file fbxlayer.h.

    {
        Clear();
    }

Member Function Documentation

FBXSDK_FRIEND_NEW ( )
static FbxLayerElementUserData* Create ( FbxLayerContainer pOwner,
char const *  pName,
int  pId,
FbxArray< FbxDataType > &  pDataTypes,
FbxArray< const char * > &  pDataNames 
) [static]

Allocation method.

Parameters:
pOwnerThe owner of this layer element.
pNameThe layer element name.
pIdThe layer element ID.
pDataTypesAttribute data types of this layer element, one direct array is allocated for each Attribute data type.
pDataNamesAttribute names of this layer element.
Returns:
A pointer to the layer element or NULL if creation fails.
Remarks:
Only "bool", "int", "float" and "double" are supported.
static FbxLayerElementUserData* Create ( FbxLayerContainer pOwner,
FbxLayerElementUserData const &  pOther 
) [static]

Allocation method.

Parameters:
pOwnerThe owner of this layer element.
pOtherOther layer element from which to copy.
Returns:
A pointer to the layer element or NULL if creation fails.
FbxLayerElementArrayTemplate<void*>* GetDirectArrayVoid ( int  pIndex,
bool *  pStatus = NULL 
) [inline]

Returns the direct array with the specified attribute index.

Parameters:
pIndexSpecified attribute index.
pStatusA flag to indicate whether the direct array is returned successfully or not.
Returns:
The specified attribute's direct array.

Definition at line 1511 of file fbxlayer.h.

    {       
        if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
        {
            if (pStatus) *pStatus = true;
            return (FbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
        }
        else
        {
            if( pStatus ) *pStatus = false;
            FBX_ASSERT_NOW("Index out of bounds");
            return (FbxLayerElementArrayTemplate<void*>*)NULL;
        }
    }
FbxLayerElementArrayTemplate<void*> const* GetDirectArrayVoid ( int  pIndex,
bool *  pStatus = NULL 
) const [inline]

Returns the direct array with the specified attribute index.

Parameters:
pIndexSpecified attribute index.
pStatusA flag to indicate whether the direct array is returned successfully or not.
Returns:
The specified attribute's direct array.

Definition at line 1531 of file fbxlayer.h.

    {
        if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
        {
            if (pStatus) *pStatus = true;
            return (FbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
        }
        else
        {
            if( pStatus ) *pStatus = false;
            FBX_ASSERT_NOW("Index out of bounds");
            return (FbxLayerElementArrayTemplate<void*> const*)NULL;
        }
    }
FbxLayerElementArrayTemplate<void *>* GetDirectArrayVoid ( const char *  pName,
bool *  pStatus = NULL 
) [inline]

Returns the direct array with the specified attribute name.

Parameters:
pNameSpecified attribute name.
pStatusA flag to indicate whether the direct array is returned successfully or not.
Returns:
The specified attribute's direct array.

Definition at line 1552 of file fbxlayer.h.

    {
        FbxString lName( pName );
        for( int i = 0; i < mDataNames.GetCount(); ++i )
        {
            if( *mDataNames[i] == lName )
                return GetDirectArrayVoid(i, pStatus);
        }

        if (pStatus) *pStatus = false;
        return (FbxLayerElementArrayTemplate<void *>*)NULL;
    }
FbxLayerElementArrayTemplate<void *> const* GetDirectArrayVoid ( const char *  pName,
bool *  pStatus = NULL 
) const [inline]

Returns the direct array with the specified attribute name.

Parameters:
pNameSpecified attribute name.
pStatusA flag to indicate whether the direct array is returned successfully or not.
Returns:
The specified attribute's direct array.

Definition at line 1570 of file fbxlayer.h.

    {
        FbxString lName( pName );
        for( int i = 0; i < mDataNames.GetCount(); ++i )
        {
            if( *mDataNames[i] == lName )
                return GetDirectArrayVoid(i, pStatus);
        }

        if (pStatus) *pStatus = false;
        return (FbxLayerElementArrayTemplate<void *> const*)NULL;
    }
FbxDataType GetDataType ( int  pIndex) const [inline]

Returns the data type for the specified index.

Parameters:
pIndexThe index of the attribute being queried
Returns:
The data type, or FbxUndefinedDT if pIndex is out of range

Definition at line 1587 of file fbxlayer.h.

    {
        if( pIndex < 0 || pIndex >= mDataTypes.GetCount() )
            return FbxUndefinedDT;

        return mDataTypes[pIndex];
    }
FbxDataType GetDataType ( const char *  pName) const [inline]

Returns the specified attribute data type.

Parameters:
pNameThe name of the attribute being queried
Returns:
The data type, or FbxUndefinedDT if no attribute has the given name

Definition at line 1599 of file fbxlayer.h.

    {
        FbxString lName( pName );

        for( int i = 0; i < mDataNames.GetCount(); ++i )
        {
            if( *mDataNames[i] == lName )
                return mDataTypes[i];
        }

        return FbxUndefinedDT;
    }
const char* GetDataName ( int  pIndex) const [inline]

Returns the attribute name at the specified index.

Parameters:
pIndexAttribute index
Returns:
The name, or NULL if pIndex is out of range.

Definition at line 1616 of file fbxlayer.h.

    {
        if( pIndex >= 0 && pIndex < mDataNames.GetCount() )
            return mDataNames[pIndex]->Buffer();

        return NULL;
    }
void ResizeAllDirectArrays ( int  pSize) [inline]

Resizes all direct arrays to the specified size.

Parameters:
pSizeThe new size of the direct arrays.

Definition at line 1627 of file fbxlayer.h.

    {
        for( int i = 0; i < GetDirectArray().GetCount(); ++i )
        {
            switch( mDataTypes[i].GetType() )
            {
                case eFbxBool:  FbxGetDirectArray<bool>(this,i).Resize( pSize )  ; break;
                case eFbxInt:   FbxGetDirectArray<int>(this,i).Resize( pSize )   ;  break;
                case eFbxFloat: FbxGetDirectArray<float>(this,i).Resize( pSize ) ;  break;
                case eFbxDouble:    FbxGetDirectArray<double>(this,i).Resize( pSize );  break;
                //case eFbxDouble3: GetDirectArray< FbxDouble3 >(i).Resize( pSize );    break;
                //case eFbxDouble4: GetDirectArray< FbxDouble4 >(i).Resize( pSize );    break;
                //case eFbxDouble4x4:   GetDirectArray< FbxDouble4x4>(i).Resize( pSize );   break;  
                default:
                    FBX_ASSERT_NOW("unknown type" ); break;
            }
        }
    }
void RemoveFromAllDirectArrays ( int  pIndex) [inline]

Removes a single element at pIndex from every direct array.

Parameters:
pIndexThe index of the element to be removed.

Definition at line 1649 of file fbxlayer.h.

    {
        for( int i = 0; i < GetDirectArray().GetCount(); ++i )
        {
            switch( mDataTypes[i].GetType() )
            {
                case eFbxBool:  FbxGetDirectArray<bool>(this,i).RemoveAt( pIndex )  ; break;
                case eFbxInt:   FbxGetDirectArray<int>(this,i).RemoveAt( pIndex )   ; break;
                case eFbxFloat: FbxGetDirectArray<float>(this,i).RemoveAt( pIndex ) ; break;
                case eFbxDouble:    FbxGetDirectArray<double>(this,i).RemoveAt( pIndex ); break;
                //case eFbxDouble3: GetDirectArray< FbxDouble3 >(i).RemoveAt( pIndex ); break;
                //case eFbxDouble4: GetDirectArray< FbxDouble4 >(i).RemoveAt( pIndex ); break;
                //case eFbxDouble4x4:   GetDirectArray< FbxDouble4x4>(i).RemoveAt( pIndex );    break;  
                default:
                    FBX_ASSERT_NOW("unknown type" ); break;
            }
        }
    }
int GetArrayCount ( int  pIndex) const [inline]

Returns the direct array count for the attribute at pIndex.

Parameters:
pIndexThe attribute index
Returns:
The specified attribute's direct array count.

Definition at line 1672 of file fbxlayer.h.

    {
        if( pIndex >= 0 && pIndex < GetDirectArray().GetCount() )
        {
            switch( mDataTypes[pIndex].GetType() )
            {
                case eFbxBool:  return FbxGetDirectArray<bool>(this,pIndex).GetCount();
                case eFbxInt:   return FbxGetDirectArray<int>(this,pIndex).GetCount();
                case eFbxFloat: return FbxGetDirectArray<float>(this,pIndex).GetCount();
                case eFbxDouble:    return FbxGetDirectArray<double>(this,pIndex).GetCount();
                //case eFbxDouble3: return GetDirectArray< FbxDouble3 >(pIndex).GetCount();
                //case eFbxDouble4: return GetDirectArray< FbxDouble4 >(pIndex).GetCount();
                //case eFbxDouble4x4:   return GetDirectArray< FbxDouble4x4>(pIndex).GetCount();
                default:
                    FBX_ASSERT_NOW("Unknown type" ); break;
            }
        }

        return -1;
    }
int GetId ( ) const [inline]

Queries the this layer element's ID.

Returns:
The ID expressed as an int

Definition at line 1696 of file fbxlayer.h.

{ return mId; }
int GetDirectArrayCount ( ) const [inline]

Returns this layer element's direct array count.

Returns:
The direct array count expressed as an int.
Remarks:
This count should be equal to the count of user data attributes.

Definition at line 1702 of file fbxlayer.h.

{ return GetDirectArray().GetCount(); }
FbxLayerElementUserData& operator= ( FbxLayerElementUserData const &  pOther) [inline]

Assignment operator which performs a deep copy.

Parameters:
pOtherOther FbxLayerElementUserData from which to perform a deep copy.
Returns:
This FbxLayerElementUserData.

Definition at line 1708 of file fbxlayer.h.

    {
        if (this == &pOther)
            return *this;

        Clear();

        mId = pOther.mId;
        mDataTypes = pOther.mDataTypes;
        mDataNames.Resize(pOther.mDataNames.GetCount());
        for(int i = 0; i < pOther.mDataNames.GetCount(); ++i)
            mDataNames.SetAt(i,  FbxNew< FbxString >( *pOther.mDataNames[i] ) );

        Init();
        for(int i = 0; i < pOther.GetDirectArrayCount(); ++i)
        {
            switch (mDataTypes[i].GetType())
            {
            case eFbxBool:
                FbxGetDirectArray<bool>(this, i) = FbxGetDirectArray<bool>(&pOther, i);
                break;

            case eFbxInt:
                FbxGetDirectArray<int>(this, i) = FbxGetDirectArray<int>(&pOther, i);
                break;

            case eFbxFloat:
                FbxGetDirectArray<float>(this, i) = FbxGetDirectArray<float>(&pOther, i);
                break;

            case eFbxDouble:
                FbxGetDirectArray<double>(this, i) = FbxGetDirectArray<double>(&pOther, i);
                break;

            default:
                FBX_ASSERT_NOW("Unknown type" );
                break;
            }
        }

        if ( ( mReferenceMode == FbxLayerElement::eIndex || 
               mReferenceMode == FbxLayerElement::eIndexToDirect) &&
             ( pOther.GetReferenceMode() == FbxLayerElement::eIndex || 
               pOther.GetReferenceMode()  == FbxLayerElement::eIndexToDirect))
        {
            GetIndexArray() = pOther.GetIndexArray();
        }

        return *this;
    }
bool Clear ( ) [inline, virtual]

Removes all data from this layer element.

Returns:
True always

Reimplemented from FbxLayerElementTemplate< void * >.

Definition at line 1762 of file fbxlayer.h.

    {
        int i;
        const int lCount = GetDirectArray().GetCount();
        FbxLayerElementArray** directArray = NULL;
        directArray = GetDirectArray().GetLocked(directArray);
        for( i = 0; directArray != NULL && i < lCount; ++i )
        {
            if( directArray[i] )
                FbxDelete(directArray[i]);
        }
        GetDirectArray().Release((void**)&directArray);

        for( i = 0; i < mDataNames.GetCount(); ++i )
        {
            FBX_SAFE_DELETE(mDataNames[i]);
        }
        mDataNames.Clear();
        mDataTypes.Clear();

        FbxLayerElementTemplate<void*>::Clear();

        return true;
    }
virtual int MemorySize ( ) const [inline, virtual]

Queries the amount of memory used by this object as well as its content.

It does not consider the content pointed.

Returns:
The amount of memory used.

Reimplemented from FbxLayerElementTemplate< void * >.

Definition at line 1791 of file fbxlayer.h.

    {
        int size = FbxLayerElementTemplate<void*>::MemorySize();
        size += sizeof(mId);

        for(int i = 0; i < mDataTypes.GetCount(); i++)
        {
            size += sizeof(mDataTypes[i]);
        }
        size += (mDataNames.GetCount() * sizeof(FbxString*));

        return size;
    }
virtual void AllocateArrays ( ) [inline, protected, virtual]

The documentation for this class was generated from the following file:

FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData
FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData FbxLayerElementUserData