|
@@ -99,7 +99,7 @@ MDLImporter::MDLImporter() :
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
// Returns whether the class can handle the format of the given file.
|
|
// Returns whether the class can handle the format of the given file.
|
|
bool MDLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
|
bool MDLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
|
- static const uint32_t tokens[] = {
|
|
|
|
|
|
+ static constexpr uint32_t tokens[] = {
|
|
AI_MDL_MAGIC_NUMBER_LE_HL2a,
|
|
AI_MDL_MAGIC_NUMBER_LE_HL2a,
|
|
AI_MDL_MAGIC_NUMBER_LE_HL2b,
|
|
AI_MDL_MAGIC_NUMBER_LE_HL2b,
|
|
AI_MDL_MAGIC_NUMBER_LE_GS7,
|
|
AI_MDL_MAGIC_NUMBER_LE_GS7,
|
|
@@ -138,6 +138,7 @@ void MDLImporter::SetupProperties(const Importer *pImp) {
|
|
mHL1ImportSettings.read_bone_controllers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS, true);
|
|
mHL1ImportSettings.read_bone_controllers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS, true);
|
|
mHL1ImportSettings.read_hitboxes = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES, true);
|
|
mHL1ImportSettings.read_hitboxes = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES, true);
|
|
mHL1ImportSettings.read_misc_global_info = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO, true);
|
|
mHL1ImportSettings.read_misc_global_info = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO, true);
|
|
|
|
+ mHL1ImportSettings.transform_coord_system = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_TRANSFORM_COORD_SYSTEM);
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
@@ -146,6 +147,20 @@ const aiImporterDesc *MDLImporter::GetInfo() const {
|
|
return &desc;
|
|
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.
|
|
// Imports the given file into the given scene structure.
|
|
void MDLImporter::InternReadFile(const std::string &pFile,
|
|
void MDLImporter::InternReadFile(const std::string &pFile,
|
|
@@ -246,18 +261,16 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
|
". Magic word (", ai_str_toprintable((const char *)&iMagicWord, sizeof(iMagicWord)), ") is not known");
|
|
". 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
|
|
// 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
|
|
// 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();
|
|
DeleteBufferAndCleanup();
|