2016-08-08 13 views
0

FBX fileを解析し、iPhone上でOpenGL経由で表示したいと考えています。 現在*.fbx形式を解析すると、FBX SDK from Autodeskが使用されます。OpenGLディスプレイ用のFBX解析

これも見つかったlink便利ですが、まだ誤解があります。私が受け取ったインデックスは間違っていると思います。私はブレンダーで単純なキューブを作成し、そのファイルを*.fbxにエクスポートします。 FBX Reviewアプリを介してこのファイルを開くと、すべて完璧に表示されますが、このキューブを描画しようとすると、解析するデータの一部が正しくない/または部分的になっているように見えます。すべてが正しいように見える(私は値を比較する - また

----Indices----24---: 0 1 2 3 4 7 6 5 0 4 5 1 1 5 6 2 2 6 7 3 4 0 3 7 

----Coordinates(Vertises)----72 
1 1 -1 
1 -1 -1 
-1 -1 -1 
-1 1 -1 
1 0.999999 1 
-1 1 1 
-1 -1 1 
0.999999 -1 1 
1 1 -1 
1 0.999999 1 
0.999999 -1 1 
1 -1 -1 
1 -1 -1 
0.999999 -1 1 
-1 -1 1 
-1 -1 -1 
-1 -1 -1 
-1 -1 1 
-1 1 1 
-1 1 -1 
1 0.999999 1 
1 1 -1 
-1 1 -1 
-1 1 1 

----Texture UV----48 
0.499999 9.7692e-05 
0.499999 0.333364 
0.250049 0.333364 
0.250049 9.78112e-05 
0.250049 0.666633 
0.499999 0.666633 
0.499999 0.9999 
0.250049 0.9999 
0.74995 0.333366 
0.74995 0.666633 
0.5 0.666633 
0.5 0.333367 
0.499998 0.333366 
0.499998 0.666632 
0.250048 0.666633 
0.250048 0.333366 
0.25005 0.333367 
0.25005 0.666633 
0.000100091 0.666633 
0.000100024 0.333367 
0.749953 0.666639 
0.749953 0.333373 
0.999903 0.333373 
0.999903 0.666639 

----Normal----72 
0 0 -1 
0 0 -1 
0 0 -1 
0 0 -1 
0 0 1 
0 0 1 
0 0 1 
0 0 1 
1 0 0 
1 0 0 
1 0 0 
1 0 0 
0 -1 0 
0 -1 0 
0 -1 0 
0 -1 0 
-1 0 0 
-1 0 0 
-1 0 0 
-1 0 0 
0 1 0 
0 1 0 
0 1 0 
0 1 0 

頂点(座標)とテクスチャのUVと法線を解析私ができる:

は私が

int numIndices = pMesh->GetPolygonVertexCount(); 
int *indices = new int [numIndices]; 
indices = pMesh->GetPolygonVertices(); 

int polygonCount = pMesh->GetPolygonCount(); 
int totalObjSize = 0; 
for (int i = 0; i < polygonCount; ++i) { 
    totalObjSize += pMesh->GetPolygonSize(i); 
} 

結果、次のコードを使用してインデックスを取得するには私は、サンプルアプリケーションImportSceneを利用して入手可能な値を得ます。link

したがって、私がopのすべてのデータを使用しようとするといくつかの予期せぬオブジェクトがあります。

質問は - 私はFBXファイルからインデックスを正しく解析していますか?

また、OpenGLの描画objに関してはthis is related my questionです。

--- --- UPDATE

また、私は、これは正しくない(ミス注文し、フルではないが)インデックスので、正しいインデックスを生成するためにどのような質問がFBXファイルから注文することがわかりますか?誰かが私が独自のソリューションを投稿し、同じ問題に直面している場合には

答えて

0

(多分これを実行する別の方法があり、これは本当の解決策よりも可能性が回避策ですので、任意の別の方法を見つけた場合 - それは素晴らしいことになるのです)

int indicessCount = index; 
    int *testIndices = new int [indicessCount]; 
     index = 0; 
    pairCounter = 0; 
    int indexElement = 0; 
    for (int i = 0; i < polygonCount; i++) { 
     int lPolygonSize = pMesh->GetPolygonSize(i); 
     for (int j = 0; j< lPolygonSize; j++) { 
      _displayModel.indises[index++] = indexElement + j; 
      if (j==2) { 
       if ((pairCounter % 1)) { 
        int firstIndex = index-3; 
        int secondIndex = index-1; 
        _displayModel.indises[index++] = _displayModel.indises[secondIndex]; 
        _displayModel.indises[index++] = _displayModel.indises[firstIndex]; 
        pairCounter = 0; 
       } 
       pairCounter++; 
      } 
     } 
    indexElement += lPolygonSize; 
} 

はまたあなたのシーンをtrinagulate

FbxGeometryConverter converter(_fbxManager); 
converter.Triangulate(_fbxScene, true);