diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 67def907c..9144b4644 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1213,10 +1213,6 @@ SET_TARGET_PROPERTIES( assimp PROPERTIES ) if (APPLE) - SET_TARGET_PROPERTIES( assimp PROPERTIES - INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR}" - ) - if (BUILD_FRAMEWORK) SET_TARGET_PROPERTIES( assimp PROPERTIES FRAMEWORK TRUE diff --git a/code/MDL/HalfLife/HL1MDLLoader.cpp b/code/MDL/HalfLife/HL1MDLLoader.cpp index 06ffd7801..aa77c08c5 100644 --- a/code/MDL/HalfLife/HL1MDLLoader.cpp +++ b/code/MDL/HalfLife/HL1MDLLoader.cpp @@ -182,6 +182,13 @@ void HL1MDLLoader::load_file() { read_global_info(); + if (!header_->numbodyparts) { + // This could be an MDL external texture file. In this case, + // add this flag to allow the scene to be loaded even if it + // has no meshes. + scene_->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; + } + // Append children to root node. if (rootnode_children_.size()) { scene_->mRootNode->addChildren( @@ -218,21 +225,6 @@ void HL1MDLLoader::validate_header(const Header_HL1 *header, bool is_texture_hea } } else { - // Every single Half-Life model is assumed to have at least one bodypart. - if (!header->numbodyparts) { - throw DeadlyImportError(MDL_HALFLIFE_LOG_HEADER "Model has no bodyparts"); - } - - // Every single Half-Life model is assumed to have at least one bone. - if (!header->numbones) { - throw DeadlyImportError(MDL_HALFLIFE_LOG_HEADER "Model has no bones"); - } - - // Every single Half-Life model is assumed to have at least one sequence group, - // which is the "default" sequence group. - if (!header->numseqgroups) { - throw DeadlyImportError(MDL_HALFLIFE_LOG_HEADER "Model has no sequence groups"); - } if (header->numbodyparts > AI_MDL_HL1_MAX_BODYPARTS) { log_warning_limit_exceeded(header->numbodyparts, "bodyparts"); @@ -381,9 +373,9 @@ void HL1MDLLoader::read_texture(const Texture_HL1 *ptexture, pResult->mFilename = ptexture->name; pResult->mWidth = outwidth; pResult->mHeight = outheight; - pResult->achFormatHint[0] = 'b'; + pResult->achFormatHint[0] = 'r'; pResult->achFormatHint[1] = 'g'; - pResult->achFormatHint[2] = 'r'; + pResult->achFormatHint[2] = 'b'; pResult->achFormatHint[3] = 'a'; pResult->achFormatHint[4] = '8'; pResult->achFormatHint[5] = '8'; @@ -498,6 +490,10 @@ void HL1MDLLoader::read_skins() { // ------------------------------------------------------------------------------------------------ void HL1MDLLoader::read_bones() { + if (!header_->numbones) { + return; + } + const Bone_HL1 *pbone = (const Bone_HL1 *)((uint8_t *)header_ + header_->boneindex); std::vector unique_bones_names(header_->numbones); @@ -588,6 +584,9 @@ void HL1MDLLoader::read_bones() { triangles, respectively (3 indices per face). */ void HL1MDLLoader::read_meshes() { + if (!header_->numbodyparts) { + return; + } int total_verts = 0; int total_triangles = 0; @@ -964,8 +963,9 @@ void HL1MDLLoader::read_meshes() { // ------------------------------------------------------------------------------------------------ void HL1MDLLoader::read_animations() { - if (!header_->numseq) + if (!header_->numseq) { return; + } const SequenceDesc_HL1 *pseqdesc = (const SequenceDesc_HL1 *)((uint8_t *)header_ + header_->seqindex); const SequenceGroup_HL1 *pseqgroup = nullptr; @@ -1067,6 +1067,9 @@ void HL1MDLLoader::read_animations() { // ------------------------------------------------------------------------------------------------ void HL1MDLLoader::read_sequence_groups_info() { + if (!header_->numseqgroups) { + return; + } aiNode *sequence_groups_node = new aiNode(AI_MDL_HL1_NODE_SEQUENCE_GROUPS); rootnode_children_.push_back(sequence_groups_node); diff --git a/test/models-nonbsd/3DS/m_rifl.bmp b/test/models-nonbsd/3DS/m_rifl.bmp index bb27dadb2..fc1d8c281 100644 Binary files a/test/models-nonbsd/3DS/m_rifl.bmp and b/test/models-nonbsd/3DS/m_rifl.bmp differ diff --git a/test/models-nonbsd/AMF/screenshot_3_bananas.jpeg b/test/models-nonbsd/AMF/screenshot_3_bananas.jpeg index faa2cac85..976fcb03b 100644 Binary files a/test/models-nonbsd/AMF/screenshot_3_bananas.jpeg and b/test/models-nonbsd/AMF/screenshot_3_bananas.jpeg differ diff --git a/test/models-nonbsd/B3D/turtle1.png b/test/models-nonbsd/B3D/turtle1.png index fbdcfb5b7..42c43db31 100644 Binary files a/test/models-nonbsd/B3D/turtle1.png and b/test/models-nonbsd/B3D/turtle1.png differ diff --git a/test/models-nonbsd/FBX/2013_ASCII/duck_sample.jpg b/test/models-nonbsd/FBX/2013_ASCII/duck_sample.jpg index 953d3e5fc..9ce7a59ca 100644 Binary files a/test/models-nonbsd/FBX/2013_ASCII/duck_sample.jpg and b/test/models-nonbsd/FBX/2013_ASCII/duck_sample.jpg differ diff --git a/test/models-nonbsd/FBX/2013_ASCII/m_rifl.bmp b/test/models-nonbsd/FBX/2013_ASCII/m_rifl.bmp index bb27dadb2..fc1d8c281 100644 Binary files a/test/models-nonbsd/FBX/2013_ASCII/m_rifl.bmp and b/test/models-nonbsd/FBX/2013_ASCII/m_rifl.bmp differ diff --git a/test/models-nonbsd/IRR/skybox/default_skybox3.jpg b/test/models-nonbsd/IRR/skybox/default_skybox3.jpg index c7dfe7c70..e8107ff99 100644 Binary files a/test/models-nonbsd/IRR/skybox/default_skybox3.jpg and b/test/models-nonbsd/IRR/skybox/default_skybox3.jpg differ diff --git a/test/models-nonbsd/IRR/skybox/default_skyboxdn.jpg b/test/models-nonbsd/IRR/skybox/default_skyboxdn.jpg index 8eb987084..af66a6176 100644 Binary files a/test/models-nonbsd/IRR/skybox/default_skyboxdn.jpg and b/test/models-nonbsd/IRR/skybox/default_skyboxdn.jpg differ diff --git a/test/models-nonbsd/IRR/skybox/default_skyboxup.jpg b/test/models-nonbsd/IRR/skybox/default_skyboxup.jpg index 730e5ec3e..7959709fa 100644 Binary files a/test/models-nonbsd/IRR/skybox/default_skyboxup.jpg and b/test/models-nonbsd/IRR/skybox/default_skyboxup.jpg differ diff --git a/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/euro_frnt_2.tga b/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/euro_frnt_2.tga index 3bb9f5097..47ff6d620 100644 Binary files a/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/euro_frnt_2.tga and b/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/euro_frnt_2.tga differ diff --git a/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt.tga b/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt.tga index 292ff31c6..0621ca3a4 100644 Binary files a/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt.tga and b/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt.tga differ diff --git a/test/models-nonbsd/MD3/water_can.tga b/test/models-nonbsd/MD3/water_can.tga index 794665a6d..0d7a1cbc5 100644 Binary files a/test/models-nonbsd/MD3/water_can.tga and b/test/models-nonbsd/MD3/water_can.tga differ diff --git a/test/models-nonbsd/MD5/guard1_body.png b/test/models-nonbsd/MD5/guard1_body.png index 908b51f83..2eb3f2caa 100644 Binary files a/test/models-nonbsd/MD5/guard1_body.png and b/test/models-nonbsd/MD5/guard1_body.png differ diff --git a/test/models-nonbsd/MD5/guard1_face.png b/test/models-nonbsd/MD5/guard1_face.png index 282f5906f..b7e17d375 100644 Binary files a/test/models-nonbsd/MD5/guard1_face.png and b/test/models-nonbsd/MD5/guard1_face.png differ diff --git a/test/models-nonbsd/MD5/guard1_helmet.png b/test/models-nonbsd/MD5/guard1_helmet.png index 081a0498f..166d790fd 100644 Binary files a/test/models-nonbsd/MD5/guard1_helmet.png and b/test/models-nonbsd/MD5/guard1_helmet.png differ diff --git a/test/models-nonbsd/MD5/iron_grill.png b/test/models-nonbsd/MD5/iron_grill.png index 3c30c53c8..53a3bbbcc 100644 Binary files a/test/models-nonbsd/MD5/iron_grill.png and b/test/models-nonbsd/MD5/iron_grill.png differ diff --git a/test/models-nonbsd/MD5/round_grill.png b/test/models-nonbsd/MD5/round_grill.png index a35cbdfa6..502a1d782 100644 Binary files a/test/models-nonbsd/MD5/round_grill.png and b/test/models-nonbsd/MD5/round_grill.png differ diff --git a/test/models-nonbsd/MDL/MDL7 (3DGS A7)/branchD_texture.png b/test/models-nonbsd/MDL/MDL7 (3DGS A7)/branchD_texture.png index 5d7888411..a1782dc6b 100644 Binary files a/test/models-nonbsd/MDL/MDL7 (3DGS A7)/branchD_texture.png and b/test/models-nonbsd/MDL/MDL7 (3DGS A7)/branchD_texture.png differ diff --git a/test/models-nonbsd/Ogre/OgreSDK/fish.jpg b/test/models-nonbsd/Ogre/OgreSDK/fish.jpg index 122bd8382..04cbf2f83 100644 Binary files a/test/models-nonbsd/Ogre/OgreSDK/fish.jpg and b/test/models-nonbsd/Ogre/OgreSDK/fish.jpg differ diff --git a/test/models/3DS/CWALL02.jpg b/test/models/3DS/CWALL02.jpg index 72ca82824..93364a0bd 100644 Binary files a/test/models/3DS/CWALL02.jpg and b/test/models/3DS/CWALL02.jpg differ diff --git a/test/models/3DS/IMAGE2.jpg b/test/models/3DS/IMAGE2.jpg index 66ba54bec..d7ce7a64c 100644 Binary files a/test/models/3DS/IMAGE2.jpg and b/test/models/3DS/IMAGE2.jpg differ diff --git a/test/models/3DS/UVTransformTest/UVTransformTestImg.png b/test/models/3DS/UVTransformTest/UVTransformTestImg.png index 906750840..020da1772 100644 Binary files a/test/models/3DS/UVTransformTest/UVTransformTestImg.png and b/test/models/3DS/UVTransformTest/UVTransformTestImg.png differ diff --git a/test/models/3DS/test.png b/test/models/3DS/test.png index e5725bbbd..501fcdecf 100644 Binary files a/test/models/3DS/test.png and b/test/models/3DS/test.png differ diff --git a/test/models/Collada/duck_sample.jpg b/test/models/Collada/duck_sample.jpg index 953d3e5fc..9ce7a59ca 100644 Binary files a/test/models/Collada/duck_sample.jpg and b/test/models/Collada/duck_sample.jpg differ diff --git a/test/models/Collada/teapots_reference.png b/test/models/Collada/teapots_reference.png index ef01c8601..c7db36213 100644 Binary files a/test/models/Collada/teapots_reference.png and b/test/models/Collada/teapots_reference.png differ diff --git a/test/models/IRRMesh/1.png b/test/models/IRRMesh/1.png index cba123d13..e7200658b 100644 Binary files a/test/models/IRRMesh/1.png and b/test/models/IRRMesh/1.png differ diff --git a/test/models/LWO/LWO2/MappingModes/earthCylindric.jpg b/test/models/LWO/LWO2/MappingModes/earthCylindric.jpg index e1bf47eaf..da9688b44 100644 Binary files a/test/models/LWO/LWO2/MappingModes/earthCylindric.jpg and b/test/models/LWO/LWO2/MappingModes/earthCylindric.jpg differ diff --git a/test/models/LWO/LWO2/MappingModes/earthSpherical.jpg b/test/models/LWO/LWO2/MappingModes/earthSpherical.jpg index 9c9a13e4e..3419e8071 100644 Binary files a/test/models/LWO/LWO2/MappingModes/earthSpherical.jpg and b/test/models/LWO/LWO2/MappingModes/earthSpherical.jpg differ diff --git a/test/models/LWO/LWO2/boxuv.png b/test/models/LWO/LWO2/boxuv.png index 1fb26e97a..9da32691e 100644 Binary files a/test/models/LWO/LWO2/boxuv.png and b/test/models/LWO/LWO2/boxuv.png differ diff --git a/test/models/LWO/LWO2/uvtest.png b/test/models/LWO/LWO2/uvtest.png index d4a2fcb3d..1701d737b 100644 Binary files a/test/models/LWO/LWO2/uvtest.png and b/test/models/LWO/LWO2/uvtest.png differ diff --git a/test/models/MD2/faerie2.bmp b/test/models/MD2/faerie2.bmp index ef372415f..56a486a6c 100644 Binary files a/test/models/MD2/faerie2.bmp and b/test/models/MD2/faerie2.bmp differ diff --git a/test/models/MD2/sydney.bmp b/test/models/MD2/sydney.bmp index 1c2d21675..2f14a5a03 100644 Binary files a/test/models/MD2/sydney.bmp and b/test/models/MD2/sydney.bmp differ diff --git a/test/models/Ogre/TheThing/Reference.JPG b/test/models/Ogre/TheThing/Reference.JPG index 29aa07a8a..6eebcc841 100644 Binary files a/test/models/Ogre/TheThing/Reference.JPG and b/test/models/Ogre/TheThing/Reference.JPG differ diff --git a/test/models/ReferenceImages/MappingModes/cylindrical.png b/test/models/ReferenceImages/MappingModes/cylindrical.png index a6e008fb6..a1ad5979b 100644 Binary files a/test/models/ReferenceImages/MappingModes/cylindrical.png and b/test/models/ReferenceImages/MappingModes/cylindrical.png differ diff --git a/test/models/ReferenceImages/MappingModes/spherical.png b/test/models/ReferenceImages/MappingModes/spherical.png index 0a3d52b8b..c6d589832 100644 Binary files a/test/models/ReferenceImages/MappingModes/spherical.png and b/test/models/ReferenceImages/MappingModes/spherical.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_Normal.png b/test/models/ReferenceImages/UVTransform/UVTransform_Normal.png index 3f3f5d69e..b8f6f54f1 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_Normal.png and b/test/models/ReferenceImages/UVTransform/UVTransform_Normal.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5-clampUV.png b/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5-clampUV.png index 8599de676..aa07d1270 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5-clampUV.png and b/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5-clampUV.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5-mirrorUV.png b/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5-mirrorUV.png index 96bae703c..447d30c32 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5-mirrorUV.png and b/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5-mirrorUV.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5.png b/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5.png index da2c67fe1..c8c1d69e0 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5.png and b/test/models/ReferenceImages/UVTransform/UVTransform_OffsetUV0.5.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.png b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.png index 39a23001c..4645a5668 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.png and b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.png b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.png index dd22c1e97..9fdc6daab 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.png and b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV10-2_OffsetUV10-mirrorUV.png b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV10-2_OffsetUV10-mirrorUV.png index 317d4a62c..3e32f1bd5 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV10-2_OffsetUV10-mirrorUV.png and b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV10-2_OffsetUV10-mirrorUV.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV2x.png b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV2x.png index af08afde6..fe9926e41 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV2x.png and b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV2x.png differ diff --git a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV2x_Rotate45.png b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV2x_Rotate45.png index 9210d2a9c..ac15908c3 100644 Binary files a/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV2x_Rotate45.png and b/test/models/ReferenceImages/UVTransform/UVTransform_ScaleUV2x_Rotate45.png differ diff --git a/test/models/SIB/This Way Up.png b/test/models/SIB/This Way Up.png index 9cac59ab5..87c8ba1dc 100644 Binary files a/test/models/SIB/This Way Up.png and b/test/models/SIB/This Way Up.png differ diff --git a/test/models/SIB/UV Mapping.png b/test/models/SIB/UV Mapping.png index 952a51d74..3d8e235d4 100644 Binary files a/test/models/SIB/UV Mapping.png and b/test/models/SIB/UV Mapping.png differ diff --git a/test/models/X/bottom.tga b/test/models/X/bottom.tga index 5a10ffaae..4d6fd56e6 100644 Binary files a/test/models/X/bottom.tga and b/test/models/X/bottom.tga differ diff --git a/test/models/X/test.png b/test/models/X/test.png index e5725bbbd..501fcdecf 100644 Binary files a/test/models/X/test.png and b/test/models/X/test.png differ diff --git a/test/models/X/top.tga b/test/models/X/top.tga index de7292fcf..16691cd1d 100644 Binary files a/test/models/X/top.tga and b/test/models/X/top.tga differ diff --git a/test/models/glTF/BoxTextured-glTF-MaterialsCommon/CesiumLogoFlat.png b/test/models/glTF/BoxTextured-glTF-MaterialsCommon/CesiumLogoFlat.png index c76b4d1a3..88bada374 100644 Binary files a/test/models/glTF/BoxTextured-glTF-MaterialsCommon/CesiumLogoFlat.png and b/test/models/glTF/BoxTextured-glTF-MaterialsCommon/CesiumLogoFlat.png differ diff --git a/test/models/glTF/BoxTextured-glTF/CesiumLogoFlat.png b/test/models/glTF/BoxTextured-glTF/CesiumLogoFlat.png index c76b4d1a3..88bada374 100644 Binary files a/test/models/glTF/BoxTextured-glTF/CesiumLogoFlat.png and b/test/models/glTF/BoxTextured-glTF/CesiumLogoFlat.png differ diff --git a/test/models/glTF/CesiumMilkTruck/CesiumMilkTruck.png b/test/models/glTF/CesiumMilkTruck/CesiumMilkTruck.png index 1bed7057f..ba7a47c7f 100644 Binary files a/test/models/glTF/CesiumMilkTruck/CesiumMilkTruck.png and b/test/models/glTF/CesiumMilkTruck/CesiumMilkTruck.png differ diff --git a/test/models/glTF2/BoxTextured-glTF-pbrSpecularGlossiness/CesiumLogoFlat.png b/test/models/glTF2/BoxTextured-glTF-pbrSpecularGlossiness/CesiumLogoFlat.png index 8b906c7aa..45d502ed2 100644 Binary files a/test/models/glTF2/BoxTextured-glTF-pbrSpecularGlossiness/CesiumLogoFlat.png and b/test/models/glTF2/BoxTextured-glTF-pbrSpecularGlossiness/CesiumLogoFlat.png differ diff --git a/test/models/glTF2/BoxTextured-glTF-techniqueWebGL/CesiumLogoFlat.png b/test/models/glTF2/BoxTextured-glTF-techniqueWebGL/CesiumLogoFlat.png index 8b906c7aa..45d502ed2 100644 Binary files a/test/models/glTF2/BoxTextured-glTF-techniqueWebGL/CesiumLogoFlat.png and b/test/models/glTF2/BoxTextured-glTF-techniqueWebGL/CesiumLogoFlat.png differ diff --git a/test/models/glTF2/BoxTextured-glTF/CesiumLogoFlat.png b/test/models/glTF2/BoxTextured-glTF/CesiumLogoFlat.png index 8b906c7aa..45d502ed2 100644 Binary files a/test/models/glTF2/BoxTextured-glTF/CesiumLogoFlat.png and b/test/models/glTF2/BoxTextured-glTF/CesiumLogoFlat.png differ diff --git a/test/unit/ImportExport/utMDLImporter.cpp b/test/unit/ImportExport/utMDLImporter.cpp index 561b3009f..b9a850175 100644 --- a/test/unit/ImportExport/utMDLImporter.cpp +++ b/test/unit/ImportExport/utMDLImporter.cpp @@ -57,13 +57,24 @@ public: virtual bool importerTest() { Assimp::Importer importer; - const aiScene *scene = importer.ReadFile(MDL_HL1_FILE_MAN, 0); - EXPECT_NE(nullptr, scene); + importerTest_HL1(&importer); // Add further MDL tests... return true; } + +private: + void importerTest_HL1(Assimp::Importer* const importer) { + const aiScene *scene = importer->ReadFile(MDL_HL1_FILE_MAN, 0); + EXPECT_NE(nullptr, scene); + + // Test that the importer can directly load an HL1 MDL external texture file. + scene = importer->ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "manT.mdl", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_NE(0u, scene->mNumTextures); + EXPECT_NE(0u, scene->mNumMaterials); + } }; TEST_F(utMDLImporter, importMDLFromFileTest) { diff --git a/tools/assimp_cmd/CompareDump.cpp b/tools/assimp_cmd/CompareDump.cpp index 86a9cfe4c..282097016 100644 --- a/tools/assimp_cmd/CompareDump.cpp +++ b/tools/assimp_cmd/CompareDump.cpp @@ -885,19 +885,19 @@ int Assimp_CompareDump (const char* const* params, unsigned int num) // --help if ((num == 1 && !strcmp( params[0], "-h")) || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) { printf("%s",AICMD_MSG_CMPDUMP_HELP); - return 0; + return AssimpCmdError::Success; } // assimp cmpdump actual expected if (num < 2) { std::cout << "assimp cmpdump: Invalid number of arguments. " "See \'assimp cmpdump --help\'\r\n" << std::endl; - return 1; + return AssimpCmdError::InvalidNumberOfArguments; } if(!strcmp(params[0],params[1])) { std::cout << "assimp cmpdump: same file, same content." << std::endl; - return 0; + return AssimpCmdError::Success; } class file_ptr @@ -924,13 +924,13 @@ int Assimp_CompareDump (const char* const* params, unsigned int num) if (!actual) { std::cout << "assimp cmpdump: Failure reading ACTUAL data from " << params[0] << std::endl; - return -5; + return AssimpCmdError::FailedToLoadInputFile; } file_ptr expected(fopen(params[1],"rb")); if (!expected) { std::cout << "assimp cmpdump: Failure reading EXPECT data from " << params[1] << std::endl; - return -6; + return AssimpCmdCompareDumpError::FailedToLoadExpectedInputFile; } comparer_context comp(actual,expected); @@ -940,17 +940,17 @@ int Assimp_CompareDump (const char* const* params, unsigned int num) } catch(const compare_fails_exception& ex) { printf("%s",ex.what()); - return -1; + return AssimpCmdCompareDumpError::FileComparaisonFailure; } catch(...) { // we don't bother checking too rigourously here, so // we might end up here ... std::cout << "Unknown failure, are the input files well-defined?"; - return -3; + return AssimpCmdCompareDumpError::UnknownFailure; } std::cout << "Success (totally " << std::dec << comp.get_num_chunks() << " chunks)" << std::endl; - return 0; + return AssimpCmdError::Success; } diff --git a/tools/assimp_cmd/Export.cpp b/tools/assimp_cmd/Export.cpp index 20dc91239..65653c558 100644 --- a/tools/assimp_cmd/Export.cpp +++ b/tools/assimp_cmd/Export.cpp @@ -76,13 +76,13 @@ int Assimp_Export(const char* const* params, unsigned int num) const char* const invalid = "assimp export: Invalid number of arguments. See \'assimp export --help\'\n"; if (num < 1) { printf(invalid); - return 1; + return AssimpCmdError::InvalidNumberOfArguments; } // --help if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) { printf("%s",AICMD_MSG_EXPORT_HELP_E); - return 0; + return AssimpCmdError::Success; } std::string in = std::string(params[0]); @@ -156,7 +156,7 @@ int Assimp_Export(const char* const* params, unsigned int num) // import the model const aiScene* scene = ImportModel(import,in); if (!scene) { - return -39; + return AssimpCmdExportError::FailedToImportModel; } // derive the final file name @@ -164,10 +164,10 @@ int Assimp_Export(const char* const* params, unsigned int num) // and call the export routine if(!ExportModel(scene, import, out,e->id)) { - return -25; + return AssimpCmdExportError::FailedToExportModel; } printf("assimp export: wrote output file: %s\n",out.c_str()); - return 0; + return AssimpCmdError::Success; } #endif // no export diff --git a/tools/assimp_cmd/ImageExtractor.cpp b/tools/assimp_cmd/ImageExtractor.cpp index c587611cb..62fa94f59 100644 --- a/tools/assimp_cmd/ImageExtractor.cpp +++ b/tools/assimp_cmd/ImageExtractor.cpp @@ -219,9 +219,9 @@ int DoExport(const aiTexture* tx, FILE* p, const std::string& extension, } else { printf("assimp extract: No available texture encoder found for %s\n", extension.c_str()); - return 1; + return AssimpCmdExtractError::NoAvailableTextureEncoderFound; } - return 0; + return AssimpCmdError::Success; } // ----------------------------------------------------------------------------------- @@ -232,13 +232,13 @@ int Assimp_Extract (const char* const* params, unsigned int num) // assimp extract in out [options] if (num < 1) { printf(invalid); - return 1; + return AssimpCmdError::InvalidNumberOfArguments; } // --help if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) { printf("%s",AICMD_MSG_DUMP_HELP_E); - return 0; + return AssimpCmdError::Success; } @@ -308,7 +308,7 @@ int Assimp_Extract (const char* const* params, unsigned int num) const aiScene* scene = ImportModel(import,in); if (!scene) { printf("assimp extract: Unable to load input file %s\n",in.c_str()); - return 5; + return AssimpCmdError::FailedToLoadInputFile; } // get the texture(s) to be exported @@ -318,7 +318,7 @@ int Assimp_Extract (const char* const* params, unsigned int num) if (texIdx >= scene->mNumTextures) { ::printf("assimp extract: Texture %i requested, but there are just %i textures\n", texIdx, scene->mNumTextures); - return 6; + return AssimpCmdExtractError::TextureIndexIsOutOfRange; } } else { @@ -358,12 +358,14 @@ int Assimp_Extract (const char* const* params, unsigned int num) FILE* p = ::fopen(out_cpy.c_str(),"wb"); if (!p) { printf("assimp extract: Unable to open output file %s\n",out_cpy.c_str()); - return 7; + return AssimpCmdError::FailedToOpenOutputFile; } int m; if (!tex->mHeight) { - m = (1 != fwrite(tex->pcData,tex->mWidth,1,p)); + m = (1 != fwrite(tex->pcData,tex->mWidth,1,p)) + ? static_cast(AssimpCmdError::Success) + : static_cast(AssimpCmdExtractError::FailedToExportCompressedTexture); } else m = DoExport(tex,p,extension,flags); ::fclose(p); @@ -372,5 +374,5 @@ int Assimp_Extract (const char* const* params, unsigned int num) if (texIdx != 0xffffffff) return m; } - return 0; + return AssimpCmdError::Success; } diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp index 0f23c1f89..1594235f9 100644 --- a/tools/assimp_cmd/Info.cpp +++ b/tools/assimp_cmd/Info.cpp @@ -283,14 +283,14 @@ int Assimp_Info (const char* const* params, unsigned int num) { // --help if (!strcmp( params[0],"-h")||!strcmp( params[0],"--help")||!strcmp( params[0],"-?") ) { printf("%s",AICMD_MSG_INFO_HELP_E); - return 0; + return AssimpCmdError::Success; } // asssimp info [-r] if (num < 1) { printf("assimp info: Invalid number of arguments. " "See \'assimp info --help\'\n"); - return 1; + return AssimpCmdError::InvalidNumberOfArguments; } const std::string in = std::string(params[0]); @@ -314,7 +314,7 @@ int Assimp_Info (const char* const* params, unsigned int num) { // Verbose and silent at the same time are not allowed if ( verbose && silent ) { printf("assimp info: Invalid arguments, verbose and silent at the same time are forbitten. "); - return 1; + return AssimpCmdInfoError::InvalidCombinaisonOfArguments; } // Parse post-processing flags unless -r was specified @@ -333,7 +333,7 @@ int Assimp_Info (const char* const* params, unsigned int num) { if (!scene) { printf("assimp info: Unable to load input file %s\n", in.c_str()); - return 5; + return AssimpCmdError::FailedToLoadInputFile; } aiMemoryInfo mem; @@ -391,7 +391,7 @@ int Assimp_Info (const char* const* params, unsigned int num) { if (silent) { printf("\n"); - return 0; + return AssimpCmdError::Success; } // meshes @@ -473,5 +473,5 @@ int Assimp_Info (const char* const* params, unsigned int num) { PrintHierarchy(scene->mRootNode,"",verbose); printf("\n"); - return 0; + return AssimpCmdError::Success; } diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index ad08b0b11..1037bd73c 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -85,7 +85,7 @@ int main (int argc, char* argv[]) { if (argc <= 1) { printf("assimp: No command specified. Use \'assimp help\' for a detailed command list\n"); - return 0; + return AssimpCmdError::Success; } // assimp version @@ -102,7 +102,7 @@ int main (int argc, char* argv[]) (flags & ASSIMP_CFLAGS_STLPORT ? "-stlport " : ""), aiGetVersionRevision()); - return 0; + return AssimpCmdError::Success; } // assimp help @@ -110,7 +110,7 @@ int main (int argc, char* argv[]) // because people could try them intuitively) if (!strcmp(argv[1], "help") || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) { printf("%s",AICMD_MSG_HELP); - return 0; + return AssimpCmdError::Success; } // assimp cmpdump @@ -137,7 +137,7 @@ int main (int argc, char* argv[]) imp.GetExtensionList(s); printf("%s\n",s.data); - return 0; + return AssimpCmdError::Success; } #ifndef ASSIMP_BUILD_NO_EXPORT @@ -155,7 +155,7 @@ int main (int argc, char* argv[]) } printf("%s\n",s.data); - return 0; + return AssimpCmdError::Success; } @@ -166,19 +166,19 @@ int main (int argc, char* argv[]) if (argc<3) { printf("Expected file format id\n"); - return -11; + return AssimpCmdError::NoFileFormatSpecified; } for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) { const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i); if (!strcmp(e->id,argv[2])) { printf("%s\n%s\n%s\n",e->id,e->fileExtension,e->description); - return 0; + return AssimpCmdError::Success; } } printf("Unknown file format id: \'%s\'\n",argv[2]); - return -12; + return AssimpCmdError::UnknownFileFormat; } // assimp export @@ -194,11 +194,11 @@ int main (int argc, char* argv[]) if (! strcmp(argv[1], "knowext")) { if (argc<3) { printf("Expected file extension"); - return -10; + return AssimpCmdError::NoFileExtensionSpecified; } const bool b = imp.IsExtensionSupported(argv[2]); printf("File extension \'%s\' is %sknown\n",argv[2],(b?"":"not ")); - return b?0:-1; + return b? AssimpCmdError::Success : AssimpCmdError::UnknownFileExtension; } // assimp info @@ -228,7 +228,7 @@ int main (int argc, char* argv[]) } printf("Unrecognized command. Use \'assimp help\' for a detailed command list\n"); - return 1; + return AssimpCmdError::UnrecognizedCommand; } @@ -505,7 +505,7 @@ int ProcessStandardArguments( fill.log = true; } - return 0; + return AssimpCmdError::Success; } // ------------------------------------------------------------------------------ @@ -517,5 +517,5 @@ int Assimp_TestBatchLoad ( globalImporter->ReadFile(params[i],aiProcessPreset_TargetRealtime_MaxQuality); // we're totally silent. scene destructs automatically. } - return 0; + return AssimpCmdError::Success; } diff --git a/tools/assimp_cmd/Main.h b/tools/assimp_cmd/Main.h index 460db2df9..bd070102c 100644 --- a/tools/assimp_cmd/Main.h +++ b/tools/assimp_cmd/Main.h @@ -114,13 +114,31 @@ struct ImportData { bool log; }; +/// \enum AssimpCmdError +/// \brief General error codes used among assimp_cmd's utilities. +enum AssimpCmdError { + Success = 0, + InvalidNumberOfArguments, + UnrecognizedCommand, + FailedToLoadInputFile, + FailedToOpenOutputFile, + NoFileFormatSpecified, + UnknownFileFormat, + NoFileExtensionSpecified, + UnknownFileExtension, + + // Add new error codes here... + + LastAssimpCmdError, // Must be last. +}; + // ------------------------------------------------------------------------------ /** Process standard arguments * * @param fill Filled by function * @param params Command line parameters to be processed * @param num NUmber of params - * @return 0 for success */ + * @return An #AssimpCmdError value. */ int ProcessStandardArguments(ImportData& fill, const char* const* params, unsigned int num); @@ -151,43 +169,88 @@ bool ExportModel(const aiScene* pOut, /** assimp_dump utility * @param params Command line parameters to 'assimp dumb' * @param Number of params - * @return 0 for success*/ + * @return An #AssimpCmdError value.*/ int Assimp_Dump ( const char* const* params, unsigned int num); +/// \enum AssimpCmdExportError +/// \brief Error codes used by the 'Export' utility. +enum AssimpCmdExportError { + FailedToImportModel = AssimpCmdError::LastAssimpCmdError, + FailedToExportModel, + + // Add new error codes here... + + LastAssimpCmdExportError, // Must be last. +}; + // ------------------------------------------------------------------------------ /** assimp_export utility * @param params Command line parameters to 'assimp export' * @param Number of params - * @return 0 for success*/ + * @return Either an #AssimpCmdError or #AssimpCmdExportError value. */ int Assimp_Export ( const char* const* params, unsigned int num); +/// \enum AssimpCmdExtractError +/// \brief Error codes used by the 'Image Extractor' utility. +enum AssimpCmdExtractError { + TextureIndexIsOutOfRange = AssimpCmdError::LastAssimpCmdError, + NoAvailableTextureEncoderFound, + FailedToExportCompressedTexture, + + // Add new error codes here... + + LastAssimpCmdExtractError, // Must be last. +}; + // ------------------------------------------------------------------------------ /** assimp_extract utility * @param params Command line parameters to 'assimp extract' * @param Number of params - * @return 0 for success*/ + * @return Either an #AssimpCmdError or #AssimpCmdExtractError value. */ int Assimp_Extract ( const char* const* params, unsigned int num); +/// \enum AssimpCmdCompareDumpError +/// \brief Error codes used by the 'Compare Dump' utility. +enum AssimpCmdCompareDumpError { + FailedToLoadExpectedInputFile = AssimpCmdError::LastAssimpCmdError, + FileComparaisonFailure, + UnknownFailure, + + // Add new error codes here... + + LastAssimpCmdCompareDumpError, // Must be last. +}; + // ------------------------------------------------------------------------------ /** assimp_cmpdump utility * @param params Command line parameters to 'assimp cmpdump' * @param Number of params - * @return 0 for success*/ + * @return Either an #AssimpCmdError or #AssimpCmdCompareDumpError. */ int Assimp_CompareDump ( const char* const* params, unsigned int num); +/// \enum AssimpCmdInfoError +/// \brief Error codes used by the 'Info' utility. +enum AssimpCmdInfoError { + InvalidCombinaisonOfArguments = AssimpCmdError::LastAssimpCmdError, + + // Add new error codes here... + + LastAssimpCmdInfoError, // Must be last. +}; + // ------------------------------------------------------------------------------ /** @brief assimp info utility * @param params Command line parameters to 'assimp info' * @param Number of params - * @return 0 for success */ + * @return Either an #AssimpCmdError or #AssimpCmdInfoError value. */ int Assimp_Info ( const char* const* params, unsigned int num); @@ -196,7 +259,7 @@ int Assimp_Info ( /** @brief assimp testbatchload utility * @param params Command line parameters to 'assimp testbatchload' * @param Number of params - * @return 0 for success */ + * @return An #AssimpCmdError value. */ int Assimp_TestBatchLoad ( const char* const* params, unsigned int num); diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index b4c22a439..f019cfd6e 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -1341,13 +1341,13 @@ int Assimp_Dump (const char* const* params, unsigned int num) // --help if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) { printf("%s",AICMD_MSG_DUMP_HELP); - return 0; + return AssimpCmdError::Success; } // asssimp dump in out [options] if (num < 1) { printf("%s", fail); - return 1; + return AssimpCmdError::InvalidNumberOfArguments; } std::string in = std::string(params[0]); @@ -1405,14 +1405,14 @@ int Assimp_Dump (const char* const* params, unsigned int num) const aiScene* scene = ImportModel(import,in); if (!scene) { printf("assimp dump: Unable to load input file %s\n",in.c_str()); - return 5; + return AssimpCmdError::FailedToLoadInputFile; } // open the output file and build the dump FILE* o = ::fopen(out.c_str(),(binary ? "wb" : "wt")); if (!o) { printf("assimp dump: Unable to open output file %s\n",out.c_str()); - return 12; + return AssimpCmdError::FailedToOpenOutputFile; } if (binary) { @@ -1426,6 +1426,6 @@ int Assimp_Dump (const char* const* params, unsigned int num) } printf("assimp dump: Wrote output dump %s\n",out.c_str()); - return 0; + return AssimpCmdError::Success; }