diff --git a/code/3DSConverter.cpp b/code/3DSConverter.cpp index e15e492b8..6730bdae7 100644 --- a/code/3DSConverter.cpp +++ b/code/3DSConverter.cpp @@ -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; } } diff --git a/code/3DSGenNormals.cpp b/code/3DSGenNormals.cpp index 51550c951..897f1d1b3 100644 --- a/code/3DSGenNormals.cpp +++ b/code/3DSGenNormals.cpp @@ -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(); } diff --git a/code/MD2Loader.cpp b/code/MD2Loader.cpp index a771057cd..a4686ac92 100644 --- a/code/MD2Loader.cpp +++ b/code/MD2Loader.cpp @@ -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; diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index fa1842061..76ddb6129 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -251,19 +251,18 @@ 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; - pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - pcUVs[ pcTriangles->INDEXES[c]].V; + pcMesh->mTextureCoords[0][iCurrent].y = 1.0f-pcUVs[ pcTriangles->INDEXES[c]].V; } // FIX: flip the face ordering for use with OpenGL pcMesh->mFaces[i].mIndices[0] = iTemp+2;