From Martins Innus: The current fbx writer doesn't seem to support BIND_PER_VERTEX for normals. If you have this type of geometry it, exports the the first normal in the array over the whole primitive set. I don't know that the attached change should be applied as is, since I don't know enough about DrawArrays and Draw Elements to know if the indices for the vertices and normals are guaranteed to be the same. I tried it on a couple models and that seemed to be the case. The alternative is to have the logic down in setControlPointAndNormalsAndUV and set the normals there with the "vertexIndex" if the binding type is per vertex. Not sure what is cleaner.

This commit is contained in:
Michael PLATINGS
2010-05-12 08:54:22 +00:00
parent 047b70c265
commit e91557fe1d
2 changed files with 16 additions and 5 deletions

View File

@@ -77,7 +77,16 @@ public:
triangle.t1 = i1;
triangle.t2 = i2;
triangle.t3 = i3;
triangle.normalIndex = _curNormalIndex;
if (_normalBinding == osg::Geometry::BIND_PER_VERTEX){
triangle.normalIndex1 = i1;
triangle.normalIndex2 = i2;
triangle.normalIndex3 = i3;
}
else{
triangle.normalIndex1 = _curNormalIndex;
triangle.normalIndex2 = _curNormalIndex;
triangle.normalIndex3 = _curNormalIndex;
}
triangle.material = _material;
_listTriangles.push_back(std::make_pair(triangle, _drawable_n));
}
@@ -486,9 +495,9 @@ unsigned int addPolygon(MapIndices & index_vert, unsigned int vertIndex, unsigne
void addPolygon(KFbxMesh * mesh, MapIndices & index_vert, const Triangle & tri, unsigned int drawableNum)
{
mesh->AddPolygon(addPolygon(index_vert, tri.t1, tri.normalIndex, drawableNum));
mesh->AddPolygon(addPolygon(index_vert, tri.t2, tri.normalIndex, drawableNum));
mesh->AddPolygon(addPolygon(index_vert, tri.t3, tri.normalIndex, drawableNum));
mesh->AddPolygon(addPolygon(index_vert, tri.t1, tri.normalIndex1, drawableNum));
mesh->AddPolygon(addPolygon(index_vert, tri.t2, tri.normalIndex2, drawableNum));
mesh->AddPolygon(addPolygon(index_vert, tri.t3, tri.normalIndex3, drawableNum));
}

View File

@@ -35,7 +35,9 @@ struct Triangle
unsigned int t1;
unsigned int t2;
unsigned int t3;
unsigned int normalIndex; ///< Normal index for all bindings except BIND_PER_VERTEX and BIND_OFF.
unsigned int normalIndex1; ///< Normal index for all bindings except BIND_PER_VERTEX and BIND_OFF.
unsigned int normalIndex2;
unsigned int normalIndex3;
int material;
};