ios - FBX parse for openGL Display -
i want parse fbx file
, display via opengl on iphone. try parse *.fbx
format using fbx sdk autodesk
.
found link useful, still have misunderstanding - guess indices receive incorrect. create simple cube in blender , export file in *.fbx
. if open file via fbx review
app - displayed perfect, when try draw cube - looks data parse incorrect/or partial.
to indices use next code
int numindices = pmesh->getpolygonvertexcount(); int *indices = new int [numindices]; indices = pmesh->getpolygonvertices(); int polygoncount = pmesh->getpolygoncount(); int totalobjsize = 0; (int = 0; < polygoncount; ++i) { totalobjsize += pmesh->getpolygonsize(i); }
result:
----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
also able parse vertices (coordinates) , textures uv , normals - looks correct (i compare value values can obtained via sample app importscene
available via link.
so when try use data in opengl got unexpected obj.
the question - correctly parse indices fbx file?
also this related question regarding drawing obj in opengl.
---update---
i find indices incorrect (miss ordered , not full), questions how generate correct indices order fbx
file?
in case face same problem post own solutions (maybe there way this, more workaround real solutions, if find way - it's great)
int indicesscount = index; int *testindices = new int [indicesscount]; index = 0; paircounter = 0; int indexelement = 0; (int = 0; < polygoncount; i++) { int lpolygonsize = pmesh->getpolygonsize(i); (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; }
also trinagulate scene
fbxgeometryconverter converter(_fbxmanager); converter.triangulate(_fbxscene, true);
Comments
Post a Comment