FBX SDK Programmer's Guide > FBX SDK Object Model >

# FBX Properties

Managing Properties

The FbxProperty template class is used to ensure that the data of a FbxObject is strongly typed. For example, the local translation vector of a FbxNode is described using a FbxTypedProperty which is parametrized for FbxDouble3.

When a FbxObject is created, its static built-in FbxPropertys are automatically initialized. To create your own FbxProperty, you must invoke FbxProperty::Create(), and pass either a reference to a FbxObject, or to another FbxProperty.

The following code sample was taken from the Animation example. In this sample, the first parameter of FbxProperty::Create() is a FbxScene object. The second parameter is the datatype of the property (a full list of datatypes can be found in the fbxdatatypes.h header file). The third parameter is the assigned name of the property.

    FbxProperty p = FbxProperty::Create(pScene, DTDouble3, "Vector3Property");
    FbxSet<FbxDouble3>(p, FbxDouble3(1.1, 2.2, 3.3);

The name with which a FbxProperty is created can be accessed by calling FbxProperty::GetName(). This name can be used to search for a property within a hierarchy (see Property Hierarchy).

An instance of FbxProperty can be destroyed by calling FbxProperty::Destroy(). A hierarchy of FbxProperty can be destroyed by invoking FbxProperty::DestroyRecursively() on the root property.

Property Data

Instances of FbxProperty contain data which can be set and accessed by respectively calling FbxProperty::Set() and FbxProperty::Get(). For example, the FbxNode geometric transformation data, represented as vectors of FbxDouble3, can be accessed in the following way:

    // ... initialize FbxNode* lNode ...
    FbxDouble3 translation = lNode->LclTranslation.Get();
    FbxDouble3 rotation = lNode->LclRotation.Get();
    FbxDouble3 scaling = lNode->LclScaling.Get();

The data contained within a FbxTypedProperty can only be set to a value that is valid for the property's data type. Some implicit conversions are supported; you can, for example, provide an int when a double is required.

Flags

Properties also contain a set of FbxPropertyFlags::eFbxPropertyFlags which can be manipulated using FbxProperty::GetFlag() and FbxProperty::ModifyFlag().

Operators

The standard comparison and assignment operators can be used to compare and assign properties to one another (FbxProperty::operator==(), FbxProperty::operator!=(), FbxProperty::operator=()).

User-defined Data

The FbxProperty class can contain user-defined data, which can be dynamically associated to a FbxObject at runtime. An example of this can be found in the UserProperties example.

Property Hierarchy

Properties can be organized in a hierarchy. A FbxProperty can be connected to a FbxObject, or to another FbxProperty. The bound FbxObject of the property can be accessed by invoking FbxProperty::GetFbxObject(). The ExportScene05 example illustrates the construction of a property hierarchy.

Accessing an FBX Object's Properties

An FBX object can have many properties, which can be searched for using FbxObject::FindProperty(). An object's properties can also be iterated by invoking methods such as FbxObject::GetFirstProperty(), and FbxObject::GetNextProperty().

NoteThe class documentation of FbxIOSettings provides useful insight into the organization of its property hierarchy.

Navigating a Property Hierarchy

A hierarchy of FBX properties can be traversed by means of the FBX property navigation functions: FbxProperty::GetParent(), FbxProperty::GetChild(), FbxProperty::GetSibling(), FbxProperty::Find(), to name but a few.

NoteThe Connections topic provides more information on how to navigate between objects and property hierarchies.

Sample Code

The following sample code was taken from the ExportScene05 example. It illustrates how to create your own FbxProperty values, and bind them to a FbxObjectMetaData instance (which inherits from FbxObject).

    // ... initialize pScene as a FbxScene* ...

    // Create a FbxObjectMetaData* object in pScene.
    FbxObjectMetaData* lFamilyMetaData = FbxObjectMetaData::Create(pScene, "Family");

    // Create and assign data to several instances of FbxProperty, based on their parametrized
    // datatypes (DTString, DTFloat, DTDouble).
    //
    // The fourth parameter is an optional label string, which can be obtained and modified
    // using FbxProperty::GetLabel() and FbxProperty::SetLabel(). This label only exists
    // in the program's main memory, and will not be exported to a file if/when the property
    // is exported.
    //
    // These properties will be contained within the pFamilyMetaData object.
    //
    FbxProperty::Create(lFamilyMetaData, DTString, "Level", "Level").Set(FbxString("Family")); // String
    FbxProperty::Create(lFamilyMetaData, DTString, "Type", "Type").Set(FbxString("Wall"));     // String
    FbxProperty::Create(lFamilyMetaData, DTFloat, "Width", "Width").Set(10.0f);              // float
    FbxProperty::Create(lFamilyMetaData, DTDouble, "Weight", "Weight").Set(25.0);            // double
    FbxProperty::Create(lFamilyMetaData, DTDouble, "Cost", "Cost").Set(1.25);                // double