From 6d13fd6aa2271fb923a6f1c1573f17f4ed47af17 Mon Sep 17 00:00:00 2001 From: Maki Date: Fri, 15 Jan 2021 02:56:45 +0000 Subject: [PATCH 1/7] Fix glTF vertex colors with types other than float --- code/AssetLib/glTF2/glTF2Importer.cpp | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index ac3b7144e..0eba5512b 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -383,6 +383,22 @@ static inline bool CheckValidFacesIndices(aiFace *faces, unsigned nFaces, unsign } #endif // ASSIMP_BUILD_DEBUG +template +aiColor4D* GetVertexColorsForType(glTF2::Ref input) { + float max = std::numeric_limits::max(); + aiColor4t* colors; + input->ExtractData(colors); + auto output = new aiColor4D[input->count]; + for (size_t i = 0; i < input->count; i++) { + output[i] = aiColor4D( + colors[i].r / max, colors[i].g / max, + colors[i].b / max, colors[i].a / max + ); + } + delete[] colors; + return output; +} + void glTF2Importer::ImportMeshes(glTF2::Asset &r) { ASSIMP_LOG_DEBUG_F("Importing ", r.meshes.Size(), " meshes"); std::vector> meshes; @@ -463,7 +479,17 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) { "\" does not match the vertex count"); continue; } - attr.color[c]->ExtractData(aim->mColors[c]); + + auto componentType = attr.color[c]->componentType; + if (componentType == glTF2::ComponentType_FLOAT) { + attr.color[c]->ExtractData(aim->mColors[c]); + } else { + if (componentType == glTF2::ComponentType_UNSIGNED_BYTE) { + aim->mColors[c] = GetVertexColorsForType(attr.color[c]); + } else if (componentType == glTF2::ComponentType_UNSIGNED_SHORT) { + aim->mColors[c] = GetVertexColorsForType(attr.color[c]); + } + } } for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) { if (!attr.texcoord[tc]) { From 8ba1d38deac09228aa58589f2a09e64a80584f16 Mon Sep 17 00:00:00 2001 From: xiaohunqupo Date: Wed, 20 Jan 2021 16:29:30 +0800 Subject: [PATCH 2/7] Fix STL Expoter error. --- code/AssetLib/STL/STLExporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/STL/STLExporter.cpp b/code/AssetLib/STL/STLExporter.cpp index fd4c41033..890ee166f 100644 --- a/code/AssetLib/STL/STLExporter.cpp +++ b/code/AssetLib/STL/STLExporter.cpp @@ -147,7 +147,7 @@ STLExporter::STLExporter(const char* _filename, const aiScene* pScene, bool expo for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { WriteMesh(pScene->mMeshes[ i ]); } - mOutput << EndSolidToken << name << endl; + mOutput << EndSolidToken << " " << name << endl; } } From 345726f5c87de405fb60dcbbe573289e77aa5b6d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 21 Jan 2021 20:56:21 +0100 Subject: [PATCH 3/7] Update Build.md --- Build.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Build.md b/Build.md index 4b7513313..b4d1bdad0 100644 --- a/Build.md +++ b/Build.md @@ -1,6 +1,6 @@ -# Build Instructions +# Build / Install Instructions -## Build on all platforms using vcpkg +## Install on all platforms using vcpkg You can download and install assimp using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: ```bash git clone https://github.com/Microsoft/vcpkg.git @@ -11,6 +11,18 @@ You can download and install assimp using the [vcpkg](https://github.com/Microso ``` The assimp port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. +## Install on Ubuntu +You can install the Asset-Importer-Lib via apt: +``` +sudo apt-get install assimp +``` + +## Install pyassimp +You need to have pip installed: +``` +pip install pyassimp +``` + ## Manual build instructions ### Install CMake @@ -24,6 +36,12 @@ Make sure you have a working git-installation. Open a command prompt and clone t ```bash git clone https://github.com/assimp/assimp.git ``` +### Build from source: +```bash +cd assimp +cmake CMakeLists.txt +cmake --build . +``` ### Build instructions for Windows with Visual-Studio From f44572157a0fe70ea3f03da8bf4c7851d9d3012a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 22 Jan 2021 13:14:59 +0100 Subject: [PATCH 4/7] Update 3DSLoader.cpp --- code/AssetLib/3DS/3DSLoader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp index 4c24394fb..c041df0a3 100644 --- a/code/AssetLib/3DS/3DSLoader.cpp +++ b/code/AssetLib/3DS/3DSLoader.cpp @@ -266,6 +266,7 @@ void Discreet3DSImporter::ParseMainChunk() { case Discreet3DS::CHUNK_PRJ: bIsPrj = true; + break; case Discreet3DS::CHUNK_MAIN: ParseEditorChunk(); break; From 0dcd72d420ddb7eb9604263bb748a35a20f088be Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 22 Jan 2021 13:18:43 +0100 Subject: [PATCH 5/7] Update IFCOpenings.cpp --- code/AssetLib/IFC/IFCOpenings.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/code/AssetLib/IFC/IFCOpenings.cpp b/code/AssetLib/IFC/IFCOpenings.cpp index e15691957..4bf74c0d3 100644 --- a/code/AssetLib/IFC/IFCOpenings.cpp +++ b/code/AssetLib/IFC/IFCOpenings.cpp @@ -1189,20 +1189,9 @@ bool GenerateOpenings(std::vector& openings, TempMesh* profile_data = opening.profileMesh.get(); bool is_2d_source = false; if (opening.profileMesh2D && norm_extrusion_dir.SquareLength() > 0) { - - if(std::fabs(norm_extrusion_dir * wall_extrusion_axis_norm) < 0.1) { - // horizontal extrusion - if (std::fabs(norm_extrusion_dir * nor) > 0.9) { - profile_data = opening.profileMesh2D.get(); - is_2d_source = true; - } - } - else { - // vertical extrusion - if (std::fabs(norm_extrusion_dir * nor) > 0.9) { - profile_data = opening.profileMesh2D.get(); - is_2d_source = true; - } + if (std::fabs(norm_extrusion_dir * nor) > 0.9) { + profile_data = opening.profileMesh2D.get(); + is_2d_source = true; } } std::vector profile_verts = profile_data->mVerts; From dc4514de826d100af588edfa3a2cf6c0dea8713b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 22 Jan 2021 13:23:39 +0100 Subject: [PATCH 6/7] Update COBLoader.cpp Fix cppcheck finding --- code/AssetLib/COB/COBLoader.cpp | 42 +++++++++++++-------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp index 80b41143e..a97ce8ea9 100644 --- a/code/AssetLib/COB/COBLoader.cpp +++ b/code/AssetLib/COB/COBLoader.cpp @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ASSIMP_BUILD_NO_COB_IMPORTER + #include "AssetLib/COB/COBLoader.h" #include "AssetLib/COB/COBScene.h" #include "PostProcessing/ConvertToLHProcess.h" @@ -90,11 +91,15 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -COBImporter::COBImporter() {} +COBImporter::COBImporter() { + // empty +} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -COBImporter::~COBImporter() {} +COBImporter::~COBImporter() { + // empty +} // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. @@ -466,8 +471,9 @@ void COBImporter::UnsupportedChunk_Ascii(LineSplitter &splitter, const ChunkInfo // missing the next line. splitter.get_stream().IncPtr(nfo.size); splitter.swallow_next_increment(); - } else + } else { ThrowException(error); + } } // ------------------------------------------------------------------------------------------------ @@ -790,25 +796,12 @@ void COBImporter::ReadBitM_Ascii(Scene & /*out*/, LineSplitter &splitter, const if (nfo.version > 1) { return UnsupportedChunk_Ascii(splitter, nfo, "BitM"); } - /* - "\nThumbNailHdrSize %ld" - "\nThumbHeader: %02hx 02hx %02hx " - "\nColorBufSize %ld" - "\nColorBufZipSize %ld" - "\nZippedThumbnail: %02hx 02hx %02hx " -*/ const unsigned int head = strtoul10((++splitter)[1]); if (head != sizeof(Bitmap::BitmapHeader)) { ASSIMP_LOG_WARN("Unexpected ThumbNailHdrSize, skipping this chunk"); return; } - - /*union { - Bitmap::BitmapHeader data; - char opaq[sizeof Bitmap::BitmapHeader()]; - };*/ - // ReadHexOctets(opaq,head,(++splitter)[1]); } // ------------------------------------------------------------------------------------------------ @@ -884,7 +877,10 @@ void COBImporter::ReadBinaryFile(Scene &out, StreamReaderLE *reader) { while (1) { std::string type; - type += reader->GetI1(), type += reader->GetI1(), type += reader->GetI1(), type += reader->GetI1(); + type += reader->GetI1(); + type += reader->GetI1(); + type += reader->GetI1(); + type += reader->GetI1(); ChunkInfo nfo; nfo.version = reader->GetI2() * 10; @@ -906,14 +902,7 @@ void COBImporter::ReadBinaryFile(Scene &out, StreamReaderLE *reader) { ReadCame_Binary(out, *reader, nfo); } else if (type == "Mat1") { ReadMat1_Binary(out, *reader, nfo); - } - /* else if (type == "Bone") { - ReadBone_Binary(out,*reader,nfo); - } - else if (type == "Chan") { - ReadChan_Binary(out,*reader,nfo); - }*/ - else if (type == "Unit") { + } else if (type == "Unit") { ReadUnit_Binary(out, *reader, nfo); } else if (type == "OLay") { // ignore layer index silently. @@ -923,8 +912,9 @@ void COBImporter::ReadBinaryFile(Scene &out, StreamReaderLE *reader) { return UnsupportedChunk_Binary(*reader, nfo, type.c_str()); } else if (type == "END ") { return; - } else + } else { UnsupportedChunk_Binary(*reader, nfo, type.c_str()); + } } } From e792455d669860b5b65a4151768be6059f51d20f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 22 Jan 2021 14:22:34 +0100 Subject: [PATCH 7/7] Remove redundant statement in if - closes https://github.com/assimp/assimp/issues/3180 --- code/AssetLib/IFC/IFCGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/IFC/IFCGeometry.cpp b/code/AssetLib/IFC/IFCGeometry.cpp index 7e8a06bbb..d6d069fc4 100644 --- a/code/AssetLib/IFC/IFCGeometry.cpp +++ b/code/AssetLib/IFC/IFCGeometry.cpp @@ -656,7 +656,7 @@ void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const Te } } - if( openings && ((sides_with_openings == 1 && sides_with_openings) || (sides_with_v_openings == 2 && sides_with_v_openings)) ) { + if( openings && (sides_with_openings == 1 || sides_with_v_openings == 2 ) ) { IFCImporter::LogWarn("failed to resolve all openings, presumably their topology is not supported by Assimp"); }