Fixed orientation of MD2, MD3 and 3DS models.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@75 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2008-07-30 23:59:03 +00:00
parent 8aa56a62c2
commit 63596e22c5
4 changed files with 21 additions and 17 deletions

View File

@ -593,7 +593,7 @@ void Dot3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,Dot3DS::Node*
while (pvCurrent != pvEnd)
{
std::swap( pvCurrent->y, pvCurrent->z );
pvCurrent->y *= -1.0f;
//pvCurrent->y *= -1.0f;
++pvCurrent;
}
}

View File

@ -66,8 +66,9 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
aiVector3D* pV2 = &sMesh->mPositions[face.mIndices[1]];
aiVector3D* pV3 = &sMesh->mPositions[face.mIndices[2]];
aiVector3D pDelta1 = *pV2 - *pV1;
aiVector3D pDelta2 = *pV3 - *pV1;
// FIX invert all vertex normals
aiVector3D pDelta1 = *pV3 - *pV1;
aiVector3D pDelta2 = *pV2 - *pV1;
aiVector3D vNor = pDelta1 ^ pDelta2;
sMesh->mNormals[face.mIndices[0]] = vNor;
@ -127,6 +128,10 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
vNormals.y /= fDiv;
vNormals.z /= fDiv;
vNormals.Normalize();
// do the common coordinate system adjustment
std::swap(vNormals.y,vNormals.z);
avNormals[(*i).mIndices[c]] = vNormals;
poResult.clear();
}

View File

@ -344,16 +344,18 @@ void MD2Importer::InternReadFile(
vec.x += pcFrame->translate[0];
// (flip z and y component)
vec.z = (float)pcVerts[iIndex].vertex[1] * pcFrame->scale[1];
vec.z += pcFrame->translate[1];
// FIX: no .... invert y instead
vec.y = (float)pcVerts[iIndex].vertex[1] * pcFrame->scale[1];
vec.y += pcFrame->translate[1];
vec.y *= -1.0f;
vec.y = (float)pcVerts[iIndex].vertex[2] * pcFrame->scale[2];
vec.y += pcFrame->translate[2];
vec.z = (float)pcVerts[iIndex].vertex[2] * pcFrame->scale[2];
vec.z += pcFrame->translate[2];
// read the normal vector from the precalculated normal table
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
std::swap ( vNormal.y,vNormal.z );
vNormal.y *= -1.0f;
// validate texture coordinates
if (pcTriangles[iIndex].textureIndices[c] >= this->m_pcHeader->numTexCoords)
@ -407,18 +409,16 @@ void MD2Importer::InternReadFile(
vec.x = (float)pcVerts[iIndex].vertex[0] * pcFrame->scale[0];
vec.x += pcFrame->translate[0];
// (flip z and y component)
vec.z = (float)pcVerts[iIndex].vertex[1] * pcFrame->scale[1];
vec.z += pcFrame->translate[1];
vec.y = (float)pcVerts[iIndex].vertex[2] * pcFrame->scale[2];
vec.y += pcFrame->translate[2];
vec.y *= -1.f;
// read the normal vector from the precalculated normal table
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
std::swap ( vNormal.y,vNormal.z );
vNormal.y *= -1.0f;
}
// FIX: flip the face order for use with OpenGL
pScene->mMeshes[0]->mFaces[i].mIndices[0] = iTemp+2;

View File

@ -251,15 +251,14 @@ void MD3Importer::InternReadFile(
{
// read vertices
pcMesh->mVertices[iCurrent].x = pcVertices[ pcTriangles->INDEXES[c]].X;
pcMesh->mVertices[iCurrent].y = pcVertices[ pcTriangles->INDEXES[c]].Y;
pcMesh->mVertices[iCurrent].z = pcVertices[ pcTriangles->INDEXES[c]].Z*-1.0f;
pcMesh->mVertices[iCurrent].y = pcVertices[ pcTriangles->INDEXES[c]].Y*-1.0f;
pcMesh->mVertices[iCurrent].z = pcVertices[ pcTriangles->INDEXES[c]].Z;
// convert the normal vector to uncompressed float3 format
LatLngNormalToVec3(pcVertices[pcTriangles->INDEXES[c]].NORMAL,
(float*)&pcMesh->mNormals[iCurrent]);
//std::swap(pcMesh->mNormals[iCurrent].z,pcMesh->mNormals[iCurrent].y);
pcMesh->mNormals[iCurrent].z *= -1.0f;
pcMesh->mNormals[iCurrent].y *= -1.0f;
// read texture coordinates
pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[ pcTriangles->INDEXES[c]].U;