fix hl1 mdl orientation, tex coords, face windings order
parent
96d0524fab
commit
4798ff3882
|
@ -868,7 +868,7 @@ void HL1MDLLoader::read_meshes() {
|
||||||
scene_mesh->mNormals[v] = bind_pose_normals[pTrivert->normindex];
|
scene_mesh->mNormals[v] = bind_pose_normals[pTrivert->normindex];
|
||||||
scene_mesh->mTextureCoords[0][v] = aiVector3D(
|
scene_mesh->mTextureCoords[0][v] = aiVector3D(
|
||||||
pTrivert->s * texcoords_s_scale,
|
pTrivert->s * texcoords_s_scale,
|
||||||
pTrivert->t * texcoords_t_scale, 0);
|
pTrivert->t * -texcoords_t_scale, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add face and indices.
|
// Add face and indices.
|
||||||
|
@ -879,9 +879,9 @@ void HL1MDLLoader::read_meshes() {
|
||||||
aiFace *face = &scene_mesh->mFaces[f];
|
aiFace *face = &scene_mesh->mFaces[f];
|
||||||
face->mNumIndices = 3;
|
face->mNumIndices = 3;
|
||||||
face->mIndices = new unsigned int[3];
|
face->mIndices = new unsigned int[3];
|
||||||
face->mIndices[0] = mesh_faces[f].v0;
|
face->mIndices[0] = mesh_faces[f].v2;
|
||||||
face->mIndices[1] = mesh_faces[f].v1;
|
face->mIndices[1] = mesh_faces[f].v1;
|
||||||
face->mIndices[2] = mesh_faces[f].v2;
|
face->mIndices[2] = mesh_faces[f].v0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add mesh bones.
|
// Add mesh bones.
|
||||||
|
|
|
@ -199,6 +199,7 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
const uint32_t iMagicWord = *((uint32_t *)mBuffer);
|
const uint32_t iMagicWord = *((uint32_t *)mBuffer);
|
||||||
|
|
||||||
// Determine the file subtype and call the appropriate member function
|
// Determine the file subtype and call the appropriate member function
|
||||||
|
bool is_half_life = false;
|
||||||
|
|
||||||
// Original Quake1 format
|
// Original Quake1 format
|
||||||
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
||||||
|
@ -240,6 +241,7 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
||||||
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord) {
|
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord) {
|
||||||
iGSFileVersion = 0;
|
iGSFileVersion = 0;
|
||||||
|
is_half_life = true;
|
||||||
|
|
||||||
HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer;
|
HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer;
|
||||||
if (pHeader->version == AI_MDL_HL1_VERSION) {
|
if (pHeader->version == AI_MDL_HL1_VERSION) {
|
||||||
|
@ -255,9 +257,19 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
". Magic word (", std::string((char *)&iMagicWord, 4), ") is not known");
|
". Magic word (", std::string((char *)&iMagicWord, 4), ") is not known");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
if (is_half_life){
|
||||||
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
|
// Now rotate the whole scene 90 degrees around the z and x axes to convert to internal coordinate system
|
||||||
0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
|
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||||
|
0.f, -1.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 1.f, 0.f,
|
||||||
|
-1.f, 0.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 0.f, 1.f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||||
|
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
DeleteBufferAndCleanup();
|
DeleteBufferAndCleanup();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
Loading…
Reference in New Issue