Make coord transfor for hs1 files optional

pull/5687/head
Kim Kulling 2024-07-26 16:49:31 +02:00
parent 104a70f845
commit 88cb1a2ea1
2 changed files with 25 additions and 11 deletions

View File

@ -63,7 +63,8 @@ struct HL1ImportSettings {
read_bone_controllers(false),
read_hitboxes(false),
read_textures(false),
read_misc_global_info(false) {
read_misc_global_info(false),
transform_coord_system(false) {
}
bool read_animations;
@ -76,6 +77,7 @@ struct HL1ImportSettings {
bool read_hitboxes;
bool read_textures;
bool read_misc_global_info;
bool transform_coord_system;
};
} // namespace HalfLife

View File

@ -146,6 +146,20 @@ const aiImporterDesc *MDLImporter::GetInfo() const {
return &desc;
}
// ------------------------------------------------------------------------------------------------
static void transformCoordinateSystem(const aiScene *pScene) {
if (pScene == nullptr) {
return;
}
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
);
}
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
void MDLImporter::InternReadFile(const std::string &pFile,
@ -246,18 +260,16 @@ void MDLImporter::InternReadFile(const std::string &pFile,
". Magic word (", ai_str_toprintable((const char *)&iMagicWord, sizeof(iMagicWord)), ") is not known");
}
if (is_half_life){
if (is_half_life && mHL1ImportSettings.transform_coord_system) {
// Now rotate the whole scene 90 degrees around the z and x axes to convert to internal coordinate system
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 {
transformCoordinateSystem(pScene);
} 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);
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();