fbx 模型转换 export

时间:2022-05-29 10:56:07

最近在做自定义类型到fbx的转换

有关polygon的理解

vertex,normal,color等信息,是离散的放置的,对fbx里面的mesh加了控制点(vertex)信息之后,

需要再设置polygon信息,就像索引那样,由哪些数据组成一个多边形

过程是这样的

// Create the FBX SDK manager

FbxManager* lSdkManager = FbxManager::Create();

// Create the entity that will hold the scene

FbxScene*lScene = FbxScene::Create(pSdkManager,"scene");

// Build the node tree.
FbxNode* lRootNode = pScene->GetRootNode();
FbxNode* lNode = FbxNode::Create(pScene,"mynode");
lRootNode->AddChild(lNode);
FbxMesh* lMesh = FbxMesh::Create(pScene,pName);
lNode->SetNodeAttribute(lMesh);
// Create control points.
lMesh->InitControlPoints(numVertex);
FbxVector4* lControlPoints = lMesh->GetControlPoints();
for(..i<numVertex..)
lControlPoints [i] = ....initialize...
for(..i<numPolygon..)
lMesh->BeginPolygon(-1, -1, false);
for(..j<numverticesPoly..)//每个多边形包含的顶点数 这个polygon是为了把之前那么多的vertex索引起来
  lMesh->AddPolygon(lPolygonVertices[j] );//....initialize..by lPolygonVertices[i] seems like index buffer function spec to form a polygon
lMesh->EndPolygon ();
 -----------------------------------
对于一个node 可以添加多个material然后 到底里面的polygon要加哪个material呢,用这个
lMesh->BeginPolygon(materialindex);
 ...
我是在face 的循环里挨个加material的所以,materialIndex用的是 face 的迭代次数
因为这个materialindex需要写 node 中材质添加进来的那个索引
--------------------
这些问题 在官方文档中都可以找到答案,他的搜索功能非常好用,就是这个http://help.autodesk.com/view/FBX/2016/ENU/?guid=__files_GUID_3E0DCCD0_5F9A_44D0_8D5E_423237D49DB6_htm

我还有一个认识就是,接触新东西的时候一开始阻抗非常高,感觉很麻烦,应着头皮做就好了, 在最初的一周靠各种猜想,靠最笨的方法,做最简单的实现.

之后再回头看同样的文档,就有所见即所得那种畅快感了,觉得他说的真清楚,但是一开始看同样这种东西的时候,会觉得...这都是什么啊...

ps:在科学领域渐进真理也是这种模式..

pps:把复杂任务分解,是最基本最重要的技能之一, (另外一个技能是搜索

---------=============================------

我现在遇到一个问题,我希望很多节点上的 mesh共用一个vertex 数组  也就是一个controlpoint

//Now we have set the UVs as eIndexToDirect reference and in eByPolygonVertex mapping mode

//we must update the size of the index array.

lUVDiffuseElement->GetIndexArray().SetCount(24);