FbxProperty(Fbx对象特性)

来源:互联网 发布:php 支付宝在线支付 编辑:程序博客网 时间:2024/05/16 08:56

对象特性

1、管理特性

FbxProperty模板类是为了保证FbxObject能够非常规范。举个例子,FbxNode就是由FbxTypedProperty(用FbxDouble3参数化描述)来表示的。

当一个FbxObject被创建时,它在FbxProperty中创建的静态数据会被自动初始化。那么为了创建自己的FbxProperty,我们必须点哟FbxProperty::Create(),用户创建的特性包含用户自己定义的数据,这些数据可以和FbxObject动态联系在一起。下面是一段调用代码(第一个参数是FbxScene对象,第二个参数是特性的类型,第三个参数是特性的名字):

FbxProperty p = FbxProperty::Create(pScene, DTDouble3, "Vector3Property");FbxSet<FbxDouble3>(p, FbxDouble3(1.1, 2.2, 3.3);
FbxProperty对象可以通过FbxProperty::GetName()来查找,但是必须要在同一层次中进行。FbxPoperty中的实例可以通过FbxProperty::Destroy()来销毁。一个层级的FbxProperty可以在根特性(也是一个FbxProperty对象)中通过调用FbxProperty::DestroyRecursively()来销毁。

2、特性数据

FbxProperty的实例中的数据可以通过FbxProperty::Get()和FbxProperty::Set()分别来写和读。比如,FbxNode图形转换信息可以这样读取:

// ... initialize FbxNode* lNode ...FbxDouble3 translation = lNode->LclTranslation.Get();FbxDouble3 rotation = lNode->LclRotation.Get();FbxDouble3 scaling = lNode->LclScaling.Get();
特性中也包含一系列的特性集合FbxPropertyFlags::eFbxPropertyFlags,它们可以通过FbxProperty::GetFlag和FbxProperty::ModifyFlag()来操作。

和FbxObject不一样,FbxProperty可以通过操作符来进行赋值和比较等操作。

3、特性层级

FbxProperty可以在FbxObject联系也可以和另一个FbxProperty联系。获取FbxObject函数FbxProperty::GetNextProperty().

  在FbxObject中获取FbxProperty可以通过名字FbxObject::FindProperty(),也可以通过迭代器依次遍历查找:FbxObject::GetFirstProperty()后者FbxObject::GetNextProperty().

  对层级之间的实行操作可以用一下函数FbxProperty::GetParent(),FbxProperty::GetChild(),FbxProperty::GetSibing(),FbxProperty::Find().


下面是一个例子,用来说明怎样来创建你自己的FbxProperty value,并且将它们与FbxObjectMetaData实例(从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")); // StringFbxProperty::Create(lFamilyMetaData, DTString, "Type", "Type").Set(FbxString("Wall"));     // StringFbxProperty::Create(lFamilyMetaData, DTFloat, "Width", "Width").Set(10.0f);              // floatFbxProperty::Create(lFamilyMetaData, DTDouble, "Weight", "Weight").Set(25.0);            // doubleFbxProperty::Create(lFamilyMetaData, DTDouble, "Cost", "Cost").Set(1.25);                // double










原创粉丝点击