|
Hi,
I’m trying to export scene meshes to file by using 3DXI. (IGame) However, I can’t correct normal, tangent and binormal information. I want to export them as world coordinates.
Here is my code. It export correct position and texture coordinates but it’s exported normals, binormals and tangents are totaly wrong. I can’t figure out the problem in here. Documentation is not clear about this subject.
// Mesh is IGameMesh
// CurrentFilePortal is a custom data structre that holds information about polygons and vertices. (Triangle list)
Mesh->InitializeData(); Mesh->InitializeBinormalData(); Mesh->SetUseWeightedNormals();
for (int I = 0; I < Mesh->GetNumberOfFaces(); I++) {
FaceEx* Face;
Face = Mesh->GetFace(I);
for (int N = 0; N < 3; N++)
{
CurrentFilePortal->Polygons[I].Material = ProcessFaceMaterial(Mesh->GetMaterialFromFace(I));
MapFileVertex* Vertex = &CurrentFilePortal->Polygons[I].Vertices[N];
int BinormalTangentIndex = Mesh->GetFaceVertexTangentBinormal(I, N);
Mesh->GetVertex(Face->vert[N], *(Point3*)&Vertex->Position, false);
Mesh->GetNormal(I, N, *(Point3*)&Vertex->Normal, false);
Vector3::Normalize(Vertex->Normal, Vertex->Normal);
Mesh->GetTangent(BinormalTangentIndex, *(Point3*)&Vertex->Tangent);
Vector3::Normalize(Vertex->Tangent, Vertex->Tangent);
Mesh->GetBinormal(BinormalTangentIndex, *(Point3*)&Vertex->Binormal);
Vector3::Normalize(Vertex->Binormal, Vertex->Binormal);
Mesh->GetTexVertex(Face->texCoord[N], *(Point2*)&Vertex->Texcoord);
}
}
All I want to do is exporting polygons vertices in world coordinates. (Without indexing just triangle list) Any help will be very appreciated.
Thanks.
Orcun
|