From ec28fe968554f866e124ff716c7c0a7444942d5e Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Mon, 18 Oct 2021 11:23:33 +0200 Subject: ObjectPicker: markDirty(AllDirty) when we change the enabled property Otherwise we would simply change it internally but this wouldn't lead to any actual changes in how we handle pick events. Change-Id: I71aedc74db538978a939620d053af3167fd67dc4 Reviewed-by: Sean Harmer (cherry picked from commit d32ff6b43b92474de495c88783a67b0b30211a7c) Reviewed-by: Qt Cherry-pick Bot --- src/render/picking/objectpicker.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/render/picking/objectpicker.cpp b/src/render/picking/objectpicker.cpp index 07a630857..00c67a846 100644 --- a/src/render/picking/objectpicker.cpp +++ b/src/render/picking/objectpicker.cpp @@ -81,13 +81,16 @@ void ObjectPicker::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstT if (!node) return; - BackendNode::syncFromFrontEnd(frontEnd, firstTime); - if (firstTime) { markDirty(AbstractRenderer::AllDirty); notifyJob(); } + if (isEnabled() != node->isEnabled()) { + markDirty(AbstractRenderer::AllDirty); + // We let QBackendNode::syncFromFrontEnd change the enabled property + } + if (node->isHoverEnabled() != m_hoverEnabled) { m_hoverEnabled = node->isHoverEnabled(); markDirty(AbstractRenderer::AllDirty); @@ -105,6 +108,8 @@ void ObjectPicker::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstT markDirty(AbstractRenderer::AllDirty); notifyJob(); } + + BackendNode::syncFromFrontEnd(frontEnd, firstTime); } void ObjectPicker::notifyJob() -- cgit v1.2.3 From 5661faeeb8301c0f114a138bb92d00c7e79028ea Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Wed, 3 Nov 2021 08:07:53 +0100 Subject: ComputeCommand: call markDirty(ComputeDirty) when enabled changes When using Manual run mode on a QComputeCommand, we rely on the enabled property changing to enable/disable the backend ComputeCommand for a given set of frames. Since we weren't setting any dirty flag when the enabled property changed, Qt 3D was not rebuilding the list of active compute commands but rather using the one stored in its cache. This resulted in the ComputeCommand, now disabled, to still be called for execution until something else triggered a command rebuild. The renderer calls ComputeDirty after it has executed a compute call. This explains why eventually we only had 2 calls (and not a perpetual loop) when calling trigger(1). One was the valid call, followed by the invalid one (and then the command list got rebuilt because of the ComputeDirty flag set by the renderer). Task-number: QTBUG-86493 Change-Id: I7b31606a03609dc13294256b1dac89ee86730ba1 Reviewed-by: Sean Harmer (cherry picked from commit 3d4ac623d444bbbaddc7f63163b204f6c6a55cab) Reviewed-by: Qt Cherry-pick Bot --- src/render/backend/computecommand.cpp | 3 +++ tests/auto/render/computecommand/tst_computecommand.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/render/backend/computecommand.cpp b/src/render/backend/computecommand.cpp index b961ffc53..adf7a2099 100644 --- a/src/render/backend/computecommand.cpp +++ b/src/render/backend/computecommand.cpp @@ -81,7 +81,10 @@ void ComputeCommand::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firs if (!node) return; + const bool wasEnabled = isEnabled(); BackendNode::syncFromFrontEnd(frontEnd, firstTime); + if (wasEnabled != isEnabled()) + markDirty(AbstractRenderer::ComputeDirty); if (m_workGroups[0] != node->workGroupX()) { m_workGroups[0] = node->workGroupX(); diff --git a/tests/auto/render/computecommand/tst_computecommand.cpp b/tests/auto/render/computecommand/tst_computecommand.cpp index d6fa1d579..e583a9c61 100644 --- a/tests/auto/render/computecommand/tst_computecommand.cpp +++ b/tests/auto/render/computecommand/tst_computecommand.cpp @@ -141,6 +141,10 @@ private Q_SLOTS: backendComputeCommand.setRenderer(&renderer); simulateInitializationSync(&computeCommand, &backendComputeCommand); + // THEN + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::ComputeDirty); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); + { // WHEN const bool newValue = false; @@ -149,6 +153,8 @@ private Q_SLOTS: // THEN QCOMPARE(backendComputeCommand.isEnabled(), newValue); + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::ComputeDirty); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); } { // WHEN @@ -158,6 +164,8 @@ private Q_SLOTS: // THEN QCOMPARE(backendComputeCommand.x(), newValue); + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::ComputeDirty); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); } { // WHEN @@ -167,6 +175,8 @@ private Q_SLOTS: // THEN QCOMPARE(backendComputeCommand.y(), newValue); + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::ComputeDirty); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); } { // WHEN @@ -176,6 +186,8 @@ private Q_SLOTS: // THEN QCOMPARE(backendComputeCommand.z(), newValue); + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::ComputeDirty); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); } { // WHEN @@ -185,6 +197,8 @@ private Q_SLOTS: // THEN QCOMPARE(backendComputeCommand.runType(), newValue); + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::ComputeDirty); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); } { // WHEN @@ -194,6 +208,8 @@ private Q_SLOTS: // THEN QCOMPARE(backendComputeCommand.frameCount(), newValue); + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::ComputeDirty); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); } } -- cgit v1.2.3 From a3b3cf04271cdc98af947823aa005a8090a1d37a Mon Sep 17 00:00:00 2001 From: Tarja Sundqvist Date: Mon, 8 Nov 2021 18:28:33 +0200 Subject: Bump version --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index f8a5b3b95..f12bc5230 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -6,4 +6,4 @@ load(qt_build_config) DEFINES += QT_NO_FOREACH DEFINES += QT_NO_JAVA_STYLE_ITERATORS -MODULE_VERSION = 5.15.7 +MODULE_VERSION = 5.15.8 -- cgit v1.2.3 From fdba23fe5ed5eb87a6bab7bc16d04b7e240a4d7e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 16 Nov 2021 14:43:51 +0100 Subject: QGeometryFactory: don't make op== virtual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That's too clever, and it backfires with compilation errors in C++20 mode: qt3d/tests/auto/render/meshfunctors/tst_meshfunctors.cpp:129:29: error: ambiguous overload for ‘operator==’ (operand types are ‘MeshFunctorA’ and ‘MeshFunctorB’) 129 | QVERIFY(!(*functorA == *functorB)); | ~~~~~~~~~ ^~ ~~~~~~~~~ | | | | MeshFunctorA MeshFunctorB qt3d/tests/auto/render/meshfunctors/tst_meshfunctors.cpp:72:10: note: candidate: ‘virtual bool MeshFunctorB::operator==(const Qt3DCore::QGeometryFactory&) const’ (reversed) 72 | bool operator ==(const Qt3DCore::QGeometryFactory &other) const override | ^~~~~~~~ qt3d/tests/auto/render/meshfunctors/tst_meshfunctors.cpp:50:10: note: candidate: ‘virtual bool MeshFunctorA::operator==(const Qt3DCore::QGeometryFactory&) const’ 50 | bool operator ==(const Qt3DCore::QGeometryFactory &other) const override | ^~~~~~~~ Fix by providing a symmetric operator== for QGeometryFactory that delegates to a virtual equals() method. Change-Id: I23d29ad1b16075629132f2b4757c5810d5615a36 Reviewed-by: Edward Welbourne Reviewed-by: Paul Lemire (cherry picked from commit ec291f9974ba6d25148955a0b9e55b30c589a9be) Reviewed-by: Qt CI Bot --- src/render/geometry/qgeometryfactory.h | 4 +++- src/render/geometry/qmesh.cpp | 2 +- src/render/geometry/qmesh_p.h | 2 +- tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp | 2 +- tests/auto/render/meshfunctors/tst_meshfunctors.cpp | 6 +++--- tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/render/geometry/qgeometryfactory.h b/src/render/geometry/qgeometryfactory.h index c2a45ddbc..d82039568 100644 --- a/src/render/geometry/qgeometryfactory.h +++ b/src/render/geometry/qgeometryfactory.h @@ -55,7 +55,9 @@ class Q_3DRENDERSHARED_EXPORT QGeometryFactory : public QAbstractFunctor public: virtual ~QGeometryFactory(); virtual QGeometry *operator()() = 0; - virtual bool operator ==(const QGeometryFactory &other) const = 0; + virtual bool equals(const QGeometryFactory &other) const = 0; + friend bool operator==(const QGeometryFactory &lhs, const QGeometryFactory &rhs) + { return lhs.equals(rhs); } }; typedef QSharedPointer QGeometryFactoryPtr; diff --git a/src/render/geometry/qmesh.cpp b/src/render/geometry/qmesh.cpp index ecbdd47d2..a8950cca8 100644 --- a/src/render/geometry/qmesh.cpp +++ b/src/render/geometry/qmesh.cpp @@ -391,7 +391,7 @@ QGeometry *MeshLoaderFunctor::operator()() /*! * \internal */ -bool MeshLoaderFunctor::operator ==(const QGeometryFactory &other) const +bool MeshLoaderFunctor::equals(const QGeometryFactory &other) const { const MeshLoaderFunctor *otherFunctor = functor_cast(&other); if (otherFunctor != nullptr) diff --git a/src/render/geometry/qmesh_p.h b/src/render/geometry/qmesh_p.h index 9ea0935bb..60b4d4632 100644 --- a/src/render/geometry/qmesh_p.h +++ b/src/render/geometry/qmesh_p.h @@ -119,7 +119,7 @@ public : QMesh::Status status() const { return m_status; } QGeometry *operator()() override; - bool operator ==(const QGeometryFactory &other) const override; + bool equals(const QGeometryFactory &other) const override; QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QT3D_FUNCTOR(MeshLoaderFunctor) diff --git a/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp b/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp index 19df24680..6026a3ff2 100644 --- a/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp +++ b/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp @@ -50,7 +50,7 @@ public: return nullptr; } - bool operator ==(const Qt3DRender::QGeometryFactory &other) const final + bool equals(const Qt3DRender::QGeometryFactory &other) const final { const TestFactory *otherFactory = Qt3DRender::functor_cast(&other); if (otherFactory != nullptr) diff --git a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp index f8110085b..f845f39c8 100644 --- a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp +++ b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp @@ -52,7 +52,7 @@ public: return nullptr; } - bool operator ==(const Qt3DRender::QGeometryFactory &other) const override + bool equals(const Qt3DRender::QGeometryFactory &other) const override { return Qt3DRender::functor_cast(&other); } @@ -74,7 +74,7 @@ public: return nullptr; } - bool operator ==(const Qt3DRender::QGeometryFactory &other) const override + bool equals(const Qt3DRender::QGeometryFactory &other) const override { return Qt3DRender::functor_cast(&other); } @@ -91,7 +91,7 @@ public: ~MeshFunctorASub() {} - bool operator ==(const Qt3DRender::QGeometryFactory &other) const override + bool equals(const Qt3DRender::QGeometryFactory &other) const override { return Qt3DRender::functor_cast(&other); } diff --git a/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp b/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp index 8cfbc0d23..8addfe9ad 100644 --- a/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp +++ b/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp @@ -56,7 +56,7 @@ public: return nullptr; } - bool operator ==(const Qt3DRender::QGeometryFactory &other) const final + bool equals(const Qt3DRender::QGeometryFactory &other) const final { const TestFactory *otherFactory = Qt3DRender::functor_cast(&other); if (otherFactory != nullptr) -- cgit v1.2.3 From e34fd22bab044c1a9eb1bbed8206bfa9afee5a9e Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Tue, 23 Nov 2021 09:27:43 +0100 Subject: AnimationClip: fix the way we compute the duration We wrongly assumed the start time of a clip was always 0. In practice this might not be the case. Therefore, we now compute duration as tEnd - tStart. Change-Id: I13ca860f3366c2aba5e978cb0c955e7bb2e7bc39 Reviewed-by: Sean Harmer (cherry picked from commit 7b23cb1ca5b32fcf24f889e79cec756786f86233) Reviewed-by: Paul Lemire --- src/animation/backend/animationclip.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/animation/backend/animationclip.cpp b/src/animation/backend/animationclip.cpp index a95e14d74..f051d68d9 100644 --- a/src/animation/backend/animationclip.cpp +++ b/src/animation/backend/animationclip.cpp @@ -354,15 +354,18 @@ void AnimationClip::clearData() float AnimationClip::findDuration() { // Iterate over the contained fcurves and find the longest one - double tMax = 0.0; + float tMax = 0.f; + float tMin = 1.0f; for (const Channel &channel : qAsConst(m_channels)) { for (const ChannelComponent &channelComponent : qAsConst(channel.channelComponents)) { - const float t = channelComponent.fcurve.endTime(); - if (t > tMax) - tMax = t; + const float tStart = channelComponent.fcurve.startTime(); + const float tEnd = channelComponent.fcurve.endTime(); + tMax = std::max(tEnd, tMax); + tMin = std::min(tStart, tMin); } } - return tMax; + // We can't have a negative duration + return std::max(tMax - tMin, 0.0f); } int AnimationClip::findChannelComponentCount() -- cgit v1.2.3 From b4d6e1b6bd7cd6a9a0e87b4ea278f2e93407c15b Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Mon, 22 Nov 2021 10:43:34 +0100 Subject: OpenGL: Fix content not updated when using OnDemand and switching textures When changing a Parameter whose value is a texture, it takes Qt3D potentially two frames to process the scene fully before it is able to draw the updated content. This patch makes it so that if we know we have the flags ParametersDirty for frame N, we request to reprocess the scene once more on frame N+1. Change-Id: Ia635e324434f92f8423a68b72d99350d96830de6 Reviewed-by: Sean Harmer (cherry picked from commit 672da697b147f039effbfd352b20f3f1891f31c6) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/renderers/opengl/renderer/renderer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/renderers/opengl/renderer/renderer.cpp b/src/plugins/renderers/opengl/renderer/renderer.cpp index 394e08fd6..5377ab9ac 100644 --- a/src/plugins/renderers/opengl/renderer/renderer.cpp +++ b/src/plugins/renderers/opengl/renderer/renderer.cpp @@ -1872,6 +1872,7 @@ QVector Renderer::renderBinJobs() // Remove previous dependencies m_cleanupJob->removeDependency(QWeakPointer()); + const bool dirtyParametersForCurrentFrame = m_dirtyBits.marked & AbstractRenderer::ParameterDirty; const BackendNodeDirtySet dirtyBitsForFrame = m_dirtyBits.marked | m_dirtyBits.remaining; m_dirtyBits.marked = {}; m_dirtyBits.remaining = {}; @@ -1995,6 +1996,10 @@ QVector Renderer::renderBinJobs() m_dirtyBits.remaining = dirtyBitsForFrame & notCleared; + // Dirty Parameters might need 2 frames to react if the parameter references a texture + if (dirtyParametersForCurrentFrame) + m_dirtyBits.remaining |= AbstractRenderer::ParameterDirty; + return renderBinJobs; } -- cgit v1.2.3 From 99241de47266acb50135bb5f20d0875b2adb2600 Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Fri, 8 May 2020 13:09:15 +0100 Subject: Build Assimp using submodule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use same submodule as QtQuick3D Change-Id: I0c138d1cbf5ff545438a7673ccb71a2236729377 Reviewed-by: Paul Lemire (cherry picked from commit ad238237b73a70867554d84b3c1762da637c210d) Reviewed-by: Tor Arne Vestbø --- .gitmodules | 3 + config.tests/assimp/main.cpp | 4 + src/3rdparty/assimp/README | 1 - src/3rdparty/assimp/Readme.md | 170 - src/3rdparty/assimp/assimp.pri | 940 ++-- src/3rdparty/assimp/code/3DSConverter.cpp | 871 ---- src/3rdparty/assimp/code/3DSExporter.cpp | 579 --- src/3rdparty/assimp/code/3DSExporter.h | 97 - src/3rdparty/assimp/code/3DSHelper.h | 595 --- src/3rdparty/assimp/code/3DSLoader.cpp | 1433 ------ src/3rdparty/assimp/code/3DSLoader.h | 283 -- src/3rdparty/assimp/code/3MFXmlTags.h | 89 - src/3rdparty/assimp/code/ACLoader.cpp | 909 ---- src/3rdparty/assimp/code/ACLoader.h | 275 -- src/3rdparty/assimp/code/AMFImporter.cpp | 704 --- src/3rdparty/assimp/code/AMFImporter.hpp | 563 --- src/3rdparty/assimp/code/AMFImporter_Geometry.cpp | 356 -- src/3rdparty/assimp/code/AMFImporter_Macro.hpp | 165 - src/3rdparty/assimp/code/AMFImporter_Material.cpp | 310 -- src/3rdparty/assimp/code/AMFImporter_Node.hpp | 400 -- .../assimp/code/AMFImporter_Postprocess.cpp | 976 ---- src/3rdparty/assimp/code/ASELoader.cpp | 1328 ------ src/3rdparty/assimp/code/ASELoader.h | 207 - src/3rdparty/assimp/code/ASEParser.cpp | 2157 --------- src/3rdparty/assimp/code/ASEParser.h | 669 --- src/3rdparty/assimp/code/AssbinExporter.cpp | 822 ---- src/3rdparty/assimp/code/AssbinExporter.h | 50 - src/3rdparty/assimp/code/AssbinLoader.cpp | 740 --- src/3rdparty/assimp/code/AssbinLoader.h | 104 - src/3rdparty/assimp/code/Assimp.cpp | 694 --- src/3rdparty/assimp/code/AssimpCExport.cpp | 156 - src/3rdparty/assimp/code/AssxmlExporter.cpp | 648 --- src/3rdparty/assimp/code/AssxmlExporter.h | 50 - src/3rdparty/assimp/code/B3DImporter.cpp | 719 --- src/3rdparty/assimp/code/B3DImporter.h | 132 - src/3rdparty/assimp/code/BVHLoader.cpp | 545 --- src/3rdparty/assimp/code/BVHLoader.h | 172 - src/3rdparty/assimp/code/BaseImporter.cpp | 601 --- src/3rdparty/assimp/code/BaseImporter.h | 361 -- src/3rdparty/assimp/code/BaseProcess.cpp | 106 - src/3rdparty/assimp/code/BaseProcess.h | 293 -- src/3rdparty/assimp/code/Bitmap.cpp | 153 - src/3rdparty/assimp/code/Bitmap.h | 123 - src/3rdparty/assimp/code/BlenderBMesh.cpp | 206 - src/3rdparty/assimp/code/BlenderBMesh.h | 94 - src/3rdparty/assimp/code/BlenderDNA.cpp | 376 -- src/3rdparty/assimp/code/BlenderDNA.h | 810 ---- src/3rdparty/assimp/code/BlenderDNA.inl | 755 --- src/3rdparty/assimp/code/BlenderIntermediate.h | 201 - src/3rdparty/assimp/code/BlenderLoader.cpp | 1318 ------ src/3rdparty/assimp/code/BlenderLoader.h | 239 - src/3rdparty/assimp/code/BlenderModifier.cpp | 326 -- src/3rdparty/assimp/code/BlenderModifier.h | 157 - src/3rdparty/assimp/code/BlenderScene.cpp | 828 ---- src/3rdparty/assimp/code/BlenderScene.h | 900 ---- src/3rdparty/assimp/code/BlenderSceneGen.h | 255 - src/3rdparty/assimp/code/BlenderTessellator.cpp | 525 --- src/3rdparty/assimp/code/BlenderTessellator.h | 209 - src/3rdparty/assimp/code/BlobIOSystem.h | 337 -- src/3rdparty/assimp/code/ByteSwapper.h | 287 -- src/3rdparty/assimp/code/C4DImporter.cpp | 650 --- src/3rdparty/assimp/code/C4DImporter.h | 123 - src/3rdparty/assimp/code/CInterfaceIOWrapper.cpp | 135 - src/3rdparty/assimp/code/CInterfaceIOWrapper.h | 98 - src/3rdparty/assimp/code/CMakeLists.txt | 1012 ---- src/3rdparty/assimp/code/COBLoader.cpp | 1300 ------ src/3rdparty/assimp/code/COBLoader.h | 175 - src/3rdparty/assimp/code/COBScene.h | 276 -- src/3rdparty/assimp/code/CSMLoader.cpp | 307 -- src/3rdparty/assimp/code/CSMLoader.h | 92 - src/3rdparty/assimp/code/CalcTangentsProcess.cpp | 318 -- src/3rdparty/assimp/code/CalcTangentsProcess.h | 116 - src/3rdparty/assimp/code/ColladaExporter.cpp | 1625 ------- src/3rdparty/assimp/code/ColladaExporter.h | 222 - src/3rdparty/assimp/code/ColladaHelper.h | 703 --- src/3rdparty/assimp/code/ColladaLoader.cpp | 1924 -------- src/3rdparty/assimp/code/ColladaLoader.h | 257 - src/3rdparty/assimp/code/ColladaParser.cpp | 3199 ------------- src/3rdparty/assimp/code/ColladaParser.h | 367 -- .../assimp/code/ComputeUVMappingProcess.cpp | 505 -- src/3rdparty/assimp/code/ComputeUVMappingProcess.h | 147 - src/3rdparty/assimp/code/ConvertToLHProcess.cpp | 332 -- src/3rdparty/assimp/code/ConvertToLHProcess.h | 169 - src/3rdparty/assimp/code/CreateAnimMesh.cpp | 92 - src/3rdparty/assimp/code/CreateAnimMesh.h | 57 - src/3rdparty/assimp/code/D3MFExporter.cpp | 328 -- src/3rdparty/assimp/code/D3MFExporter.h | 103 - src/3rdparty/assimp/code/D3MFImporter.cpp | 334 -- src/3rdparty/assimp/code/D3MFImporter.h | 64 - src/3rdparty/assimp/code/D3MFOpcPackage.cpp | 520 --- src/3rdparty/assimp/code/D3MFOpcPackage.h | 81 - src/3rdparty/assimp/code/DXFHelper.h | 236 - src/3rdparty/assimp/code/DXFLoader.cpp | 919 ---- src/3rdparty/assimp/code/DXFLoader.h | 154 - src/3rdparty/assimp/code/DeboneProcess.cpp | 466 -- src/3rdparty/assimp/code/DeboneProcess.h | 133 - src/3rdparty/assimp/code/DefaultIOStream.cpp | 152 - src/3rdparty/assimp/code/DefaultIOSystem.cpp | 199 - src/3rdparty/assimp/code/DefaultLogger.cpp | 429 -- src/3rdparty/assimp/code/DefaultProgressHandler.h | 66 - src/3rdparty/assimp/code/Exceptional.h | 125 - src/3rdparty/assimp/code/Exporter.cpp | 602 --- src/3rdparty/assimp/code/FBXAnimation.cpp | 304 -- src/3rdparty/assimp/code/FBXBinaryTokenizer.cpp | 460 -- src/3rdparty/assimp/code/FBXCompileConfig.h | 69 - src/3rdparty/assimp/code/FBXConverter.cpp | 3356 ------------- src/3rdparty/assimp/code/FBXConverter.h | 65 - src/3rdparty/assimp/code/FBXDeformer.cpp | 165 - src/3rdparty/assimp/code/FBXDocument.cpp | 713 --- src/3rdparty/assimp/code/FBXDocument.h | 1167 ----- src/3rdparty/assimp/code/FBXDocumentUtil.cpp | 134 - src/3rdparty/assimp/code/FBXDocumentUtil.h | 122 - src/3rdparty/assimp/code/FBXImportSettings.h | 152 - src/3rdparty/assimp/code/FBXImporter.cpp | 194 - src/3rdparty/assimp/code/FBXImporter.h | 99 - src/3rdparty/assimp/code/FBXMaterial.cpp | 344 -- src/3rdparty/assimp/code/FBXMeshGeometry.cpp | 639 --- src/3rdparty/assimp/code/FBXMeshGeometry.h | 181 - src/3rdparty/assimp/code/FBXModel.cpp | 152 - src/3rdparty/assimp/code/FBXNodeAttribute.cpp | 169 - src/3rdparty/assimp/code/FBXParser.cpp | 1307 ------ src/3rdparty/assimp/code/FBXParser.h | 235 - src/3rdparty/assimp/code/FBXProperties.cpp | 237 - src/3rdparty/assimp/code/FBXProperties.h | 172 - src/3rdparty/assimp/code/FBXTokenizer.cpp | 249 - src/3rdparty/assimp/code/FBXTokenizer.h | 186 - src/3rdparty/assimp/code/FBXUtil.cpp | 119 - src/3rdparty/assimp/code/FBXUtil.h | 104 - src/3rdparty/assimp/code/FIReader.cpp | 1833 -------- src/3rdparty/assimp/code/FIReader.hpp | 185 - src/3rdparty/assimp/code/FileLogStream.h | 106 - src/3rdparty/assimp/code/FileSystemFilter.h | 300 -- src/3rdparty/assimp/code/FindDegenerates.cpp | 258 - src/3rdparty/assimp/code/FindDegenerates.h | 127 - src/3rdparty/assimp/code/FindInstancesProcess.cpp | 278 -- src/3rdparty/assimp/code/FindInstancesProcess.h | 136 - .../assimp/code/FindInvalidDataProcess.cpp | 429 -- src/3rdparty/assimp/code/FindInvalidDataProcess.h | 106 - src/3rdparty/assimp/code/FixNormalsStep.cpp | 181 - src/3rdparty/assimp/code/FixNormalsStep.h | 90 - src/3rdparty/assimp/code/GenFaceNormalsProcess.cpp | 144 - src/3rdparty/assimp/code/GenFaceNormalsProcess.h | 85 - .../assimp/code/GenVertexNormalsProcess.cpp | 236 - src/3rdparty/assimp/code/GenVertexNormalsProcess.h | 113 - src/3rdparty/assimp/code/GenericProperty.h | 126 - src/3rdparty/assimp/code/HMPFileData.h | 136 - src/3rdparty/assimp/code/HMPLoader.cpp | 519 --- src/3rdparty/assimp/code/HMPLoader.h | 151 - src/3rdparty/assimp/code/HalfLifeFileData.h | 148 - src/3rdparty/assimp/code/Hash.h | 117 - src/3rdparty/assimp/code/IFCBoolean.cpp | 831 ---- src/3rdparty/assimp/code/IFCCurve.cpp | 617 --- src/3rdparty/assimp/code/IFCGeometry.cpp | 885 ---- src/3rdparty/assimp/code/IFCLoader.cpp | 982 ---- src/3rdparty/assimp/code/IFCLoader.h | 133 - src/3rdparty/assimp/code/IFCMaterial.cpp | 205 - src/3rdparty/assimp/code/IFCOpenings.cpp | 1699 ------- src/3rdparty/assimp/code/IFCProfile.cpp | 190 - src/3rdparty/assimp/code/IFCReaderGen.h | 4368 ----------------- src/3rdparty/assimp/code/IFCReaderGen1.cpp | 3168 ------------- src/3rdparty/assimp/code/IFCReaderGen2.cpp | 1917 -------- src/3rdparty/assimp/code/IFCUtil.cpp | 707 --- src/3rdparty/assimp/code/IFCUtil.h | 429 -- src/3rdparty/assimp/code/IFF.h | 102 - src/3rdparty/assimp/code/IOStreamBuffer.h | 350 -- src/3rdparty/assimp/code/IRRLoader.cpp | 1488 ------ src/3rdparty/assimp/code/IRRLoader.h | 314 -- src/3rdparty/assimp/code/IRRMeshLoader.cpp | 535 --- src/3rdparty/assimp/code/IRRMeshLoader.h | 100 - src/3rdparty/assimp/code/IRRShared.cpp | 505 -- src/3rdparty/assimp/code/IRRShared.h | 118 - src/3rdparty/assimp/code/Importer.cpp | 1195 ----- src/3rdparty/assimp/code/Importer.h | 228 - src/3rdparty/assimp/code/ImporterRegistry.cpp | 364 -- src/3rdparty/assimp/code/ImproveCacheLocality.cpp | 388 -- src/3rdparty/assimp/code/ImproveCacheLocality.h | 99 - src/3rdparty/assimp/code/JoinVerticesProcess.cpp | 417 -- src/3rdparty/assimp/code/JoinVerticesProcess.h | 98 - src/3rdparty/assimp/code/LWOAnimation.cpp | 603 --- src/3rdparty/assimp/code/LWOAnimation.h | 346 -- src/3rdparty/assimp/code/LWOBLoader.cpp | 423 -- src/3rdparty/assimp/code/LWOFileData.h | 702 --- src/3rdparty/assimp/code/LWOLoader.cpp | 1480 ------ src/3rdparty/assimp/code/LWOLoader.h | 489 -- src/3rdparty/assimp/code/LWOMaterial.cpp | 898 ---- src/3rdparty/assimp/code/LWSLoader.cpp | 935 ---- src/3rdparty/assimp/code/LWSLoader.h | 253 - .../assimp/code/LimitBoneWeightsProcess.cpp | 202 - src/3rdparty/assimp/code/LimitBoneWeightsProcess.h | 143 - src/3rdparty/assimp/code/LineSplitter.h | 243 - src/3rdparty/assimp/code/LogAux.h | 133 - src/3rdparty/assimp/code/MD2FileData.h | 163 - src/3rdparty/assimp/code/MD2Loader.cpp | 458 -- src/3rdparty/assimp/code/MD2Loader.h | 123 - src/3rdparty/assimp/code/MD2NormalTable.h | 218 - src/3rdparty/assimp/code/MD3FileData.h | 313 -- src/3rdparty/assimp/code/MD3Loader.cpp | 1094 ----- src/3rdparty/assimp/code/MD3Loader.h | 332 -- src/3rdparty/assimp/code/MD4FileData.h | 218 - src/3rdparty/assimp/code/MD5Loader.cpp | 757 --- src/3rdparty/assimp/code/MD5Loader.h | 194 - src/3rdparty/assimp/code/MD5Parser.cpp | 487 -- src/3rdparty/assimp/code/MD5Parser.h | 466 -- src/3rdparty/assimp/code/MDCFileData.h | 219 - src/3rdparty/assimp/code/MDCLoader.cpp | 494 -- src/3rdparty/assimp/code/MDCLoader.h | 129 - src/3rdparty/assimp/code/MDCNormalTable.h | 299 -- src/3rdparty/assimp/code/MDLDefaultColorMap.h | 119 - src/3rdparty/assimp/code/MDLFileData.h | 947 ---- src/3rdparty/assimp/code/MDLLoader.cpp | 1972 -------- src/3rdparty/assimp/code/MDLLoader.h | 458 -- src/3rdparty/assimp/code/MDLMaterialLoader.cpp | 840 ---- src/3rdparty/assimp/code/MMDCpp14.h | 82 - src/3rdparty/assimp/code/MMDImporter.cpp | 370 -- src/3rdparty/assimp/code/MMDImporter.h | 96 - src/3rdparty/assimp/code/MMDPmdParser.h | 596 --- src/3rdparty/assimp/code/MMDPmxParser.cpp | 637 --- src/3rdparty/assimp/code/MMDPmxParser.h | 780 ---- src/3rdparty/assimp/code/MMDVmdParser.h | 375 -- src/3rdparty/assimp/code/MS3DLoader.cpp | 671 --- src/3rdparty/assimp/code/MS3DLoader.h | 161 - src/3rdparty/assimp/code/Macros.h | 49 - src/3rdparty/assimp/code/MakeVerboseFormat.cpp | 222 - src/3rdparty/assimp/code/MakeVerboseFormat.h | 104 - src/3rdparty/assimp/code/MaterialSystem.cpp | 627 --- src/3rdparty/assimp/code/MaterialSystem.h | 71 - src/3rdparty/assimp/code/MathFunctions.h | 77 - src/3rdparty/assimp/code/MemoryIOWrapper.h | 198 - src/3rdparty/assimp/code/NDOLoader.cpp | 310 -- src/3rdparty/assimp/code/NDOLoader.h | 126 - src/3rdparty/assimp/code/NFFLoader.cpp | 1276 ----- src/3rdparty/assimp/code/NFFLoader.h | 214 - src/3rdparty/assimp/code/OFFLoader.cpp | 254 - src/3rdparty/assimp/code/OFFLoader.h | 93 - src/3rdparty/assimp/code/ObjExporter.cpp | 454 -- src/3rdparty/assimp/code/ObjExporter.h | 176 - src/3rdparty/assimp/code/ObjFileData.h | 335 -- src/3rdparty/assimp/code/ObjFileImporter.cpp | 769 --- src/3rdparty/assimp/code/ObjFileImporter.h | 122 - src/3rdparty/assimp/code/ObjFileMtlImporter.cpp | 495 -- src/3rdparty/assimp/code/ObjFileMtlImporter.h | 116 - src/3rdparty/assimp/code/ObjFileParser.cpp | 862 ---- src/3rdparty/assimp/code/ObjFileParser.h | 163 - src/3rdparty/assimp/code/ObjTools.h | 307 -- src/3rdparty/assimp/code/OgreBinarySerializer.cpp | 1110 ----- src/3rdparty/assimp/code/OgreBinarySerializer.h | 422 -- src/3rdparty/assimp/code/OgreImporter.cpp | 149 - src/3rdparty/assimp/code/OgreImporter.h | 101 - src/3rdparty/assimp/code/OgreMaterial.cpp | 596 --- src/3rdparty/assimp/code/OgreParsingUtils.h | 144 - src/3rdparty/assimp/code/OgreStructs.cpp | 1205 ----- src/3rdparty/assimp/code/OgreStructs.h | 695 --- src/3rdparty/assimp/code/OgreXmlSerializer.cpp | 1005 ---- src/3rdparty/assimp/code/OgreXmlSerializer.h | 117 - src/3rdparty/assimp/code/OpenGEXExporter.cpp | 61 - src/3rdparty/assimp/code/OpenGEXExporter.h | 67 - src/3rdparty/assimp/code/OpenGEXImporter.cpp | 1303 ------ src/3rdparty/assimp/code/OpenGEXImporter.h | 213 - src/3rdparty/assimp/code/OpenGEXStructs.h | 263 -- src/3rdparty/assimp/code/OptimizeGraph.cpp | 362 -- src/3rdparty/assimp/code/OptimizeGraph.h | 144 - src/3rdparty/assimp/code/OptimizeMeshes.cpp | 257 - src/3rdparty/assimp/code/OptimizeMeshes.h | 183 - src/3rdparty/assimp/code/ParsingUtils.h | 251 - src/3rdparty/assimp/code/PlyExporter.cpp | 393 -- src/3rdparty/assimp/code/PlyExporter.h | 87 - src/3rdparty/assimp/code/PlyLoader.cpp | 1014 ---- src/3rdparty/assimp/code/PlyLoader.h | 140 - src/3rdparty/assimp/code/PlyParser.cpp | 1121 ----- src/3rdparty/assimp/code/PlyParser.h | 489 -- src/3rdparty/assimp/code/PolyTools.h | 228 - src/3rdparty/assimp/code/PostStepRegistry.cpp | 230 - src/3rdparty/assimp/code/PretransformVertices.cpp | 730 --- src/3rdparty/assimp/code/PretransformVertices.h | 167 - src/3rdparty/assimp/code/ProcessHelper.cpp | 442 -- src/3rdparty/assimp/code/ProcessHelper.h | 385 -- src/3rdparty/assimp/code/Profiler.h | 98 - src/3rdparty/assimp/code/Q3BSPFileData.h | 218 - src/3rdparty/assimp/code/Q3BSPFileImporter.cpp | 771 --- src/3rdparty/assimp/code/Q3BSPFileImporter.h | 118 - src/3rdparty/assimp/code/Q3BSPFileParser.cpp | 281 -- src/3rdparty/assimp/code/Q3BSPFileParser.h | 90 - src/3rdparty/assimp/code/Q3BSPZipArchive.cpp | 316 -- src/3rdparty/assimp/code/Q3BSPZipArchive.h | 130 - src/3rdparty/assimp/code/Q3DLoader.cpp | 616 --- src/3rdparty/assimp/code/Q3DLoader.h | 133 - src/3rdparty/assimp/code/RawLoader.cpp | 327 -- src/3rdparty/assimp/code/RawLoader.h | 120 - src/3rdparty/assimp/code/RemoveComments.cpp | 108 - src/3rdparty/assimp/code/RemoveComments.h | 90 - .../assimp/code/RemoveRedundantMaterials.cpp | 222 - .../assimp/code/RemoveRedundantMaterials.h | 105 - src/3rdparty/assimp/code/RemoveVCProcess.cpp | 333 -- src/3rdparty/assimp/code/RemoveVCProcess.h | 122 - src/3rdparty/assimp/code/SGSpatialSort.cpp | 167 - src/3rdparty/assimp/code/SGSpatialSort.h | 141 - src/3rdparty/assimp/code/SIBImporter.cpp | 941 ---- src/3rdparty/assimp/code/SIBImporter.h | 116 - src/3rdparty/assimp/code/SMDLoader.cpp | 1161 ----- src/3rdparty/assimp/code/SMDLoader.h | 418 -- src/3rdparty/assimp/code/STEPFile.h | 1019 ---- src/3rdparty/assimp/code/STEPFileEncoding.cpp | 427 -- src/3rdparty/assimp/code/STEPFileEncoding.h | 64 - src/3rdparty/assimp/code/STEPFileReader.cpp | 544 --- src/3rdparty/assimp/code/STEPFileReader.h | 65 - src/3rdparty/assimp/code/STLExporter.cpp | 188 - src/3rdparty/assimp/code/STLExporter.h | 86 - src/3rdparty/assimp/code/STLLoader.cpp | 537 --- src/3rdparty/assimp/code/STLLoader.h | 124 - src/3rdparty/assimp/code/ScaleProcess.cpp | 105 - src/3rdparty/assimp/code/ScaleProcess.h | 87 - src/3rdparty/assimp/code/SceneCombiner.cpp | 1286 ----- src/3rdparty/assimp/code/ScenePreprocessor.cpp | 260 -- src/3rdparty/assimp/code/ScenePreprocessor.h | 124 - src/3rdparty/assimp/code/ScenePrivate.h | 87 - src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp | 269 -- src/3rdparty/assimp/code/SkeletonMeshBuilder.h | 124 - src/3rdparty/assimp/code/SmoothingGroups.h | 109 - src/3rdparty/assimp/code/SmoothingGroups.inl | 138 - src/3rdparty/assimp/code/SortByPTypeProcess.cpp | 410 -- src/3rdparty/assimp/code/SortByPTypeProcess.h | 84 - src/3rdparty/assimp/code/SpatialSort.cpp | 341 -- src/3rdparty/assimp/code/SpatialSort.h | 171 - .../assimp/code/SplitByBoneCountProcess.cpp | 406 -- src/3rdparty/assimp/code/SplitByBoneCountProcess.h | 110 - src/3rdparty/assimp/code/SplitLargeMeshes.cpp | 676 --- src/3rdparty/assimp/code/SplitLargeMeshes.h | 209 - src/3rdparty/assimp/code/StandardShapes.cpp | 506 -- src/3rdparty/assimp/code/StandardShapes.h | 199 - src/3rdparty/assimp/code/StdOStreamLogStream.h | 100 - src/3rdparty/assimp/code/StepExporter.cpp | 372 -- src/3rdparty/assimp/code/StepExporter.h | 110 - src/3rdparty/assimp/code/StreamReader.h | 347 -- src/3rdparty/assimp/code/StreamWriter.h | 240 - src/3rdparty/assimp/code/StringComparison.h | 225 - src/3rdparty/assimp/code/StringUtils.h | 110 - src/3rdparty/assimp/code/Subdivision.cpp | 590 --- src/3rdparty/assimp/code/Subdivision.h | 130 - src/3rdparty/assimp/code/TargetAnimation.cpp | 247 - src/3rdparty/assimp/code/TargetAnimation.h | 182 - src/3rdparty/assimp/code/TerragenLoader.cpp | 273 -- src/3rdparty/assimp/code/TerragenLoader.h | 104 - src/3rdparty/assimp/code/TextureTransform.cpp | 571 --- src/3rdparty/assimp/code/TextureTransform.h | 232 - src/3rdparty/assimp/code/TinyFormatter.h | 165 - src/3rdparty/assimp/code/TriangulateProcess.cpp | 527 --- src/3rdparty/assimp/code/TriangulateProcess.h | 94 - src/3rdparty/assimp/code/UnrealLoader.cpp | 444 -- src/3rdparty/assimp/code/UnrealLoader.h | 205 - src/3rdparty/assimp/code/ValidateDataStructure.cpp | 969 ---- src/3rdparty/assimp/code/ValidateDataStructure.h | 187 - src/3rdparty/assimp/code/Version.cpp | 174 - src/3rdparty/assimp/code/Vertex.h | 323 -- .../assimp/code/VertexTriangleAdjacency.cpp | 136 - src/3rdparty/assimp/code/VertexTriangleAdjacency.h | 127 - src/3rdparty/assimp/code/Win32DebugLogStream.h | 94 - src/3rdparty/assimp/code/X3DExporter.cpp | 735 --- src/3rdparty/assimp/code/X3DExporter.hpp | 235 - src/3rdparty/assimp/code/X3DImporter.cpp | 1728 ------- src/3rdparty/assimp/code/X3DImporter.hpp | 833 ---- .../assimp/code/X3DImporter_Geometry2D.cpp | 521 --- .../assimp/code/X3DImporter_Geometry3D.cpp | 998 ---- src/3rdparty/assimp/code/X3DImporter_Group.cpp | 317 -- src/3rdparty/assimp/code/X3DImporter_Light.cpp | 289 -- src/3rdparty/assimp/code/X3DImporter_Macro.hpp | 194 - src/3rdparty/assimp/code/X3DImporter_Metadata.cpp | 276 -- .../assimp/code/X3DImporter_Networking.cpp | 133 - src/3rdparty/assimp/code/X3DImporter_Node.hpp | 779 ---- .../assimp/code/X3DImporter_Postprocess.cpp | 826 ---- src/3rdparty/assimp/code/X3DImporter_Rendering.cpp | 1070 ----- src/3rdparty/assimp/code/X3DImporter_Shape.cpp | 249 - src/3rdparty/assimp/code/X3DImporter_Texturing.cpp | 196 - src/3rdparty/assimp/code/X3DVocabulary.cpp | 1675 ------- src/3rdparty/assimp/code/XFileExporter.cpp | 538 --- src/3rdparty/assimp/code/XFileExporter.h | 139 - src/3rdparty/assimp/code/XFileHelper.h | 210 - src/3rdparty/assimp/code/XFileImporter.cpp | 717 --- src/3rdparty/assimp/code/XFileImporter.h | 148 - src/3rdparty/assimp/code/XFileParser.cpp | 1480 ------ src/3rdparty/assimp/code/XFileParser.h | 163 - src/3rdparty/assimp/code/XGLLoader.cpp | 964 ---- src/3rdparty/assimp/code/XGLLoader.h | 215 - src/3rdparty/assimp/code/XMLTools.h | 82 - src/3rdparty/assimp/code/assbin_chunks.h | 196 - src/3rdparty/assimp/code/fast_atof.h | 387 -- src/3rdparty/assimp/code/glTF2Asset.h | 1131 ----- src/3rdparty/assimp/code/glTF2Asset.inl | 1449 ------ src/3rdparty/assimp/code/glTF2AssetWriter.h | 93 - src/3rdparty/assimp/code/glTF2AssetWriter.inl | 638 --- src/3rdparty/assimp/code/glTF2Exporter.cpp | 1080 ----- src/3rdparty/assimp/code/glTF2Exporter.h | 134 - src/3rdparty/assimp/code/glTF2Importer.cpp | 694 --- src/3rdparty/assimp/code/glTF2Importer.h | 91 - src/3rdparty/assimp/code/glTFAsset.h | 1196 ----- src/3rdparty/assimp/code/glTFAsset.inl | 1645 ------- src/3rdparty/assimp/code/glTFAssetWriter.h | 95 - src/3rdparty/assimp/code/glTFAssetWriter.inl | 680 --- src/3rdparty/assimp/code/glTFExporter.cpp | 1007 ---- src/3rdparty/assimp/code/glTFExporter.h | 118 - src/3rdparty/assimp/code/glTFImporter.cpp | 683 --- src/3rdparty/assimp/code/glTFImporter.h | 91 - src/3rdparty/assimp/code/irrXMLWrapper.h | 143 - src/3rdparty/assimp/code/qnan.h | 156 - src/3rdparty/assimp/code/res/assimp.rc | 80 - src/3rdparty/assimp/code/res/resource.h | 14 - src/3rdparty/assimp/code/scene.cpp | 139 - src/3rdparty/assimp/config.h | 1013 ++++ .../assimp/contrib/Open3DGC/o3dgcAdjacencyInfo.h | 155 - .../contrib/Open3DGC/o3dgcArithmeticCodec.cpp | 865 ---- .../assimp/contrib/Open3DGC/o3dgcArithmeticCodec.h | 339 -- .../assimp/contrib/Open3DGC/o3dgcBinaryStream.h | 433 -- src/3rdparty/assimp/contrib/Open3DGC/o3dgcCommon.h | 412 -- .../assimp/contrib/Open3DGC/o3dgcDVEncodeParams.h | 62 - .../assimp/contrib/Open3DGC/o3dgcDynamicVector.h | 84 - .../contrib/Open3DGC/o3dgcDynamicVectorDecoder.cpp | 278 -- .../contrib/Open3DGC/o3dgcDynamicVectorDecoder.h | 76 - .../contrib/Open3DGC/o3dgcDynamicVectorEncoder.cpp | 295 -- .../contrib/Open3DGC/o3dgcDynamicVectorEncoder.h | 79 - src/3rdparty/assimp/contrib/Open3DGC/o3dgcFIFO.h | 97 - .../assimp/contrib/Open3DGC/o3dgcIndexedFaceSet.h | 263 -- .../contrib/Open3DGC/o3dgcIndexedFaceSet.inl | 47 - .../assimp/contrib/Open3DGC/o3dgcSC3DMCDecoder.h | 111 - .../assimp/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl | 850 ---- .../contrib/Open3DGC/o3dgcSC3DMCEncodeParams.h | 140 - .../assimp/contrib/Open3DGC/o3dgcSC3DMCEncoder.h | 116 - .../assimp/contrib/Open3DGC/o3dgcSC3DMCEncoder.inl | 927 ---- src/3rdparty/assimp/contrib/Open3DGC/o3dgcTimer.h | 134 - .../assimp/contrib/Open3DGC/o3dgcTools.cpp | 22 - .../assimp/contrib/Open3DGC/o3dgcTriangleFans.cpp | 475 -- .../assimp/contrib/Open3DGC/o3dgcTriangleFans.h | 291 -- .../contrib/Open3DGC/o3dgcTriangleListDecoder.h | 133 - .../contrib/Open3DGC/o3dgcTriangleListDecoder.inl | 364 -- .../contrib/Open3DGC/o3dgcTriangleListEncoder.h | 101 - .../contrib/Open3DGC/o3dgcTriangleListEncoder.inl | 719 --- src/3rdparty/assimp/contrib/Open3DGC/o3dgcVector.h | 184 - .../assimp/contrib/Open3DGC/o3dgcVector.inl | 317 -- src/3rdparty/assimp/contrib/clipper/License.txt | 29 - src/3rdparty/assimp/contrib/clipper/clipper.cpp | 3451 -------------- src/3rdparty/assimp/contrib/clipper/clipper.hpp | 306 -- .../assimp/contrib/irrXML/CXMLReaderImpl.h | 809 ---- src/3rdparty/assimp/contrib/irrXML/heapsort.h | 73 - src/3rdparty/assimp/contrib/irrXML/irrArray.h | 444 -- src/3rdparty/assimp/contrib/irrXML/irrString.h | 664 --- src/3rdparty/assimp/contrib/irrXML/irrTypes.h | 108 - src/3rdparty/assimp/contrib/irrXML/irrXML.cpp | 151 - src/3rdparty/assimp/contrib/irrXML/irrXML.h | 540 --- src/3rdparty/assimp/contrib/irrXML_note.txt | 6 - .../assimp/contrib/openddlparser/CMakeLists.txt | 170 - src/3rdparty/assimp/contrib/openddlparser/CREDITS | 19 - src/3rdparty/assimp/contrib/openddlparser/LICENSE | 22 - .../assimp/contrib/openddlparser/README.md | 136 - .../assimp/contrib/openddlparser/code/DDLNode.cpp | 217 - .../contrib/openddlparser/code/OpenDDLCommon.cpp | 212 - .../contrib/openddlparser/code/OpenDDLExport.cpp | 384 -- .../contrib/openddlparser/code/OpenDDLParser.cpp | 1025 ---- .../contrib/openddlparser/code/OpenDDLStream.cpp | 96 - .../assimp/contrib/openddlparser/code/Value.cpp | 439 -- .../openddlparser/include/openddlparser/DDLNode.h | 173 - .../include/openddlparser/OpenDDLCommon.h | 246 - .../include/openddlparser/OpenDDLExport.h | 80 - .../include/openddlparser/OpenDDLParser.h | 201 - .../include/openddlparser/OpenDDLParserUtils.h | 282 -- .../include/openddlparser/OpenDDLStream.h | 89 - .../openddlparser/include/openddlparser/Value.h | 273 -- src/3rdparty/assimp/contrib/poly2tri/AUTHORS | 8 - src/3rdparty/assimp/contrib/poly2tri/LICENSE | 27 - src/3rdparty/assimp/contrib/poly2tri/README | 51 - .../contrib/poly2tri/poly2tri/common/shapes.cc | 365 -- .../contrib/poly2tri/poly2tri/common/shapes.h | 327 -- .../contrib/poly2tri/poly2tri/common/utils.h | 127 - .../assimp/contrib/poly2tri/poly2tri/poly2tri.h | 38 - .../poly2tri/poly2tri/sweep/advancing_front.cc | 108 - .../poly2tri/poly2tri/sweep/advancing_front.h | 118 - .../assimp/contrib/poly2tri/poly2tri/sweep/cdt.cc | 71 - .../assimp/contrib/poly2tri/poly2tri/sweep/cdt.h | 105 - .../contrib/poly2tri/poly2tri/sweep/sweep.cc | 799 ---- .../assimp/contrib/poly2tri/poly2tri/sweep/sweep.h | 285 -- .../poly2tri/poly2tri/sweep/sweep_context.cc | 211 - .../poly2tri/poly2tri/sweep/sweep_context.h | 186 - src/3rdparty/assimp/contrib/poly2tri_patch.txt | 75 - .../rapidjson/include/rapidjson/allocators.h | 271 -- .../contrib/rapidjson/include/rapidjson/document.h | 2613 ----------- .../rapidjson/include/rapidjson/encodedstream.h | 299 -- .../rapidjson/include/rapidjson/encodings.h | 716 --- .../contrib/rapidjson/include/rapidjson/error/en.h | 74 - .../rapidjson/include/rapidjson/error/error.h | 161 - .../rapidjson/include/rapidjson/filereadstream.h | 99 - .../rapidjson/include/rapidjson/filewritestream.h | 104 - .../contrib/rapidjson/include/rapidjson/fwd.h | 151 - .../include/rapidjson/internal/biginteger.h | 290 -- .../rapidjson/include/rapidjson/internal/diyfp.h | 258 - .../rapidjson/include/rapidjson/internal/dtoa.h | 245 - .../rapidjson/include/rapidjson/internal/ieee754.h | 78 - .../rapidjson/include/rapidjson/internal/itoa.h | 304 -- .../rapidjson/include/rapidjson/internal/meta.h | 181 - .../rapidjson/include/rapidjson/internal/pow10.h | 55 - .../rapidjson/include/rapidjson/internal/regex.h | 734 --- .../rapidjson/include/rapidjson/internal/stack.h | 231 - .../rapidjson/include/rapidjson/internal/strfunc.h | 69 - .../rapidjson/include/rapidjson/internal/strtod.h | 269 -- .../rapidjson/include/rapidjson/internal/swap.h | 46 - .../rapidjson/include/rapidjson/istreamwrapper.h | 115 - .../rapidjson/include/rapidjson/memorybuffer.h | 70 - .../rapidjson/include/rapidjson/memorystream.h | 71 - .../include/rapidjson/msinttypes/inttypes.h | 316 -- .../include/rapidjson/msinttypes/stdint.h | 300 -- .../rapidjson/include/rapidjson/ostreamwrapper.h | 81 - .../contrib/rapidjson/include/rapidjson/pointer.h | 1358 ------ .../rapidjson/include/rapidjson/prettywriter.h | 277 -- .../rapidjson/include/rapidjson/rapidjson.h | 628 --- .../contrib/rapidjson/include/rapidjson/reader.h | 2221 --------- .../contrib/rapidjson/include/rapidjson/schema.h | 2016 -------- .../contrib/rapidjson/include/rapidjson/stream.h | 179 - .../rapidjson/include/rapidjson/stringbuffer.h | 121 - .../contrib/rapidjson/include/rapidjson/writer.h | 711 --- src/3rdparty/assimp/contrib/rapidjson/license.txt | 57 - src/3rdparty/assimp/contrib/rapidjson/readme.md | 160 - src/3rdparty/assimp/contrib/unzip/crypt.h | 132 - src/3rdparty/assimp/contrib/unzip/ioapi.c | 177 - src/3rdparty/assimp/contrib/unzip/ioapi.h | 75 - src/3rdparty/assimp/contrib/unzip/unzip.c | 1611 ------- src/3rdparty/assimp/contrib/unzip/unzip.h | 354 -- .../assimp/contrib/utf8cpp/doc/ReleaseNotes | 12 - .../assimp/contrib/utf8cpp/doc/utf8cpp.html | 1789 ------- src/3rdparty/assimp/contrib/utf8cpp/source/utf8.h | 34 - .../assimp/contrib/utf8cpp/source/utf8/checked.h | 327 -- .../assimp/contrib/utf8cpp/source/utf8/core.h | 329 -- .../assimp/contrib/utf8cpp/source/utf8/unchecked.h | 228 - src/3rdparty/assimp/contrib/zip/README.md | 139 - src/3rdparty/assimp/contrib/zip/UNLICENSE | 26 - src/3rdparty/assimp/contrib/zip/src/miniz.h | 4928 -------------------- src/3rdparty/assimp/contrib/zip/src/zip.c | 640 --- src/3rdparty/assimp/contrib/zip/src/zip.h | 193 - .../assimp/include/assimp/Compiler/poppack1.h | 22 - .../assimp/include/assimp/Compiler/pstdint.h | 912 ---- .../assimp/include/assimp/Compiler/pushpack1.h | 43 - .../assimp/include/assimp/DefaultIOStream.h | 141 - .../assimp/include/assimp/DefaultIOSystem.h | 99 - .../assimp/include/assimp/DefaultLogger.hpp | 191 - src/3rdparty/assimp/include/assimp/Defines.h | 49 - src/3rdparty/assimp/include/assimp/Exporter.hpp | 483 -- src/3rdparty/assimp/include/assimp/IOStream.hpp | 140 - src/3rdparty/assimp/include/assimp/IOSystem.hpp | 359 -- src/3rdparty/assimp/include/assimp/Importer.hpp | 653 --- src/3rdparty/assimp/include/assimp/LogStream.hpp | 110 - src/3rdparty/assimp/include/assimp/Logger.hpp | 268 -- src/3rdparty/assimp/include/assimp/NullLogger.hpp | 98 - .../assimp/include/assimp/ProgressHandler.hpp | 126 - src/3rdparty/assimp/include/assimp/SceneCombiner.h | 400 -- src/3rdparty/assimp/include/assimp/ai_assert.h | 53 - src/3rdparty/assimp/include/assimp/anim.h | 572 --- src/3rdparty/assimp/include/assimp/camera.h | 225 - src/3rdparty/assimp/include/assimp/cexport.h | 263 -- src/3rdparty/assimp/include/assimp/cfileio.h | 137 - src/3rdparty/assimp/include/assimp/cimport.h | 564 --- src/3rdparty/assimp/include/assimp/color4.h | 104 - src/3rdparty/assimp/include/assimp/color4.inl | 204 - src/3rdparty/assimp/include/assimp/config.h | 964 ---- src/3rdparty/assimp/include/assimp/defs.h | 290 -- src/3rdparty/assimp/include/assimp/importerdesc.h | 145 - src/3rdparty/assimp/include/assimp/light.h | 258 - src/3rdparty/assimp/include/assimp/material.h | 1564 ------- src/3rdparty/assimp/include/assimp/material.inl | 389 -- src/3rdparty/assimp/include/assimp/matrix3x3.h | 182 - src/3rdparty/assimp/include/assimp/matrix3x3.inl | 356 -- src/3rdparty/assimp/include/assimp/matrix4x4.h | 279 -- src/3rdparty/assimp/include/assimp/matrix4x4.inl | 681 --- src/3rdparty/assimp/include/assimp/mesh.h | 773 --- src/3rdparty/assimp/include/assimp/metadata.h | 314 -- .../assimp/port/AndroidJNI/AndroidJNIIOSystem.h | 92 - src/3rdparty/assimp/include/assimp/postprocess.h | 645 --- src/3rdparty/assimp/include/assimp/quaternion.h | 129 - src/3rdparty/assimp/include/assimp/quaternion.inl | 285 -- src/3rdparty/assimp/include/assimp/scene.h | 384 -- src/3rdparty/assimp/include/assimp/texture.h | 217 - src/3rdparty/assimp/include/assimp/types.h | 518 -- src/3rdparty/assimp/include/assimp/vector2.h | 116 - src/3rdparty/assimp/include/assimp/vector2.inl | 227 - src/3rdparty/assimp/include/assimp/vector3.h | 145 - src/3rdparty/assimp/include/assimp/vector3.inl | 260 -- src/3rdparty/assimp/include/assimp/version.h | 108 - src/3rdparty/assimp/revision.h | 4 +- src/3rdparty/assimp/src | 1 + src/3rdparty/assimp/unzip/unzip.h | 355 ++ 584 files changed, 1764 insertions(+), 244039 deletions(-) create mode 100644 .gitmodules delete mode 100644 src/3rdparty/assimp/README delete mode 100644 src/3rdparty/assimp/Readme.md delete mode 100644 src/3rdparty/assimp/code/3DSConverter.cpp delete mode 100644 src/3rdparty/assimp/code/3DSExporter.cpp delete mode 100644 src/3rdparty/assimp/code/3DSExporter.h delete mode 100644 src/3rdparty/assimp/code/3DSHelper.h delete mode 100644 src/3rdparty/assimp/code/3DSLoader.cpp delete mode 100644 src/3rdparty/assimp/code/3DSLoader.h delete mode 100644 src/3rdparty/assimp/code/3MFXmlTags.h delete mode 100644 src/3rdparty/assimp/code/ACLoader.cpp delete mode 100644 src/3rdparty/assimp/code/ACLoader.h delete mode 100644 src/3rdparty/assimp/code/AMFImporter.cpp delete mode 100644 src/3rdparty/assimp/code/AMFImporter.hpp delete mode 100644 src/3rdparty/assimp/code/AMFImporter_Geometry.cpp delete mode 100644 src/3rdparty/assimp/code/AMFImporter_Macro.hpp delete mode 100644 src/3rdparty/assimp/code/AMFImporter_Material.cpp delete mode 100644 src/3rdparty/assimp/code/AMFImporter_Node.hpp delete mode 100644 src/3rdparty/assimp/code/AMFImporter_Postprocess.cpp delete mode 100644 src/3rdparty/assimp/code/ASELoader.cpp delete mode 100644 src/3rdparty/assimp/code/ASELoader.h delete mode 100644 src/3rdparty/assimp/code/ASEParser.cpp delete mode 100644 src/3rdparty/assimp/code/ASEParser.h delete mode 100644 src/3rdparty/assimp/code/AssbinExporter.cpp delete mode 100644 src/3rdparty/assimp/code/AssbinExporter.h delete mode 100644 src/3rdparty/assimp/code/AssbinLoader.cpp delete mode 100644 src/3rdparty/assimp/code/AssbinLoader.h delete mode 100644 src/3rdparty/assimp/code/Assimp.cpp delete mode 100644 src/3rdparty/assimp/code/AssimpCExport.cpp delete mode 100644 src/3rdparty/assimp/code/AssxmlExporter.cpp delete mode 100644 src/3rdparty/assimp/code/AssxmlExporter.h delete mode 100644 src/3rdparty/assimp/code/B3DImporter.cpp delete mode 100644 src/3rdparty/assimp/code/B3DImporter.h delete mode 100644 src/3rdparty/assimp/code/BVHLoader.cpp delete mode 100644 src/3rdparty/assimp/code/BVHLoader.h delete mode 100644 src/3rdparty/assimp/code/BaseImporter.cpp delete mode 100644 src/3rdparty/assimp/code/BaseImporter.h delete mode 100644 src/3rdparty/assimp/code/BaseProcess.cpp delete mode 100644 src/3rdparty/assimp/code/BaseProcess.h delete mode 100644 src/3rdparty/assimp/code/Bitmap.cpp delete mode 100644 src/3rdparty/assimp/code/Bitmap.h delete mode 100644 src/3rdparty/assimp/code/BlenderBMesh.cpp delete mode 100644 src/3rdparty/assimp/code/BlenderBMesh.h delete mode 100644 src/3rdparty/assimp/code/BlenderDNA.cpp delete mode 100644 src/3rdparty/assimp/code/BlenderDNA.h delete mode 100644 src/3rdparty/assimp/code/BlenderDNA.inl delete mode 100644 src/3rdparty/assimp/code/BlenderIntermediate.h delete mode 100644 src/3rdparty/assimp/code/BlenderLoader.cpp delete mode 100644 src/3rdparty/assimp/code/BlenderLoader.h delete mode 100644 src/3rdparty/assimp/code/BlenderModifier.cpp delete mode 100644 src/3rdparty/assimp/code/BlenderModifier.h delete mode 100644 src/3rdparty/assimp/code/BlenderScene.cpp delete mode 100644 src/3rdparty/assimp/code/BlenderScene.h delete mode 100644 src/3rdparty/assimp/code/BlenderSceneGen.h delete mode 100644 src/3rdparty/assimp/code/BlenderTessellator.cpp delete mode 100644 src/3rdparty/assimp/code/BlenderTessellator.h delete mode 100644 src/3rdparty/assimp/code/BlobIOSystem.h delete mode 100644 src/3rdparty/assimp/code/ByteSwapper.h delete mode 100644 src/3rdparty/assimp/code/C4DImporter.cpp delete mode 100644 src/3rdparty/assimp/code/C4DImporter.h delete mode 100644 src/3rdparty/assimp/code/CInterfaceIOWrapper.cpp delete mode 100644 src/3rdparty/assimp/code/CInterfaceIOWrapper.h delete mode 100644 src/3rdparty/assimp/code/CMakeLists.txt delete mode 100644 src/3rdparty/assimp/code/COBLoader.cpp delete mode 100644 src/3rdparty/assimp/code/COBLoader.h delete mode 100644 src/3rdparty/assimp/code/COBScene.h delete mode 100644 src/3rdparty/assimp/code/CSMLoader.cpp delete mode 100644 src/3rdparty/assimp/code/CSMLoader.h delete mode 100644 src/3rdparty/assimp/code/CalcTangentsProcess.cpp delete mode 100644 src/3rdparty/assimp/code/CalcTangentsProcess.h delete mode 100644 src/3rdparty/assimp/code/ColladaExporter.cpp delete mode 100644 src/3rdparty/assimp/code/ColladaExporter.h delete mode 100644 src/3rdparty/assimp/code/ColladaHelper.h delete mode 100644 src/3rdparty/assimp/code/ColladaLoader.cpp delete mode 100644 src/3rdparty/assimp/code/ColladaLoader.h delete mode 100644 src/3rdparty/assimp/code/ColladaParser.cpp delete mode 100644 src/3rdparty/assimp/code/ColladaParser.h delete mode 100644 src/3rdparty/assimp/code/ComputeUVMappingProcess.cpp delete mode 100644 src/3rdparty/assimp/code/ComputeUVMappingProcess.h delete mode 100644 src/3rdparty/assimp/code/ConvertToLHProcess.cpp delete mode 100644 src/3rdparty/assimp/code/ConvertToLHProcess.h delete mode 100644 src/3rdparty/assimp/code/CreateAnimMesh.cpp delete mode 100644 src/3rdparty/assimp/code/CreateAnimMesh.h delete mode 100644 src/3rdparty/assimp/code/D3MFExporter.cpp delete mode 100644 src/3rdparty/assimp/code/D3MFExporter.h delete mode 100644 src/3rdparty/assimp/code/D3MFImporter.cpp delete mode 100644 src/3rdparty/assimp/code/D3MFImporter.h delete mode 100644 src/3rdparty/assimp/code/D3MFOpcPackage.cpp delete mode 100644 src/3rdparty/assimp/code/D3MFOpcPackage.h delete mode 100644 src/3rdparty/assimp/code/DXFHelper.h delete mode 100644 src/3rdparty/assimp/code/DXFLoader.cpp delete mode 100644 src/3rdparty/assimp/code/DXFLoader.h delete mode 100644 src/3rdparty/assimp/code/DeboneProcess.cpp delete mode 100644 src/3rdparty/assimp/code/DeboneProcess.h delete mode 100644 src/3rdparty/assimp/code/DefaultIOStream.cpp delete mode 100644 src/3rdparty/assimp/code/DefaultIOSystem.cpp delete mode 100644 src/3rdparty/assimp/code/DefaultLogger.cpp delete mode 100644 src/3rdparty/assimp/code/DefaultProgressHandler.h delete mode 100644 src/3rdparty/assimp/code/Exceptional.h delete mode 100644 src/3rdparty/assimp/code/Exporter.cpp delete mode 100644 src/3rdparty/assimp/code/FBXAnimation.cpp delete mode 100644 src/3rdparty/assimp/code/FBXBinaryTokenizer.cpp delete mode 100644 src/3rdparty/assimp/code/FBXCompileConfig.h delete mode 100644 src/3rdparty/assimp/code/FBXConverter.cpp delete mode 100644 src/3rdparty/assimp/code/FBXConverter.h delete mode 100644 src/3rdparty/assimp/code/FBXDeformer.cpp delete mode 100644 src/3rdparty/assimp/code/FBXDocument.cpp delete mode 100644 src/3rdparty/assimp/code/FBXDocument.h delete mode 100644 src/3rdparty/assimp/code/FBXDocumentUtil.cpp delete mode 100644 src/3rdparty/assimp/code/FBXDocumentUtil.h delete mode 100644 src/3rdparty/assimp/code/FBXImportSettings.h delete mode 100644 src/3rdparty/assimp/code/FBXImporter.cpp delete mode 100644 src/3rdparty/assimp/code/FBXImporter.h delete mode 100644 src/3rdparty/assimp/code/FBXMaterial.cpp delete mode 100644 src/3rdparty/assimp/code/FBXMeshGeometry.cpp delete mode 100644 src/3rdparty/assimp/code/FBXMeshGeometry.h delete mode 100644 src/3rdparty/assimp/code/FBXModel.cpp delete mode 100644 src/3rdparty/assimp/code/FBXNodeAttribute.cpp delete mode 100644 src/3rdparty/assimp/code/FBXParser.cpp delete mode 100644 src/3rdparty/assimp/code/FBXParser.h delete mode 100644 src/3rdparty/assimp/code/FBXProperties.cpp delete mode 100644 src/3rdparty/assimp/code/FBXProperties.h delete mode 100644 src/3rdparty/assimp/code/FBXTokenizer.cpp delete mode 100644 src/3rdparty/assimp/code/FBXTokenizer.h delete mode 100644 src/3rdparty/assimp/code/FBXUtil.cpp delete mode 100644 src/3rdparty/assimp/code/FBXUtil.h delete mode 100644 src/3rdparty/assimp/code/FIReader.cpp delete mode 100644 src/3rdparty/assimp/code/FIReader.hpp delete mode 100644 src/3rdparty/assimp/code/FileLogStream.h delete mode 100644 src/3rdparty/assimp/code/FileSystemFilter.h delete mode 100644 src/3rdparty/assimp/code/FindDegenerates.cpp delete mode 100644 src/3rdparty/assimp/code/FindDegenerates.h delete mode 100644 src/3rdparty/assimp/code/FindInstancesProcess.cpp delete mode 100644 src/3rdparty/assimp/code/FindInstancesProcess.h delete mode 100644 src/3rdparty/assimp/code/FindInvalidDataProcess.cpp delete mode 100644 src/3rdparty/assimp/code/FindInvalidDataProcess.h delete mode 100644 src/3rdparty/assimp/code/FixNormalsStep.cpp delete mode 100644 src/3rdparty/assimp/code/FixNormalsStep.h delete mode 100644 src/3rdparty/assimp/code/GenFaceNormalsProcess.cpp delete mode 100644 src/3rdparty/assimp/code/GenFaceNormalsProcess.h delete mode 100644 src/3rdparty/assimp/code/GenVertexNormalsProcess.cpp delete mode 100644 src/3rdparty/assimp/code/GenVertexNormalsProcess.h delete mode 100644 src/3rdparty/assimp/code/GenericProperty.h delete mode 100644 src/3rdparty/assimp/code/HMPFileData.h delete mode 100644 src/3rdparty/assimp/code/HMPLoader.cpp delete mode 100644 src/3rdparty/assimp/code/HMPLoader.h delete mode 100644 src/3rdparty/assimp/code/HalfLifeFileData.h delete mode 100644 src/3rdparty/assimp/code/Hash.h delete mode 100644 src/3rdparty/assimp/code/IFCBoolean.cpp delete mode 100644 src/3rdparty/assimp/code/IFCCurve.cpp delete mode 100644 src/3rdparty/assimp/code/IFCGeometry.cpp delete mode 100644 src/3rdparty/assimp/code/IFCLoader.cpp delete mode 100644 src/3rdparty/assimp/code/IFCLoader.h delete mode 100644 src/3rdparty/assimp/code/IFCMaterial.cpp delete mode 100644 src/3rdparty/assimp/code/IFCOpenings.cpp delete mode 100644 src/3rdparty/assimp/code/IFCProfile.cpp delete mode 100644 src/3rdparty/assimp/code/IFCReaderGen.h delete mode 100644 src/3rdparty/assimp/code/IFCReaderGen1.cpp delete mode 100644 src/3rdparty/assimp/code/IFCReaderGen2.cpp delete mode 100644 src/3rdparty/assimp/code/IFCUtil.cpp delete mode 100644 src/3rdparty/assimp/code/IFCUtil.h delete mode 100644 src/3rdparty/assimp/code/IFF.h delete mode 100644 src/3rdparty/assimp/code/IOStreamBuffer.h delete mode 100644 src/3rdparty/assimp/code/IRRLoader.cpp delete mode 100644 src/3rdparty/assimp/code/IRRLoader.h delete mode 100644 src/3rdparty/assimp/code/IRRMeshLoader.cpp delete mode 100644 src/3rdparty/assimp/code/IRRMeshLoader.h delete mode 100644 src/3rdparty/assimp/code/IRRShared.cpp delete mode 100644 src/3rdparty/assimp/code/IRRShared.h delete mode 100644 src/3rdparty/assimp/code/Importer.cpp delete mode 100644 src/3rdparty/assimp/code/Importer.h delete mode 100644 src/3rdparty/assimp/code/ImporterRegistry.cpp delete mode 100644 src/3rdparty/assimp/code/ImproveCacheLocality.cpp delete mode 100644 src/3rdparty/assimp/code/ImproveCacheLocality.h delete mode 100644 src/3rdparty/assimp/code/JoinVerticesProcess.cpp delete mode 100644 src/3rdparty/assimp/code/JoinVerticesProcess.h delete mode 100644 src/3rdparty/assimp/code/LWOAnimation.cpp delete mode 100644 src/3rdparty/assimp/code/LWOAnimation.h delete mode 100644 src/3rdparty/assimp/code/LWOBLoader.cpp delete mode 100644 src/3rdparty/assimp/code/LWOFileData.h delete mode 100644 src/3rdparty/assimp/code/LWOLoader.cpp delete mode 100644 src/3rdparty/assimp/code/LWOLoader.h delete mode 100644 src/3rdparty/assimp/code/LWOMaterial.cpp delete mode 100644 src/3rdparty/assimp/code/LWSLoader.cpp delete mode 100644 src/3rdparty/assimp/code/LWSLoader.h delete mode 100644 src/3rdparty/assimp/code/LimitBoneWeightsProcess.cpp delete mode 100644 src/3rdparty/assimp/code/LimitBoneWeightsProcess.h delete mode 100644 src/3rdparty/assimp/code/LineSplitter.h delete mode 100644 src/3rdparty/assimp/code/LogAux.h delete mode 100644 src/3rdparty/assimp/code/MD2FileData.h delete mode 100644 src/3rdparty/assimp/code/MD2Loader.cpp delete mode 100644 src/3rdparty/assimp/code/MD2Loader.h delete mode 100644 src/3rdparty/assimp/code/MD2NormalTable.h delete mode 100644 src/3rdparty/assimp/code/MD3FileData.h delete mode 100644 src/3rdparty/assimp/code/MD3Loader.cpp delete mode 100644 src/3rdparty/assimp/code/MD3Loader.h delete mode 100644 src/3rdparty/assimp/code/MD4FileData.h delete mode 100644 src/3rdparty/assimp/code/MD5Loader.cpp delete mode 100644 src/3rdparty/assimp/code/MD5Loader.h delete mode 100644 src/3rdparty/assimp/code/MD5Parser.cpp delete mode 100644 src/3rdparty/assimp/code/MD5Parser.h delete mode 100644 src/3rdparty/assimp/code/MDCFileData.h delete mode 100644 src/3rdparty/assimp/code/MDCLoader.cpp delete mode 100644 src/3rdparty/assimp/code/MDCLoader.h delete mode 100644 src/3rdparty/assimp/code/MDCNormalTable.h delete mode 100644 src/3rdparty/assimp/code/MDLDefaultColorMap.h delete mode 100644 src/3rdparty/assimp/code/MDLFileData.h delete mode 100644 src/3rdparty/assimp/code/MDLLoader.cpp delete mode 100644 src/3rdparty/assimp/code/MDLLoader.h delete mode 100644 src/3rdparty/assimp/code/MDLMaterialLoader.cpp delete mode 100644 src/3rdparty/assimp/code/MMDCpp14.h delete mode 100644 src/3rdparty/assimp/code/MMDImporter.cpp delete mode 100644 src/3rdparty/assimp/code/MMDImporter.h delete mode 100644 src/3rdparty/assimp/code/MMDPmdParser.h delete mode 100644 src/3rdparty/assimp/code/MMDPmxParser.cpp delete mode 100644 src/3rdparty/assimp/code/MMDPmxParser.h delete mode 100644 src/3rdparty/assimp/code/MMDVmdParser.h delete mode 100644 src/3rdparty/assimp/code/MS3DLoader.cpp delete mode 100644 src/3rdparty/assimp/code/MS3DLoader.h delete mode 100644 src/3rdparty/assimp/code/Macros.h delete mode 100644 src/3rdparty/assimp/code/MakeVerboseFormat.cpp delete mode 100644 src/3rdparty/assimp/code/MakeVerboseFormat.h delete mode 100644 src/3rdparty/assimp/code/MaterialSystem.cpp delete mode 100644 src/3rdparty/assimp/code/MaterialSystem.h delete mode 100644 src/3rdparty/assimp/code/MathFunctions.h delete mode 100644 src/3rdparty/assimp/code/MemoryIOWrapper.h delete mode 100644 src/3rdparty/assimp/code/NDOLoader.cpp delete mode 100644 src/3rdparty/assimp/code/NDOLoader.h delete mode 100644 src/3rdparty/assimp/code/NFFLoader.cpp delete mode 100644 src/3rdparty/assimp/code/NFFLoader.h delete mode 100644 src/3rdparty/assimp/code/OFFLoader.cpp delete mode 100644 src/3rdparty/assimp/code/OFFLoader.h delete mode 100644 src/3rdparty/assimp/code/ObjExporter.cpp delete mode 100644 src/3rdparty/assimp/code/ObjExporter.h delete mode 100644 src/3rdparty/assimp/code/ObjFileData.h delete mode 100644 src/3rdparty/assimp/code/ObjFileImporter.cpp delete mode 100644 src/3rdparty/assimp/code/ObjFileImporter.h delete mode 100644 src/3rdparty/assimp/code/ObjFileMtlImporter.cpp delete mode 100644 src/3rdparty/assimp/code/ObjFileMtlImporter.h delete mode 100644 src/3rdparty/assimp/code/ObjFileParser.cpp delete mode 100644 src/3rdparty/assimp/code/ObjFileParser.h delete mode 100644 src/3rdparty/assimp/code/ObjTools.h delete mode 100644 src/3rdparty/assimp/code/OgreBinarySerializer.cpp delete mode 100644 src/3rdparty/assimp/code/OgreBinarySerializer.h delete mode 100644 src/3rdparty/assimp/code/OgreImporter.cpp delete mode 100644 src/3rdparty/assimp/code/OgreImporter.h delete mode 100644 src/3rdparty/assimp/code/OgreMaterial.cpp delete mode 100644 src/3rdparty/assimp/code/OgreParsingUtils.h delete mode 100644 src/3rdparty/assimp/code/OgreStructs.cpp delete mode 100644 src/3rdparty/assimp/code/OgreStructs.h delete mode 100644 src/3rdparty/assimp/code/OgreXmlSerializer.cpp delete mode 100644 src/3rdparty/assimp/code/OgreXmlSerializer.h delete mode 100644 src/3rdparty/assimp/code/OpenGEXExporter.cpp delete mode 100644 src/3rdparty/assimp/code/OpenGEXExporter.h delete mode 100644 src/3rdparty/assimp/code/OpenGEXImporter.cpp delete mode 100644 src/3rdparty/assimp/code/OpenGEXImporter.h delete mode 100644 src/3rdparty/assimp/code/OpenGEXStructs.h delete mode 100644 src/3rdparty/assimp/code/OptimizeGraph.cpp delete mode 100644 src/3rdparty/assimp/code/OptimizeGraph.h delete mode 100644 src/3rdparty/assimp/code/OptimizeMeshes.cpp delete mode 100644 src/3rdparty/assimp/code/OptimizeMeshes.h delete mode 100644 src/3rdparty/assimp/code/ParsingUtils.h delete mode 100644 src/3rdparty/assimp/code/PlyExporter.cpp delete mode 100644 src/3rdparty/assimp/code/PlyExporter.h delete mode 100644 src/3rdparty/assimp/code/PlyLoader.cpp delete mode 100644 src/3rdparty/assimp/code/PlyLoader.h delete mode 100644 src/3rdparty/assimp/code/PlyParser.cpp delete mode 100644 src/3rdparty/assimp/code/PlyParser.h delete mode 100644 src/3rdparty/assimp/code/PolyTools.h delete mode 100644 src/3rdparty/assimp/code/PostStepRegistry.cpp delete mode 100644 src/3rdparty/assimp/code/PretransformVertices.cpp delete mode 100644 src/3rdparty/assimp/code/PretransformVertices.h delete mode 100644 src/3rdparty/assimp/code/ProcessHelper.cpp delete mode 100644 src/3rdparty/assimp/code/ProcessHelper.h delete mode 100644 src/3rdparty/assimp/code/Profiler.h delete mode 100644 src/3rdparty/assimp/code/Q3BSPFileData.h delete mode 100644 src/3rdparty/assimp/code/Q3BSPFileImporter.cpp delete mode 100644 src/3rdparty/assimp/code/Q3BSPFileImporter.h delete mode 100644 src/3rdparty/assimp/code/Q3BSPFileParser.cpp delete mode 100644 src/3rdparty/assimp/code/Q3BSPFileParser.h delete mode 100644 src/3rdparty/assimp/code/Q3BSPZipArchive.cpp delete mode 100644 src/3rdparty/assimp/code/Q3BSPZipArchive.h delete mode 100644 src/3rdparty/assimp/code/Q3DLoader.cpp delete mode 100644 src/3rdparty/assimp/code/Q3DLoader.h delete mode 100644 src/3rdparty/assimp/code/RawLoader.cpp delete mode 100644 src/3rdparty/assimp/code/RawLoader.h delete mode 100644 src/3rdparty/assimp/code/RemoveComments.cpp delete mode 100644 src/3rdparty/assimp/code/RemoveComments.h delete mode 100644 src/3rdparty/assimp/code/RemoveRedundantMaterials.cpp delete mode 100644 src/3rdparty/assimp/code/RemoveRedundantMaterials.h delete mode 100644 src/3rdparty/assimp/code/RemoveVCProcess.cpp delete mode 100644 src/3rdparty/assimp/code/RemoveVCProcess.h delete mode 100644 src/3rdparty/assimp/code/SGSpatialSort.cpp delete mode 100644 src/3rdparty/assimp/code/SGSpatialSort.h delete mode 100644 src/3rdparty/assimp/code/SIBImporter.cpp delete mode 100644 src/3rdparty/assimp/code/SIBImporter.h delete mode 100644 src/3rdparty/assimp/code/SMDLoader.cpp delete mode 100644 src/3rdparty/assimp/code/SMDLoader.h delete mode 100644 src/3rdparty/assimp/code/STEPFile.h delete mode 100644 src/3rdparty/assimp/code/STEPFileEncoding.cpp delete mode 100644 src/3rdparty/assimp/code/STEPFileEncoding.h delete mode 100644 src/3rdparty/assimp/code/STEPFileReader.cpp delete mode 100644 src/3rdparty/assimp/code/STEPFileReader.h delete mode 100644 src/3rdparty/assimp/code/STLExporter.cpp delete mode 100644 src/3rdparty/assimp/code/STLExporter.h delete mode 100644 src/3rdparty/assimp/code/STLLoader.cpp delete mode 100644 src/3rdparty/assimp/code/STLLoader.h delete mode 100644 src/3rdparty/assimp/code/ScaleProcess.cpp delete mode 100644 src/3rdparty/assimp/code/ScaleProcess.h delete mode 100644 src/3rdparty/assimp/code/SceneCombiner.cpp delete mode 100644 src/3rdparty/assimp/code/ScenePreprocessor.cpp delete mode 100644 src/3rdparty/assimp/code/ScenePreprocessor.h delete mode 100644 src/3rdparty/assimp/code/ScenePrivate.h delete mode 100644 src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp delete mode 100644 src/3rdparty/assimp/code/SkeletonMeshBuilder.h delete mode 100644 src/3rdparty/assimp/code/SmoothingGroups.h delete mode 100644 src/3rdparty/assimp/code/SmoothingGroups.inl delete mode 100644 src/3rdparty/assimp/code/SortByPTypeProcess.cpp delete mode 100644 src/3rdparty/assimp/code/SortByPTypeProcess.h delete mode 100644 src/3rdparty/assimp/code/SpatialSort.cpp delete mode 100644 src/3rdparty/assimp/code/SpatialSort.h delete mode 100644 src/3rdparty/assimp/code/SplitByBoneCountProcess.cpp delete mode 100644 src/3rdparty/assimp/code/SplitByBoneCountProcess.h delete mode 100644 src/3rdparty/assimp/code/SplitLargeMeshes.cpp delete mode 100644 src/3rdparty/assimp/code/SplitLargeMeshes.h delete mode 100644 src/3rdparty/assimp/code/StandardShapes.cpp delete mode 100644 src/3rdparty/assimp/code/StandardShapes.h delete mode 100644 src/3rdparty/assimp/code/StdOStreamLogStream.h delete mode 100644 src/3rdparty/assimp/code/StepExporter.cpp delete mode 100644 src/3rdparty/assimp/code/StepExporter.h delete mode 100644 src/3rdparty/assimp/code/StreamReader.h delete mode 100644 src/3rdparty/assimp/code/StreamWriter.h delete mode 100644 src/3rdparty/assimp/code/StringComparison.h delete mode 100644 src/3rdparty/assimp/code/StringUtils.h delete mode 100644 src/3rdparty/assimp/code/Subdivision.cpp delete mode 100644 src/3rdparty/assimp/code/Subdivision.h delete mode 100644 src/3rdparty/assimp/code/TargetAnimation.cpp delete mode 100644 src/3rdparty/assimp/code/TargetAnimation.h delete mode 100644 src/3rdparty/assimp/code/TerragenLoader.cpp delete mode 100644 src/3rdparty/assimp/code/TerragenLoader.h delete mode 100644 src/3rdparty/assimp/code/TextureTransform.cpp delete mode 100644 src/3rdparty/assimp/code/TextureTransform.h delete mode 100644 src/3rdparty/assimp/code/TinyFormatter.h delete mode 100644 src/3rdparty/assimp/code/TriangulateProcess.cpp delete mode 100644 src/3rdparty/assimp/code/TriangulateProcess.h delete mode 100644 src/3rdparty/assimp/code/UnrealLoader.cpp delete mode 100644 src/3rdparty/assimp/code/UnrealLoader.h delete mode 100644 src/3rdparty/assimp/code/ValidateDataStructure.cpp delete mode 100644 src/3rdparty/assimp/code/ValidateDataStructure.h delete mode 100644 src/3rdparty/assimp/code/Version.cpp delete mode 100644 src/3rdparty/assimp/code/Vertex.h delete mode 100644 src/3rdparty/assimp/code/VertexTriangleAdjacency.cpp delete mode 100644 src/3rdparty/assimp/code/VertexTriangleAdjacency.h delete mode 100644 src/3rdparty/assimp/code/Win32DebugLogStream.h delete mode 100644 src/3rdparty/assimp/code/X3DExporter.cpp delete mode 100644 src/3rdparty/assimp/code/X3DExporter.hpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter.hpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Geometry2D.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Geometry3D.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Group.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Light.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Macro.hpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Metadata.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Networking.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Node.hpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Postprocess.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Rendering.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Shape.cpp delete mode 100644 src/3rdparty/assimp/code/X3DImporter_Texturing.cpp delete mode 100644 src/3rdparty/assimp/code/X3DVocabulary.cpp delete mode 100644 src/3rdparty/assimp/code/XFileExporter.cpp delete mode 100644 src/3rdparty/assimp/code/XFileExporter.h delete mode 100644 src/3rdparty/assimp/code/XFileHelper.h delete mode 100644 src/3rdparty/assimp/code/XFileImporter.cpp delete mode 100644 src/3rdparty/assimp/code/XFileImporter.h delete mode 100644 src/3rdparty/assimp/code/XFileParser.cpp delete mode 100644 src/3rdparty/assimp/code/XFileParser.h delete mode 100644 src/3rdparty/assimp/code/XGLLoader.cpp delete mode 100644 src/3rdparty/assimp/code/XGLLoader.h delete mode 100644 src/3rdparty/assimp/code/XMLTools.h delete mode 100644 src/3rdparty/assimp/code/assbin_chunks.h delete mode 100644 src/3rdparty/assimp/code/fast_atof.h delete mode 100644 src/3rdparty/assimp/code/glTF2Asset.h delete mode 100644 src/3rdparty/assimp/code/glTF2Asset.inl delete mode 100644 src/3rdparty/assimp/code/glTF2AssetWriter.h delete mode 100644 src/3rdparty/assimp/code/glTF2AssetWriter.inl delete mode 100644 src/3rdparty/assimp/code/glTF2Exporter.cpp delete mode 100644 src/3rdparty/assimp/code/glTF2Exporter.h delete mode 100644 src/3rdparty/assimp/code/glTF2Importer.cpp delete mode 100644 src/3rdparty/assimp/code/glTF2Importer.h delete mode 100644 src/3rdparty/assimp/code/glTFAsset.h delete mode 100644 src/3rdparty/assimp/code/glTFAsset.inl delete mode 100644 src/3rdparty/assimp/code/glTFAssetWriter.h delete mode 100644 src/3rdparty/assimp/code/glTFAssetWriter.inl delete mode 100644 src/3rdparty/assimp/code/glTFExporter.cpp delete mode 100644 src/3rdparty/assimp/code/glTFExporter.h delete mode 100644 src/3rdparty/assimp/code/glTFImporter.cpp delete mode 100644 src/3rdparty/assimp/code/glTFImporter.h delete mode 100644 src/3rdparty/assimp/code/irrXMLWrapper.h delete mode 100644 src/3rdparty/assimp/code/qnan.h delete mode 100644 src/3rdparty/assimp/code/res/assimp.rc delete mode 100644 src/3rdparty/assimp/code/res/resource.h delete mode 100644 src/3rdparty/assimp/code/scene.cpp create mode 100644 src/3rdparty/assimp/config.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcAdjacencyInfo.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcArithmeticCodec.cpp delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcArithmeticCodec.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcBinaryStream.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcCommon.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcDVEncodeParams.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcDynamicVector.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcDynamicVectorDecoder.cpp delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcDynamicVectorDecoder.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcDynamicVectorEncoder.cpp delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcDynamicVectorEncoder.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcFIFO.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcIndexedFaceSet.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcIndexedFaceSet.inl delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcSC3DMCDecoder.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcSC3DMCEncodeParams.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcSC3DMCEncoder.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcSC3DMCEncoder.inl delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcTimer.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcTools.cpp delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcTriangleFans.cpp delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcTriangleFans.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcTriangleListDecoder.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcTriangleListDecoder.inl delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcTriangleListEncoder.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcTriangleListEncoder.inl delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcVector.h delete mode 100644 src/3rdparty/assimp/contrib/Open3DGC/o3dgcVector.inl delete mode 100644 src/3rdparty/assimp/contrib/clipper/License.txt delete mode 100644 src/3rdparty/assimp/contrib/clipper/clipper.cpp delete mode 100644 src/3rdparty/assimp/contrib/clipper/clipper.hpp delete mode 100644 src/3rdparty/assimp/contrib/irrXML/CXMLReaderImpl.h delete mode 100644 src/3rdparty/assimp/contrib/irrXML/heapsort.h delete mode 100644 src/3rdparty/assimp/contrib/irrXML/irrArray.h delete mode 100644 src/3rdparty/assimp/contrib/irrXML/irrString.h delete mode 100644 src/3rdparty/assimp/contrib/irrXML/irrTypes.h delete mode 100644 src/3rdparty/assimp/contrib/irrXML/irrXML.cpp delete mode 100644 src/3rdparty/assimp/contrib/irrXML/irrXML.h delete mode 100644 src/3rdparty/assimp/contrib/irrXML_note.txt delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/CMakeLists.txt delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/CREDITS delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/LICENSE delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/README.md delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/code/DDLNode.cpp delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/code/OpenDDLCommon.cpp delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/code/OpenDDLExport.cpp delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/code/OpenDDLParser.cpp delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/code/OpenDDLStream.cpp delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/code/Value.cpp delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/include/openddlparser/DDLNode.h delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/include/openddlparser/OpenDDLExport.h delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParser.h delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/include/openddlparser/OpenDDLStream.h delete mode 100644 src/3rdparty/assimp/contrib/openddlparser/include/openddlparser/Value.h delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/AUTHORS delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/LICENSE delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/README delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/common/shapes.cc delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/common/shapes.h delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/common/utils.h delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/poly2tri.h delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/sweep/advancing_front.cc delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/sweep/advancing_front.h delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/sweep/cdt.cc delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/sweep/cdt.h delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/sweep/sweep.cc delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/sweep/sweep.h delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/sweep/sweep_context.cc delete mode 100644 src/3rdparty/assimp/contrib/poly2tri/poly2tri/sweep/sweep_context.h delete mode 100644 src/3rdparty/assimp/contrib/poly2tri_patch.txt delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/allocators.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/document.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/encodedstream.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/encodings.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/error/en.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/error/error.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/filereadstream.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/filewritestream.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/fwd.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/biginteger.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/diyfp.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/dtoa.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/ieee754.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/itoa.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/meta.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/pow10.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/regex.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/stack.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/strfunc.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/strtod.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/internal/swap.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/istreamwrapper.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/memorybuffer.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/memorystream.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/msinttypes/inttypes.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/msinttypes/stdint.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/ostreamwrapper.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/pointer.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/prettywriter.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/rapidjson.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/reader.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/schema.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/stream.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/stringbuffer.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/include/rapidjson/writer.h delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/license.txt delete mode 100644 src/3rdparty/assimp/contrib/rapidjson/readme.md delete mode 100644 src/3rdparty/assimp/contrib/unzip/crypt.h delete mode 100644 src/3rdparty/assimp/contrib/unzip/ioapi.c delete mode 100644 src/3rdparty/assimp/contrib/unzip/ioapi.h delete mode 100644 src/3rdparty/assimp/contrib/unzip/unzip.c delete mode 100644 src/3rdparty/assimp/contrib/unzip/unzip.h delete mode 100644 src/3rdparty/assimp/contrib/utf8cpp/doc/ReleaseNotes delete mode 100644 src/3rdparty/assimp/contrib/utf8cpp/doc/utf8cpp.html delete mode 100644 src/3rdparty/assimp/contrib/utf8cpp/source/utf8.h delete mode 100644 src/3rdparty/assimp/contrib/utf8cpp/source/utf8/checked.h delete mode 100644 src/3rdparty/assimp/contrib/utf8cpp/source/utf8/core.h delete mode 100644 src/3rdparty/assimp/contrib/utf8cpp/source/utf8/unchecked.h delete mode 100644 src/3rdparty/assimp/contrib/zip/README.md delete mode 100644 src/3rdparty/assimp/contrib/zip/UNLICENSE delete mode 100644 src/3rdparty/assimp/contrib/zip/src/miniz.h delete mode 100644 src/3rdparty/assimp/contrib/zip/src/zip.c delete mode 100644 src/3rdparty/assimp/contrib/zip/src/zip.h delete mode 100644 src/3rdparty/assimp/include/assimp/Compiler/poppack1.h delete mode 100644 src/3rdparty/assimp/include/assimp/Compiler/pstdint.h delete mode 100644 src/3rdparty/assimp/include/assimp/Compiler/pushpack1.h delete mode 100644 src/3rdparty/assimp/include/assimp/DefaultIOStream.h delete mode 100644 src/3rdparty/assimp/include/assimp/DefaultIOSystem.h delete mode 100644 src/3rdparty/assimp/include/assimp/DefaultLogger.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/Defines.h delete mode 100644 src/3rdparty/assimp/include/assimp/Exporter.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/IOStream.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/IOSystem.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/Importer.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/LogStream.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/Logger.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/NullLogger.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/ProgressHandler.hpp delete mode 100644 src/3rdparty/assimp/include/assimp/SceneCombiner.h delete mode 100644 src/3rdparty/assimp/include/assimp/ai_assert.h delete mode 100644 src/3rdparty/assimp/include/assimp/anim.h delete mode 100644 src/3rdparty/assimp/include/assimp/camera.h delete mode 100644 src/3rdparty/assimp/include/assimp/cexport.h delete mode 100644 src/3rdparty/assimp/include/assimp/cfileio.h delete mode 100644 src/3rdparty/assimp/include/assimp/cimport.h delete mode 100644 src/3rdparty/assimp/include/assimp/color4.h delete mode 100644 src/3rdparty/assimp/include/assimp/color4.inl delete mode 100644 src/3rdparty/assimp/include/assimp/config.h delete mode 100644 src/3rdparty/assimp/include/assimp/defs.h delete mode 100644 src/3rdparty/assimp/include/assimp/importerdesc.h delete mode 100644 src/3rdparty/assimp/include/assimp/light.h delete mode 100644 src/3rdparty/assimp/include/assimp/material.h delete mode 100644 src/3rdparty/assimp/include/assimp/material.inl delete mode 100644 src/3rdparty/assimp/include/assimp/matrix3x3.h delete mode 100644 src/3rdparty/assimp/include/assimp/matrix3x3.inl delete mode 100644 src/3rdparty/assimp/include/assimp/matrix4x4.h delete mode 100644 src/3rdparty/assimp/include/assimp/matrix4x4.inl delete mode 100644 src/3rdparty/assimp/include/assimp/mesh.h delete mode 100644 src/3rdparty/assimp/include/assimp/metadata.h delete mode 100644 src/3rdparty/assimp/include/assimp/port/AndroidJNI/AndroidJNIIOSystem.h delete mode 100644 src/3rdparty/assimp/include/assimp/postprocess.h delete mode 100644 src/3rdparty/assimp/include/assimp/quaternion.h delete mode 100644 src/3rdparty/assimp/include/assimp/quaternion.inl delete mode 100644 src/3rdparty/assimp/include/assimp/scene.h delete mode 100644 src/3rdparty/assimp/include/assimp/texture.h delete mode 100644 src/3rdparty/assimp/include/assimp/types.h delete mode 100644 src/3rdparty/assimp/include/assimp/vector2.h delete mode 100644 src/3rdparty/assimp/include/assimp/vector2.inl delete mode 100644 src/3rdparty/assimp/include/assimp/vector3.h delete mode 100644 src/3rdparty/assimp/include/assimp/vector3.inl delete mode 100644 src/3rdparty/assimp/include/assimp/version.h create mode 160000 src/3rdparty/assimp/src create mode 100644 src/3rdparty/assimp/unzip/unzip.h diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..46804f477 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/3rdparty/assimp/src"] + path = src/3rdparty/assimp/src + url = ../qtquick3d-assimp.git diff --git a/config.tests/assimp/main.cpp b/config.tests/assimp/main.cpp index 8d5e86f85..8a88e9e1b 100644 --- a/config.tests/assimp/main.cpp +++ b/config.tests/assimp/main.cpp @@ -45,5 +45,9 @@ int main(int , char **) aiAnimation anim; anim.mNumMorphMeshChannels = 0; + // Check for something that was set in a recent version + aiMaterial aiM; + (void)aiM.GetName(); + return 0; } diff --git a/src/3rdparty/assimp/README b/src/3rdparty/assimp/README deleted file mode 100644 index 24619ab94..000000000 --- a/src/3rdparty/assimp/README +++ /dev/null @@ -1 +0,0 @@ -See Readme.md diff --git a/src/3rdparty/assimp/Readme.md b/src/3rdparty/assimp/Readme.md deleted file mode 100644 index 1f6c4118f..000000000 --- a/src/3rdparty/assimp/Readme.md +++ /dev/null @@ -1,170 +0,0 @@ -Open Asset Import Library (assimp) -================================== -A library to import and export various 3d-model-formats including scene-post-processing to generate missing render data. -### Current build status ### -[![Linux Build Status](https://travis-ci.org/assimp/assimp.svg)](https://travis-ci.org/assimp/assimp) -[![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp) - - Coverity Scan Build Status - -[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master) -[![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -
- -APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS. - -Additionally, assimp features various __mesh post processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more. - -This is the development repo containing the latest features and bugfixes. For productive use though, we recommend one of the stable releases available from [Github Assimp Releases](https://github.com/assimp/assimp/releases). - -Monthly donations via Patreon: -
[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/assimp) - -
- -One-off donations via PayPal: -
[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4) - -
- -Please check our Wiki as well: https://github.com/assimp/assimp/wiki - -#### Supported file formats #### - -A full list [is here](http://assimp.org/main_features_formats.html). -__Importers__: -- 3D -- 3DS -- 3MF -- AC -- AC3D -- ACC -- AMJ -- ASE -- ASK -- B3D; -- BLEND (Blender) -- BVH -- COB -- CMS -- DAE/Collada -- DXF -- ENFF -- FBX -- glTF 1.0 + GLB -- glTF 2.0 -- HMB -- IFC-STEP -- IRR / IRRMESH -- LWO -- LWS -- LXO -- MD2 -- MD3 -- MD5 -- MDC -- MDL -- MESH / MESH.XML -- MOT -- MS3D -- NDO -- NFF -- OBJ -- OFF -- OGEX -- PLY -- PMX -- PRJ -- Q3O -- Q3S -- RAW -- SCN -- SIB -- SMD -- STL -- STP -- TER -- UC -- VTA -- X -- X3D -- XGL -- ZGL - -Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default): - -- C4D (https://github.com/assimp/assimp/wiki/Cinema4D-&-Melange) - -__Exporters__: - -- DAE (Collada) -- STL -- OBJ -- PLY -- X -- 3DS -- JSON (for WebGl, via https://github.com/acgessler/assimp2json) -- ASSBIN -- STEP -- glTF 1.0 (partial) -- glTF 2.0 (partial) - -### Building ### -Take a look into the `INSTALL` file. Our build system is CMake, if you used CMake before there is a good chance you know what to do. - -### Ports ### -* [Android](port/AndroidJNI/README.md) -* [Python](port/PyAssimp/README.md) -* [.NET](port/AssimpNET/Readme.md) -* [Pascal](port/AssimpPascal/Readme.md) -* [Javascript (Alpha)](https://github.com/makc/assimp2json) -* [Unity 3d Plugin](https://www.assetstore.unity3d.com/en/#!/content/91777) -* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (currently supported obj, ply, stl, collada, md2) - -### Other tools ### -[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities. - -#### Repository structure #### -Open Asset Import Library is implemented in C++. The directory structure is: - - /code Source code - /contrib Third-party libraries - /doc Documentation (doxysource and pre-compiled docs) - /include Public header C and C++ header files - /scripts Scripts used to generate the loading code for some formats - /port Ports to other languages and scripts to maintain those. - /test Unit- and regression tests, test suite of models - /tools Tools (old assimp viewer, command line `assimp`) - /samples A small number of samples to illustrate possible - use cases for Assimp - /workspaces Build environments for vc,xcode,... (deprecated, - CMake has superseeded all legacy build options!) - - -### Where to get help ### -For more information, visit [our website](http://assimp.org/). Or check out the `./doc`- folder, which contains the official documentation in HTML format. -(CHMs for Windows are included in some release packages and should be located right here in the root folder). - -If the docs don't solve your problem, ask on [StackOverflow](http://stackoverflow.com/questions/tagged/assimp?sort=newest). If you think you found a bug, please open an issue on Github. - -For development discussions, there is also a (very low-volume) mailing list, _assimp-discussions_ - [(subscribe here)]( https://lists.sourceforge.net/lists/listinfo/assimp-discussions) - -Open Asset Import Library is a library to load various 3d file formats into a shared, in-memory format. It supports more than __40 file formats__ for import and a growing selection of file formats for export. - -And we also have a Gitter-channel:Gitter [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
- -### Contributing ### -Contributions to assimp are highly appreciated. The easiest way to get involved is to submit -a pull request with your changes against the main repository's `master` branch. - -### License ### -Our license is based on the modified, __3-clause BSD__-License. - -An _informal_ summary is: do whatever you want, but include Assimp's license text with your product - -and don't sue us if our code doesn't work. Note that, unlike LGPLed code, you may link statically to Assimp. -For the legal details, see the `LICENSE` file. - -### Why this name ### -Sorry, we're germans :-), no english native speakers ... diff --git a/src/3rdparty/assimp/assimp.pri b/src/3rdparty/assimp/assimp.pri index 995f76e68..2ad74b9d6 100644 --- a/src/3rdparty/assimp/assimp.pri +++ b/src/3rdparty/assimp/assimp.pri @@ -12,13 +12,57 @@ else: \ QT_PRIVATE += zlib-private DEFINES += \ - ASSIMP_BUILD_NO_OWN_ZLIB \ - ASSIMP_BUILD_NO_COMPRESSED_IFC \ - ASSIMP_BUILD_NO_Q3BSP_IMPORTER \ - ASSIMP_BUILD_NO_C4D_IMPORTER \ - ASSIMP_BUILD_NO_3MF_IMPORTER \ - OPENDDL_STATIC_LIBARY \ - NOUNCRYPT + ASSIMP_BUILD_NO_X_IMPORTER \ + ASSIMP_BUILD_NO_AMF_IMPORTER \ + ASSIMP_BUILD_NO_3DS_IMPORTER \ + ASSIMP_BUILD_NO_MD3_IMPORTER \ + ASSIMP_BUILD_NO_MDL_IMPORTER \ + ASSIMP_BUILD_NO_MD2_IMPORTER \ + ASSIMP_BUILD_NO_PLY_IMPORTER \ + ASSIMP_BUILD_NO_ASE_IMPORTER \ + ASSIMP_BUILD_NO_HMP_IMPORTER \ + ASSIMP_BUILD_NO_SMD_IMPORTER \ + ASSIMP_BUILD_NO_MDC_IMPORTER \ + ASSIMP_BUILD_NO_MD5_IMPORTER \ + ASSIMP_BUILD_NO_STL_IMPORTER \ + ASSIMP_BUILD_NO_LWO_IMPORTER \ + ASSIMP_BUILD_NO_DXF_IMPORTER \ + ASSIMP_BUILD_NO_NFF_IMPORTER \ + ASSIMP_BUILD_NO_RAW_IMPORTER \ + ASSIMP_BUILD_NO_SIB_IMPORTER \ + ASSIMP_BUILD_NO_OFF_IMPORTER \ + ASSIMP_BUILD_NO_AC_IMPORTER \ + ASSIMP_BUILD_NO_BVH_IMPORTER \ + ASSIMP_BUILD_NO_IRRMESH_IMPORTER \ + ASSIMP_BUILD_NO_IRR_IMPORTER \ + ASSIMP_BUILD_NO_Q3D_IMPORTER \ + ASSIMP_BUILD_NO_B3D_IMPORTER \ + ASSIMP_BUILD_NO_TERRAGEN_IMPORTER \ + ASSIMP_BUILD_NO_CSM_IMPORTER \ + ASSIMP_BUILD_NO_3D_IMPORTER \ + ASSIMP_BUILD_NO_LWS_IMPORTER \ + ASSIMP_BUILD_NO_OGRE_IMPORTER \ + ASSIMP_BUILD_NO_OPENGEX_IMPORTER \ + ASSIMP_BUILD_NO_MS3D_IMPORTER \ + ASSIMP_BUILD_NO_COB_IMPORTER \ + ASSIMP_BUILD_NO_Q3BSP_IMPORTER \ + ASSIMP_BUILD_NO_NDO_IMPORTER \ + ASSIMP_BUILD_NO_IFC_IMPORTER \ + ASSIMP_BUILD_NO_XGL_IMPORTER \ + ASSIMP_BUILD_NO_ASSBIN_IMPORTER \ + ASSIMP_BUILD_NO_C4D_IMPORTER \ + ASSIMP_BUILD_NO_3MF_IMPORTER \ + ASSIMP_BUILD_NO_X3D_IMPORTER \ + ASSIMP_BUILD_NO_MMD_IMPORTER \ + ASSIMP_BUILD_NO_STEP_IMPORTER \ + ASSIMP_BUILD_NO_OWN_ZLIB \ + ASSIMP_BUILD_NO_COMPRESSED_IFC \ + ASSIMP_BUILD_NO_EXPORT \ + ASSIMP_BUILD_BOOST_WORKAROUND \ + OPENDDL_STATIC_LIBARY \ + NOUNCRYPT + +win32: DEFINES += WindowsStore intel_icc: { # warning #310: old-style parameter list (anachronism) @@ -58,556 +102,344 @@ msvc: QMAKE_CXXFLAGS += /bigobj CONFIG += warn_on VPATH += \ - $$PWD \ - $$PWD/code \ - $$PWD/code/res \ - $$PWD/contrib/clipper \ - $$PWD/contrib/ConvertUTF \ - $$PWD/contrib/irrXML \ - $$PWD/contrib/unzip + $$PWD/src \ + $$PWD/src/code \ + $$PWD/src/code/res INCLUDEPATH += \ $$PWD \ - $$PWD/code \ - $$PWD/include \ - $$PWD/include/assimp/Compiler \ - $$PWD/contrib/clipper \ - $$PWD/contrib/ConvertUTF \ - $$PWD/contrib/irrXML \ - $$PWD/contrib/openddlparser/include \ - $$PWD/contrib/poly2tri/poly2tri \ - $$PWD/contrib/rapidjson/include \ - $$PWD/contrib/unzip + $$PWD/.. \ + $$PWD/src \ + $$PWD/src/code \ + $$PWD/src/code/Common \ + $$PWD/src/code/Collada \ + $$PWD/src/code/Material \ + $$PWD/src/code/Obj \ + $$PWD/src/code/Blender \ + $$PWD/src/code/FBX \ + $$PWD/src/code/PostProcessing \ + $$PWD/src/code/glTF \ + $$PWD/src/code/glTF2 \ + $$PWD/src/code/CApi \ + $$PWD/src/include \ + $$PWD/src/include/assimp/Compiler + +HEADERS += \ + $$PWD/config.h \ + $$PWD/revision.h + +HEADERS += \ + $$PWD/src/include/assimp/Compiler/pushpack1.h \ + $$PWD/src/include/assimp/Compiler/poppack1.h \ + $$PWD/src/include/assimp/Compiler/pstdint.h \ + $$PWD/src/include/assimp/anim.h \ + $$PWD/src/include/assimp/ai_assert.h \ + $$PWD/src/include/assimp/camera.h \ + $$PWD/src/include/assimp/color4.h \ + $$PWD/src/include/assimp/color4.inl \ + $$PWD/src/include/assimp/defs.h \ + $$PWD/src/include/assimp/Defines.h \ + $$PWD/src/include/assimp/cfileio.h \ + $$PWD/src/include/assimp/light.h \ + $$PWD/src/include/assimp/material.h \ + $$PWD/src/include/assimp/material.inl \ + $$PWD/src/include/assimp/matrix3x3.h \ + $$PWD/src/include/assimp/matrix3x3.inl \ + $$PWD/src/include/assimp/matrix4x4.h \ + $$PWD/src/include/assimp/matrix4x4.inl \ + $$PWD/src/include/assimp/mesh.h \ + $$PWD/src/include/assimp/pbrmaterial.h \ + $$PWD/src/include/assimp/postprocess.h \ + $$PWD/src/include/assimp/quaternion.h \ + $$PWD/src/include/assimp/quaternion.inl \ + $$PWD/src/include/assimp/scene.h \ + $$PWD/src/include/assimp/metadata.h \ + $$PWD/src/include/assimp/texture.h \ + $$PWD/src/include/assimp/types.h \ + $$PWD/src/include/assimp/vector2.h \ + $$PWD/src/include/assimp/vector2.inl \ + $$PWD/src/include/assimp/vector3.h \ + $$PWD/src/include/assimp/vector3.inl \ + $$PWD/src/include/assimp/version.h \ + $$PWD/src/include/assimp/cimport.h \ + $$PWD/src/include/assimp/importerdesc.h \ + $$PWD/src/include/assimp/Importer.hpp \ + $$PWD/src/include/assimp/DefaultLogger.hpp \ + $$PWD/src/include/assimp/ProgressHandler.hpp \ + $$PWD/src/include/assimp/IOStream.hpp \ + $$PWD/src/include/assimp/IOSystem.hpp \ + $$PWD/src/include/assimp/Logger.hpp \ + $$PWD/src/include/assimp/LogStream.hpp \ + $$PWD/src/include/assimp/NullLogger.hpp \ + $$PWD/src/include/assimp/cexport.h \ + $$PWD/src/include/assimp/Exporter.hpp \ + $$PWD/src/include/assimp/DefaultIOStream.h \ + $$PWD/src/include/assimp/DefaultIOSystem.h \ + $$PWD/src/include/assimp/SceneCombiner.h \ + $$PWD/src/include/assimp/fast_atof.h \ + $$PWD/src/include/assimp/qnan.h \ + $$PWD/src/include/assimp/BaseImporter.h \ + $$PWD/src/include/assimp/Hash.h \ + $$PWD/src/include/assimp/MemoryIOWrapper.h \ + $$PWD/src/include/assimp/ParsingUtils.h \ + $$PWD/src/include/assimp/StreamReader.h \ + $$PWD/src/include/assimp/StreamWriter.h \ + $$PWD/src/include/assimp/StringComparison.h \ + $$PWD/src/include/assimp/StringUtils.h \ + $$PWD/src/include/assimp/SGSpatialSort.h \ + $$PWD/src/include/assimp/GenericProperty.h \ + $$PWD/src/include/assimp/SpatialSort.h \ + $$PWD/src/include/assimp/SkeletonMeshBuilder.h \ + $$PWD/src/include/assimp/SmoothingGroups.h \ + $$PWD/src/include/assimp/SmoothingGroups.inl \ + $$PWD/src/include/assimp/StandardShapes.h \ + $$PWD/src/include/assimp/RemoveComments.h \ + $$PWD/src/include/assimp/Subdivision.h \ + $$PWD/src/include/assimp/Vertex.h \ + $$PWD/src/include/assimp/LineSplitter.h \ + $$PWD/src/include/assimp/TinyFormatter.h \ + $$PWD/src/include/assimp/Profiler.h \ + $$PWD/src/include/assimp/LogAux.h \ + $$PWD/src/include/assimp/Bitmap.h \ + $$PWD/src/include/assimp/XMLTools.h \ + $$PWD/src/include/assimp/IOStreamBuffer.h \ + $$PWD/src/include/assimp/CreateAnimMesh.h \ + $$PWD/src/include/assimp/irrXMLWrapper.h \ + $$PWD/src/include/assimp/BlobIOSystem.h \ + $$PWD/src/include/assimp/MathFunctions.h \ + $$PWD/src/include/assimp/Macros.h \ + $$PWD/src/include/assimp/Exceptional.h \ + $$PWD/src/include/assimp/ByteSwapper.h \ + $$PWD/src/include/assimp/DefaultLogger.hpp \ + $$PWD/src/include/assimp/LogStream.hpp \ + $$PWD/src/include/assimp/Logger.hpp \ + $$PWD/src/include/assimp/NullLogger.hpp \ + $$PWD/src/include/assimp/ZipArchiveIOSystem.h \ + $$PWD/src/code/Common/FileLogStream.h \ + $$PWD/src/code/Common/StdOStreamLogStream.h \ + $$PWD/src/code/Common/BaseProcess.h \ + $$PWD/src/code/Common/Importer.h \ + $$PWD/src/code/Common/ScenePrivate.h \ + $$PWD/src/code/Common/DefaultProgressHandler.h \ + $$PWD/src/code/CApi/CInterfaceIOWrapper.h \ + $$PWD/src/code/Common/IFF.h \ + $$PWD/src/code/Common/VertexTriangleAdjacency.h \ + $$PWD/src/code/Common/ScenePreprocessor.h \ + $$PWD/src/code/Common/SplitByBoneCountProcess.h \ + $$PWD/src/code/Common/TargetAnimation.h \ + $$PWD/src/code/Common/simd.h \ + $$PWD/src/code/Collada/ColladaHelper.h \ + $$PWD/src/code/Collada/ColladaLoader.h \ + $$PWD/src/code/Collada/ColladaParser.h \ + $$PWD/src/code/Material/MaterialSystem.h \ + $$PWD/src/code/Obj/ObjFileData.h \ + $$PWD/src/code/Obj/ObjFileImporter.h \ + $$PWD/src/code/Obj/ObjFileMtlImporter.h \ + $$PWD/src/code/Obj/ObjFileParser.h \ + $$PWD/src/code/Obj/ObjTools.h \ + $$PWD/src/code/Blender/BlenderLoader.h \ + $$PWD/src/code/Blender/BlenderDNA.h \ + $$PWD/src/code/Blender/BlenderDNA.inl \ + $$PWD/src/code/Blender/BlenderScene.h \ + $$PWD/src/code/Blender/BlenderSceneGen.h \ + $$PWD/src/code/Blender/BlenderIntermediate.h \ + $$PWD/src/code/Blender/BlenderModifier.h \ + $$PWD/src/code/Blender/BlenderBMesh.h \ + $$PWD/src/code/Blender/BlenderTessellator.h \ + $$PWD/src/code/Blender/BlenderCustomData.h \ + $$PWD/src/code/FBX/FBXCompileConfig.h \ + $$PWD/src/code/FBX/FBXImporter.h \ + $$PWD/src/code/FBX/FBXParser.h \ + $$PWD/src/code/FBX/FBXTokenizer.h \ + $$PWD/src/code/FBX/FBXImportSettings.h \ + $$PWD/src/code/FBX/FBXConverter.h \ + $$PWD/src/code/FBX/FBXUtil.h \ + $$PWD/src/code/FBX/FBXDocument.h \ + $$PWD/src/code/FBX/FBXProperties.h \ + $$PWD/src/code/FBX/FBXMeshGeometry.h \ + $$PWD/src/code/FBX/FBXCommon.h \ + $$PWD/src/code/PostProcessing/CalcTangentsProcess.h \ + $$PWD/src/code/PostProcessing/ComputeUVMappingProcess.h \ + $$PWD/src/code/PostProcessing/ConvertToLHProcess.h \ + $$PWD/src/code/PostProcessing/EmbedTexturesProcess.h \ + $$PWD/src/code/PostProcessing/FindDegenerates.h \ + $$PWD/src/code/PostProcessing/FindInstancesProcess.h \ + $$PWD/src/code/PostProcessing/FindInvalidDataProcess.h \ + $$PWD/src/code/PostProcessing/FixNormalsStep.h \ + $$PWD/src/code/PostProcessing/DropFaceNormalsProcess.h \ + $$PWD/src/code/PostProcessing/GenBoundingBoxesProcess.h \ + $$PWD/src/code/PostProcessing/GenFaceNormalsProcess.h \ + $$PWD/src/code/PostProcessing/GenVertexNormalsProcess.h \ + $$PWD/src/code/PostProcessing/PretransformVertices.h \ + $$PWD/src/code/PostProcessing/ImproveCacheLocality.h \ + $$PWD/src/code/PostProcessing/JoinVerticesProcess.h \ + $$PWD/src/code/PostProcessing/LimitBoneWeightsProcess.h \ + $$PWD/src/code/PostProcessing/RemoveRedundantMaterials.h \ + $$PWD/src/code/PostProcessing/RemoveVCProcess.h \ + $$PWD/src/code/PostProcessing/SortByPTypeProcess.h \ + $$PWD/src/code/PostProcessing/SplitLargeMeshes.h \ + $$PWD/src/code/PostProcessing/TextureTransform.h \ + $$PWD/src/code/PostProcessing/TriangulateProcess.h \ + $$PWD/src/code/PostProcessing/ValidateDataStructure.h \ + $$PWD/src/code/PostProcessing/OptimizeGraph.h \ + $$PWD/src/code/PostProcessing/OptimizeMeshes.h \ + $$PWD/src/code/PostProcessing/DeboneProcess.h \ + $$PWD/src/code/PostProcessing/ProcessHelper.h \ + $$PWD/src/code/Common/PolyTools.h \ + $$PWD/src/code/PostProcessing/MakeVerboseFormat.h \ + $$PWD/src/code/PostProcessing/ScaleProcess.h \ + $$PWD/src/code/glTF/glTFAsset.h \ + $$PWD/src/code/glTF/glTFAsset.inl \ + $$PWD/src/code/glTF/glTFAssetWriter.inl \ + $$PWD/src/code/glTF/glTFAssetWriter.h \ + $$PWD/src/code/glTF/glTFImporter.h \ + $$PWD/src/code/glTF/glTFCommon.h \ + $$PWD/src/code/glTF2/glTF2AssetWriter.h \ + $$PWD/src/code/glTF2/glTF2Asset.h \ + $$PWD/src/code/glTF2/glTF2Asset.inl \ + $$PWD/src/code/glTF2/glTF2AssetWriter.inl \ + $$PWD/src/code/glTF2/glTF2Importer.h + +SOURCES += \ + $$PWD/src/code/Common/Assimp.cpp \ + $$PWD/src/code/Common/DefaultLogger.cpp \ + $$PWD/src/code/Common/BaseImporter.cpp \ + $$PWD/src/code/Common/BaseProcess.cpp \ + $$PWD/src/code/Common/PostStepRegistry.cpp \ + $$PWD/src/code/Common/ImporterRegistry.cpp \ + $$PWD/src/code/Common/DefaultIOStream.cpp \ + $$PWD/src/code/Common/DefaultIOSystem.cpp \ + $$PWD/src/code/CApi/CInterfaceIOWrapper.cpp \ + $$PWD/src/code/Common/Importer.cpp \ + $$PWD/src/code/Common/SGSpatialSort.cpp \ + $$PWD/src/code/Common/VertexTriangleAdjacency.cpp \ + $$PWD/src/code/Common/SpatialSort.cpp \ + $$PWD/src/code/Common/SceneCombiner.cpp \ + $$PWD/src/code/Common/ScenePreprocessor.cpp \ + $$PWD/src/code/Common/SkeletonMeshBuilder.cpp \ + $$PWD/src/code/Common/SplitByBoneCountProcess.cpp \ + $$PWD/src/code/Common/StandardShapes.cpp \ + $$PWD/src/code/Common/TargetAnimation.cpp \ + $$PWD/src/code/Common/RemoveComments.cpp \ + $$PWD/src/code/Common/Subdivision.cpp \ + $$PWD/src/code/Common/scene.cpp \ + $$PWD/src/code/Common/Bitmap.cpp \ + $$PWD/src/code/Common/Version.cpp \ + $$PWD/src/code/Common/CreateAnimMesh.cpp \ + $$PWD/src/code/Common/simd.cpp \ + $$PWD/src/code/Common/ZipArchiveIOSystem.cpp \ + $$PWD/src/code/Collada/ColladaLoader.cpp \ + $$PWD/src/code/Collada/ColladaParser.cpp \ + $$PWD/src/code/Material/MaterialSystem.cpp \ + $$PWD/src/code/Obj/ObjFileImporter.cpp \ + $$PWD/src/code/Obj/ObjFileMtlImporter.cpp \ + $$PWD/src/code/Obj/ObjFileParser.cpp \ + $$PWD/src/code/Blender/BlenderLoader.cpp \ + $$PWD/src/code/Blender/BlenderDNA.cpp \ + $$PWD/src/code/Blender/BlenderScene.cpp \ + $$PWD/src/code/Blender/BlenderModifier.cpp \ + $$PWD/src/code/Blender/BlenderBMesh.cpp \ + $$PWD/src/code/Blender/BlenderTessellator.cpp \ + $$PWD/src/code/Blender/BlenderCustomData.cpp \ + $$PWD/src/code/FBX/FBXImporter.cpp \ + $$PWD/src/code/FBX/FBXParser.cpp \ + $$PWD/src/code/FBX/FBXTokenizer.cpp \ + $$PWD/src/code/FBX/FBXConverter.cpp \ + $$PWD/src/code/FBX/FBXUtil.cpp \ + $$PWD/src/code/FBX/FBXDocument.cpp \ + $$PWD/src/code/FBX/FBXProperties.cpp \ + $$PWD/src/code/FBX/FBXMeshGeometry.cpp \ + $$PWD/src/code/FBX/FBXMaterial.cpp \ + $$PWD/src/code/FBX/FBXModel.cpp \ + $$PWD/src/code/FBX/FBXAnimation.cpp \ + $$PWD/src/code/FBX/FBXNodeAttribute.cpp \ + $$PWD/src/code/FBX/FBXDeformer.cpp \ + $$PWD/src/code/FBX/FBXBinaryTokenizer.cpp \ + $$PWD/src/code/FBX/FBXDocumentUtil.cpp \ + $$PWD/src/code/PostProcessing/CalcTangentsProcess.cpp \ + $$PWD/src/code/PostProcessing/ComputeUVMappingProcess.cpp \ + $$PWD/src/code/PostProcessing/ConvertToLHProcess.cpp \ + $$PWD/src/code/PostProcessing/EmbedTexturesProcess.cpp \ + $$PWD/src/code/PostProcessing/FindDegenerates.cpp \ + $$PWD/src/code/PostProcessing/FindInstancesProcess.cpp \ + $$PWD/src/code/PostProcessing/FindInvalidDataProcess.cpp \ + $$PWD/src/code/PostProcessing/FixNormalsStep.cpp \ + $$PWD/src/code/PostProcessing/DropFaceNormalsProcess.cpp \ + $$PWD/src/code/PostProcessing/GenBoundingBoxesProcess.cpp \ + $$PWD/src/code/PostProcessing/GenFaceNormalsProcess.cpp \ + $$PWD/src/code/PostProcessing/GenVertexNormalsProcess.cpp \ + $$PWD/src/code/PostProcessing/PretransformVertices.cpp \ + $$PWD/src/code/PostProcessing/ImproveCacheLocality.cpp \ + $$PWD/src/code/PostProcessing/JoinVerticesProcess.cpp \ + $$PWD/src/code/PostProcessing/LimitBoneWeightsProcess.cpp \ + $$PWD/src/code/PostProcessing/RemoveRedundantMaterials.cpp \ + $$PWD/src/code/PostProcessing/RemoveVCProcess.cpp \ + $$PWD/src/code/PostProcessing/SortByPTypeProcess.cpp \ + $$PWD/src/code/PostProcessing/SplitLargeMeshes.cpp \ + $$PWD/src/code/PostProcessing/TextureTransform.cpp \ + $$PWD/src/code/PostProcessing/TriangulateProcess.cpp \ + $$PWD/src/code/PostProcessing/ValidateDataStructure.cpp \ + $$PWD/src/code/PostProcessing/OptimizeGraph.cpp \ + $$PWD/src/code/PostProcessing/OptimizeMeshes.cpp \ + $$PWD/src/code/PostProcessing/DeboneProcess.cpp \ + $$PWD/src/code/PostProcessing/ProcessHelper.cpp \ + $$PWD/src/code/PostProcessing/MakeVerboseFormat.cpp \ + $$PWD/src/code/PostProcessing/ScaleProcess.cpp \ + $$PWD/src/code/glTF/glTFImporter.cpp \ + $$PWD/src/code/glTF/glTFCommon.cpp \ + $$PWD/src/code/glTF2/glTF2Importer.cpp + +# IrrXML (needed for DAE/Collada support) +HEADERS += \ + $$PWD/src/contrib/irrXML/CXMLReaderImpl.h \ + $$PWD/src/contrib/irrXML/heapsort.h \ + $$PWD/src/contrib/irrXML/irrArray.h \ + $$PWD/src/contrib/irrXML/irrString.h \ + $$PWD/src/contrib/irrXML/irrTypes.h \ + $$PWD/src/contrib/irrXML/irrXML.h + +SOURCES += $$PWD/src/contrib/irrXML/irrXML.cpp + +VPATH += $$PWD/src/contrib/irrXML +INCLUDEPATH += $$PWD/src/contrib/irrXML + +msvc: DEFINES += _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS + +# rapidjson (needed for GLTF/GLTF2) +VPATH += $$PWD/src/contrib/rapidjson/include +INCLUDEPATH += $$PWD/src/contrib/rapidjson/include + +# utf8cpp +VPATH += $$PWD/src/contrib/utf8cpp/source +INCLUDEPATH += $$PWD/src/contrib/utf8cpp/source + +# poly2tri (blender tessellator) +VPATH += $$PWD/src/contrib/poly2tri +INCLUDEPATH += $$PWD/src/contrib/poly2tri + +HEADERS += \ + $$PWD/src/contrib/poly2tri/poly2tri/common/shapes.h \ + $$PWD/src/contrib/poly2tri/poly2tri/common/utils.h \ + $$PWD/src/contrib/poly2tri/poly2tri/sweep/advancing_front.h \ + $$PWD/src/contrib/poly2tri/poly2tri/sweep/cdt.h \ + $$PWD/src/contrib/poly2tri/poly2tri/sweep/sweep.h \ + $$PWD/src/contrib/poly2tri/poly2tri/sweep/sweep_context.h + +SOURCES += \ + $$PWD/src/contrib/poly2tri/poly2tri/common/shapes.cc \ + $$PWD/src/contrib/poly2tri/poly2tri/sweep/advancing_front.cc \ + $$PWD/src/contrib/poly2tri/poly2tri/sweep/cdt.cc \ + $$PWD/src/contrib/poly2tri/poly2tri/sweep/sweep.cc \ + $$PWD/src/contrib/poly2tri/poly2tri/sweep/sweep_context.cc -# Input -HEADERS += revision.h \ - code/3DSExporter.h \ - code/3DSHelper.h \ - code/3DSLoader.h \ - code/3MFXmlTags.h \ - code/ACLoader.h \ - code/ASELoader.h \ - code/ASEParser.h \ - code/AssbinExporter.h \ - code/AssbinLoader.h \ - code/AssxmlExporter.h \ - code/B3DImporter.h \ - code/BVHLoader.h \ - code/BaseImporter.h \ - code/BaseProcess.h \ - code/Bitmap.h \ - code/BlenderBMesh.h \ - code/BlenderDNA.h \ - code/BlenderIntermediate.h \ - code/BlenderLoader.h \ - code/BlenderModifier.h \ - code/BlenderScene.h \ - code/BlenderSceneGen.h \ - code/BlenderTessellator.h \ - code/BlobIOSystem.h \ - code/ByteSwapper.h \ - code/C4DImporter.h \ - code/CInterfaceIOWrapper.h \ - code/COBLoader.h \ - code/COBScene.h \ - code/CSMLoader.h \ - code/CalcTangentsProcess.h \ - code/ColladaExporter.h \ - code/ColladaHelper.h \ - code/ColladaLoader.h \ - code/ColladaParser.h \ - code/ComputeUVMappingProcess.h \ - code/ConvertToLHProcess.h \ - code/CreateAnimMesh.h \ - code/D3MFExporter.h \ - code/D3MFImporter.h \ - code/D3MFOpcPackage.h \ - code/DXFHelper.h \ - code/DXFLoader.h \ - code/DeboneProcess.h \ - code/DefaultProgressHandler.h \ - code/Exceptional.h \ - code/FBXCompileConfig.h \ - code/FBXConverter.h \ - code/FBXDocument.h \ - code/FBXDocumentUtil.h \ - code/FBXImportSettings.h \ - code/FBXImporter.h \ - code/FBXMeshGeometry.h \ - code/FBXParser.h \ - code/FBXProperties.h \ - code/FBXTokenizer.h \ - code/FBXUtil.h \ - code/FileLogStream.h \ - code/FileSystemFilter.h \ - code/FindDegenerates.h \ - code/FindInstancesProcess.h \ - code/FindInvalidDataProcess.h \ - code/FixNormalsStep.h \ - code/GenFaceNormalsProcess.h \ - code/GenVertexNormalsProcess.h \ - code/GenericProperty.h \ - code/HMPFileData.h \ - code/HMPLoader.h \ - code/HalfLifeFileData.h \ - code/Hash.h \ - code/IFCLoader.h \ - code/IFCReaderGen.h \ - code/IFCUtil.h \ - code/IFF.h \ - code/IOStreamBuffer.h \ - code/IRRLoader.h \ - code/IRRMeshLoader.h \ - code/IRRShared.h \ - code/Importer.h \ - code/ImproveCacheLocality.h \ - code/JoinVerticesProcess.h \ - code/LWOAnimation.h \ - code/LWOFileData.h \ - code/LWOLoader.h \ - code/LWSLoader.h \ - code/LimitBoneWeightsProcess.h \ - code/LineSplitter.h \ - code/LogAux.h \ - code/MD2FileData.h \ - code/MD2Loader.h \ - code/MD2NormalTable.h \ - code/MD3FileData.h \ - code/MD3Loader.h \ - code/MD4FileData.h \ - code/MD5Loader.h \ - code/MD5Parser.h \ - code/MDCFileData.h \ - code/MDCLoader.h \ - code/MDCNormalTable.h \ - code/MDLDefaultColorMap.h \ - code/MDLFileData.h \ - code/MDLLoader.h \ - code/MMDCpp14.h \ - code/MMDImporter.h \ - code/MMDPmdParser.h \ - code/MMDPmxParser.h \ - code/MMDVmdParser.h \ - code/MS3DLoader.h \ - code/Macros.h \ - code/MakeVerboseFormat.h \ - code/MaterialSystem.h \ - code/MathFunctions.h \ - code/MemoryIOWrapper.h \ - code/NDOLoader.h \ - code/NFFLoader.h \ - code/OFFLoader.h \ - code/ObjExporter.h \ - code/ObjFileData.h \ - code/ObjFileImporter.h \ - code/ObjFileMtlImporter.h \ - code/ObjFileParser.h \ - code/ObjTools.h \ - code/OgreBinarySerializer.h \ - code/OgreImporter.h \ - code/OgreParsingUtils.h \ - code/OgreStructs.h \ - code/OgreXmlSerializer.h \ - code/OpenGEXExporter.h \ - code/OpenGEXImporter.h \ - code/OpenGEXStructs.h \ - code/OptimizeGraph.h \ - code/OptimizeMeshes.h \ - code/ParsingUtils.h \ - code/PlyExporter.h \ - code/PlyLoader.h \ - code/PlyParser.h \ - code/PolyTools.h \ - code/PretransformVertices.h \ - code/ProcessHelper.h \ - code/Profiler.h \ - code/Q3BSPFileData.h \ - code/Q3BSPFileImporter.h \ - code/Q3BSPFileParser.h \ - code/Q3BSPZipArchive.h \ - code/Q3DLoader.h \ - code/RawLoader.h \ - code/RemoveComments.h \ - code/RemoveRedundantMaterials.h \ - code/RemoveVCProcess.h \ - code/SGSpatialSort.h \ - code/SIBImporter.h \ - code/SMDLoader.h \ - code/STEPFile.h \ - code/STEPFileEncoding.h \ - code/STEPFileReader.h \ - code/STLExporter.h \ - code/STLLoader.h \ - code/ScaleProcess.h \ - code/ScenePreprocessor.h \ - code/ScenePrivate.h \ - code/SkeletonMeshBuilder.h \ - code/SmoothingGroups.h \ - code/SortByPTypeProcess.h \ - code/SpatialSort.h \ - code/SplitByBoneCountProcess.h \ - code/SplitLargeMeshes.h \ - code/StandardShapes.h \ - code/StdOStreamLogStream.h \ - code/StepExporter.h \ - code/StreamReader.h \ - code/StreamWriter.h \ - code/StringComparison.h \ - code/StringUtils.h \ - code/Subdivision.h \ - code/TargetAnimation.h \ - code/TerragenLoader.h \ - code/TextureTransform.h \ - code/TinyFormatter.h \ - code/TriangulateProcess.h \ - code/UnrealLoader.h \ - code/ValidateDataStructure.h \ - code/Vertex.h \ - code/VertexTriangleAdjacency.h \ - code/Win32DebugLogStream.h \ - code/XFileExporter.h \ - code/XFileHelper.h \ - code/XFileImporter.h \ - code/XFileParser.h \ - code/XGLLoader.h \ - code/XMLTools.h \ - code/assbin_chunks.h \ - code/fast_atof.h \ - code/glTF2Asset.h \ - code/glTF2AssetWriter.h \ - code/glTF2Exporter.h \ - code/glTF2Importer.h \ - code/glTFAsset.h \ - code/glTFAssetWriter.h \ - code/glTFExporter.h \ - code/glTFImporter.h \ - code/irrXMLWrapper.h \ - code/qnan.h \ - code/res/resource.h \ - contrib/Open3DGC/o3dgcAdjacencyInfo.h \ - contrib/Open3DGC/o3dgcArithmeticCodec.h \ - contrib/Open3DGC/o3dgcBinaryStream.h \ - contrib/Open3DGC/o3dgcCommon.h \ - contrib/Open3DGC/o3dgcDVEncodeParams.h \ - contrib/Open3DGC/o3dgcDynamicVector.h \ - contrib/Open3DGC/o3dgcDynamicVectorDecoder.h \ - contrib/Open3DGC/o3dgcDynamicVectorEncoder.h \ - contrib/Open3DGC/o3dgcFIFO.h \ - contrib/Open3DGC/o3dgcIndexedFaceSet.h \ - contrib/Open3DGC/o3dgcSC3DMCDecoder.h \ - contrib/Open3DGC/o3dgcSC3DMCEncodeParams.h \ - contrib/Open3DGC/o3dgcSC3DMCEncoder.h \ - contrib/Open3DGC/o3dgcTimer.h \ - contrib/Open3DGC/o3dgcTriangleFans.h \ - contrib/Open3DGC/o3dgcTriangleListDecoder.h \ - contrib/Open3DGC/o3dgcTriangleListEncoder.h \ - contrib/Open3DGC/o3dgcVector.h \ - contrib/clipper/clipper.hpp \ - contrib/irrXML/CXMLReaderImpl.h \ - contrib/irrXML/heapsort.h \ - contrib/irrXML/irrArray.h \ - contrib/irrXML/irrString.h \ - contrib/irrXML/irrTypes.h \ - contrib/irrXML/irrXML.h \ - contrib/openddlparser/include/openddlparser/DDLNode.h \ - contrib/openddlparser/include/openddlparser/OpenDDLCommon.h \ - contrib/openddlparser/include/openddlparser/OpenDDLExport.h \ - contrib/openddlparser/include/openddlparser/OpenDDLParser.h \ - contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h \ - contrib/openddlparser/include/openddlparser/OpenDDLStream.h \ - contrib/openddlparser/include/openddlparser/Value.h \ - contrib/poly2tri/poly2tri/common/shapes.h \ - contrib/poly2tri/poly2tri/common/utils.h \ - contrib/poly2tri/poly2tri/poly2tri.h \ - contrib/poly2tri/poly2tri/sweep/advancing_front.h \ - contrib/poly2tri/poly2tri/sweep/cdt.h \ - contrib/poly2tri/poly2tri/sweep/sweep.h \ - contrib/poly2tri/poly2tri/sweep/sweep_context.h \ - contrib/rapidjson/include/rapidjson/allocators.h \ - contrib/rapidjson/include/rapidjson/document.h \ - contrib/rapidjson/include/rapidjson/encodedstream.h \ - contrib/rapidjson/include/rapidjson/encodings.h \ - contrib/rapidjson/include/rapidjson/error/en.h \ - contrib/rapidjson/include/rapidjson/error/error.h \ - contrib/rapidjson/include/rapidjson/filereadstream.h \ - contrib/rapidjson/include/rapidjson/filewritestream.h \ - contrib/rapidjson/include/rapidjson/fwd.h \ - contrib/rapidjson/include/rapidjson/internal/biginteger.h \ - contrib/rapidjson/include/rapidjson/internal/diyfp.h \ - contrib/rapidjson/include/rapidjson/internal/dtoa.h \ - contrib/rapidjson/include/rapidjson/internal/ieee754.h \ - contrib/rapidjson/include/rapidjson/internal/itoa.h \ - contrib/rapidjson/include/rapidjson/internal/meta.h \ - contrib/rapidjson/include/rapidjson/internal/pow10.h \ - contrib/rapidjson/include/rapidjson/internal/regex.h \ - contrib/rapidjson/include/rapidjson/internal/stack.h \ - contrib/rapidjson/include/rapidjson/internal/strfunc.h \ - contrib/rapidjson/include/rapidjson/internal/strtod.h \ - contrib/rapidjson/include/rapidjson/internal/swap.h \ - contrib/rapidjson/include/rapidjson/istreamwrapper.h \ - contrib/rapidjson/include/rapidjson/memorybuffer.h \ - contrib/rapidjson/include/rapidjson/memorystream.h \ - contrib/rapidjson/include/rapidjson/msinttypes/inttypes.h \ - contrib/rapidjson/include/rapidjson/msinttypes/stdint.h \ - contrib/rapidjson/include/rapidjson/ostreamwrapper.h \ - contrib/rapidjson/include/rapidjson/pointer.h \ - contrib/rapidjson/include/rapidjson/prettywriter.h \ - contrib/rapidjson/include/rapidjson/rapidjson.h \ - contrib/rapidjson/include/rapidjson/reader.h \ - contrib/rapidjson/include/rapidjson/schema.h \ - contrib/rapidjson/include/rapidjson/stream.h \ - contrib/rapidjson/include/rapidjson/stringbuffer.h \ - contrib/rapidjson/include/rapidjson/writer.h \ - contrib/unzip/crypt.h \ - contrib/unzip/ioapi.h \ - contrib/unzip/unzip.h \ - contrib/utf8cpp/source/utf8.h \ - contrib/utf8cpp/source/utf8/checked.h \ - contrib/utf8cpp/source/utf8/core.h \ - contrib/utf8cpp/source/utf8/unchecked.h \ - include/assimp/Compiler/poppack1.h \ - include/assimp/Compiler/pstdint.h \ - include/assimp/Compiler/pushpack1.h \ - include/assimp/DefaultIOStream.h \ - include/assimp/DefaultIOSystem.h \ - include/assimp/DefaultLogger.hpp \ - include/assimp/Defines.h \ - include/assimp/Exporter.hpp \ - include/assimp/IOStream.hpp \ - include/assimp/IOSystem.hpp \ - include/assimp/Importer.hpp \ - include/assimp/LogStream.hpp \ - include/assimp/Logger.hpp \ - include/assimp/NullLogger.hpp \ - include/assimp/ProgressHandler.hpp \ - include/assimp/SceneCombiner.h \ - include/assimp/ai_assert.h \ - include/assimp/anim.h \ - include/assimp/camera.h \ - include/assimp/cexport.h \ - include/assimp/cfileio.h \ - include/assimp/cimport.h \ - include/assimp/color4.h \ - include/assimp/config.h \ - include/assimp/defs.h \ - include/assimp/importerdesc.h \ - include/assimp/light.h \ - include/assimp/material.h \ - include/assimp/matrix3x3.h \ - include/assimp/matrix4x4.h \ - include/assimp/mesh.h \ - include/assimp/metadata.h \ - include/assimp/port/AndroidJNI/AndroidJNIIOSystem.h \ - include/assimp/postprocess.h \ - include/assimp/quaternion.h \ - include/assimp/scene.h \ - include/assimp/texture.h \ - include/assimp/types.h \ - include/assimp/vector2.h \ - include/assimp/vector3.h \ - include/assimp/version.h +# unzip (collada loader) +VPATH += $$PWD/unzip $$PWD/contrib/unzip +INCLUDEPATH += $$PWD/unzip $$PWD/contrib/unzip +HEADERS += \ + $$PWD/src/contrib/unzip/crypt.h \ + $$PWD/src/contrib/unzip/ioapi.h \ + $$PWD/unzip/unzip.h SOURCES += \ - code/3DSConverter.cpp \ - code/3DSExporter.cpp \ - code/3DSLoader.cpp \ - code/ACLoader.cpp \ - code/AMFImporter.cpp \ - code/AMFImporter_Geometry.cpp \ - code/AMFImporter_Material.cpp \ - code/AMFImporter_Postprocess.cpp \ - code/ASELoader.cpp \ - code/ASEParser.cpp \ - code/AssbinExporter.cpp \ - code/AssbinLoader.cpp \ - code/Assimp.cpp \ - code/AssimpCExport.cpp \ - code/AssxmlExporter.cpp \ - code/B3DImporter.cpp \ - code/BVHLoader.cpp \ - code/BaseImporter.cpp \ - code/BaseProcess.cpp \ - code/Bitmap.cpp \ - code/BlenderBMesh.cpp \ - code/BlenderDNA.cpp \ - code/BlenderLoader.cpp \ - code/BlenderModifier.cpp \ - code/BlenderScene.cpp \ - code/BlenderTessellator.cpp \ - code/C4DImporter.cpp \ - code/CInterfaceIOWrapper.cpp \ - code/COBLoader.cpp \ - code/CSMLoader.cpp \ - code/CalcTangentsProcess.cpp \ - code/ColladaExporter.cpp \ - code/ColladaLoader.cpp \ - code/ColladaParser.cpp \ - code/ComputeUVMappingProcess.cpp \ - code/ConvertToLHProcess.cpp \ - code/CreateAnimMesh.cpp \ - code/D3MFExporter.cpp \ - code/D3MFImporter.cpp \ - code/D3MFOpcPackage.cpp \ - code/DXFLoader.cpp \ - code/DeboneProcess.cpp \ - code/DefaultIOStream.cpp \ - code/DefaultIOSystem.cpp \ - code/DefaultLogger.cpp \ - code/Exporter.cpp \ - code/FBXAnimation.cpp \ - code/FBXBinaryTokenizer.cpp \ - code/FBXConverter.cpp \ - code/FBXDeformer.cpp \ - code/FBXDocument.cpp \ - code/FBXDocumentUtil.cpp \ - code/FBXImporter.cpp \ - code/FBXMaterial.cpp \ - code/FBXMeshGeometry.cpp \ - code/FBXModel.cpp \ - code/FBXNodeAttribute.cpp \ - code/FBXParser.cpp \ - code/FBXProperties.cpp \ - code/FBXTokenizer.cpp \ - code/FBXUtil.cpp \ - code/FIReader.cpp \ - code/FindDegenerates.cpp \ - code/FindInstancesProcess.cpp \ - code/FindInvalidDataProcess.cpp \ - code/FixNormalsStep.cpp \ - code/GenFaceNormalsProcess.cpp \ - code/GenVertexNormalsProcess.cpp \ - code/HMPLoader.cpp \ - code/IFCBoolean.cpp \ - code/IFCCurve.cpp \ - code/IFCGeometry.cpp \ - code/IFCLoader.cpp \ - code/IFCMaterial.cpp \ - code/IFCOpenings.cpp \ - code/IFCProfile.cpp \ - code/IFCReaderGen1.cpp \ - code/IFCReaderGen2.cpp \ - code/IFCUtil.cpp \ - code/IRRLoader.cpp \ - code/IRRMeshLoader.cpp \ - code/IRRShared.cpp \ - code/Importer.cpp \ - code/ImporterRegistry.cpp \ - code/ImproveCacheLocality.cpp \ - code/JoinVerticesProcess.cpp \ - code/LWOAnimation.cpp \ - code/LWOBLoader.cpp \ - code/LWOLoader.cpp \ - code/LWOMaterial.cpp \ - code/LWSLoader.cpp \ - code/LimitBoneWeightsProcess.cpp \ - code/MD2Loader.cpp \ - code/MD3Loader.cpp \ - code/MD5Loader.cpp \ - code/MD5Parser.cpp \ - code/MDCLoader.cpp \ - code/MDLLoader.cpp \ - code/MDLMaterialLoader.cpp \ - code/MMDImporter.cpp \ - code/MMDPmxParser.cpp \ - code/MS3DLoader.cpp \ - code/MakeVerboseFormat.cpp \ - code/MaterialSystem.cpp \ - code/NDOLoader.cpp \ - code/NFFLoader.cpp \ - code/OFFLoader.cpp \ - code/ObjExporter.cpp \ - code/ObjFileImporter.cpp \ - code/ObjFileMtlImporter.cpp \ - code/ObjFileParser.cpp \ - code/OgreBinarySerializer.cpp \ - code/OgreImporter.cpp \ - code/OgreMaterial.cpp \ - code/OgreStructs.cpp \ - code/OgreXmlSerializer.cpp \ - code/OpenGEXExporter.cpp \ - code/OpenGEXImporter.cpp \ - code/OptimizeGraph.cpp \ - code/OptimizeMeshes.cpp \ - code/PlyExporter.cpp \ - code/PlyLoader.cpp \ - code/PlyParser.cpp \ - code/PostStepRegistry.cpp \ - code/PretransformVertices.cpp \ - code/ProcessHelper.cpp \ - code/Q3BSPFileImporter.cpp \ - code/Q3BSPFileParser.cpp \ - code/Q3BSPZipArchive.cpp \ - code/Q3DLoader.cpp \ - code/RawLoader.cpp \ - code/RemoveComments.cpp \ - code/RemoveRedundantMaterials.cpp \ - code/RemoveVCProcess.cpp \ - code/SGSpatialSort.cpp \ - code/SIBImporter.cpp \ - code/SMDLoader.cpp \ - code/STEPFileEncoding.cpp \ - code/STEPFileReader.cpp \ - code/STLExporter.cpp \ - code/STLLoader.cpp \ - code/ScaleProcess.cpp \ - code/SceneCombiner.cpp \ - code/ScenePreprocessor.cpp \ - code/SkeletonMeshBuilder.cpp \ - code/SortByPTypeProcess.cpp \ - code/SpatialSort.cpp \ - code/SplitByBoneCountProcess.cpp \ - code/SplitLargeMeshes.cpp \ - code/StandardShapes.cpp \ - code/StepExporter.cpp \ - code/Subdivision.cpp \ - code/TargetAnimation.cpp \ - code/TerragenLoader.cpp \ - code/TextureTransform.cpp \ - code/TriangulateProcess.cpp \ - code/UnrealLoader.cpp \ - code/ValidateDataStructure.cpp \ - code/Version.cpp \ - code/VertexTriangleAdjacency.cpp \ - code/X3DExporter.cpp \ - code/X3DImporter.cpp \ - code/X3DImporter_Geometry2D.cpp \ - code/X3DImporter_Geometry3D.cpp \ - code/X3DImporter_Group.cpp \ - code/X3DImporter_Light.cpp \ - code/X3DImporter_Metadata.cpp \ - code/X3DImporter_Networking.cpp \ - code/X3DImporter_Postprocess.cpp \ - code/X3DImporter_Rendering.cpp \ - code/X3DImporter_Shape.cpp \ - code/X3DImporter_Texturing.cpp \ - code/X3DVocabulary.cpp \ - code/XFileExporter.cpp \ - code/XFileImporter.cpp \ - code/XFileParser.cpp \ - code/XGLLoader.cpp \ - code/glTF2Exporter.cpp \ - code/glTF2Importer.cpp \ - code/glTFExporter.cpp \ - code/glTFImporter.cpp \ - code/scene.cpp \ - contrib/Open3DGC/o3dgcArithmeticCodec.cpp \ - contrib/Open3DGC/o3dgcDynamicVectorDecoder.cpp \ - contrib/Open3DGC/o3dgcDynamicVectorEncoder.cpp \ - contrib/Open3DGC/o3dgcTools.cpp \ - contrib/Open3DGC/o3dgcTriangleFans.cpp \ - contrib/clipper/clipper.cpp \ - contrib/irrXML/irrXML.cpp \ - contrib/openddlparser/code/DDLNode.cpp \ - contrib/openddlparser/code/OpenDDLCommon.cpp \ - contrib/openddlparser/code/OpenDDLExport.cpp \ - contrib/openddlparser/code/OpenDDLParser.cpp \ - contrib/openddlparser/code/OpenDDLStream.cpp \ - contrib/openddlparser/code/Value.cpp \ - contrib/poly2tri/poly2tri/common/shapes.cc \ - contrib/poly2tri/poly2tri/sweep/advancing_front.cc \ - contrib/poly2tri/poly2tri/sweep/cdt.cc \ - contrib/poly2tri/poly2tri/sweep/sweep.cc \ - contrib/poly2tri/poly2tri/sweep/sweep_context.cc \ - contrib/unzip/ioapi.c \ - contrib/unzip/unzip.c \ - contrib/zip/src/zip.c + $$PWD/src/contrib/unzip/ioapi.c \ + $$PWD/src/contrib/unzip/unzip.c diff --git a/src/3rdparty/assimp/code/3DSConverter.cpp b/src/3rdparty/assimp/code/3DSConverter.cpp deleted file mode 100644 index 820c28f90..000000000 --- a/src/3rdparty/assimp/code/3DSConverter.cpp +++ /dev/null @@ -1,871 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file Implementation of the 3ds importer class */ - - -#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER - -// internal headers -#include "3DSLoader.h" -#include "TargetAnimation.h" -#include -#include -#include "StringComparison.h" -#include -#include - -using namespace Assimp; - -static const unsigned int NotSet = 0xcdcdcdcd; - -// ------------------------------------------------------------------------------------------------ -// Setup final material indices, generae a default material if necessary -void Discreet3DSImporter::ReplaceDefaultMaterial() -{ - // Try to find an existing material that matches the - // typical default material setting: - // - no textures - // - diffuse color (in grey!) - // NOTE: This is here to workaround the fact that some - // exporters are writing a default material, too. - unsigned int idx( NotSet ); - for (unsigned int i = 0; i < mScene->mMaterials.size();++i) - { - std::string s = mScene->mMaterials[i].mName; - for ( std::string::iterator it = s.begin(); it != s.end(); ++it ) { - *it = static_cast< char >( ::tolower( *it ) ); - } - - if (std::string::npos == s.find("default"))continue; - - if (mScene->mMaterials[i].mDiffuse.r != - mScene->mMaterials[i].mDiffuse.g || - mScene->mMaterials[i].mDiffuse.r != - mScene->mMaterials[i].mDiffuse.b)continue; - - if (mScene->mMaterials[i].sTexDiffuse.mMapName.length() != 0 || - mScene->mMaterials[i].sTexBump.mMapName.length() != 0 || - mScene->mMaterials[i].sTexOpacity.mMapName.length() != 0 || - mScene->mMaterials[i].sTexEmissive.mMapName.length() != 0 || - mScene->mMaterials[i].sTexSpecular.mMapName.length() != 0 || - mScene->mMaterials[i].sTexShininess.mMapName.length() != 0 ) - { - continue; - } - idx = i; - } - if ( NotSet == idx ) { - idx = ( unsigned int )mScene->mMaterials.size(); - } - - // now iterate through all meshes and through all faces and - // find all faces that are using the default material - unsigned int cnt = 0; - for (std::vector::iterator - i = mScene->mMeshes.begin(); - i != mScene->mMeshes.end();++i) - { - for (std::vector::iterator - a = (*i).mFaceMaterials.begin(); - a != (*i).mFaceMaterials.end();++a) - { - // NOTE: The additional check seems to be necessary, - // some exporters seem to generate invalid data here - if (0xcdcdcdcd == (*a)) - { - (*a) = idx; - ++cnt; - } - else if ( (*a) >= mScene->mMaterials.size()) - { - (*a) = idx; - DefaultLogger::get()->warn("Material index overflow in 3DS file. Using default material"); - ++cnt; - } - } - } - if (cnt && idx == mScene->mMaterials.size()) - { - // We need to create our own default material - D3DS::Material sMat; - sMat.mDiffuse = aiColor3D(0.3f,0.3f,0.3f); - sMat.mName = "%%%DEFAULT"; - mScene->mMaterials.push_back(sMat); - - DefaultLogger::get()->info("3DS: Generating default material"); - } -} - -// ------------------------------------------------------------------------------------------------ -// Check whether all indices are valid. Otherwise we'd crash before the validation step is reached -void Discreet3DSImporter::CheckIndices(D3DS::Mesh& sMesh) -{ - for (std::vector< D3DS::Face >::iterator i = sMesh.mFaces.begin(); i != sMesh.mFaces.end();++i) - { - // check whether all indices are in range - for (unsigned int a = 0; a < 3;++a) - { - if ((*i).mIndices[a] >= sMesh.mPositions.size()) - { - DefaultLogger::get()->warn("3DS: Vertex index overflow)"); - (*i).mIndices[a] = (uint32_t)sMesh.mPositions.size()-1; - } - if ( !sMesh.mTexCoords.empty() && (*i).mIndices[a] >= sMesh.mTexCoords.size()) - { - DefaultLogger::get()->warn("3DS: Texture coordinate index overflow)"); - (*i).mIndices[a] = (uint32_t)sMesh.mTexCoords.size()-1; - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -// Generate out unique verbose format representation -void Discreet3DSImporter::MakeUnique(D3DS::Mesh& sMesh) -{ - // TODO: really necessary? I don't think. Just a waste of memory and time - // to do it now in a separate buffer. - - // Allocate output storage - std::vector vNew (sMesh.mFaces.size() * 3); - std::vector vNew2; - if (sMesh.mTexCoords.size()) - vNew2.resize(sMesh.mFaces.size() * 3); - - for (unsigned int i = 0, base = 0; i < sMesh.mFaces.size();++i) - { - D3DS::Face& face = sMesh.mFaces[i]; - - // Positions - for (unsigned int a = 0; a < 3;++a,++base) - { - vNew[base] = sMesh.mPositions[face.mIndices[a]]; - if (sMesh.mTexCoords.size()) - vNew2[base] = sMesh.mTexCoords[face.mIndices[a]]; - - face.mIndices[a] = base; - } - } - sMesh.mPositions = vNew; - sMesh.mTexCoords = vNew2; -} - -// ------------------------------------------------------------------------------------------------ -// Convert a 3DS texture to texture keys in an aiMaterial -void CopyTexture(aiMaterial& mat, D3DS::Texture& texture, aiTextureType type) -{ - // Setup the texture name - aiString tex; - tex.Set( texture.mMapName); - mat.AddProperty( &tex, AI_MATKEY_TEXTURE(type,0)); - - // Setup the texture blend factor - if (is_not_qnan(texture.mTextureBlend)) - mat.AddProperty( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0)); - - // Setup the texture mapping mode - mat.AddProperty((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_U(type,0)); - mat.AddProperty((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_V(type,0)); - - // Mirroring - double the scaling values - // FIXME: this is not really correct ... - if (texture.mMapMode == aiTextureMapMode_Mirror) - { - texture.mScaleU *= 2.0; - texture.mScaleV *= 2.0; - texture.mOffsetU /= 2.0; - texture.mOffsetV /= 2.0; - } - - // Setup texture UV transformations - mat.AddProperty(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0)); -} - -// ------------------------------------------------------------------------------------------------ -// Convert a 3DS material to an aiMaterial -void Discreet3DSImporter::ConvertMaterial(D3DS::Material& oldMat, - aiMaterial& mat) -{ - // NOTE: Pass the background image to the viewer by bypassing the - // material system. This is an evil hack, never do it again! - if (0 != mBackgroundImage.length() && bHasBG) - { - aiString tex; - tex.Set( mBackgroundImage); - mat.AddProperty( &tex, AI_MATKEY_GLOBAL_BACKGROUND_IMAGE); - - // Be sure this is only done for the first material - mBackgroundImage = std::string(""); - } - - // At first add the base ambient color of the scene to the material - oldMat.mAmbient.r += mClrAmbient.r; - oldMat.mAmbient.g += mClrAmbient.g; - oldMat.mAmbient.b += mClrAmbient.b; - - aiString name; - name.Set( oldMat.mName); - mat.AddProperty( &name, AI_MATKEY_NAME); - - // Material colors - mat.AddProperty( &oldMat.mAmbient, 1, AI_MATKEY_COLOR_AMBIENT); - mat.AddProperty( &oldMat.mDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE); - mat.AddProperty( &oldMat.mSpecular, 1, AI_MATKEY_COLOR_SPECULAR); - mat.AddProperty( &oldMat.mEmissive, 1, AI_MATKEY_COLOR_EMISSIVE); - - // Phong shininess and shininess strength - if (D3DS::Discreet3DS::Phong == oldMat.mShading || - D3DS::Discreet3DS::Metal == oldMat.mShading) - { - if (!oldMat.mSpecularExponent || !oldMat.mShininessStrength) - { - oldMat.mShading = D3DS::Discreet3DS::Gouraud; - } - else - { - mat.AddProperty( &oldMat.mSpecularExponent, 1, AI_MATKEY_SHININESS); - mat.AddProperty( &oldMat.mShininessStrength, 1, AI_MATKEY_SHININESS_STRENGTH); - } - } - - // Opacity - mat.AddProperty( &oldMat.mTransparency,1,AI_MATKEY_OPACITY); - - // Bump height scaling - mat.AddProperty( &oldMat.mBumpHeight,1,AI_MATKEY_BUMPSCALING); - - // Two sided rendering? - if (oldMat.mTwoSided) - { - int i = 1; - mat.AddProperty(&i,1,AI_MATKEY_TWOSIDED); - } - - // Shading mode - aiShadingMode eShading = aiShadingMode_NoShading; - switch (oldMat.mShading) - { - case D3DS::Discreet3DS::Flat: - eShading = aiShadingMode_Flat; break; - - // I don't know what "Wire" shading should be, - // assume it is simple lambertian diffuse shading - case D3DS::Discreet3DS::Wire: - { - // Set the wireframe flag - unsigned int iWire = 1; - mat.AddProperty( (int*)&iWire,1,AI_MATKEY_ENABLE_WIREFRAME); - } - - case D3DS::Discreet3DS::Gouraud: - eShading = aiShadingMode_Gouraud; break; - - // assume cook-torrance shading for metals. - case D3DS::Discreet3DS::Phong : - eShading = aiShadingMode_Phong; break; - - case D3DS::Discreet3DS::Metal : - eShading = aiShadingMode_CookTorrance; break; - - // FIX to workaround a warning with GCC 4 who complained - // about a missing case Blinn: here - Blinn isn't a valid - // value in the 3DS Loader, it is just needed for ASE - case D3DS::Discreet3DS::Blinn : - eShading = aiShadingMode_Blinn; break; - } - mat.AddProperty( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL); - - // DIFFUSE texture - if( oldMat.sTexDiffuse.mMapName.length() > 0) - CopyTexture(mat,oldMat.sTexDiffuse, aiTextureType_DIFFUSE); - - // SPECULAR texture - if( oldMat.sTexSpecular.mMapName.length() > 0) - CopyTexture(mat,oldMat.sTexSpecular, aiTextureType_SPECULAR); - - // OPACITY texture - if( oldMat.sTexOpacity.mMapName.length() > 0) - CopyTexture(mat,oldMat.sTexOpacity, aiTextureType_OPACITY); - - // EMISSIVE texture - if( oldMat.sTexEmissive.mMapName.length() > 0) - CopyTexture(mat,oldMat.sTexEmissive, aiTextureType_EMISSIVE); - - // BUMP texture - if( oldMat.sTexBump.mMapName.length() > 0) - CopyTexture(mat,oldMat.sTexBump, aiTextureType_HEIGHT); - - // SHININESS texture - if( oldMat.sTexShininess.mMapName.length() > 0) - CopyTexture(mat,oldMat.sTexShininess, aiTextureType_SHININESS); - - // REFLECTION texture - if( oldMat.sTexReflective.mMapName.length() > 0) - CopyTexture(mat,oldMat.sTexReflective, aiTextureType_REFLECTION); - - // Store the name of the material itself, too - if( oldMat.mName.length()) { - aiString tex; - tex.Set( oldMat.mName); - mat.AddProperty( &tex, AI_MATKEY_NAME); - } -} - -// ------------------------------------------------------------------------------------------------ -// Split meshes by their materials and generate output aiMesh'es -void Discreet3DSImporter::ConvertMeshes(aiScene* pcOut) -{ - std::vector avOutMeshes; - avOutMeshes.reserve(mScene->mMeshes.size() * 2); - - unsigned int iFaceCnt = 0,num = 0; - aiString name; - - // we need to split all meshes by their materials - for (std::vector::iterator i = mScene->mMeshes.begin(); i != mScene->mMeshes.end();++i) { - std::unique_ptr< std::vector[] > aiSplit(new std::vector[mScene->mMaterials.size()]); - - name.length = ASSIMP_itoa10(name.data,num++); - - unsigned int iNum = 0; - for (std::vector::const_iterator a = (*i).mFaceMaterials.begin(); - a != (*i).mFaceMaterials.end();++a,++iNum) - { - aiSplit[*a].push_back(iNum); - } - // now generate submeshes - for (unsigned int p = 0; p < mScene->mMaterials.size();++p) - { - if (aiSplit[p].empty()) { - continue; - } - aiMesh* meshOut = new aiMesh(); - meshOut->mName = name; - meshOut->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - - // be sure to setup the correct material index - meshOut->mMaterialIndex = p; - - // use the color data as temporary storage - meshOut->mColors[0] = (aiColor4D*)(&*i); - avOutMeshes.push_back(meshOut); - - // convert vertices - meshOut->mNumFaces = (unsigned int)aiSplit[p].size(); - meshOut->mNumVertices = meshOut->mNumFaces*3; - - // allocate enough storage for faces - meshOut->mFaces = new aiFace[meshOut->mNumFaces]; - iFaceCnt += meshOut->mNumFaces; - - meshOut->mVertices = new aiVector3D[meshOut->mNumVertices]; - meshOut->mNormals = new aiVector3D[meshOut->mNumVertices]; - if ((*i).mTexCoords.size()) - { - meshOut->mTextureCoords[0] = new aiVector3D[meshOut->mNumVertices]; - } - for (unsigned int q = 0, base = 0; q < aiSplit[p].size();++q) - { - unsigned int index = aiSplit[p][q]; - aiFace& face = meshOut->mFaces[q]; - - face.mIndices = new unsigned int[3]; - face.mNumIndices = 3; - - for (unsigned int a = 0; a < 3;++a,++base) - { - unsigned int idx = (*i).mFaces[index].mIndices[a]; - meshOut->mVertices[base] = (*i).mPositions[idx]; - meshOut->mNormals [base] = (*i).mNormals[idx]; - - if ((*i).mTexCoords.size()) - meshOut->mTextureCoords[0][base] = (*i).mTexCoords[idx]; - - face.mIndices[a] = base; - } - } - } - } - - // Copy them to the output array - pcOut->mNumMeshes = (unsigned int)avOutMeshes.size(); - pcOut->mMeshes = new aiMesh*[pcOut->mNumMeshes](); - for (unsigned int a = 0; a < pcOut->mNumMeshes;++a) { - pcOut->mMeshes[a] = avOutMeshes[a]; - } - - // We should have at least one face here - if (!iFaceCnt) { - throw DeadlyImportError("No faces loaded. The mesh is empty"); - } -} - -// ------------------------------------------------------------------------------------------------ -// Add a node to the scenegraph and setup its final transformation -void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut, - D3DS::Node* pcIn, aiMatrix4x4& /*absTrafo*/) -{ - std::vector iArray; - iArray.reserve(3); - - aiMatrix4x4 abs; - - // Find all meshes with the same name as the node - for (unsigned int a = 0; a < pcSOut->mNumMeshes;++a) - { - const D3DS::Mesh* pcMesh = (const D3DS::Mesh*)pcSOut->mMeshes[a]->mColors[0]; - ai_assert(NULL != pcMesh); - - if (pcIn->mName == pcMesh->mName) - iArray.push_back(a); - } - if (!iArray.empty()) - { - // The matrix should be identical for all meshes with the - // same name. It HAS to be identical for all meshes ..... - D3DS::Mesh* imesh = ((D3DS::Mesh*)pcSOut->mMeshes[iArray[0]]->mColors[0]); - - // Compute the inverse of the transformation matrix to move the - // vertices back to their relative and local space - aiMatrix4x4 mInv = imesh->mMat, mInvTransposed = imesh->mMat; - mInv.Inverse();mInvTransposed.Transpose(); - aiVector3D pivot = pcIn->vPivot; - - pcOut->mNumMeshes = (unsigned int)iArray.size(); - pcOut->mMeshes = new unsigned int[iArray.size()]; - for (unsigned int i = 0;i < iArray.size();++i) { - const unsigned int iIndex = iArray[i]; - aiMesh* const mesh = pcSOut->mMeshes[iIndex]; - - if (mesh->mColors[1] == NULL) - { - // Transform the vertices back into their local space - // fixme: consider computing normals after this, so we don't need to transform them - const aiVector3D* const pvEnd = mesh->mVertices + mesh->mNumVertices; - aiVector3D* pvCurrent = mesh->mVertices, *t2 = mesh->mNormals; - - for (; pvCurrent != pvEnd; ++pvCurrent, ++t2) { - *pvCurrent = mInv * (*pvCurrent); - *t2 = mInvTransposed * (*t2); - } - - // Handle negative transformation matrix determinant -> invert vertex x - if (imesh->mMat.Determinant() < 0.0f) - { - /* we *must* have normals */ - for (pvCurrent = mesh->mVertices, t2 = mesh->mNormals; pvCurrent != pvEnd; ++pvCurrent, ++t2) { - pvCurrent->x *= -1.f; - t2->x *= -1.f; - } - DefaultLogger::get()->info("3DS: Flipping mesh X-Axis"); - } - - // Handle pivot point - if (pivot.x || pivot.y || pivot.z) - { - for (pvCurrent = mesh->mVertices; pvCurrent != pvEnd; ++pvCurrent) { - *pvCurrent -= pivot; - } - } - - mesh->mColors[1] = (aiColor4D*)1; - } - else - mesh->mColors[1] = (aiColor4D*)1; - - // Setup the mesh index - pcOut->mMeshes[i] = iIndex; - } - } - - // Setup the name of the node - // First instance keeps its name otherwise something might break, all others will be postfixed with their instance number - if (pcIn->mInstanceNumber > 1) - { - char tmp[12]; - ASSIMP_itoa10(tmp, pcIn->mInstanceNumber); - std::string tempStr = pcIn->mName + "_inst_"; - tempStr += tmp; - pcOut->mName.Set(tempStr); - } - else - pcOut->mName.Set(pcIn->mName); - - // Now build the transformation matrix of the node - // ROTATION - if (pcIn->aRotationKeys.size()){ - - // FIX to get to Assimp's quaternion conventions - for (std::vector::iterator it = pcIn->aRotationKeys.begin(); it != pcIn->aRotationKeys.end(); ++it) { - (*it).mValue.w *= -1.f; - } - - pcOut->mTransformation = aiMatrix4x4( pcIn->aRotationKeys[0].mValue.GetMatrix() ); - } - else if (pcIn->aCameraRollKeys.size()) - { - aiMatrix4x4::RotationZ(AI_DEG_TO_RAD(- pcIn->aCameraRollKeys[0].mValue), - pcOut->mTransformation); - } - - // SCALING - aiMatrix4x4& m = pcOut->mTransformation; - if (pcIn->aScalingKeys.size()) - { - const aiVector3D& v = pcIn->aScalingKeys[0].mValue; - m.a1 *= v.x; m.b1 *= v.x; m.c1 *= v.x; - m.a2 *= v.y; m.b2 *= v.y; m.c2 *= v.y; - m.a3 *= v.z; m.b3 *= v.z; m.c3 *= v.z; - } - - // TRANSLATION - if (pcIn->aPositionKeys.size()) - { - const aiVector3D& v = pcIn->aPositionKeys[0].mValue; - m.a4 += v.x; - m.b4 += v.y; - m.c4 += v.z; - } - - // Generate animation channels for the node - if (pcIn->aPositionKeys.size() > 1 || pcIn->aRotationKeys.size() > 1 || - pcIn->aScalingKeys.size() > 1 || pcIn->aCameraRollKeys.size() > 1 || - pcIn->aTargetPositionKeys.size() > 1) - { - aiAnimation* anim = pcSOut->mAnimations[0]; - ai_assert(NULL != anim); - - if (pcIn->aCameraRollKeys.size() > 1) - { - DefaultLogger::get()->debug("3DS: Converting camera roll track ..."); - - // Camera roll keys - in fact they're just rotations - // around the camera's z axis. The angles are given - // in degrees (and they're clockwise). - pcIn->aRotationKeys.resize(pcIn->aCameraRollKeys.size()); - for (unsigned int i = 0; i < pcIn->aCameraRollKeys.size();++i) - { - aiQuatKey& q = pcIn->aRotationKeys[i]; - aiFloatKey& f = pcIn->aCameraRollKeys[i]; - - q.mTime = f.mTime; - - // FIX to get to Assimp quaternion conventions - q.mValue = aiQuaternion(0.f,0.f,AI_DEG_TO_RAD( /*-*/ f.mValue)); - } - } -#if 0 - if (pcIn->aTargetPositionKeys.size() > 1) - { - DefaultLogger::get()->debug("3DS: Converting target track ..."); - - // Camera or spot light - need to convert the separate - // target position channel to our representation - TargetAnimationHelper helper; - - if (pcIn->aPositionKeys.empty()) - { - // We can just pass zero here ... - helper.SetFixedMainAnimationChannel(aiVector3D()); - } - else helper.SetMainAnimationChannel(&pcIn->aPositionKeys); - helper.SetTargetAnimationChannel(&pcIn->aTargetPositionKeys); - - // Do the conversion - std::vector distanceTrack; - helper.Process(&distanceTrack); - - // Now add a new node as child, name it .Target - // and assign the distance track to it. This is that the - // information where the target is and how it moves is - // not lost - D3DS::Node* nd = new D3DS::Node(); - pcIn->push_back(nd); - - nd->mName = pcIn->mName + ".Target"; - - aiNodeAnim* nda = anim->mChannels[anim->mNumChannels++] = new aiNodeAnim(); - nda->mNodeName.Set(nd->mName); - - nda->mNumPositionKeys = (unsigned int)distanceTrack.size(); - nda->mPositionKeys = new aiVectorKey[nda->mNumPositionKeys]; - ::memcpy(nda->mPositionKeys,&distanceTrack[0], - sizeof(aiVectorKey)*nda->mNumPositionKeys); - } -#endif - - // Cameras or lights define their transformation in their parent node and in the - // corresponding light or camera chunks. However, we read and process the latter - // to to be able to return valid cameras/lights even if no scenegraph is given. - for (unsigned int n = 0; n < pcSOut->mNumCameras;++n) { - if (pcSOut->mCameras[n]->mName == pcOut->mName) { - pcSOut->mCameras[n]->mLookAt = aiVector3D(0.f,0.f,1.f); - } - } - for (unsigned int n = 0; n < pcSOut->mNumLights;++n) { - if (pcSOut->mLights[n]->mName == pcOut->mName) { - pcSOut->mLights[n]->mDirection = aiVector3D(0.f,0.f,1.f); - } - } - - // Allocate a new node anim and setup its name - aiNodeAnim* nda = anim->mChannels[anim->mNumChannels++] = new aiNodeAnim(); - nda->mNodeName.Set(pcIn->mName); - - // POSITION keys - if (pcIn->aPositionKeys.size() > 0) - { - nda->mNumPositionKeys = (unsigned int)pcIn->aPositionKeys.size(); - nda->mPositionKeys = new aiVectorKey[nda->mNumPositionKeys]; - ::memcpy(nda->mPositionKeys,&pcIn->aPositionKeys[0], - sizeof(aiVectorKey)*nda->mNumPositionKeys); - } - - // ROTATION keys - if (pcIn->aRotationKeys.size() > 0) - { - nda->mNumRotationKeys = (unsigned int)pcIn->aRotationKeys.size(); - nda->mRotationKeys = new aiQuatKey[nda->mNumRotationKeys]; - - // Rotations are quaternion offsets - aiQuaternion abs1; - for (unsigned int n = 0; n < nda->mNumRotationKeys;++n) - { - const aiQuatKey& q = pcIn->aRotationKeys[n]; - - abs1 = (n ? abs1 * q.mValue : q.mValue); - nda->mRotationKeys[n].mTime = q.mTime; - nda->mRotationKeys[n].mValue = abs1.Normalize(); - } - } - - // SCALING keys - if (pcIn->aScalingKeys.size() > 0) - { - nda->mNumScalingKeys = (unsigned int)pcIn->aScalingKeys.size(); - nda->mScalingKeys = new aiVectorKey[nda->mNumScalingKeys]; - ::memcpy(nda->mScalingKeys,&pcIn->aScalingKeys[0], - sizeof(aiVectorKey)*nda->mNumScalingKeys); - } - } - - // Allocate storage for children - pcOut->mNumChildren = (unsigned int)pcIn->mChildren.size(); - pcOut->mChildren = new aiNode*[pcIn->mChildren.size()]; - - // Recursively process all children - const unsigned int size = static_cast(pcIn->mChildren.size()); - for (unsigned int i = 0; i < size;++i) - { - pcOut->mChildren[i] = new aiNode(); - pcOut->mChildren[i]->mParent = pcOut; - AddNodeToGraph(pcSOut,pcOut->mChildren[i],pcIn->mChildren[i],abs); - } -} - -// ------------------------------------------------------------------------------------------------ -// Find out how many node animation channels we'll have finally -void CountTracks(D3DS::Node* node, unsigned int& cnt) -{ - ////////////////////////////////////////////////////////////////////////////// - // We will never generate more than one channel for a node, so - // this is rather easy here. - - if (node->aPositionKeys.size() > 1 || node->aRotationKeys.size() > 1 || - node->aScalingKeys.size() > 1 || node->aCameraRollKeys.size() > 1 || - node->aTargetPositionKeys.size() > 1) - { - ++cnt; - - // account for the additional channel for the camera/spotlight target position - if (node->aTargetPositionKeys.size() > 1)++cnt; - } - - // Recursively process all children - for (unsigned int i = 0; i < node->mChildren.size();++i) - CountTracks(node->mChildren[i],cnt); -} - -// ------------------------------------------------------------------------------------------------ -// Generate the output node graph -void Discreet3DSImporter::GenerateNodeGraph(aiScene* pcOut) -{ - pcOut->mRootNode = new aiNode(); - if (0 == mRootNode->mChildren.size()) - { - ////////////////////////////////////////////////////////////////////////////// - // It seems the file is so messed up that it has not even a hierarchy. - // generate a flat hiearachy which looks like this: - // - // ROOT_NODE - // | - // ---------------------------------------- - // | | | | | - // MESH_0 MESH_1 MESH_2 ... MESH_N CAMERA_0 .... - // - DefaultLogger::get()->warn("No hierarchy information has been found in the file. "); - - pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes + - static_cast(mScene->mCameras.size() + mScene->mLights.size()); - - pcOut->mRootNode->mChildren = new aiNode* [ pcOut->mRootNode->mNumChildren ]; - pcOut->mRootNode->mName.Set("<3DSDummyRoot>"); - - // Build dummy nodes for all meshes - unsigned int a = 0; - for (unsigned int i = 0; i < pcOut->mNumMeshes;++i,++a) - { - aiNode* pcNode = pcOut->mRootNode->mChildren[a] = new aiNode(); - pcNode->mParent = pcOut->mRootNode; - pcNode->mMeshes = new unsigned int[1]; - pcNode->mMeshes[0] = i; - pcNode->mNumMeshes = 1; - - // Build a name for the node - pcNode->mName.length = ai_snprintf(pcNode->mName.data, MAXLEN, "3DSMesh_%u",i); - } - - // Build dummy nodes for all cameras - for (unsigned int i = 0; i < (unsigned int )mScene->mCameras.size();++i,++a) - { - aiNode* pcNode = pcOut->mRootNode->mChildren[a] = new aiNode(); - pcNode->mParent = pcOut->mRootNode; - - // Build a name for the node - pcNode->mName = mScene->mCameras[i]->mName; - } - - // Build dummy nodes for all lights - for (unsigned int i = 0; i < (unsigned int )mScene->mLights.size();++i,++a) - { - aiNode* pcNode = pcOut->mRootNode->mChildren[a] = new aiNode(); - pcNode->mParent = pcOut->mRootNode; - - // Build a name for the node - pcNode->mName = mScene->mLights[i]->mName; - } - } - else - { - // First of all: find out how many scaling, rotation and translation - // animation tracks we'll have afterwards - unsigned int numChannel = 0; - CountTracks(mRootNode,numChannel); - - if (numChannel) - { - // Allocate a primary animation channel - pcOut->mNumAnimations = 1; - pcOut->mAnimations = new aiAnimation*[1]; - aiAnimation* anim = pcOut->mAnimations[0] = new aiAnimation(); - - anim->mName.Set("3DSMasterAnim"); - - // Allocate enough storage for all node animation channels, - // but don't set the mNumChannels member - we'll use it to - // index into the array - anim->mChannels = new aiNodeAnim*[numChannel]; - } - - aiMatrix4x4 m; - AddNodeToGraph(pcOut, pcOut->mRootNode, mRootNode,m); - } - - // We used the first and second vertex color set to store some temporary values so we need to cleanup here - for (unsigned int a = 0; a < pcOut->mNumMeshes; ++a) - { - pcOut->mMeshes[a]->mColors[0] = NULL; - pcOut->mMeshes[a]->mColors[1] = NULL; - } - - pcOut->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) * pcOut->mRootNode->mTransformation; - - // If the root node is unnamed name it "<3DSRoot>" - if (::strstr( pcOut->mRootNode->mName.data, "UNNAMED" ) || - (pcOut->mRootNode->mName.data[0] == '$' && pcOut->mRootNode->mName.data[1] == '$') ) - { - pcOut->mRootNode->mName.Set("<3DSRoot>"); - } -} - -// ------------------------------------------------------------------------------------------------ -// Convert all meshes in the scene and generate the final output scene. -void Discreet3DSImporter::ConvertScene(aiScene* pcOut) -{ - // Allocate enough storage for all output materials - pcOut->mNumMaterials = (unsigned int)mScene->mMaterials.size(); - pcOut->mMaterials = new aiMaterial*[pcOut->mNumMaterials]; - - // ... and convert the 3DS materials to aiMaterial's - for (unsigned int i = 0; i < pcOut->mNumMaterials;++i) - { - aiMaterial* pcNew = new aiMaterial(); - ConvertMaterial(mScene->mMaterials[i],*pcNew); - pcOut->mMaterials[i] = pcNew; - } - - // Generate the output mesh list - ConvertMeshes(pcOut); - - // Now copy all light sources to the output scene - pcOut->mNumLights = (unsigned int)mScene->mLights.size(); - if (pcOut->mNumLights) - { - pcOut->mLights = new aiLight*[pcOut->mNumLights]; - ::memcpy(pcOut->mLights,&mScene->mLights[0],sizeof(void*)*pcOut->mNumLights); - } - - // Now copy all cameras to the output scene - pcOut->mNumCameras = (unsigned int)mScene->mCameras.size(); - if (pcOut->mNumCameras) - { - pcOut->mCameras = new aiCamera*[pcOut->mNumCameras]; - ::memcpy(pcOut->mCameras,&mScene->mCameras[0],sizeof(void*)*pcOut->mNumCameras); - } -} - -#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER diff --git a/src/3rdparty/assimp/code/3DSExporter.cpp b/src/3rdparty/assimp/code/3DSExporter.cpp deleted file mode 100644 index 2f561fcd6..000000000 --- a/src/3rdparty/assimp/code/3DSExporter.cpp +++ /dev/null @@ -1,579 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -#ifndef ASSIMP_BUILD_NO_EXPORT -#ifndef ASSIMP_BUILD_NO_3DS_EXPORTER - -#include "3DSExporter.h" -#include "3DSLoader.h" -#include "3DSHelper.h" -#include -#include "SplitLargeMeshes.h" -#include "StringComparison.h" -#include -#include -#include -#include - -using namespace Assimp; -namespace Assimp { -using namespace D3DS; - -namespace { - - ////////////////////////////////////////////////////////////////////////////////////// - // Scope utility to write a 3DS file chunk. - // - // Upon construction, the chunk header is written with the chunk type (flags) - // filled out, but the chunk size left empty. Upon destruction, the correct chunk - // size based on the then-position of the output stream cursor is filled in. - class ChunkWriter { - enum { - CHUNK_SIZE_NOT_SET = 0xdeadbeef - , SIZE_OFFSET = 2 - }; - public: - - ChunkWriter(StreamWriterLE& writer, uint16_t chunk_type) - : writer(writer) - { - chunk_start_pos = writer.GetCurrentPos(); - writer.PutU2(chunk_type); - writer.PutU4(CHUNK_SIZE_NOT_SET); - } - - ~ChunkWriter() { - std::size_t head_pos = writer.GetCurrentPos(); - - ai_assert(head_pos > chunk_start_pos); - const std::size_t chunk_size = head_pos - chunk_start_pos; - - writer.SetCurrentPos(chunk_start_pos + SIZE_OFFSET); - writer.PutU4(static_cast(chunk_size)); - writer.SetCurrentPos(head_pos); - } - - private: - StreamWriterLE& writer; - std::size_t chunk_start_pos; - }; - - - // Return an unique name for a given |mesh| attached to |node| that - // preserves the mesh's given name if it has one. |index| is the index - // of the mesh in |aiScene::mMeshes|. - std::string GetMeshName(const aiMesh& mesh, unsigned int index, const aiNode& node) { - static const std::string underscore = "_"; - char postfix[10] = {0}; - ASSIMP_itoa10(postfix, index); - - std::string result = node.mName.C_Str(); - if (mesh.mName.length > 0) { - result += underscore + mesh.mName.C_Str(); - } - return result + underscore + postfix; - } - - // Return an unique name for a given |mat| with original position |index| - // in |aiScene::mMaterials|. The name preserves the original material - // name if possible. - std::string GetMaterialName(const aiMaterial& mat, unsigned int index) { - static const std::string underscore = "_"; - char postfix[10] = {0}; - ASSIMP_itoa10(postfix, index); - - aiString mat_name; - if (AI_SUCCESS == mat.Get(AI_MATKEY_NAME, mat_name)) { - return mat_name.C_Str() + underscore + postfix; - } - - return "Material" + underscore + postfix; - } - - // Collect world transformations for each node - void CollectTrafos(const aiNode* node, std::map& trafos) { - const aiMatrix4x4& parent = node->mParent ? trafos[node->mParent] : aiMatrix4x4(); - trafos[node] = parent * node->mTransformation; - for (unsigned int i = 0; i < node->mNumChildren; ++i) { - CollectTrafos(node->mChildren[i], trafos); - } - } - - // Generate a flat list of the meshes (by index) assigned to each node - void CollectMeshes(const aiNode* node, std::multimap& meshes) { - for (unsigned int i = 0; i < node->mNumMeshes; ++i) { - meshes.insert(std::make_pair(node, node->mMeshes[i])); - } - for (unsigned int i = 0; i < node->mNumChildren; ++i) { - CollectMeshes(node->mChildren[i], meshes); - } - } -} - -// ------------------------------------------------------------------------------------------------ -// Worker function for exporting a scene to 3DS. Prototyped and registered in Exporter.cpp -void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) -{ - std::shared_ptr outfile (pIOSystem->Open(pFile, "wb")); - if(!outfile) { - throw DeadlyExportError("Could not open output .3ds file: " + std::string(pFile)); - } - - // TODO: This extra copy should be avoided and all of this made a preprocess - // requirement of the 3DS exporter. - // - // 3DS meshes can be max 0xffff (16 Bit) vertices and faces, respectively. - // SplitLargeMeshes can do this, but it requires the correct limit to be set - // which is not possible with the current way of specifying preprocess steps - // in |Exporter::ExportFormatEntry|. - aiScene* scenecopy_tmp; - SceneCombiner::CopyScene(&scenecopy_tmp,pScene); - std::unique_ptr scenecopy(scenecopy_tmp); - - SplitLargeMeshesProcess_Triangle tri_splitter; - tri_splitter.SetLimit(0xffff); - tri_splitter.Execute(scenecopy.get()); - - SplitLargeMeshesProcess_Vertex vert_splitter; - vert_splitter.SetLimit(0xffff); - vert_splitter.Execute(scenecopy.get()); - - // Invoke the actual exporter - Discreet3DSExporter exporter(outfile, scenecopy.get()); -} - -} // end of namespace Assimp - -// ------------------------------------------------------------------------------------------------ -Discreet3DSExporter:: Discreet3DSExporter(std::shared_ptr outfile, const aiScene* scene) -: scene(scene) -, writer(outfile) -{ - CollectTrafos(scene->mRootNode, trafos); - CollectMeshes(scene->mRootNode, meshes); - - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAIN); - - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_OBJMESH); - WriteMaterials(); - WriteMeshes(); - - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MASTER_SCALE); - writer.PutF4(1.0f); - } - } - - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_KEYFRAMER); - WriteHierarchy(*scene->mRootNode, -1, -1); - } -} - -// ------------------------------------------------------------------------------------------------ -Discreet3DSExporter::~Discreet3DSExporter() { - // empty -} - - -// ------------------------------------------------------------------------------------------------ -int Discreet3DSExporter::WriteHierarchy(const aiNode& node, int seq, int sibling_level) -{ - // 3DS scene hierarchy is serialized as in http://www.martinreddy.net/gfx/3d/3DS.spec - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_TRACKINFO); - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_TRACKOBJNAME); - - // Assimp node names are unique and distinct from all mesh-node - // names we generate; thus we can use them as-is - WriteString(node.mName); - - // Two unknown int16 values - it is even unclear if 0 is a safe value - // but luckily importers do not know better either. - writer.PutI4(0); - - int16_t hierarchy_pos = static_cast(seq); - if (sibling_level != -1) { - hierarchy_pos = sibling_level; - } - - // Write the hierarchy position - writer.PutI2(hierarchy_pos); - } - } - - // TODO: write transformation chunks - - ++seq; - sibling_level = seq; - - // Write all children - for (unsigned int i = 0; i < node.mNumChildren; ++i) { - seq = WriteHierarchy(*node.mChildren[i], seq, i == 0 ? -1 : sibling_level); - } - - // Write all meshes as separate nodes to be able to reference the meshes by name - for (unsigned int i = 0; i < node.mNumMeshes; ++i) { - const bool first_child = node.mNumChildren == 0 && i == 0; - - const unsigned int mesh_idx = node.mMeshes[i]; - const aiMesh& mesh = *scene->mMeshes[mesh_idx]; - - ChunkWriter chunk(writer, Discreet3DS::CHUNK_TRACKINFO); - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_TRACKOBJNAME); - WriteString(GetMeshName(mesh, mesh_idx, node)); - - writer.PutI4(0); - writer.PutI2(static_cast(first_child ? seq : sibling_level)); - ++seq; - } - } - return seq; -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WriteMaterials() -{ - for (unsigned int i = 0; i < scene->mNumMaterials; ++i) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_MATERIAL); - const aiMaterial& mat = *scene->mMaterials[i]; - - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_MATNAME); - const std::string& name = GetMaterialName(mat, i); - WriteString(name); - } - - aiColor3D color; - if (mat.Get(AI_MATKEY_COLOR_DIFFUSE, color) == AI_SUCCESS) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_DIFFUSE); - WriteColor(color); - } - - if (mat.Get(AI_MATKEY_COLOR_SPECULAR, color) == AI_SUCCESS) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_SPECULAR); - WriteColor(color); - } - - if (mat.Get(AI_MATKEY_COLOR_AMBIENT, color) == AI_SUCCESS) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_AMBIENT); - WriteColor(color); - } - - if (mat.Get(AI_MATKEY_COLOR_EMISSIVE, color) == AI_SUCCESS) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_SELF_ILLUM); - WriteColor(color); - } - - aiShadingMode shading_mode = aiShadingMode_Flat; - if (mat.Get(AI_MATKEY_SHADING_MODEL, shading_mode) == AI_SUCCESS) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_SHADING); - - Discreet3DS::shadetype3ds shading_mode_out; - switch(shading_mode) { - case aiShadingMode_Flat: - case aiShadingMode_NoShading: - shading_mode_out = Discreet3DS::Flat; - break; - - case aiShadingMode_Gouraud: - case aiShadingMode_Toon: - case aiShadingMode_OrenNayar: - case aiShadingMode_Minnaert: - shading_mode_out = Discreet3DS::Gouraud; - break; - - case aiShadingMode_Phong: - case aiShadingMode_Blinn: - case aiShadingMode_CookTorrance: - case aiShadingMode_Fresnel: - shading_mode_out = Discreet3DS::Phong; - break; - - default: - shading_mode_out = Discreet3DS::Flat; - ai_assert(false); - }; - writer.PutU2(static_cast(shading_mode_out)); - } - - - float f; - if (mat.Get(AI_MATKEY_SHININESS, f) == AI_SUCCESS) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_SHININESS); - WritePercentChunk(f); - } - - if (mat.Get(AI_MATKEY_SHININESS_STRENGTH, f) == AI_SUCCESS) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_SHININESS_PERCENT); - WritePercentChunk(f); - } - - int twosided; - if (mat.Get(AI_MATKEY_TWOSIDED, twosided) == AI_SUCCESS && twosided != 0) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_TWO_SIDE); - writer.PutI2(1); - } - - WriteTexture(mat, aiTextureType_DIFFUSE, Discreet3DS::CHUNK_MAT_TEXTURE); - WriteTexture(mat, aiTextureType_HEIGHT, Discreet3DS::CHUNK_MAT_BUMPMAP); - WriteTexture(mat, aiTextureType_OPACITY, Discreet3DS::CHUNK_MAT_OPACMAP); - WriteTexture(mat, aiTextureType_SHININESS, Discreet3DS::CHUNK_MAT_MAT_SHINMAP); - WriteTexture(mat, aiTextureType_SPECULAR, Discreet3DS::CHUNK_MAT_SPECMAP); - WriteTexture(mat, aiTextureType_EMISSIVE, Discreet3DS::CHUNK_MAT_SELFIMAP); - WriteTexture(mat, aiTextureType_REFLECTION, Discreet3DS::CHUNK_MAT_REFLMAP); - } -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WriteTexture(const aiMaterial& mat, aiTextureType type, uint16_t chunk_flags) -{ - aiString path; - aiTextureMapMode map_mode[2] = { - aiTextureMapMode_Wrap, aiTextureMapMode_Wrap - }; - ai_real blend = 1.0; - if (mat.GetTexture(type, 0, &path, NULL, NULL, &blend, NULL, map_mode) != AI_SUCCESS || !path.length) { - return; - } - - // TODO: handle embedded textures properly - if (path.data[0] == '*') { - DefaultLogger::get()->error("Ignoring embedded texture for export: " + std::string(path.C_Str())); - return; - } - - ChunkWriter chunk(writer, chunk_flags); - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAPFILE); - WriteString(path); - } - - WritePercentChunk(blend); - - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_MAP_TILING); - uint16_t val = 0; // WRAP - if (map_mode[0] == aiTextureMapMode_Mirror) { - val = 0x2; - } - else if (map_mode[0] == aiTextureMapMode_Decal) { - val = 0x10; - } - writer.PutU2(val); - } - // TODO: export texture transformation (i.e. UV offset, scale, rotation) -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WriteMeshes() -{ - // NOTE: 3DS allows for instances. However: - // i) not all importers support reading them - // ii) instances are not as flexible as they are in assimp, in particular, - // nodes can carry (and instance) only one mesh. - // - // This exporter currently deep clones all instanced meshes, i.e. for each mesh - // attached to a node a full TRIMESH chunk is written to the file. - // - // Furthermore, the TRIMESH is transformed into world space so that it will - // appear correctly if importers don't read the scene hierarchy at all. - for (MeshesByNodeMap::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { - const aiNode& node = *(*it).first; - const unsigned int mesh_idx = (*it).second; - - const aiMesh& mesh = *scene->mMeshes[mesh_idx]; - - // This should not happen if the SLM step is correctly executed - // before the scene is handed to the exporter - ai_assert(mesh.mNumVertices <= 0xffff); - ai_assert(mesh.mNumFaces <= 0xffff); - - const aiMatrix4x4& trafo = trafos[&node]; - - ChunkWriter chunk(writer, Discreet3DS::CHUNK_OBJBLOCK); - - // Mesh name is tied to the node it is attached to so it can later be referenced - const std::string& name = GetMeshName(mesh, mesh_idx, node); - WriteString(name); - - - // TRIMESH chunk - ChunkWriter chunk2(writer, Discreet3DS::CHUNK_TRIMESH); - - // Vertices in world space - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_VERTLIST); - - const uint16_t count = static_cast(mesh.mNumVertices); - writer.PutU2(count); - for (unsigned int i = 0; i < mesh.mNumVertices; ++i) { - const aiVector3D& v = trafo * mesh.mVertices[i]; - writer.PutF4(v.x); - writer.PutF4(v.y); - writer.PutF4(v.z); - } - } - - // UV coordinates - if (mesh.HasTextureCoords(0)) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAPLIST); - const uint16_t count = static_cast(mesh.mNumVertices); - writer.PutU2(count); - - for (unsigned int i = 0; i < mesh.mNumVertices; ++i) { - const aiVector3D& v = mesh.mTextureCoords[0][i]; - writer.PutF4(v.x); - writer.PutF4(v.y); - } - } - - // Faces (indices) - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_FACELIST); - - ai_assert(mesh.mNumFaces <= 0xffff); - - // Count triangles, discard lines and points - uint16_t count = 0; - for (unsigned int i = 0; i < mesh.mNumFaces; ++i) { - const aiFace& f = mesh.mFaces[i]; - if (f.mNumIndices < 3) { - continue; - } - // TRIANGULATE step is a pre-requisite so we should not see polys here - ai_assert(f.mNumIndices == 3); - ++count; - } - - writer.PutU2(count); - for (unsigned int i = 0; i < mesh.mNumFaces; ++i) { - const aiFace& f = mesh.mFaces[i]; - if (f.mNumIndices < 3) { - continue; - } - - for (unsigned int j = 0; j < 3; ++j) { - ai_assert(f.mIndices[j] <= 0xffff); - writer.PutI2(static_cast(f.mIndices[j])); - } - - // Edge visibility flag - writer.PutI2(0x0); - } - - // TODO: write smoothing groups (CHUNK_SMOOLIST) - - WriteFaceMaterialChunk(mesh); - } - - // Transformation matrix by which the mesh vertices have been pre-transformed with. - { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_TRMATRIX); - for (unsigned int r = 0; r < 4; ++r) { - for (unsigned int c = 0; c < 3; ++c) { - writer.PutF4(trafo[r][c]); - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WriteFaceMaterialChunk(const aiMesh& mesh) -{ - ChunkWriter chunk(writer, Discreet3DS::CHUNK_FACEMAT); - const std::string& name = GetMaterialName(*scene->mMaterials[mesh.mMaterialIndex], mesh.mMaterialIndex); - WriteString(name); - - // Because assimp splits meshes by material, only a single - // FACEMAT chunk needs to be written - ai_assert(mesh.mNumFaces <= 0xffff); - const uint16_t count = static_cast(mesh.mNumFaces); - writer.PutU2(count); - - for (unsigned int i = 0; i < mesh.mNumFaces; ++i) { - writer.PutU2(static_cast(i)); - } -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WriteString(const std::string& s) { - for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) { - writer.PutI1(*it); - } - writer.PutI1('\0'); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WriteString(const aiString& s) { - for (std::size_t i = 0; i < s.length; ++i) { - writer.PutI1(s.data[i]); - } - writer.PutI1('\0'); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WriteColor(const aiColor3D& color) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_RGBF); - writer.PutF4(color.r); - writer.PutF4(color.g); - writer.PutF4(color.b); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WritePercentChunk(float f) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_PERCENTF); - writer.PutF4(f); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSExporter::WritePercentChunk(double f) { - ChunkWriter chunk(writer, Discreet3DS::CHUNK_PERCENTD); - writer.PutF8(f); -} - - -#endif // ASSIMP_BUILD_NO_3DS_EXPORTER -#endif // ASSIMP_BUILD_NO_EXPORT diff --git a/src/3rdparty/assimp/code/3DSExporter.h b/src/3rdparty/assimp/code/3DSExporter.h deleted file mode 100644 index fc02e2390..000000000 --- a/src/3rdparty/assimp/code/3DSExporter.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file 3DSExporter.h - * 3DS Exporter Main Header - */ -#ifndef AI_3DSEXPORTER_H_INC -#define AI_3DSEXPORTER_H_INC - -#include -#include - -#include "StreamWriter.h" -#include - -struct aiScene; -struct aiNode; -struct aiMaterial; -struct aiMesh; - -namespace Assimp -{ - -// ------------------------------------------------------------------------------------------------ -/** - * @brief Helper class to export a given scene to a 3DS file. - */ -// ------------------------------------------------------------------------------------------------ -class Discreet3DSExporter { -public: - Discreet3DSExporter(std::shared_ptr outfile, const aiScene* pScene); - ~Discreet3DSExporter(); - -private: - void WriteMeshes(); - void WriteMaterials(); - void WriteTexture(const aiMaterial& mat, aiTextureType type, uint16_t chunk_flags); - void WriteFaceMaterialChunk(const aiMesh& mesh); - int WriteHierarchy(const aiNode& node, int level, int sibling_level); - void WriteString(const std::string& s); - void WriteString(const aiString& s); - void WriteColor(const aiColor3D& color); - void WritePercentChunk(float f); - void WritePercentChunk(double f); - -private: - const aiScene* const scene; - StreamWriterLE writer; - - std::map trafos; - - typedef std::multimap MeshesByNodeMap; - MeshesByNodeMap meshes; - -}; - -} // Namespace Assimp - -#endif // AI_3DSEXPORTER_H_INC diff --git a/src/3rdparty/assimp/code/3DSHelper.h b/src/3rdparty/assimp/code/3DSHelper.h deleted file mode 100644 index 9e701c3dd..000000000 --- a/src/3rdparty/assimp/code/3DSHelper.h +++ /dev/null @@ -1,595 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file Defines helper data structures for the import of 3DS files */ - -#ifndef AI_3DSFILEHELPER_H_INC -#define AI_3DSFILEHELPER_H_INC - -#include "SpatialSort.h" -#include "SmoothingGroups.h" -#include "StringUtils.h" -#include "qnan.h" -#include -#include -#include -#include -#include //sprintf - -namespace Assimp { -namespace D3DS { - -#include "./../include/assimp/Compiler/pushpack1.h" - -// --------------------------------------------------------------------------- -/** Discreet3DS class: Helper class for loading 3ds files. Defines chunks -* and data structures. -*/ -class Discreet3DS { -private: - Discreet3DS() { - // empty - } - - ~Discreet3DS() { - // empty - } - -public: - //! data structure for a single chunk in a .3ds file - struct Chunk { - uint16_t Flag; - uint32_t Size; - } PACK_STRUCT; - - - //! Used for shading field in material3ds structure - //! From AutoDesk 3ds SDK - typedef enum - { - // translated to gouraud shading with wireframe active - Wire = 0x0, - - // if this material is set, no vertex normals will - // be calculated for the model. Face normals + gouraud - Flat = 0x1, - - // standard gouraud shading - Gouraud = 0x2, - - // phong shading - Phong = 0x3, - - // cooktorrance or anistropic phong shading ... - // the exact meaning is unknown, if you know it - // feel free to tell me ;-) - Metal = 0x4, - - // required by the ASE loader - Blinn = 0x5 - } shadetype3ds; - - // Flags for animated keys - enum - { - KEY_USE_TENS = 0x1, - KEY_USE_CONT = 0x2, - KEY_USE_BIAS = 0x4, - KEY_USE_EASE_TO = 0x8, - KEY_USE_EASE_FROM = 0x10 - } ; - - enum - { - - // ******************************************************************** - // Basic chunks which can be found everywhere in the file - CHUNK_VERSION = 0x0002, - CHUNK_RGBF = 0x0010, // float4 R; float4 G; float4 B - CHUNK_RGBB = 0x0011, // int1 R; int1 G; int B - - // Linear color values (gamma = 2.2?) - CHUNK_LINRGBF = 0x0013, // float4 R; float4 G; float4 B - CHUNK_LINRGBB = 0x0012, // int1 R; int1 G; int B - - CHUNK_PERCENTW = 0x0030, // int2 percentage - CHUNK_PERCENTF = 0x0031, // float4 percentage - CHUNK_PERCENTD = 0x0032, // float8 percentage - // ******************************************************************** - - // Prj master chunk - CHUNK_PRJ = 0xC23D, - - // MDLI master chunk - CHUNK_MLI = 0x3DAA, - - // Primary main chunk of the .3ds file - CHUNK_MAIN = 0x4D4D, - - // Mesh main chunk - CHUNK_OBJMESH = 0x3D3D, - - // Specifies the background color of the .3ds file - // This is passed through the material system for - // viewing purposes. - CHUNK_BKGCOLOR = 0x1200, - - // Specifies the ambient base color of the scene. - // This is added to all materials in the file - CHUNK_AMBCOLOR = 0x2100, - - // Specifies the background image for the whole scene - // This value is passed through the material system - // to the viewer - CHUNK_BIT_MAP = 0x1100, - CHUNK_BIT_MAP_EXISTS = 0x1101, - - // ******************************************************************** - // Viewport related stuff. Ignored - CHUNK_DEFAULT_VIEW = 0x3000, - CHUNK_VIEW_TOP = 0x3010, - CHUNK_VIEW_BOTTOM = 0x3020, - CHUNK_VIEW_LEFT = 0x3030, - CHUNK_VIEW_RIGHT = 0x3040, - CHUNK_VIEW_FRONT = 0x3050, - CHUNK_VIEW_BACK = 0x3060, - CHUNK_VIEW_USER = 0x3070, - CHUNK_VIEW_CAMERA = 0x3080, - // ******************************************************************** - - // Mesh chunks - CHUNK_OBJBLOCK = 0x4000, - CHUNK_TRIMESH = 0x4100, - CHUNK_VERTLIST = 0x4110, - CHUNK_VERTFLAGS = 0x4111, - CHUNK_FACELIST = 0x4120, - CHUNK_FACEMAT = 0x4130, - CHUNK_MAPLIST = 0x4140, - CHUNK_SMOOLIST = 0x4150, - CHUNK_TRMATRIX = 0x4160, - CHUNK_MESHCOLOR = 0x4165, - CHUNK_TXTINFO = 0x4170, - CHUNK_LIGHT = 0x4600, - CHUNK_CAMERA = 0x4700, - CHUNK_HIERARCHY = 0x4F00, - - // Specifies the global scaling factor. This is applied - // to the root node's transformation matrix - CHUNK_MASTER_SCALE = 0x0100, - - // ******************************************************************** - // Material chunks - CHUNK_MAT_MATERIAL = 0xAFFF, - - // asciiz containing the name of the material - CHUNK_MAT_MATNAME = 0xA000, - CHUNK_MAT_AMBIENT = 0xA010, // followed by color chunk - CHUNK_MAT_DIFFUSE = 0xA020, // followed by color chunk - CHUNK_MAT_SPECULAR = 0xA030, // followed by color chunk - - // Specifies the shininess of the material - // followed by percentage chunk - CHUNK_MAT_SHININESS = 0xA040, - CHUNK_MAT_SHININESS_PERCENT = 0xA041 , - - // Specifies the shading mode to be used - // followed by a short - CHUNK_MAT_SHADING = 0xA100, - - // NOTE: Emissive color (self illumination) seems not - // to be a color but a single value, type is unknown. - // Make the parser accept both of them. - // followed by percentage chunk (?) - CHUNK_MAT_SELF_ILLUM = 0xA080, - - // Always followed by percentage chunk (?) - CHUNK_MAT_SELF_ILPCT = 0xA084, - - // Always followed by percentage chunk - CHUNK_MAT_TRANSPARENCY = 0xA050, - - // Diffuse texture channel 0 - CHUNK_MAT_TEXTURE = 0xA200, - - // Contains opacity information for each texel - CHUNK_MAT_OPACMAP = 0xA210, - - // Contains a reflection map to be used to reflect - // the environment. This is partially supported. - CHUNK_MAT_REFLMAP = 0xA220, - - // Self Illumination map (emissive colors) - CHUNK_MAT_SELFIMAP = 0xA33d, - - // Bumpmap. Not specified whether it is a heightmap - // or a normal map. Assme it is a heightmap since - // artist normally prefer this format. - CHUNK_MAT_BUMPMAP = 0xA230, - - // Specular map. Seems to influence the specular color - CHUNK_MAT_SPECMAP = 0xA204, - - // Holds shininess data. - CHUNK_MAT_MAT_SHINMAP = 0xA33C, - - // Scaling in U/V direction. - // (need to gen separate UV coordinate set - // and do this by hand) - CHUNK_MAT_MAP_USCALE = 0xA354, - CHUNK_MAT_MAP_VSCALE = 0xA356, - - // Translation in U/V direction. - // (need to gen separate UV coordinate set - // and do this by hand) - CHUNK_MAT_MAP_UOFFSET = 0xA358, - CHUNK_MAT_MAP_VOFFSET = 0xA35a, - - // UV-coordinates rotation around the z-axis - // Assumed to be in radians. - CHUNK_MAT_MAP_ANG = 0xA35C, - - // Tiling flags for 3DS files - CHUNK_MAT_MAP_TILING = 0xa351, - - // Specifies the file name of a texture - CHUNK_MAPFILE = 0xA300, - - // Specifies whether a materail requires two-sided rendering - CHUNK_MAT_TWO_SIDE = 0xA081, - // ******************************************************************** - - // Main keyframer chunk. Contains translation/rotation/scaling data - CHUNK_KEYFRAMER = 0xB000, - - // Supported sub chunks - CHUNK_TRACKINFO = 0xB002, - CHUNK_TRACKOBJNAME = 0xB010, - CHUNK_TRACKDUMMYOBJNAME = 0xB011, - CHUNK_TRACKPIVOT = 0xB013, - CHUNK_TRACKPOS = 0xB020, - CHUNK_TRACKROTATE = 0xB021, - CHUNK_TRACKSCALE = 0xB022, - - // ******************************************************************** - // Keyframes for various other stuff in the file - // Partially ignored - CHUNK_AMBIENTKEY = 0xB001, - CHUNK_TRACKMORPH = 0xB026, - CHUNK_TRACKHIDE = 0xB029, - CHUNK_OBJNUMBER = 0xB030, - CHUNK_TRACKCAMERA = 0xB003, - CHUNK_TRACKFOV = 0xB023, - CHUNK_TRACKROLL = 0xB024, - CHUNK_TRACKCAMTGT = 0xB004, - CHUNK_TRACKLIGHT = 0xB005, - CHUNK_TRACKLIGTGT = 0xB006, - CHUNK_TRACKSPOTL = 0xB007, - CHUNK_FRAMES = 0xB008, - // ******************************************************************** - - // light sub-chunks - CHUNK_DL_OFF = 0x4620, - CHUNK_DL_OUTER_RANGE = 0x465A, - CHUNK_DL_INNER_RANGE = 0x4659, - CHUNK_DL_MULTIPLIER = 0x465B, - CHUNK_DL_EXCLUDE = 0x4654, - CHUNK_DL_ATTENUATE = 0x4625, - CHUNK_DL_SPOTLIGHT = 0x4610, - - // camera sub-chunks - CHUNK_CAM_RANGES = 0x4720 - }; -}; - -// --------------------------------------------------------------------------- -/** Helper structure representing a 3ds mesh face */ -struct Face : public FaceWithSmoothingGroup -{ -}; - -// --------------------------------------------------------------------------- -/** Helper structure representing a texture */ -struct Texture -{ - //! Default constructor - Texture() - : mOffsetU (0.0) - , mOffsetV (0.0) - , mScaleU (1.0) - , mScaleV (1.0) - , mRotation (0.0) - , mMapMode (aiTextureMapMode_Wrap) - , bPrivate() - , iUVSrc (0) - { - mTextureBlend = get_qnan(); - } - - //! Specifies the blend factor for the texture - ai_real mTextureBlend; - - //! Specifies the filename of the texture - std::string mMapName; - - //! Specifies texture coordinate offsets/scaling/rotations - ai_real mOffsetU; - ai_real mOffsetV; - ai_real mScaleU; - ai_real mScaleV; - ai_real mRotation; - - //! Specifies the mapping mode to be used for the texture - aiTextureMapMode mMapMode; - - //! Used internally - bool bPrivate; - int iUVSrc; -}; - -#include "./../include/assimp/Compiler/poppack1.h" - -// --------------------------------------------------------------------------- -/** Helper structure representing a 3ds material */ -struct Material -{ - //! Default constructor. Builds a default name for the material - Material() - : mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black - , mSpecularExponent ( ai_real( 0.0 ) ) - , mShininessStrength ( ai_real( 1.0 ) ) - , mShading(Discreet3DS::Gouraud) - , mTransparency ( ai_real( 1.0 ) ) - , mBumpHeight ( ai_real( 1.0 ) ) - , mTwoSided (false) - { - static int iCnt = 0; - - char szTemp[128]; - ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - } - - //! Name of the material - std::string mName; - //! Diffuse color of the material - aiColor3D mDiffuse; - //! Specular exponent - ai_real mSpecularExponent; - //! Shininess strength, in percent - ai_real mShininessStrength; - //! Specular color of the material - aiColor3D mSpecular; - //! Ambient color of the material - aiColor3D mAmbient; - //! Shading type to be used - Discreet3DS::shadetype3ds mShading; - //! Opacity of the material - ai_real mTransparency; - //! Diffuse texture channel - Texture sTexDiffuse; - //! Opacity texture channel - Texture sTexOpacity; - //! Specular texture channel - Texture sTexSpecular; - //! Reflective texture channel - Texture sTexReflective; - //! Bump texture channel - Texture sTexBump; - //! Emissive texture channel - Texture sTexEmissive; - //! Shininess texture channel - Texture sTexShininess; - //! Scaling factor for the bump values - ai_real mBumpHeight; - //! Emissive color - aiColor3D mEmissive; - //! Ambient texture channel - //! (used by the ASE format) - Texture sTexAmbient; - //! True if the material must be rendered from two sides - bool mTwoSided; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent a 3ds file mesh */ -struct Mesh : public MeshWithSmoothingGroups -{ - //! Default constructor - Mesh() - { - static int iCnt = 0; - - // Generate a default name for the mesh - char szTemp[128]; - ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - } - - //! Name of the mesh - std::string mName; - - //! Texture coordinates - std::vector mTexCoords; - - //! Face materials - std::vector mFaceMaterials; - - //! Local transformation matrix - aiMatrix4x4 mMat; -}; - -// --------------------------------------------------------------------------- -/** Float key - quite similar to aiVectorKey and aiQuatKey. Both are in the - C-API, so it would be difficult to make them a template. */ -struct aiFloatKey -{ - double mTime; ///< The time of this key - ai_real mValue; ///< The value of this key - -#ifdef __cplusplus - - // time is not compared - bool operator == (const aiFloatKey& o) const - {return o.mValue == this->mValue;} - - bool operator != (const aiFloatKey& o) const - {return o.mValue != this->mValue;} - - // Only time is compared. This operator is defined - // for use with std::sort - bool operator < (const aiFloatKey& o) const - {return mTime < o.mTime;} - - bool operator > (const aiFloatKey& o) const - {return mTime > o.mTime;} - -#endif -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent a 3ds file node */ -struct Node -{ - Node(): - mParent(NULL) - , mInstanceNumber(0) - , mHierarchyPos (0) - , mHierarchyIndex (0) - , mInstanceCount (1) - { - static int iCnt = 0; - - // Generate a default name for the node - char szTemp[128]; - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - - aRotationKeys.reserve (20); - aPositionKeys.reserve (20); - aScalingKeys.reserve (20); - } - - ~Node() - { - for (unsigned int i = 0; i < mChildren.size();++i) - delete mChildren[i]; - } - - //! Pointer to the parent node - Node* mParent; - - //! Holds all child nodes - std::vector mChildren; - - //! Name of the node - std::string mName; - - //! InstanceNumber of the node - int32_t mInstanceNumber; - - //! Dummy nodes: real name to be combined with the $$$DUMMY - std::string mDummyName; - - //! Position of the node in the hierarchy (tree depth) - int16_t mHierarchyPos; - - //! Index of the node - int16_t mHierarchyIndex; - - //! Rotation keys loaded from the file - std::vector aRotationKeys; - - //! Position keys loaded from the file - std::vector aPositionKeys; - - //! Scaling keys loaded from the file - std::vector aScalingKeys; - - - // For target lights (spot lights and directional lights): - // The position of the target - std::vector< aiVectorKey > aTargetPositionKeys; - - // For cameras: the camera roll angle - std::vector< aiFloatKey > aCameraRollKeys; - - //! Pivot position loaded from the file - aiVector3D vPivot; - - //instance count, will be kept only for the first node - int32_t mInstanceCount; - - //! Add a child node, setup the right parent node for it - //! \param pc Node to be 'adopted' - inline Node& push_back(Node* pc) - { - mChildren.push_back(pc); - pc->mParent = this; - return *this; - } -}; -// --------------------------------------------------------------------------- -/** Helper structure analogue to aiScene */ -struct Scene -{ - //! List of all materials loaded - //! NOTE: 3ds references materials globally - std::vector mMaterials; - - //! List of all meshes loaded - std::vector mMeshes; - - //! List of all cameras loaded - std::vector mCameras; - - //! List of all lights loaded - std::vector mLights; - - //! Pointer to the root node of the scene - // --- moved to main class - // Node* pcRootNode; -}; - - -} // end of namespace D3DS -} // end of namespace Assimp - -#endif // AI_XFILEHELPER_H_INC diff --git a/src/3rdparty/assimp/code/3DSLoader.cpp b/src/3rdparty/assimp/code/3DSLoader.cpp deleted file mode 100644 index 704884a57..000000000 --- a/src/3rdparty/assimp/code/3DSLoader.cpp +++ /dev/null @@ -1,1433 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file 3DSLoader.cpp - * @brief Implementation of the 3ds importer class - * - * http://www.the-labs.com/Blender/3DS-details.html - */ - - -#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER - -// internal headers -#include "3DSLoader.h" -#include "Macros.h" -#include -#include -#include -#include -#include "StringComparison.h" - -using namespace Assimp; - -static const aiImporterDesc desc = { - "Discreet 3DS Importer", - "", - "", - "Limited animation support", - aiImporterFlags_SupportBinaryFlavour, - 0, - 0, - 0, - 0, - "3ds prj" -}; - - -// ------------------------------------------------------------------------------------------------ -// Begins a new parsing block -// - Reads the current chunk and validates it -// - computes its length -#define ASSIMP_3DS_BEGIN_CHUNK() \ - while (true) { \ - if (stream->GetRemainingSizeToLimit() < sizeof(Discreet3DS::Chunk)){ \ - return; \ - } \ - Discreet3DS::Chunk chunk; \ - ReadChunk(&chunk); \ - int chunkSize = chunk.Size-sizeof(Discreet3DS::Chunk); \ - if(chunkSize <= 0) \ - continue; \ - const unsigned int oldReadLimit = stream->SetReadLimit( \ - stream->GetCurrentPos() + chunkSize); \ - - -// ------------------------------------------------------------------------------------------------ -// End a parsing block -// Must follow at the end of each parsing block, reset chunk end marker to previous value -#define ASSIMP_3DS_END_CHUNK() \ - stream->SkipToReadLimit(); \ - stream->SetReadLimit(oldReadLimit); \ - if (stream->GetRemainingSizeToLimit() == 0) \ - return; \ - } - -// ------------------------------------------------------------------------------------------------ -// Constructor to be privately used by Importer -Discreet3DSImporter::Discreet3DSImporter() - : stream(), - mLastNodeIndex(), - mCurrentNode(), - mRootNode(), - mScene(), - mMasterScale(), - bHasBG(), - bIsPrj() -{} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -Discreet3DSImporter::~Discreet3DSImporter() -{} - -// ------------------------------------------------------------------------------------------------ -// Returns whether the class can handle the format of the given file. -bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const -{ - std::string extension = GetExtension(pFile); - if(extension == "3ds" || extension == "prj" ) { - return true; - } - if (!extension.length() || checkSig) { - uint16_t token[3]; - token[0] = 0x4d4d; - token[1] = 0x3dc2; - //token[2] = 0x3daa; - return CheckMagicToken(pIOHandler,pFile,token,2,0,2); - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -// Loader registry entry -const aiImporterDesc* Discreet3DSImporter::GetInfo () const -{ - return &desc; -} - -// ------------------------------------------------------------------------------------------------ -// Setup configuration properties -void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/) -{ - // nothing to be done for the moment -} - -// ------------------------------------------------------------------------------------------------ -// Imports the given file into the given scene structure. -void Discreet3DSImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ - StreamReaderLE stream(pIOHandler->Open(pFile,"rb")); - this->stream = &stream; - - // We should have at least one chunk - if (stream.GetRemainingSize() < 16) { - throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile); - } - - // Allocate our temporary 3DS representation - mScene = new D3DS::Scene(); - - // Initialize members - mLastNodeIndex = -1; - mCurrentNode = new D3DS::Node(); - mRootNode = mCurrentNode; - mRootNode->mHierarchyPos = -1; - mRootNode->mHierarchyIndex = -1; - mRootNode->mParent = NULL; - mMasterScale = 1.0f; - mBackgroundImage = ""; - bHasBG = false; - bIsPrj = false; - - // Parse the file - ParseMainChunk(); - - // Process all meshes in the file. First check whether all - // face indices have valid values. The generate our - // internal verbose representation. Finally compute normal - // vectors from the smoothing groups we read from the - // file. - for (auto &mesh : mScene->mMeshes) { - if (mesh.mFaces.size() > 0 && mesh.mPositions.size() == 0) { - delete mScene; - throw DeadlyImportError("3DS file contains faces but no vertices: " + pFile); - } - CheckIndices(mesh); - MakeUnique (mesh); - ComputeNormalsWithSmoothingsGroups(mesh); - } - - // Replace all occurrences of the default material with a - // valid material. Generate it if no material containing - // DEFAULT in its name has been found in the file - ReplaceDefaultMaterial(); - - // Convert the scene from our internal representation to an - // aiScene object. This involves copying all meshes, lights - // and cameras to the scene - ConvertScene(pScene); - - // Generate the node graph for the scene. This is a little bit - // tricky since we'll need to split some meshes into submeshes - GenerateNodeGraph(pScene); - - // Now apply the master scaling factor to the scene - ApplyMasterScale(pScene); - - // Delete our internal scene representation and the root - // node, so the whole hierarchy will follow - delete mRootNode; - delete mScene; - - AI_DEBUG_INVALIDATE_PTR(mRootNode); - AI_DEBUG_INVALIDATE_PTR(mScene); - AI_DEBUG_INVALIDATE_PTR(this->stream); -} - -// ------------------------------------------------------------------------------------------------ -// Applies a master-scaling factor to the imported scene -void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene) -{ - // There are some 3DS files with a zero scaling factor - if (!mMasterScale)mMasterScale = 1.0f; - else mMasterScale = 1.0f / mMasterScale; - - // Construct an uniform scaling matrix and multiply with it - pScene->mRootNode->mTransformation *= aiMatrix4x4( - mMasterScale,0.0f, 0.0f, 0.0f, - 0.0f, mMasterScale,0.0f, 0.0f, - 0.0f, 0.0f, mMasterScale,0.0f, - 0.0f, 0.0f, 0.0f, 1.0f); - - // Check whether a scaling track is assigned to the root node. -} - -// ------------------------------------------------------------------------------------------------ -// Reads a new chunk from the file -void Discreet3DSImporter::ReadChunk(Discreet3DS::Chunk* pcOut) -{ - ai_assert(pcOut != NULL); - - pcOut->Flag = stream->GetI2(); - pcOut->Size = stream->GetI4(); - - if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize()) - throw DeadlyImportError("Chunk is too large"); - - if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit()) - DefaultLogger::get()->error("3DS: Chunk overflow"); -} - -// ------------------------------------------------------------------------------------------------ -// Skip a chunk -void Discreet3DSImporter::SkipChunk() -{ - Discreet3DS::Chunk psChunk; - ReadChunk(&psChunk); - - stream->IncPtr(psChunk.Size-sizeof(Discreet3DS::Chunk)); - return; -} - -// ------------------------------------------------------------------------------------------------ -// Process the primary chunk of the file -void Discreet3DSImporter::ParseMainChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // get chunk type - switch (chunk.Flag) - { - - case Discreet3DS::CHUNK_PRJ: - bIsPrj = true; - case Discreet3DS::CHUNK_MAIN: - ParseEditorChunk(); - break; - }; - - ASSIMP_3DS_END_CHUNK(); - // recursively continue processing this hierarchy level - return ParseMainChunk(); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSImporter::ParseEditorChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_OBJMESH: - - ParseObjectChunk(); - break; - - // NOTE: In several documentations in the internet this - // chunk appears at different locations - case Discreet3DS::CHUNK_KEYFRAMER: - - ParseKeyframeChunk(); - break; - - case Discreet3DS::CHUNK_VERSION: - { - // print the version number - char buff[10]; - ASSIMP_itoa10(buff,stream->GetI2()); - DefaultLogger::get()->info(std::string("3DS file format version: ") + buff); - } - break; - }; - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSImporter::ParseObjectChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_OBJBLOCK: - { - unsigned int cnt = 0; - const char* sz = (const char*)stream->GetPtr(); - - // Get the name of the geometry object - while (stream->GetI1())++cnt; - ParseChunk(sz,cnt); - } - break; - - case Discreet3DS::CHUNK_MAT_MATERIAL: - - // Add a new material to the list - mScene->mMaterials.push_back(D3DS::Material()); - ParseMaterialChunk(); - break; - - case Discreet3DS::CHUNK_AMBCOLOR: - - // This is the ambient base color of the scene. - // We add it to the ambient color of all materials - ParseColorChunk(&mClrAmbient,true); - if (is_qnan(mClrAmbient.r)) - { - // We failed to read the ambient base color. - DefaultLogger::get()->error("3DS: Failed to read ambient base color"); - mClrAmbient.r = mClrAmbient.g = mClrAmbient.b = 0.0f; - } - break; - - case Discreet3DS::CHUNK_BIT_MAP: - { - // Specifies the background image. The string should already be - // properly 0 terminated but we need to be sure - unsigned int cnt = 0; - const char* sz = (const char*)stream->GetPtr(); - while (stream->GetI1())++cnt; - mBackgroundImage = std::string(sz,cnt); - } - break; - - case Discreet3DS::CHUNK_BIT_MAP_EXISTS: - bHasBG = true; - break; - - case Discreet3DS::CHUNK_MASTER_SCALE: - // Scene master scaling factor - mMasterScale = stream->GetF4(); - break; - }; - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num) -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // IMPLEMENTATION NOTE; - // Cameras or lights define their transformation in their parent node and in the - // corresponding light or camera chunks. However, we read and process the latter - // to to be able to return valid cameras/lights even if no scenegraph is given. - - // get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_TRIMESH: - { - // this starts a new triangle mesh - mScene->mMeshes.push_back(D3DS::Mesh()); - D3DS::Mesh& m = mScene->mMeshes.back(); - - // Setup the name of the mesh - m.mName = std::string(name, num); - - // Read mesh chunks - ParseMeshChunk(); - } - break; - - case Discreet3DS::CHUNK_LIGHT: - { - // This starts a new light - aiLight* light = new aiLight(); - mScene->mLights.push_back(light); - - light->mName.Set(std::string(name, num)); - - // First read the position of the light - light->mPosition.x = stream->GetF4(); - light->mPosition.y = stream->GetF4(); - light->mPosition.z = stream->GetF4(); - - light->mColorDiffuse = aiColor3D(1.f,1.f,1.f); - - // Now check for further subchunks - if (!bIsPrj) /* fixme */ - ParseLightChunk(); - - // The specular light color is identical the the diffuse light color. The ambient light color - // is equal to the ambient base color of the whole scene. - light->mColorSpecular = light->mColorDiffuse; - light->mColorAmbient = mClrAmbient; - - if (light->mType == aiLightSource_UNDEFINED) - { - // It must be a point light - light->mType = aiLightSource_POINT; - }} - break; - - case Discreet3DS::CHUNK_CAMERA: - { - // This starts a new camera - aiCamera* camera = new aiCamera(); - mScene->mCameras.push_back(camera); - camera->mName.Set(std::string(name, num)); - - // First read the position of the camera - camera->mPosition.x = stream->GetF4(); - camera->mPosition.y = stream->GetF4(); - camera->mPosition.z = stream->GetF4(); - - // Then the camera target - camera->mLookAt.x = stream->GetF4() - camera->mPosition.x; - camera->mLookAt.y = stream->GetF4() - camera->mPosition.y; - camera->mLookAt.z = stream->GetF4() - camera->mPosition.z; - ai_real len = camera->mLookAt.Length(); - if (len < 1e-5) { - - // There are some files with lookat == position. Don't know why or whether it's ok or not. - DefaultLogger::get()->error("3DS: Unable to read proper camera look-at vector"); - camera->mLookAt = aiVector3D(0.0,1.0,0.0); - - } - else camera->mLookAt /= len; - - // And finally - the camera rotation angle, in counter clockwise direction - const ai_real angle = AI_DEG_TO_RAD( stream->GetF4() ); - aiQuaternion quat(camera->mLookAt,angle); - camera->mUp = quat.GetMatrix() * aiVector3D(0.0,1.0,0.0); - - // Read the lense angle - camera->mHorizontalFOV = AI_DEG_TO_RAD ( stream->GetF4() ); - if (camera->mHorizontalFOV < 0.001f) { - camera->mHorizontalFOV = AI_DEG_TO_RAD(45.f); - } - - // Now check for further subchunks - if (!bIsPrj) /* fixme */ { - ParseCameraChunk(); - }} - break; - }; - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSImporter::ParseLightChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - aiLight* light = mScene->mLights.back(); - - // get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_DL_SPOTLIGHT: - // Now we can be sure that the light is a spot light - light->mType = aiLightSource_SPOT; - - // We wouldn't need to normalize here, but we do it - light->mDirection.x = stream->GetF4() - light->mPosition.x; - light->mDirection.y = stream->GetF4() - light->mPosition.y; - light->mDirection.z = stream->GetF4() - light->mPosition.z; - light->mDirection.Normalize(); - - // Now the hotspot and falloff angles - in degrees - light->mAngleInnerCone = AI_DEG_TO_RAD( stream->GetF4() ); - - // FIX: the falloff angle is just an offset - light->mAngleOuterCone = light->mAngleInnerCone+AI_DEG_TO_RAD( stream->GetF4() ); - break; - - // intensity multiplier - case Discreet3DS::CHUNK_DL_MULTIPLIER: - light->mColorDiffuse = light->mColorDiffuse * stream->GetF4(); - break; - - // light color - case Discreet3DS::CHUNK_RGBF: - case Discreet3DS::CHUNK_LINRGBF: - light->mColorDiffuse.r *= stream->GetF4(); - light->mColorDiffuse.g *= stream->GetF4(); - light->mColorDiffuse.b *= stream->GetF4(); - break; - - // light attenuation - case Discreet3DS::CHUNK_DL_ATTENUATE: - light->mAttenuationLinear = stream->GetF4(); - break; - }; - - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSImporter::ParseCameraChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - aiCamera* camera = mScene->mCameras.back(); - - // get chunk type - switch (chunk.Flag) - { - // near and far clip plane - case Discreet3DS::CHUNK_CAM_RANGES: - camera->mClipPlaneNear = stream->GetF4(); - camera->mClipPlaneFar = stream->GetF4(); - break; - } - - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSImporter::ParseKeyframeChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_TRACKCAMTGT: - case Discreet3DS::CHUNK_TRACKSPOTL: - case Discreet3DS::CHUNK_TRACKCAMERA: - case Discreet3DS::CHUNK_TRACKINFO: - case Discreet3DS::CHUNK_TRACKLIGHT: - case Discreet3DS::CHUNK_TRACKLIGTGT: - - // this starts a new mesh hierarchy chunk - ParseHierarchyChunk(chunk.Flag); - break; - }; - - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -// Little helper function for ParseHierarchyChunk -void Discreet3DSImporter::InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCurrent) -{ - if (!pcCurrent) { - mRootNode->push_back(pcNode); - return; - } - - if (pcCurrent->mHierarchyPos == pcNode->mHierarchyPos) { - if(pcCurrent->mParent) { - pcCurrent->mParent->push_back(pcNode); - } - else pcCurrent->push_back(pcNode); - return; - } - return InverseNodeSearch(pcNode,pcCurrent->mParent); -} - -// ------------------------------------------------------------------------------------------------ -// Find a node with a specific name in the import hierarchy -D3DS::Node* FindNode(D3DS::Node* root, const std::string& name) -{ - if (root->mName == name) - return root; - for (std::vector::iterator it = root->mChildren.begin();it != root->mChildren.end(); ++it) { - D3DS::Node* nd; - if (( nd = FindNode(*it,name))) - return nd; - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -// Binary predicate for std::unique() -template -bool KeyUniqueCompare(const T& first, const T& second) -{ - return first.mTime == second.mTime; -} - -// ------------------------------------------------------------------------------------------------ -// Skip some additional import data. -void Discreet3DSImporter::SkipTCBInfo() -{ - unsigned int flags = stream->GetI2(); - - if (!flags) { - // Currently we can't do anything with these values. They occur - // quite rare, so it wouldn't be worth the effort implementing - // them. 3DS ist not really suitable for complex animations, - // so full support is not required. - DefaultLogger::get()->warn("3DS: Skipping TCB animation info"); - } - - if (flags & Discreet3DS::KEY_USE_TENS) { - stream->IncPtr(4); - } - if (flags & Discreet3DS::KEY_USE_BIAS) { - stream->IncPtr(4); - } - if (flags & Discreet3DS::KEY_USE_CONT) { - stream->IncPtr(4); - } - if (flags & Discreet3DS::KEY_USE_EASE_FROM) { - stream->IncPtr(4); - } - if (flags & Discreet3DS::KEY_USE_EASE_TO) { - stream->IncPtr(4); - } -} - -// ------------------------------------------------------------------------------------------------ -// Read hierarchy and keyframe info -void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_TRACKOBJNAME: - - // This is the name of the object to which the track applies. The chunk also - // defines the position of this object in the hierarchy. - { - - // First of all: get the name of the object - unsigned int cnt = 0; - const char* sz = (const char*)stream->GetPtr(); - - while (stream->GetI1())++cnt; - std::string name = std::string(sz,cnt); - - // Now find out whether we have this node already (target animation channels - // are stored with a separate object ID) - D3DS::Node* pcNode = FindNode(mRootNode,name); - int instanceNumber = 1; - - if ( pcNode) - { - // if the source is not a CHUNK_TRACKINFO block it won't be an object instance - if (parent != Discreet3DS::CHUNK_TRACKINFO) - { - mCurrentNode = pcNode; - break; - } - pcNode->mInstanceCount++; - instanceNumber = pcNode->mInstanceCount; - } - pcNode = new D3DS::Node(); - pcNode->mName = name; - pcNode->mInstanceNumber = instanceNumber; - - // There are two unknown values which we can safely ignore - stream->IncPtr(4); - - // Now read the hierarchy position of the object - uint16_t hierarchy = stream->GetI2() + 1; - pcNode->mHierarchyPos = hierarchy; - pcNode->mHierarchyIndex = mLastNodeIndex; - - // And find a proper position in the graph for it - if (mCurrentNode && mCurrentNode->mHierarchyPos == hierarchy) { - - // add to the parent of the last touched node - mCurrentNode->mParent->push_back(pcNode); - mLastNodeIndex++; - } - else if(hierarchy >= mLastNodeIndex) { - - // place it at the current position in the hierarchy - mCurrentNode->push_back(pcNode); - mLastNodeIndex = hierarchy; - } - else { - // need to go back to the specified position in the hierarchy. - InverseNodeSearch(pcNode,mCurrentNode); - mLastNodeIndex++; - } - // Make this node the current node - mCurrentNode = pcNode; - } - break; - - case Discreet3DS::CHUNK_TRACKDUMMYOBJNAME: - - // This is the "real" name of a $$$DUMMY object - { - const char* sz = (const char*) stream->GetPtr(); - while (stream->GetI1()); - - // If object name is DUMMY, take this one instead - if (mCurrentNode->mName == "$$$DUMMY") { - //DefaultLogger::get()->warn("3DS: Skipping dummy object name for non-dummy object"); - mCurrentNode->mName = std::string(sz); - break; - } - } - break; - - case Discreet3DS::CHUNK_TRACKPIVOT: - - if ( Discreet3DS::CHUNK_TRACKINFO != parent) - { - DefaultLogger::get()->warn("3DS: Skipping pivot subchunk for non usual object"); - break; - } - - // Pivot = origin of rotation and scaling - mCurrentNode->vPivot.x = stream->GetF4(); - mCurrentNode->vPivot.y = stream->GetF4(); - mCurrentNode->vPivot.z = stream->GetF4(); - break; - - - // //////////////////////////////////////////////////////////////////// - // POSITION KEYFRAME - case Discreet3DS::CHUNK_TRACKPOS: - { - stream->IncPtr(10); - const unsigned int numFrames = stream->GetI4(); - bool sortKeys = false; - - // This could also be meant as the target position for - // (targeted) lights and cameras - std::vector* l; - if ( Discreet3DS::CHUNK_TRACKCAMTGT == parent || Discreet3DS::CHUNK_TRACKLIGTGT == parent) { - l = & mCurrentNode->aTargetPositionKeys; - } - else l = & mCurrentNode->aPositionKeys; - - l->reserve(numFrames); - for (unsigned int i = 0; i < numFrames;++i) { - const unsigned int fidx = stream->GetI4(); - - // Setup a new position key - aiVectorKey v; - v.mTime = (double)fidx; - - SkipTCBInfo(); - v.mValue.x = stream->GetF4(); - v.mValue.y = stream->GetF4(); - v.mValue.z = stream->GetF4(); - - // check whether we'll need to sort the keys - if (!l->empty() && v.mTime <= l->back().mTime) - sortKeys = true; - - // Add the new keyframe to the list - l->push_back(v); - } - - // Sort all keys with ascending time values and remove duplicates? - if (sortKeys) { - std::stable_sort(l->begin(),l->end()); - l->erase ( std::unique (l->begin(),l->end(),&KeyUniqueCompare), l->end() ); - }} - - break; - - // //////////////////////////////////////////////////////////////////// - // CAMERA ROLL KEYFRAME - case Discreet3DS::CHUNK_TRACKROLL: - { - // roll keys are accepted for cameras only - if (parent != Discreet3DS::CHUNK_TRACKCAMERA) { - DefaultLogger::get()->warn("3DS: Ignoring roll track for non-camera object"); - break; - } - bool sortKeys = false; - std::vector* l = &mCurrentNode->aCameraRollKeys; - - stream->IncPtr(10); - const unsigned int numFrames = stream->GetI4(); - l->reserve(numFrames); - for (unsigned int i = 0; i < numFrames;++i) { - const unsigned int fidx = stream->GetI4(); - - // Setup a new position key - aiFloatKey v; - v.mTime = (double)fidx; - - // This is just a single float - SkipTCBInfo(); - v.mValue = stream->GetF4(); - - // Check whether we'll need to sort the keys - if (!l->empty() && v.mTime <= l->back().mTime) - sortKeys = true; - - // Add the new keyframe to the list - l->push_back(v); - } - - // Sort all keys with ascending time values and remove duplicates? - if (sortKeys) { - std::stable_sort(l->begin(),l->end()); - l->erase ( std::unique (l->begin(),l->end(),&KeyUniqueCompare), l->end() ); - }} - break; - - - // //////////////////////////////////////////////////////////////////// - // CAMERA FOV KEYFRAME - case Discreet3DS::CHUNK_TRACKFOV: - { - DefaultLogger::get()->error("3DS: Skipping FOV animation track. " - "This is not supported"); - } - break; - - - // //////////////////////////////////////////////////////////////////// - // ROTATION KEYFRAME - case Discreet3DS::CHUNK_TRACKROTATE: - { - stream->IncPtr(10); - const unsigned int numFrames = stream->GetI4(); - - bool sortKeys = false; - std::vector* l = &mCurrentNode->aRotationKeys; - l->reserve(numFrames); - - for (unsigned int i = 0; i < numFrames;++i) { - const unsigned int fidx = stream->GetI4(); - SkipTCBInfo(); - - aiQuatKey v; - v.mTime = (double)fidx; - - // The rotation keyframe is given as an axis-angle pair - const float rad = stream->GetF4(); - aiVector3D axis; - axis.x = stream->GetF4(); - axis.y = stream->GetF4(); - axis.z = stream->GetF4(); - - if (!axis.x && !axis.y && !axis.z) - axis.y = 1.f; - - // Construct a rotation quaternion from the axis-angle pair - v.mValue = aiQuaternion(axis,rad); - - // Check whether we'll need to sort the keys - if (!l->empty() && v.mTime <= l->back().mTime) - sortKeys = true; - - // add the new keyframe to the list - l->push_back(v); - } - // Sort all keys with ascending time values and remove duplicates? - if (sortKeys) { - std::stable_sort(l->begin(),l->end()); - l->erase ( std::unique (l->begin(),l->end(),&KeyUniqueCompare), l->end() ); - }} - break; - - // //////////////////////////////////////////////////////////////////// - // SCALING KEYFRAME - case Discreet3DS::CHUNK_TRACKSCALE: - { - stream->IncPtr(10); - const unsigned int numFrames = stream->GetI2(); - stream->IncPtr(2); - - bool sortKeys = false; - std::vector* l = &mCurrentNode->aScalingKeys; - l->reserve(numFrames); - - for (unsigned int i = 0; i < numFrames;++i) { - const unsigned int fidx = stream->GetI4(); - SkipTCBInfo(); - - // Setup a new key - aiVectorKey v; - v.mTime = (double)fidx; - - // ... and read its value - v.mValue.x = stream->GetF4(); - v.mValue.y = stream->GetF4(); - v.mValue.z = stream->GetF4(); - - // check whether we'll need to sort the keys - if (!l->empty() && v.mTime <= l->back().mTime) - sortKeys = true; - - // Remove zero-scalings on singular axes - they've been reported to be there erroneously in some strange files - if (!v.mValue.x) v.mValue.x = 1.f; - if (!v.mValue.y) v.mValue.y = 1.f; - if (!v.mValue.z) v.mValue.z = 1.f; - - l->push_back(v); - } - // Sort all keys with ascending time values and remove duplicates? - if (sortKeys) { - std::stable_sort(l->begin(),l->end()); - l->erase ( std::unique (l->begin(),l->end(),&KeyUniqueCompare), l->end() ); - }} - break; - }; - - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -// Read a face chunk - it contains smoothing groups and material assignments -void Discreet3DSImporter::ParseFaceChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // Get the mesh we're currently working on - D3DS::Mesh& mMesh = mScene->mMeshes.back(); - - // Get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_SMOOLIST: - { - // This is the list of smoothing groups - a bitfield for every face. - // Up to 32 smoothing groups assigned to a single face. - unsigned int num = chunkSize/4, m = 0; - if (num > mMesh.mFaces.size()) { - throw DeadlyImportError("3DS: More smoothing groups than faces"); - } - for (std::vector::iterator i = mMesh.mFaces.begin(); m != num;++i, ++m) { - // nth bit is set for nth smoothing group - (*i).iSmoothGroup = stream->GetI4(); - }} - break; - - case Discreet3DS::CHUNK_FACEMAT: - { - // at fist an asciiz with the material name - const char* sz = (const char*)stream->GetPtr(); - while (stream->GetI1()); - - // find the index of the material - unsigned int idx = 0xcdcdcdcd, cnt = 0; - for (std::vector::const_iterator i = mScene->mMaterials.begin();i != mScene->mMaterials.end();++i,++cnt) { - // use case independent comparisons. hopefully it will work. - if ((*i).mName.length() && !ASSIMP_stricmp(sz, (*i).mName.c_str())) { - idx = cnt; - break; - } - } - if (0xcdcdcdcd == idx) { - DefaultLogger::get()->error(std::string("3DS: Unknown material: ") + sz); - } - - // Now continue and read all material indices - cnt = (uint16_t)stream->GetI2(); - for (unsigned int i = 0; i < cnt;++i) { - unsigned int fidx = (uint16_t)stream->GetI2(); - - // check range - if (fidx >= mMesh.mFaceMaterials.size()) { - DefaultLogger::get()->error("3DS: Invalid face index in face material list"); - } - else mMesh.mFaceMaterials[fidx] = idx; - }} - break; - }; - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -// Read a mesh chunk. Here's the actual mesh data -void Discreet3DSImporter::ParseMeshChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // Get the mesh we're currently working on - D3DS::Mesh& mMesh = mScene->mMeshes.back(); - - // get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_VERTLIST: - { - // This is the list of all vertices in the current mesh - int num = (int)(uint16_t)stream->GetI2(); - mMesh.mPositions.reserve(num); - while (num-- > 0) { - aiVector3D v; - v.x = stream->GetF4(); - v.y = stream->GetF4(); - v.z = stream->GetF4(); - mMesh.mPositions.push_back(v); - }} - break; - case Discreet3DS::CHUNK_TRMATRIX: - { - // This is the RLEATIVE transformation matrix of the current mesh. Vertices are - // pretransformed by this matrix wonder. - mMesh.mMat.a1 = stream->GetF4(); - mMesh.mMat.b1 = stream->GetF4(); - mMesh.mMat.c1 = stream->GetF4(); - mMesh.mMat.a2 = stream->GetF4(); - mMesh.mMat.b2 = stream->GetF4(); - mMesh.mMat.c2 = stream->GetF4(); - mMesh.mMat.a3 = stream->GetF4(); - mMesh.mMat.b3 = stream->GetF4(); - mMesh.mMat.c3 = stream->GetF4(); - mMesh.mMat.a4 = stream->GetF4(); - mMesh.mMat.b4 = stream->GetF4(); - mMesh.mMat.c4 = stream->GetF4(); - } - break; - - case Discreet3DS::CHUNK_MAPLIST: - { - // This is the list of all UV coords in the current mesh - int num = (int)(uint16_t)stream->GetI2(); - mMesh.mTexCoords.reserve(num); - while (num-- > 0) { - aiVector3D v; - v.x = stream->GetF4(); - v.y = stream->GetF4(); - mMesh.mTexCoords.push_back(v); - }} - break; - - case Discreet3DS::CHUNK_FACELIST: - { - // This is the list of all faces in the current mesh - int num = (int)(uint16_t)stream->GetI2(); - mMesh.mFaces.reserve(num); - while (num-- > 0) { - // 3DS faces are ALWAYS triangles - mMesh.mFaces.push_back(D3DS::Face()); - D3DS::Face& sFace = mMesh.mFaces.back(); - - sFace.mIndices[0] = (uint16_t)stream->GetI2(); - sFace.mIndices[1] = (uint16_t)stream->GetI2(); - sFace.mIndices[2] = (uint16_t)stream->GetI2(); - - stream->IncPtr(2); // skip edge visibility flag - } - - // Resize the material array (0xcdcdcdcd marks the default material; so if a face is - // not referenced by a material, $$DEFAULT will be assigned to it) - mMesh.mFaceMaterials.resize(mMesh.mFaces.size(),0xcdcdcdcd); - - // Larger 3DS files could have multiple FACE chunks here - chunkSize = stream->GetRemainingSizeToLimit(); - if ( chunkSize > (int) sizeof(Discreet3DS::Chunk ) ) - ParseFaceChunk(); - } - break; - }; - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -// Read a 3DS material chunk -void Discreet3DSImporter::ParseMaterialChunk() -{ - ASSIMP_3DS_BEGIN_CHUNK(); - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_MAT_MATNAME: - - { - // The material name string is already zero-terminated, but we need to be sure ... - const char* sz = (const char*)stream->GetPtr(); - unsigned int cnt = 0; - while (stream->GetI1()) - ++cnt; - - if (!cnt) { - // This may not be, we use the default name instead - DefaultLogger::get()->error("3DS: Empty material name"); - } - else mScene->mMaterials.back().mName = std::string(sz,cnt); - } - break; - - case Discreet3DS::CHUNK_MAT_DIFFUSE: - { - // This is the diffuse material color - aiColor3D* pc = &mScene->mMaterials.back().mDiffuse; - ParseColorChunk(pc); - if (is_qnan(pc->r)) { - // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read DIFFUSE chunk"); - pc->r = pc->g = pc->b = 1.0f; - }} - break; - - case Discreet3DS::CHUNK_MAT_SPECULAR: - { - // This is the specular material color - aiColor3D* pc = &mScene->mMaterials.back().mSpecular; - ParseColorChunk(pc); - if (is_qnan(pc->r)) { - // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read SPECULAR chunk"); - pc->r = pc->g = pc->b = 1.0f; - }} - break; - - case Discreet3DS::CHUNK_MAT_AMBIENT: - { - // This is the ambient material color - aiColor3D* pc = &mScene->mMaterials.back().mAmbient; - ParseColorChunk(pc); - if (is_qnan(pc->r)) { - // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read AMBIENT chunk"); - pc->r = pc->g = pc->b = 0.0f; - }} - break; - - case Discreet3DS::CHUNK_MAT_SELF_ILLUM: - { - // This is the emissive material color - aiColor3D* pc = &mScene->mMaterials.back().mEmissive; - ParseColorChunk(pc); - if (is_qnan(pc->r)) { - // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read EMISSIVE chunk"); - pc->r = pc->g = pc->b = 0.0f; - }} - break; - - case Discreet3DS::CHUNK_MAT_TRANSPARENCY: - { - // This is the material's transparency - ai_real* pcf = &mScene->mMaterials.back().mTransparency; - *pcf = ParsePercentageChunk(); - - // NOTE: transparency, not opacity - if (is_qnan(*pcf)) - *pcf = ai_real( 1.0 ); - else - *pcf = ai_real( 1.0 ) - *pcf * (ai_real)0xFFFF / ai_real( 100.0 ); - } - break; - - case Discreet3DS::CHUNK_MAT_SHADING: - // This is the material shading mode - mScene->mMaterials.back().mShading = (D3DS::Discreet3DS::shadetype3ds)stream->GetI2(); - break; - - case Discreet3DS::CHUNK_MAT_TWO_SIDE: - // This is the two-sided flag - mScene->mMaterials.back().mTwoSided = true; - break; - - case Discreet3DS::CHUNK_MAT_SHININESS: - { // This is the shininess of the material - ai_real* pcf = &mScene->mMaterials.back().mSpecularExponent; - *pcf = ParsePercentageChunk(); - if (is_qnan(*pcf)) - *pcf = 0.0; - else *pcf *= (ai_real)0xFFFF; - } - break; - - case Discreet3DS::CHUNK_MAT_SHININESS_PERCENT: - { // This is the shininess strength of the material - ai_real* pcf = &mScene->mMaterials.back().mShininessStrength; - *pcf = ParsePercentageChunk(); - if (is_qnan(*pcf)) - *pcf = ai_real( 0.0 ); - else - *pcf *= (ai_real)0xffff / ai_real( 100.0 ); - } - break; - - case Discreet3DS::CHUNK_MAT_SELF_ILPCT: - { // This is the self illumination strength of the material - ai_real f = ParsePercentageChunk(); - if (is_qnan(f)) - f = ai_real( 0.0 ); - else - f *= (ai_real)0xFFFF / ai_real( 100.0 ); - mScene->mMaterials.back().mEmissive = aiColor3D(f,f,f); - } - break; - - // Parse texture chunks - case Discreet3DS::CHUNK_MAT_TEXTURE: - // Diffuse texture - ParseTextureChunk(&mScene->mMaterials.back().sTexDiffuse); - break; - case Discreet3DS::CHUNK_MAT_BUMPMAP: - // Height map - ParseTextureChunk(&mScene->mMaterials.back().sTexBump); - break; - case Discreet3DS::CHUNK_MAT_OPACMAP: - // Opacity texture - ParseTextureChunk(&mScene->mMaterials.back().sTexOpacity); - break; - case Discreet3DS::CHUNK_MAT_MAT_SHINMAP: - // Shininess map - ParseTextureChunk(&mScene->mMaterials.back().sTexShininess); - break; - case Discreet3DS::CHUNK_MAT_SPECMAP: - // Specular map - ParseTextureChunk(&mScene->mMaterials.back().sTexSpecular); - break; - case Discreet3DS::CHUNK_MAT_SELFIMAP: - // Self-illumination (emissive) map - ParseTextureChunk(&mScene->mMaterials.back().sTexEmissive); - break; - case Discreet3DS::CHUNK_MAT_REFLMAP: - // Reflection map - ParseTextureChunk(&mScene->mMaterials.back().sTexReflective); - break; - }; - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) -{ - ASSIMP_3DS_BEGIN_CHUNK(); - - // get chunk type - switch (chunk.Flag) - { - case Discreet3DS::CHUNK_MAPFILE: - { - // The material name string is already zero-terminated, but we need to be sure ... - const char* sz = (const char*)stream->GetPtr(); - unsigned int cnt = 0; - while (stream->GetI1()) - ++cnt; - pcOut->mMapName = std::string(sz,cnt); - } - break; - - - case Discreet3DS::CHUNK_PERCENTD: - // Manually parse the blend factor - pcOut->mTextureBlend = ai_real( stream->GetF8() ); - break; - - case Discreet3DS::CHUNK_PERCENTF: - // Manually parse the blend factor - pcOut->mTextureBlend = stream->GetF4(); - break; - - case Discreet3DS::CHUNK_PERCENTW: - // Manually parse the blend factor - pcOut->mTextureBlend = (ai_real)((uint16_t)stream->GetI2()) / ai_real( 100.0 ); - break; - - case Discreet3DS::CHUNK_MAT_MAP_USCALE: - // Texture coordinate scaling in the U direction - pcOut->mScaleU = stream->GetF4(); - if (0.0f == pcOut->mScaleU) - { - DefaultLogger::get()->warn("Texture coordinate scaling in the x direction is zero. Assuming 1."); - pcOut->mScaleU = 1.0f; - } - break; - case Discreet3DS::CHUNK_MAT_MAP_VSCALE: - // Texture coordinate scaling in the V direction - pcOut->mScaleV = stream->GetF4(); - if (0.0f == pcOut->mScaleV) - { - DefaultLogger::get()->warn("Texture coordinate scaling in the y direction is zero. Assuming 1."); - pcOut->mScaleV = 1.0f; - } - break; - - case Discreet3DS::CHUNK_MAT_MAP_UOFFSET: - // Texture coordinate offset in the U direction - pcOut->mOffsetU = -stream->GetF4(); - break; - - case Discreet3DS::CHUNK_MAT_MAP_VOFFSET: - // Texture coordinate offset in the V direction - pcOut->mOffsetV = stream->GetF4(); - break; - - case Discreet3DS::CHUNK_MAT_MAP_ANG: - // Texture coordinate rotation, CCW in DEGREES - pcOut->mRotation = -AI_DEG_TO_RAD( stream->GetF4() ); - break; - - case Discreet3DS::CHUNK_MAT_MAP_TILING: - { - const uint16_t iFlags = stream->GetI2(); - - // Get the mapping mode (for both axes) - if (iFlags & 0x2u) - pcOut->mMapMode = aiTextureMapMode_Mirror; - - else if (iFlags & 0x10u) - pcOut->mMapMode = aiTextureMapMode_Decal; - - // wrapping in all remaining cases - else pcOut->mMapMode = aiTextureMapMode_Wrap; - } - break; - }; - - ASSIMP_3DS_END_CHUNK(); -} - -// ------------------------------------------------------------------------------------------------ -// Read a percentage chunk -ai_real Discreet3DSImporter::ParsePercentageChunk() -{ - Discreet3DS::Chunk chunk; - ReadChunk(&chunk); - - if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag) - return stream->GetF4(); - else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag) - return (ai_real)((uint16_t)stream->GetI2()) / (ai_real)0xFFFF; - return get_qnan(); -} - -// ------------------------------------------------------------------------------------------------ -// Read a color chunk. If a percentage chunk is found instead it is read as a grayscale color -void Discreet3DSImporter::ParseColorChunk( aiColor3D* out, bool acceptPercent ) -{ - ai_assert(out != NULL); - - // error return value - const ai_real qnan = get_qnan(); - static const aiColor3D clrError = aiColor3D(qnan,qnan,qnan); - - Discreet3DS::Chunk chunk; - ReadChunk(&chunk); - const unsigned int diff = chunk.Size - sizeof(Discreet3DS::Chunk); - - bool bGamma = false; - - // Get the type of the chunk - switch(chunk.Flag) - { - case Discreet3DS::CHUNK_LINRGBF: - bGamma = true; - - case Discreet3DS::CHUNK_RGBF: - if (sizeof(float) * 3 > diff) { - *out = clrError; - return; - } - out->r = stream->GetF4(); - out->g = stream->GetF4(); - out->b = stream->GetF4(); - break; - - case Discreet3DS::CHUNK_LINRGBB: - bGamma = true; - case Discreet3DS::CHUNK_RGBB: - { - if ( sizeof( char ) * 3 > diff ) { - *out = clrError; - return; - } - const ai_real invVal = ai_real( 1.0 ) / ai_real( 255.0 ); - out->r = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal; - out->g = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal; - out->b = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal; - } - break; - - // Percentage chunks are accepted, too. - case Discreet3DS::CHUNK_PERCENTF: - if (acceptPercent && 4 <= diff) { - out->g = out->b = out->r = stream->GetF4(); - break; - } - *out = clrError; - return; - - case Discreet3DS::CHUNK_PERCENTW: - if (acceptPercent && 1 <= diff) { - out->g = out->b = out->r = (ai_real)(uint8_t)stream->GetI1() / ai_real( 255.0 ); - break; - } - *out = clrError; - return; - - default: - stream->IncPtr(diff); - // Skip unknown chunks, hope this won't cause any problems. - return ParseColorChunk(out,acceptPercent); - }; - (void)bGamma; -} - -#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER diff --git a/src/3rdparty/assimp/code/3DSLoader.h b/src/3rdparty/assimp/code/3DSLoader.h deleted file mode 100644 index 0e377180b..000000000 --- a/src/3rdparty/assimp/code/3DSLoader.h +++ /dev/null @@ -1,283 +0,0 @@ - -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file 3DSLoader.h - * @brief 3DS File format loader - */ -#ifndef AI_3DSIMPORTER_H_INC -#define AI_3DSIMPORTER_H_INC - -#include "BaseImporter.h" -#include - -#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER - -#include "3DSHelper.h" -#include "StreamReader.h" - -struct aiNode; - -namespace Assimp { - - -using namespace D3DS; - -// --------------------------------------------------------------------------------- -/** Importer class for 3D Studio r3 and r4 3DS files - */ -class Discreet3DSImporter : public BaseImporter -{ -public: - - Discreet3DSImporter(); - ~Discreet3DSImporter(); - -public: - - // ------------------------------------------------------------------- - /** Returns whether the class can handle the format of the given file. - * See BaseImporter::CanRead() for details. - */ - bool CanRead( const std::string& pFile, IOSystem* pIOHandler, - bool checkSig) const; - - // ------------------------------------------------------------------- - /** Called prior to ReadFile(). - * The function is a request to the importer to update its configuration - * basing on the Importer's configuration property list. - */ - void SetupProperties(const Importer* pImp); - -protected: - - // ------------------------------------------------------------------- - /** Return importer meta information. - * See #BaseImporter::GetInfo for the details - */ - const aiImporterDesc* GetInfo () const; - - // ------------------------------------------------------------------- - /** Imports the given file into the given scene structure. - * See BaseImporter::InternReadFile() for details - */ - void InternReadFile( const std::string& pFile, aiScene* pScene, - IOSystem* pIOHandler); - - // ------------------------------------------------------------------- - /** Converts a temporary material to the outer representation - */ - void ConvertMaterial(D3DS::Material& p_cMat, - aiMaterial& p_pcOut); - - // ------------------------------------------------------------------- - /** Read a chunk - * - * @param pcOut Receives the current chunk - */ - void ReadChunk(Discreet3DS::Chunk* pcOut); - - // ------------------------------------------------------------------- - /** Parse a percentage chunk. mCurrent will point to the next - * chunk behind afterwards. If no percentage chunk is found - * QNAN is returned. - */ - ai_real ParsePercentageChunk(); - - // ------------------------------------------------------------------- - /** Parse a color chunk. mCurrent will point to the next - * chunk behind afterwards. If no color chunk is found - * QNAN is returned in all members. - */ - void ParseColorChunk(aiColor3D* p_pcOut, - bool p_bAcceptPercent = true); - - - // ------------------------------------------------------------------- - /** Skip a chunk in the file - */ - void SkipChunk(); - - // ------------------------------------------------------------------- - /** Generate the nodegraph - */ - void GenerateNodeGraph(aiScene* pcOut); - - // ------------------------------------------------------------------- - /** Parse a main top-level chunk in the file - */ - void ParseMainChunk(); - - // ------------------------------------------------------------------- - /** Parse a top-level chunk in the file - */ - void ParseChunk(const char* name, unsigned int num); - - // ------------------------------------------------------------------- - /** Parse a top-level editor chunk in the file - */ - void ParseEditorChunk(); - - // ------------------------------------------------------------------- - /** Parse a top-level object chunk in the file - */ - void ParseObjectChunk(); - - // ------------------------------------------------------------------- - /** Parse a material chunk in the file - */ - void ParseMaterialChunk(); - - // ------------------------------------------------------------------- - /** Parse a mesh chunk in the file - */ - void ParseMeshChunk(); - - // ------------------------------------------------------------------- - /** Parse a light chunk in the file - */ - void ParseLightChunk(); - - // ------------------------------------------------------------------- - /** Parse a camera chunk in the file - */ - void ParseCameraChunk(); - - // ------------------------------------------------------------------- - /** Parse a face list chunk in the file - */ - void ParseFaceChunk(); - - // ------------------------------------------------------------------- - /** Parse a keyframe chunk in the file - */ - void ParseKeyframeChunk(); - - // ------------------------------------------------------------------- - /** Parse a hierarchy chunk in the file - */ - void ParseHierarchyChunk(uint16_t parent); - - // ------------------------------------------------------------------- - /** Parse a texture chunk in the file - */ - void ParseTextureChunk(D3DS::Texture* pcOut); - - // ------------------------------------------------------------------- - /** Convert the meshes in the file - */ - void ConvertMeshes(aiScene* pcOut); - - // ------------------------------------------------------------------- - /** Replace the default material in the scene - */ - void ReplaceDefaultMaterial(); - - // ------------------------------------------------------------------- - /** Convert the whole scene - */ - void ConvertScene(aiScene* pcOut); - - // ------------------------------------------------------------------- - /** generate unique vertices for a mesh - */ - void MakeUnique(D3DS::Mesh& sMesh); - - // ------------------------------------------------------------------- - /** Add a node to the node graph - */ - void AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,D3DS::Node* pcIn, - aiMatrix4x4& absTrafo); - - // ------------------------------------------------------------------- - /** Search for a node in the graph. - * Called recursively - */ - void InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCurrent); - - // ------------------------------------------------------------------- - /** Apply the master scaling factor to the mesh - */ - void ApplyMasterScale(aiScene* pScene); - - // ------------------------------------------------------------------- - /** Clamp all indices in the file to a valid range - */ - void CheckIndices(D3DS::Mesh& sMesh); - - // ------------------------------------------------------------------- - /** Skip the TCB info in a track key - */ - void SkipTCBInfo(); - -protected: - - /** Stream to read from */ - StreamReaderLE* stream; - - /** Last touched node index */ - short mLastNodeIndex; - - /** Current node, root node */ - D3DS::Node* mCurrentNode, *mRootNode; - - /** Scene under construction */ - D3DS::Scene* mScene; - - /** Ambient base color of the scene */ - aiColor3D mClrAmbient; - - /** Master scaling factor of the scene */ - ai_real mMasterScale; - - /** Path to the background image of the scene */ - std::string mBackgroundImage; - bool bHasBG; - - /** true if PRJ file */ - bool bIsPrj; -}; - -} // end of namespace Assimp - -#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER - -#endif // AI_3DSIMPORTER_H_INC diff --git a/src/3rdparty/assimp/code/3MFXmlTags.h b/src/3rdparty/assimp/code/3MFXmlTags.h deleted file mode 100644 index 7e47422f1..000000000 --- a/src/3rdparty/assimp/code/3MFXmlTags.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ -#pragma once - -namespace Assimp { -namespace D3MF { - -namespace XmlTag { - static const std::string model = "model"; - static const std::string model_unit = "unit"; - static const std::string metadata = "metadata"; - static const std::string resources = "resources"; - static const std::string object = "object"; - static const std::string mesh = "mesh"; - static const std::string vertices = "vertices"; - static const std::string vertex = "vertex"; - static const std::string triangles = "triangles"; - static const std::string triangle = "triangle"; - static const std::string x = "x"; - static const std::string y = "y"; - static const std::string z = "z"; - static const std::string v1 = "v1"; - static const std::string v2 = "v2"; - static const std::string v3 = "v3"; - static const std::string id = "id"; - static const std::string name = "name"; - static const std::string type = "type"; - static const std::string build = "build"; - static const std::string item = "item"; - static const std::string objectid = "objectid"; - static const std::string transform = "transform"; - - static const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml"; - static const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels"; - static const std::string SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types"; - static const std::string SCHEMA_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships"; - static const std::string RELS_RELATIONSHIP_CONTAINER = "Relationships"; - static const std::string RELS_RELATIONSHIP_NODE = "Relationship"; - static const std::string RELS_ATTRIB_TARGET = "Target"; - static const std::string RELS_ATTRIB_TYPE = "Type"; - static const std::string RELS_ATTRIB_ID = "Id"; - static const std::string PACKAGE_START_PART_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel"; - static const std::string PACKAGE_PRINT_TICKET_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket"; - static const std::string PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture"; - static const std::string PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"; - static const std::string PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"; - -} - -} // Namespace D3MF -} // Namespace Assimp diff --git a/src/3rdparty/assimp/code/ACLoader.cpp b/src/3rdparty/assimp/code/ACLoader.cpp deleted file mode 100644 index a30baa75a..000000000 --- a/src/3rdparty/assimp/code/ACLoader.cpp +++ /dev/null @@ -1,909 +0,0 @@ - -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file Implementation of the AC3D importer class */ - - - -#ifndef ASSIMP_BUILD_NO_AC_IMPORTER - -// internal headers -#include "ACLoader.h" -#include "ParsingUtils.h" -#include "fast_atof.h" -#include "Subdivision.h" -#include "Importer.h" -#include "BaseImporter.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Assimp; - -static const aiImporterDesc desc = { - "AC3D Importer", - "", - "", - "", - aiImporterFlags_SupportTextFlavour, - 0, - 0, - 0, - 0, - "ac acc ac3d" -}; - -// ------------------------------------------------------------------------------------------------ -// skip to the next token -#define AI_AC_SKIP_TO_NEXT_TOKEN() \ - if (!SkipSpaces(&buffer)) \ - { \ - DefaultLogger::get()->error("AC3D: Unexpected EOF/EOL"); \ - continue; \ - } - -// ------------------------------------------------------------------------------------------------ -// read a string (may be enclosed in double quotation marks). buffer must point to " -#define AI_AC_GET_STRING(out) \ - if (*buffer == '\0') { \ - throw DeadlyImportError("AC3D: Unexpected EOF in string"); \ - } \ - ++buffer; \ - const char* sz = buffer; \ - while ('\"' != *buffer) \ - { \ - if (IsLineEnd( *buffer )) \ - { \ - DefaultLogger::get()->error("AC3D: Unexpected EOF/EOL in string"); \ - out = "ERROR"; \ - break; \ - } \ - ++buffer; \ - } \ - if (IsLineEnd( *buffer ))continue; \ - out = std::string(sz,(unsigned int)(buffer-sz)); \ - ++buffer; - - -// ------------------------------------------------------------------------------------------------ -// read 1 to n floats prefixed with an optional predefined identifier -#define AI_AC_CHECKED_LOAD_FLOAT_ARRAY(name,name_length,num,out) \ - AI_AC_SKIP_TO_NEXT_TOKEN(); \ - if (name_length) \ - { \ - if (strncmp(buffer,name,name_length) || !IsSpace(buffer[name_length])) \ - { \ - DefaultLogger::get()->error("AC3D: Unexpexted token. " name " was expected."); \ - continue; \ - } \ - buffer += name_length+1; \ - } \ - for (unsigned int i = 0; i < num;++i) \ - { \ - AI_AC_SKIP_TO_NEXT_TOKEN(); \ - buffer = fast_atoreal_move(buffer,((float*)out)[i]); \ - } - - -// ------------------------------------------------------------------------------------------------ -// Constructor to be privately used by Importer -AC3DImporter::AC3DImporter() - : buffer(), - configSplitBFCull(), - configEvalSubdivision(), - mNumMeshes(), - mLights(), - lights(), - groups(), - polys(), - worlds() -{ - // nothing to be done here -} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -AC3DImporter::~AC3DImporter() -{ - // nothing to be done here -} - -// ------------------------------------------------------------------------------------------------ -// Returns whether the class can handle the format of the given file. -bool AC3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const -{ - std::string extension = GetExtension(pFile); - - // fixme: are acc and ac3d *really* used? Some sources say they are - if(extension == "ac" || extension == "ac3d" || extension == "acc") { - return true; - } - if (!extension.length() || checkSig) { - uint32_t token = AI_MAKE_MAGIC("AC3D"); - return CheckMagicToken(pIOHandler,pFile,&token,1,0); - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -// Loader meta information -const aiImporterDesc* AC3DImporter::GetInfo () const -{ - return &desc; -} - -// ------------------------------------------------------------------------------------------------ -// Get a pointer to the next line from the file -bool AC3DImporter::GetNextLine( ) -{ - SkipLine(&buffer); - return SkipSpaces(&buffer); -} - -// ------------------------------------------------------------------------------------------------ -// Parse an object section in an AC file -void AC3DImporter::LoadObjectSection(std::vector& objects) -{ - if (!TokenMatch(buffer,"OBJECT",6)) - return; - - SkipSpaces(&buffer); - - ++mNumMeshes; - - objects.push_back(Object()); - Object& obj = objects.back(); - - aiLight* light = NULL; - if (!ASSIMP_strincmp(buffer,"light",5)) - { - // This is a light source. Add it to the list - mLights->push_back(light = new aiLight()); - - // Return a point light with no attenuation - light->mType = aiLightSource_POINT; - light->mColorDiffuse = light->mColorSpecular = aiColor3D(1.f,1.f,1.f); - light->mAttenuationConstant = 1.f; - - // Generate a default name for both the light source and the node - // FIXME - what's the right way to print a size_t? Is 'zu' universally available? stick with the safe version. - light->mName.length = ::ai_snprintf(light->mName.data, MAXLEN, "ACLight_%i",static_cast(mLights->size())-1); - obj.name = std::string( light->mName.data ); - - DefaultLogger::get()->debug("AC3D: Light source encountered"); - obj.type = Object::Light; - } - else if (!ASSIMP_strincmp(buffer,"group",5)) - { - obj.type = Object::Group; - } - else if (!ASSIMP_strincmp(buffer,"world",5)) - { - obj.type = Object::World; - } - else obj.type = Object::Poly; - while (GetNextLine()) - { - if (TokenMatch(buffer,"kids",4)) - { - SkipSpaces(&buffer); - unsigned int num = strtoul10(buffer,&buffer); - GetNextLine(); - if (num) - { - // load the children of this object recursively - obj.children.reserve(num); - for (unsigned int i = 0; i < num; ++i) - LoadObjectSection(obj.children); - } - return; - } - else if (TokenMatch(buffer,"name",4)) - { - SkipSpaces(&buffer); - AI_AC_GET_STRING(obj.name); - - // If this is a light source, we'll also need to store - // the name of the node in it. - if (light) - { - light->mName.Set(obj.name); - } - } - else if (TokenMatch(buffer,"texture",7)) - { - SkipSpaces(&buffer); - AI_AC_GET_STRING(obj.texture); - } - else if (TokenMatch(buffer,"texrep",6)) - { - SkipSpaces(&buffer); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,2,&obj.texRepeat); - if (!obj.texRepeat.x || !obj.texRepeat.y) - obj.texRepeat = aiVector2D (1.f,1.f); - } - else if (TokenMatch(buffer,"texoff",6)) - { - SkipSpaces(&buffer); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,2,&obj.texOffset); - } - else if (TokenMatch(buffer,"rot",3)) - { - SkipSpaces(&buffer); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,9,&obj.rotation); - } - else if (TokenMatch(buffer,"loc",3)) - { - SkipSpaces(&buffer); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,3,&obj.translation); - } - else if (TokenMatch(buffer,"subdiv",6)) - { - SkipSpaces(&buffer); - obj.subDiv = strtoul10(buffer,&buffer); - } - else if (TokenMatch(buffer,"crease",6)) - { - SkipSpaces(&buffer); - obj.crease = fast_atof(buffer); - } - else if (TokenMatch(buffer,"numvert",7)) - { - SkipSpaces(&buffer); - - unsigned int t = strtoul10(buffer,&buffer); - if (t >= AI_MAX_ALLOC(aiVector3D)) { - throw DeadlyImportError("AC3D: Too many vertices, would run out of memory"); - } - obj.vertices.reserve(t); - for (unsigned int i = 0; i < t;++i) - { - if (!GetNextLine()) - { - DefaultLogger::get()->error("AC3D: Unexpected EOF: not all vertices have been parsed yet"); - break; - } - else if (!IsNumeric(*buffer)) - { - DefaultLogger::get()->error("AC3D: Unexpected token: not all vertices have been parsed yet"); - --buffer; // make sure the line is processed a second time - break; - } - obj.vertices.push_back(aiVector3D()); - aiVector3D& v = obj.vertices.back(); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,3,&v.x); - } - } - else if (TokenMatch(buffer,"numsurf",7)) - { - SkipSpaces(&buffer); - - bool Q3DWorkAround = false; - - const unsigned int t = strtoul10(buffer,&buffer); - obj.surfaces.reserve(t); - for (unsigned int i = 0; i < t;++i) - { - GetNextLine(); - if (!TokenMatch(buffer,"SURF",4)) - { - // FIX: this can occur for some files - Quick 3D for - // example writes no surf chunks - if (!Q3DWorkAround) - { - DefaultLogger::get()->warn("AC3D: SURF token was expected"); - DefaultLogger::get()->debug("Continuing with Quick3D Workaround enabled"); - } - --buffer; // make sure the line is processed a second time - // break; --- see fix notes above - - Q3DWorkAround = true; - } - SkipSpaces(&buffer); - obj.surfaces.push_back(Surface()); - Surface& surf = obj.surfaces.back(); - surf.flags = strtoul_cppstyle(buffer); - - while (1) - { - if(!GetNextLine()) - { - throw DeadlyImportError("AC3D: Unexpected EOF: surface is incomplete"); - } - if (TokenMatch(buffer,"mat",3)) - { - SkipSpaces(&buffer); - surf.mat = strtoul10(buffer); - } - else if (TokenMatch(buffer,"refs",4)) - { - // --- see fix notes above - if (Q3DWorkAround) - { - if (!surf.entries.empty()) - { - buffer -= 6; - break; - } - } - - SkipSpaces(&buffer); - const unsigned int m = strtoul10(buffer); - surf.entries.reserve(m); - - obj.numRefs += m; - - for (unsigned int k = 0; k < m; ++k) - { - if(!GetNextLine()) - { - DefaultLogger::get()->error("AC3D: Unexpected EOF: surface references are incomplete"); - break; - } - surf.entries.push_back(Surface::SurfaceEntry()); - Surface::SurfaceEntry& entry = surf.entries.back(); - - entry.first = strtoul10(buffer,&buffer); - SkipSpaces(&buffer); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,2,&entry.second); - } - } - else - { - - --buffer; // make sure the line is processed a second time - break; - } - } - } - } - } - DefaultLogger::get()->error("AC3D: Unexpected EOF: \'kids\' line was expected"); -} - -// ------------------------------------------------------------------------------------------------ -// Convert a material from AC3DImporter::Material to aiMaterial -void AC3DImporter::ConvertMaterial(const Object& object, - const Material& matSrc, - aiMaterial& matDest) -{ - aiString s; - - if (matSrc.name.length()) - { - s.Set(matSrc.name); - matDest.AddProperty(&s,AI_MATKEY_NAME); - } - if (object.texture.length()) - { - s.Set(object.texture); - matDest.AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0)); - - // UV transformation - if (1.f != object.texRepeat.x || 1.f != object.texRepeat.y || - object.texOffset.x || object.texOffset.y) - { - aiUVTransform transform; - transform.mScaling = object.texRepeat; - transform.mTranslation = object.texOffset; - matDest.AddProperty(&transform,1,AI_MATKEY_UVTRANSFORM_DIFFUSE(0)); - } - } - - matDest.AddProperty(&matSrc.rgb,1, AI_MATKEY_COLOR_DIFFUSE); - matDest.AddProperty(&matSrc.amb,1, AI_MATKEY_COLOR_AMBIENT); - matDest.AddProperty(&matSrc.emis,1,AI_MATKEY_COLOR_EMISSIVE); - matDest.AddProperty(&matSrc.spec,1,AI_MATKEY_COLOR_SPECULAR); - - int n; - if (matSrc.shin) - { - n = aiShadingMode_Phong; - matDest.AddProperty(&matSrc.shin,1,AI_MATKEY_SHININESS); - } - else n = aiShadingMode_Gouraud; - matDest.AddProperty(&n,1,AI_MATKEY_SHADING_MODEL); - - float f = 1.f - matSrc.trans; - matDest.AddProperty(&f,1,AI_MATKEY_OPACITY); -} - -// ------------------------------------------------------------------------------------------------ -// Converts the loaded data to the internal verbose representation -aiNode* AC3DImporter::ConvertObjectSection(Object& object, - std::vector& meshes, - std::vector& outMaterials, - const std::vector& materials, - aiNode* parent) -{ - aiNode* node = new aiNode(); - node->mParent = parent; - if (object.vertices.size()) - { - if (!object.surfaces.size() || !object.numRefs) - { - /* " An object with 7 vertices (no surfaces, no materials defined). - This is a good way of getting point data into AC3D. - The Vertex->create convex-surface/object can be used on these - vertices to 'wrap' a 3d shape around them " - (http://www.opencity.info/html/ac3dfileformat.html) - - therefore: if no surfaces are defined return point data only - */ - - DefaultLogger::get()->info("AC3D: No surfaces defined in object definition, " - "a point list is returned"); - - meshes.push_back(new aiMesh()); - aiMesh* mesh = meshes.back(); - - mesh->mNumFaces = mesh->mNumVertices = (unsigned int)object.vertices.size(); - aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces]; - aiVector3D* verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices]; - - for (unsigned int i = 0; i < mesh->mNumVertices;++i,++faces,++verts) - { - *verts = object.vertices[i]; - faces->mNumIndices = 1; - faces->mIndices = new unsigned int[1]; - faces->mIndices[0] = i; - } - - // use the primary material in this case. this should be the - // default material if all objects of the file contain points - // and no faces. - mesh->mMaterialIndex = 0; - outMaterials.push_back(new aiMaterial()); - ConvertMaterial(object, materials[0], *outMaterials.back()); - } - else - { - // need to generate one or more meshes for this object. - // find out how many different materials we have - typedef std::pair< unsigned int, unsigned int > IntPair; - typedef std::vector< IntPair > MatTable; - MatTable needMat(materials.size(),IntPair(0,0)); - - std::vector::iterator it,end = object.surfaces.end(); - std::vector::iterator it2,end2; - - for (it = object.surfaces.begin(); it != end; ++it) - { - unsigned int idx = (*it).mat; - if (idx >= needMat.size()) - { - DefaultLogger::get()->error("AC3D: material index is out of range"); - idx = 0; - } - if ((*it).entries.empty()) - { - DefaultLogger::get()->warn("AC3D: surface her zero vertex references"); - } - - // validate all vertex indices to make sure we won't crash here - for (it2 = (*it).entries.begin(), - end2 = (*it).entries.end(); it2 != end2; ++it2) - { - if ((*it2).first >= object.vertices.size()) - { - DefaultLogger::get()->warn("AC3D: Invalid vertex reference"); - (*it2).first = 0; - } - } - - if (!needMat[idx].first)++node->mNumMeshes; - - switch ((*it).flags & 0xf) - { - // closed line - case 0x1: - - needMat[idx].first += (unsigned int)(*it).entries.size(); - needMat[idx].second += (unsigned int)(*it).entries.size()<<1u; - break; - - // unclosed line - case 0x2: - - needMat[idx].first += (unsigned int)(*it).entries.size()-1; - needMat[idx].second += ((unsigned int)(*it).entries.size()-1)<<1u; - break; - - // 0 == polygon, else unknown - default: - - if ((*it).flags & 0xf) - { - DefaultLogger::get()->warn("AC3D: The type flag of a surface is unknown"); - (*it).flags &= ~(0xf); - } - - // the number of faces increments by one, the number - // of vertices by surface.numref. - needMat[idx].first++; - needMat[idx].second += (unsigned int)(*it).entries.size(); - }; - } - unsigned int* pip = node->mMeshes = new unsigned int[node->mNumMeshes]; - unsigned int mat = 0; - const size_t oldm = meshes.size(); - for (MatTable::const_iterator cit = needMat.begin(), cend = needMat.end(); - cit != cend; ++cit, ++mat) - { - if (!(*cit).first)continue; - - // allocate a new aiMesh object - *pip++ = (unsigned int)meshes.size(); - aiMesh* mesh = new aiMesh(); - meshes.push_back(mesh); - - mesh->mMaterialIndex = (unsigned int)outMaterials.size(); - outMaterials.push_back(new aiMaterial()); - ConvertMaterial(object, materials[mat], *outMaterials.back()); - - // allocate storage for vertices and normals - mesh->mNumFaces = (*cit).first; - if (mesh->mNumFaces == 0) { - throw DeadlyImportError("AC3D: No faces"); - } else if (mesh->mNumFaces > AI_MAX_ALLOC(aiFace)) { - throw DeadlyImportError("AC3D: Too many faces, would run out of memory"); - } - aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces]; - - mesh->mNumVertices = (*cit).second; - if (mesh->mNumVertices == 0) { - throw DeadlyImportError("AC3D: No vertices"); - } else if (mesh->mNumVertices > AI_MAX_ALLOC(aiVector3D)) { - throw DeadlyImportError("AC3D: Too many vertices, would run out of memory"); - } - aiVector3D* vertices = mesh->mVertices = new aiVector3D[mesh->mNumVertices]; - unsigned int cur = 0; - - // allocate UV coordinates, but only if the texture name for the - // surface is not empty - aiVector3D* uv = NULL; - if(object.texture.length()) - { - uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices]; - mesh->mNumUVComponents[0] = 2; - } - - for (it = object.surfaces.begin(); it != end; ++it) - { - if (mat == (*it).mat) - { - const Surface& src = *it; - - // closed polygon - unsigned int type = (*it).flags & 0xf; - if (!type) - { - aiFace& face = *faces++; - if((face.mNumIndices = (unsigned int)src.entries.size())) - { - face.mIndices = new unsigned int[face.mNumIndices]; - for (unsigned int i = 0; i < face.mNumIndices;++i,++vertices) - { - const Surface::SurfaceEntry& entry = src.entries[i]; - face.mIndices[i] = cur++; - - // copy vertex positions - if (static_cast(vertices - mesh->mVertices) >= mesh->mNumVertices) { - throw DeadlyImportError("AC3D: Invalid number of vertices"); - } - *vertices = object.vertices[entry.first] + object.translation; - - - // copy texture coordinates - if (uv) - { - uv->x = entry.second.x; - uv->y = entry.second.y; - ++uv; - } - } - } - } - else - { - - it2 = (*it).entries.begin(); - - // either a closed or an unclosed line - unsigned int tmp = (unsigned int)(*it).entries.size(); - if (0x2 == type)--tmp; - for (unsigned int m = 0; m < tmp;++m) - { - aiFace& face = *faces++; - - face.mNumIndices = 2; - face.mIndices = new unsigned int[2]; - face.mIndices[0] = cur++; - face.mIndices[1] = cur++; - - // copy vertex positions - if (it2 == (*it).entries.end() ) { - throw DeadlyImportError("AC3D: Bad line"); - } - ai_assert((*it2).first < object.vertices.size()); - *vertices++ = object.vertices[(*it2).first]; - - // copy texture coordinates - if (uv) - { - uv->x = (*it2).second.x; - uv->y = (*it2).second.y; - ++uv; - } - - - if (0x1 == type && tmp-1 == m) - { - // if this is a closed line repeat its beginning now - it2 = (*it).entries.begin(); - } - else ++it2; - - // second point - *vertices++ = object.vertices[(*it2).first]; - - if (uv) - { - uv->x = (*it2).second.x; - uv->y = (*it2).second.y; - ++uv; - } - } - } - } - } - } - - // Now apply catmull clark subdivision if necessary. We split meshes into - // materials which is not done by AC3D during smoothing, so we need to - // collect all meshes using the same material group. - if (object.subDiv) { - if (configEvalSubdivision) { - std::unique_ptr div(Subdivider::Create(Subdivider::CATMULL_CLARKE)); - DefaultLogger::get()->info("AC3D: Evaluating subdivision surface: "+object.name); - - std::vector cpy(meshes.size()-oldm,NULL); - div->Subdivide(&meshes[oldm],cpy.size(),&cpy.front(),object.subDiv,true); - std::copy(cpy.begin(),cpy.end(),meshes.begin()+oldm); - - // previous meshes are deleted vy Subdivide(). - } - else { - DefaultLogger::get()->info("AC3D: Letting the subdivision surface untouched due to my configuration: " - +object.name); - } - } - } - } - - if (object.name.length()) - node->mName.Set(object.name); - else - { - // generate a name depending on the type of the node - switch (object.type) - { - case Object::Group: - node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACGroup_%i",groups++); - break; - case Object::Poly: - node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACPoly_%i",polys++); - break; - case Object::Light: - node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACLight_%i",lights++); - break; - - // there shouldn't be more than one world, but we don't care - case Object::World: - node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACWorld_%i",worlds++); - break; - } - } - - - // setup the local transformation matrix of the object - // compute the transformation offset to the parent node - node->mTransformation = aiMatrix4x4 ( object.rotation ); - - if (object.type == Object::Group || !object.numRefs) - { - node->mTransformation.a4 = object.translation.x; - node->mTransformation.b4 = object.translation.y; - node->mTransformation.c4 = object.translation.z; - } - - // add children to the object - if (object.children.size()) - { - node->mNumChildren = (unsigned int)object.children.size(); - node->mChildren = new aiNode*[node->mNumChildren]; - for (unsigned int i = 0; i < node->mNumChildren;++i) - { - node->mChildren[i] = ConvertObjectSection(object.children[i],meshes,outMaterials,materials,node); - } - } - - return node; -} - -// ------------------------------------------------------------------------------------------------ -void AC3DImporter::SetupProperties(const Importer* pImp) -{ - configSplitBFCull = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_AC_SEPARATE_BFCULL,1) ? true : false; - configEvalSubdivision = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_AC_EVAL_SUBDIVISION,1) ? true : false; -} - -// ------------------------------------------------------------------------------------------------ -// Imports the given file into the given scene structure. -void AC3DImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ - std::unique_ptr file( pIOHandler->Open( pFile, "rb")); - - // Check whether we can read from the file - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open AC3D file " + pFile + "."); - - // allocate storage and copy the contents of the file to a memory buffer - std::vector mBuffer2; - TextFileToBuffer(file.get(),mBuffer2); - - buffer = &mBuffer2[0]; - mNumMeshes = 0; - - lights = polys = worlds = groups = 0; - - if (::strncmp(buffer,"AC3D",4)) { - throw DeadlyImportError("AC3D: No valid AC3D file, magic sequence not found"); - } - - // print the file format version to the console - unsigned int version = HexDigitToDecimal( buffer[4] ); - char msg[3]; - ASSIMP_itoa10(msg,3,version); - DefaultLogger::get()->info(std::string("AC3D file format version: ") + msg); - - std::vector materials; - materials.reserve(5); - - std::vector rootObjects; - rootObjects.reserve(5); - - std::vector lights; - mLights = & lights; - - while (GetNextLine()) - { - if (TokenMatch(buffer,"MATERIAL",8)) - { - materials.push_back(Material()); - Material& mat = materials.back(); - - // manually parse the material ... sscanf would use the buldin atof ... - // Format: (name) rgb %f %f %f amb %f %f %f emis %f %f %f spec %f %f %f shi %d trans %f - - AI_AC_SKIP_TO_NEXT_TOKEN(); - if ('\"' == *buffer) - { - AI_AC_GET_STRING(mat.name); - AI_AC_SKIP_TO_NEXT_TOKEN(); - } - - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("rgb",3,3,&mat.rgb); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("amb",3,3,&mat.amb); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("emis",4,3,&mat.emis); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("spec",4,3,&mat.spec); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("shi",3,1,&mat.shin); - AI_AC_CHECKED_LOAD_FLOAT_ARRAY("trans",5,1,&mat.trans); - } - LoadObjectSection(rootObjects); - } - - if (rootObjects.empty() || !mNumMeshes) - { - throw DeadlyImportError("AC3D: No meshes have been loaded"); - } - if (materials.empty()) - { - DefaultLogger::get()->warn("AC3D: No material has been found"); - materials.push_back(Material()); - } - - mNumMeshes += (mNumMeshes>>2u) + 1; - std::vector meshes; - meshes.reserve(mNumMeshes); - - std::vector omaterials; - materials.reserve(mNumMeshes); - - // generate a dummy root if there are multiple objects on the top layer - Object* root; - if (1 == rootObjects.size()) - root = &rootObjects[0]; - else - { - root = new Object(); - } - - // now convert the imported stuff to our output data structure - pScene->mRootNode = ConvertObjectSection(*root,meshes,omaterials,materials); - if (1 != rootObjects.size())delete root; - - if (!::strncmp( pScene->mRootNode->mName.data, "Node", 4)) - pScene->mRootNode->mName.Set(""); - - // copy meshes - if (meshes.empty()) - { - throw DeadlyImportError("An unknown error occurred during converting"); - } - pScene->mNumMeshes = (unsigned int)meshes.size(); - pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; - ::memcpy(pScene->mMeshes,&meshes[0],pScene->mNumMeshes*sizeof(void*)); - - // copy materials - pScene->mNumMaterials = (unsigned int)omaterials.size(); - pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; - ::memcpy(pScene->mMaterials,&omaterials[0],pScene->mNumMaterials*sizeof(void*)); - - // copy lights - pScene->mNumLights = (unsigned int)lights.size(); - if (lights.size()) - { - pScene->mLights = new aiLight*[lights.size()]; - ::memcpy(pScene->mLights,&lights[0],lights.size()*sizeof(void*)); - } -} - -#endif //!defined ASSIMP_BUILD_NO_AC_IMPORTER diff --git a/src/3rdparty/assimp/code/ACLoader.h b/src/3rdparty/assimp/code/ACLoader.h deleted file mode 100644 index 4b202b77a..000000000 --- a/src/3rdparty/assimp/code/ACLoader.h +++ /dev/null @@ -1,275 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file ACLoader.h - * @brief Declaration of the .ac importer class. - */ -#ifndef AI_AC3DLOADER_H_INCLUDED -#define AI_AC3DLOADER_H_INCLUDED - -#include - -#include "BaseImporter.h" -#include - -struct aiNode; -struct aiMesh; -struct aiMaterial; -struct aiLight; - - -namespace Assimp { - -// --------------------------------------------------------------------------- -/** AC3D (*.ac) importer class -*/ -class AC3DImporter : public BaseImporter -{ -public: - AC3DImporter(); - ~AC3DImporter(); - - - - // Represents an AC3D material - struct Material - { - Material() - : rgb (0.6f,0.6f,0.6f) - , spec (1.f,1.f,1.f) - , shin (0.f) - , trans (0.f) - {} - - // base color of the material - aiColor3D rgb; - - // ambient color of the material - aiColor3D amb; - - // emissive color of the material - aiColor3D emis; - - // specular color of the material - aiColor3D spec; - - // shininess exponent - float shin; - - // transparency. 0 == opaque - float trans; - - // name of the material. optional. - std::string name; - }; - - // Represents an AC3D surface - struct Surface - { - Surface() - : mat (0) - , flags (0) - {} - - unsigned int mat,flags; - - typedef std::pair SurfaceEntry; - std::vector< SurfaceEntry > entries; - }; - - // Represents an AC3D object - struct Object - { - Object() - : type (World) - , name( "" ) - , children() - , texture( "" ) - , texRepeat( 1.f, 1.f ) - , texOffset( 0.0f, 0.0f ) - , rotation() - , translation() - , vertices() - , surfaces() - , numRefs (0) - , subDiv (0) - , crease() - {} - - // Type description - enum Type - { - World = 0x0, - Poly = 0x1, - Group = 0x2, - Light = 0x4 - } type; - - // name of the object - std::string name; - - // object children - std::vector children; - - // texture to be assigned to all surfaces of the object - std::string texture; - - // texture repat factors (scaling for all coordinates) - aiVector2D texRepeat, texOffset; - - // rotation matrix - aiMatrix3x3 rotation; - - // translation vector - aiVector3D translation; - - // vertices - std::vector vertices; - - // surfaces - std::vector surfaces; - - // number of indices (= num verts in verbose format) - unsigned int numRefs; - - // number of subdivisions to be performed on the - // imported data - unsigned int subDiv; - - // max angle limit for smoothing - float crease; - }; - - -public: - - // ------------------------------------------------------------------- - /** Returns whether the class can handle the format of the given file. - * See BaseImporter::CanRead() for details. - */ - bool CanRead( const std::string& pFile, IOSystem* pIOHandler, - bool checkSig) const; - -protected: - - // ------------------------------------------------------------------- - /** Return importer meta information. - * See #BaseImporter::GetInfo for the details */ - const aiImporterDesc* GetInfo () const; - - // ------------------------------------------------------------------- - /** Imports the given file into the given scene structure. - * See BaseImporter::InternReadFile() for details*/ - void InternReadFile( const std::string& pFile, aiScene* pScene, - IOSystem* pIOHandler); - - // ------------------------------------------------------------------- - /** Called prior to ReadFile(). - * The function is a request to the importer to update its configuration - * basing on the Importer's configuration property list.*/ - void SetupProperties(const Importer* pImp); - -private: - - // ------------------------------------------------------------------- - /** Get the next line from the file. - * @return false if the end of the file was reached*/ - bool GetNextLine(); - - // ------------------------------------------------------------------- - /** Load the object section. This method is called recursively to - * load subobjects, the method returns after a 'kids 0' was - * encountered. - * @objects List of output objects*/ - void LoadObjectSection(std::vector& objects); - - // ------------------------------------------------------------------- - /** Convert all objects into meshes and nodes. - * @param object Current object to work on - * @param meshes Pointer to the list of output meshes - * @param outMaterials List of output materials - * @param materials Material list - * @param Scenegraph node for the object */ - aiNode* ConvertObjectSection(Object& object, - std::vector& meshes, - std::vector& outMaterials, - const std::vector& materials, - aiNode* parent = NULL); - - // ------------------------------------------------------------------- - /** Convert a material - * @param object Current object - * @param matSrc Source material description - * @param matDest Destination material to be filled */ - void ConvertMaterial(const Object& object, - const Material& matSrc, - aiMaterial& matDest); - -private: - - - // points to the next data line - const char* buffer; - - // Configuration option: if enabled, up to two meshes - // are generated per material: those faces who have - // their bf cull flags set are separated. - bool configSplitBFCull; - - // Configuration switch: subdivision surfaces are only - // evaluated if the value is true. - bool configEvalSubdivision; - - // counts how many objects we have in the tree. - // basing on this information we can find a - // good estimate how many meshes we'll have in the final scene. - unsigned int mNumMeshes; - - // current list of light sources - std::vector* mLights; - - // name counters - unsigned int lights, groups, polys, worlds; -}; - -} // end of namespace Assimp - -#endif // AI_AC3DIMPORTER_H_INC diff --git a/src/3rdparty/assimp/code/AMFImporter.cpp b/src/3rdparty/assimp/code/AMFImporter.cpp deleted file mode 100644 index e9211fe53..000000000 --- a/src/3rdparty/assimp/code/AMFImporter.cpp +++ /dev/null @@ -1,704 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/// \file AMFImporter.cpp -/// \brief AMF-format files importer for Assimp: main algorithm implementation. -/// \date 2016 -/// \author smal.root@gmail.com - -#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER - -// Header files, Assimp. -#include "AMFImporter.hpp" -#include "AMFImporter_Macro.hpp" - -#include "fast_atof.h" -#include - -// Header files, stdlib. -#include - -namespace Assimp -{ - -/// \var aiImporterDesc AMFImporter::Description -/// Conastant which hold importer description -const aiImporterDesc AMFImporter::Description = { - "Additive manufacturing file format(AMF) Importer", - "smalcom", - "", - "See documentation in source code. Chapter: Limitations.", - aiImporterFlags_SupportTextFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental, - 0, - 0, - 0, - 0, - "amf" -}; - -void AMFImporter::Clear() -{ - mNodeElement_Cur = nullptr; - mUnit.clear(); - mMaterial_Converted.clear(); - mTexture_Converted.clear(); - // Delete all elements - if(mNodeElement_List.size()) - { - for(CAMFImporter_NodeElement* ne: mNodeElement_List) { delete ne; } - - mNodeElement_List.clear(); - } -} - -AMFImporter::~AMFImporter() -{ - if(mReader != nullptr) delete mReader; - // Clear() is accounting if data already is deleted. So, just check again if all data is deleted. - Clear(); -} - -/*********************************************************************************************************************************************/ -/************************************************************ Functions: find set ************************************************************/ -/*********************************************************************************************************************************************/ - -bool AMFImporter::Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const -{ - for(CAMFImporter_NodeElement* ne: mNodeElement_List) - { - if((ne->ID == pID) && (ne->Type == pType)) - { - if(pNodeElement != nullptr) *pNodeElement = ne; - - return true; - } - }// for(CAMFImporter_NodeElement* ne: mNodeElement_List) - - return false; -} - -bool AMFImporter::Find_ConvertedNode(const std::string& pID, std::list& pNodeList, aiNode** pNode) const -{ -aiString node_name(pID.c_str()); - - for(aiNode* node: pNodeList) - { - if(node->mName == node_name) - { - if(pNode != nullptr) *pNode = node; - - return true; - } - }// for(aiNode* node: pNodeList) - - return false; -} - -bool AMFImporter::Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const -{ - for(const SPP_Material& mat: mMaterial_Converted) - { - if(mat.ID == pID) - { - if(pConvertedMaterial != nullptr) *pConvertedMaterial = &mat; - - return true; - } - }// for(const SPP_Material& mat: mMaterial_Converted) - - return false; -} - -/*********************************************************************************************************************************************/ -/************************************************************ Functions: throw set ***********************************************************/ -/*********************************************************************************************************************************************/ - -void AMFImporter::Throw_CloseNotFound(const std::string& pNode) -{ - throw DeadlyImportError("Close tag for node <" + pNode + "> not found. Seems file is corrupt."); -} - -void AMFImporter::Throw_IncorrectAttr(const std::string& pAttrName) -{ - throw DeadlyImportError("Node <" + std::string(mReader->getNodeName()) + "> has incorrect attribute \"" + pAttrName + "\"."); -} - -void AMFImporter::Throw_IncorrectAttrValue(const std::string& pAttrName) -{ - throw DeadlyImportError("Attribute \"" + pAttrName + "\" in node <" + std::string(mReader->getNodeName()) + "> has incorrect value."); -} - -void AMFImporter::Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription) -{ - throw DeadlyImportError("\"" + pNodeType + "\" node can be used only once in " + mReader->getNodeName() + ". Description: " + pDescription); -} - -void AMFImporter::Throw_ID_NotFound(const std::string& pID) const -{ - throw DeadlyImportError("Not found node with name \"" + pID + "\"."); -} - -/*********************************************************************************************************************************************/ -/************************************************************* Functions: XML set ************************************************************/ -/*********************************************************************************************************************************************/ - -void AMFImporter::XML_CheckNode_MustHaveChildren() -{ - if(mReader->isEmptyElement()) throw DeadlyImportError(std::string("Node <") + mReader->getNodeName() + "> must have children."); -} - -void AMFImporter::XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName) -{ - static const size_t Uns_Skip_Len = 3; - const char* Uns_Skip[Uns_Skip_Len] = { "composite", "edge", "normal" }; - - static bool skipped_before[Uns_Skip_Len] = { false, false, false }; - - std::string nn(mReader->getNodeName()); - bool found = false; - bool close_found = false; - size_t sk_idx; - - for(sk_idx = 0; sk_idx < Uns_Skip_Len; sk_idx++) - { - if(nn != Uns_Skip[sk_idx]) continue; - - found = true; - if(mReader->isEmptyElement()) - { - close_found = true; - - goto casu_cres; - } - - while(mReader->read()) - { - if((mReader->getNodeType() == irr::io::EXN_ELEMENT_END) && (nn == mReader->getNodeName())) - { - close_found = true; - - goto casu_cres; - } - } - }// for(sk_idx = 0; sk_idx < Uns_Skip_Len; sk_idx++) - -casu_cres: - - if(!found) throw DeadlyImportError("Unknown node \"" + nn + "\" in " + pParentNodeName + "."); - if(!close_found) Throw_CloseNotFound(nn); - - if(!skipped_before[sk_idx]) - { - skipped_before[sk_idx] = true; - LogWarning("Skipping node \"" + nn + "\" in " + pParentNodeName + "."); - } -} - -bool AMFImporter::XML_SearchNode(const std::string& pNodeName) -{ - while(mReader->read()) - { - if((mReader->getNodeType() == irr::io::EXN_ELEMENT) && XML_CheckNode_NameEqual(pNodeName)) return true; - } - - return false; -} - -bool AMFImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx) -{ - std::string val(mReader->getAttributeValue(pAttrIdx)); - - if((val == "false") || (val == "0")) - return false; - else if((val == "true") || (val == "1")) - return true; - else - throw DeadlyImportError("Bool attribute value can contain \"false\"/\"0\" or \"true\"/\"1\" not the \"" + val + "\""); -} - -float AMFImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) -{ - std::string val; - float tvalf; - - ParseHelper_FixTruncatedFloatString(mReader->getAttributeValue(pAttrIdx), val); - fast_atoreal_move(val.c_str(), tvalf, false); - - return tvalf; -} - -uint32_t AMFImporter::XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx) -{ - return strtoul10(mReader->getAttributeValue(pAttrIdx)); -} - -float AMFImporter::XML_ReadNode_GetVal_AsFloat() -{ - std::string val; - float tvalf; - - if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. No data, seems file is corrupt."); - if(mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. Invalid type of XML element, seems file is corrupt."); - - ParseHelper_FixTruncatedFloatString(mReader->getNodeData(), val); - fast_atoreal_move(val.c_str(), tvalf, false); - - return tvalf; -} - -uint32_t AMFImporter::XML_ReadNode_GetVal_AsU32() -{ - if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. No data, seems file is corrupt."); - if(mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. Invalid type of XML element, seems file is corrupt."); - - return strtoul10(mReader->getNodeData()); -} - -void AMFImporter::XML_ReadNode_GetVal_AsString(std::string& pValue) -{ - if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsString. No data, seems file is corrupt."); - if(mReader->getNodeType() != irr::io::EXN_TEXT) - throw DeadlyImportError("XML_ReadNode_GetVal_AsString. Invalid type of XML element, seems file is corrupt."); - - pValue = mReader->getNodeData(); -} - -/*********************************************************************************************************************************************/ -/************************************************************ Functions: parse set ***********************************************************/ -/*********************************************************************************************************************************************/ - -void AMFImporter::ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode) -{ - mNodeElement_Cur->Child.push_back(pNode);// add new element to current element child list. - mNodeElement_Cur = pNode;// switch current element to new one. -} - -void AMFImporter::ParseHelper_Node_Exit() -{ - // check if we can walk up. - if(mNodeElement_Cur != nullptr) mNodeElement_Cur = mNodeElement_Cur->Parent; -} - -void AMFImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString) -{ - size_t instr_len; - - pOutString.clear(); - instr_len = strlen(pInStr); - if(!instr_len) return; - - pOutString.reserve(instr_len * 3 / 2); - // check and correct floats in format ".x". Must be "x.y". - if(pInStr[0] == '.') pOutString.push_back('0'); - - pOutString.push_back(pInStr[0]); - for(size_t ci = 1; ci < instr_len; ci++) - { - if((pInStr[ci] == '.') && ((pInStr[ci - 1] == ' ') || (pInStr[ci - 1] == '-') || (pInStr[ci - 1] == '+') || (pInStr[ci - 1] == '\t'))) - { - pOutString.push_back('0'); - pOutString.push_back('.'); - } - else - { - pOutString.push_back(pInStr[ci]); - } - } -} - -static bool ParseHelper_Decode_Base64_IsBase64(const char pChar) -{ - return (isalnum(pChar) || (pChar == '+') || (pChar == '/')); -} - -void AMFImporter::ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector& pOutputData) const -{ - // With help from - // René Nyffenegger http://www.adp-gmbh.ch/cpp/common/base64.html - const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - uint8_t tidx = 0; - uint8_t arr4[4], arr3[3]; - - // check input data - if(pInputBase64.size() % 4) throw DeadlyImportError("Base64-encoded data must have size multiply of four."); - // prepare output place - pOutputData.clear(); - pOutputData.reserve(pInputBase64.size() / 4 * 3); - - for(size_t in_len = pInputBase64.size(), in_idx = 0; (in_len > 0) && (pInputBase64[in_idx] != '='); in_len--) - { - if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx])) - { - arr4[tidx++] = pInputBase64[in_idx++]; - if(tidx == 4) - { - for(tidx = 0; tidx < 4; tidx++) arr4[tidx] = (uint8_t)base64_chars.find(arr4[tidx]); - - arr3[0] = (arr4[0] << 2) + ((arr4[1] & 0x30) >> 4); - arr3[1] = ((arr4[1] & 0x0F) << 4) + ((arr4[2] & 0x3C) >> 2); - arr3[2] = ((arr4[2] & 0x03) << 6) + arr4[3]; - for(tidx = 0; tidx < 3; tidx++) pOutputData.push_back(arr3[tidx]); - - tidx = 0; - }// if(tidx == 4) - }// if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx])) - else - { - in_idx++; - }// if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx])) else - } - - if(tidx) - { - for(uint8_t i = tidx; i < 4; i++) arr4[i] = 0; - for(uint8_t i = 0; i < 4; i++) arr4[i] = (uint8_t)(base64_chars.find(arr4[i])); - - arr3[0] = (arr4[0] << 2) + ((arr4[1] & 0x30) >> 4); - arr3[1] = ((arr4[1] & 0x0F) << 4) + ((arr4[2] & 0x3C) >> 2); - arr3[2] = ((arr4[2] & 0x03) << 6) + arr4[3]; - for(uint8_t i = 0; i < (tidx - 1); i++) pOutputData.push_back(arr3[i]); - } -} - -void AMFImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler) -{ - irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader. - std::unique_ptr file(pIOHandler->Open(pFile, "rb")); - - // Check whether we can read from the file - if(file.get() == NULL) throw DeadlyImportError("Failed to open AMF file " + pFile + "."); - - // generate a XML reader for it - std::unique_ptr mIOWrapper(new CIrrXML_IOStreamReader(file.get())); - mReader = irr::io::createIrrXMLReader(mIOWrapper.get()); - if(!mReader) throw DeadlyImportError("Failed to create XML reader for file" + pFile + "."); - // - // start reading - // search for root tag - if(XML_SearchNode("amf")) - ParseNode_Root(); - else - throw DeadlyImportError("Root node \"amf\" not found."); - - delete mReader; - // restore old XMLreader - mReader = OldReader; -} - -// -// -// Root XML element. -// Multi elements - No. -void AMFImporter::ParseNode_Root() -{ - std::string unit, version; - CAMFImporter_NodeElement *ne( nullptr ); - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("unit", unit, mReader->getAttributeValue); - MACRO_ATTRREAD_CHECK_RET("version", version, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND_WSKIP; - - // Check attributes - if(!mUnit.empty()) - { - if((mUnit != "inch") && (mUnit != "millimeter") && (mUnit != "meter") && (mUnit != "feet") && (mUnit != "micron")) Throw_IncorrectAttrValue("unit"); - } - - // create root node element. - ne = new CAMFImporter_NodeElement_Root(nullptr); - mNodeElement_Cur = ne;// set first "current" element - // and assign attribute's values - ((CAMFImporter_NodeElement_Root*)ne)->Unit = unit; - ((CAMFImporter_NodeElement_Root*)ne)->Version = version; - - // Check for child nodes - if(!mReader->isEmptyElement()) - { - MACRO_NODECHECK_LOOPBEGIN("amf"); - if(XML_CheckNode_NameEqual("object")) { ParseNode_Object(); continue; } - if(XML_CheckNode_NameEqual("material")) { ParseNode_Material(); continue; } - if(XML_CheckNode_NameEqual("texture")) { ParseNode_Texture(); continue; } - if(XML_CheckNode_NameEqual("constellation")) { ParseNode_Constellation(); continue; } - if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } - MACRO_NODECHECK_LOOPEND("amf"); - mNodeElement_Cur = ne;// force restore "current" element - }// if(!mReader->isEmptyElement()) - - mNodeElement_List.push_back(ne);// add to node element list because its a new object in graph. -} - -// -// -// A collection of objects or constellations with specific relative locations. -// Multi elements - Yes. -// Parent element - . -void AMFImporter::ParseNode_Constellation() -{ - std::string id; - CAMFImporter_NodeElement* ne( nullptr ); - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND; - - // create and if needed - define new grouping object. - ne = new CAMFImporter_NodeElement_Constellation(mNodeElement_Cur); - - CAMFImporter_NodeElement_Constellation& als = *((CAMFImporter_NodeElement_Constellation*)ne);// alias for convenience - - if(!id.empty()) als.ID = id; - // Check for child nodes - if(!mReader->isEmptyElement()) - { - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("constellation"); - if(XML_CheckNode_NameEqual("instance")) { ParseNode_Instance(); continue; } - if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } - MACRO_NODECHECK_LOOPEND("constellation"); - ParseHelper_Node_Exit(); - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// A collection of objects or constellations with specific relative locations. -// Multi elements - Yes. -// Parent element - . -void AMFImporter::ParseNode_Instance() -{ - std::string objectid; - CAMFImporter_NodeElement* ne( nullptr ); - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("objectid", objectid, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND; - - // used object id must be defined, check that. - if(objectid.empty()) throw DeadlyImportError("\"objectid\" in must be defined."); - // create and define new grouping object. - ne = new CAMFImporter_NodeElement_Instance(mNodeElement_Cur); - - CAMFImporter_NodeElement_Instance& als = *((CAMFImporter_NodeElement_Instance*)ne);// alias for convenience - - als.ObjectID = objectid; - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool read_flag[6] = { false, false, false, false, false, false }; - - als.Delta.Set(0, 0, 0); - als.Rotation.Set(0, 0, 0); - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("instance"); - MACRO_NODECHECK_READCOMP_F("deltax", read_flag[0], als.Delta.x); - MACRO_NODECHECK_READCOMP_F("deltay", read_flag[1], als.Delta.y); - MACRO_NODECHECK_READCOMP_F("deltaz", read_flag[2], als.Delta.z); - MACRO_NODECHECK_READCOMP_F("rx", read_flag[3], als.Rotation.x); - MACRO_NODECHECK_READCOMP_F("ry", read_flag[4], als.Rotation.y); - MACRO_NODECHECK_READCOMP_F("rz", read_flag[5], als.Rotation.z); - MACRO_NODECHECK_LOOPEND("instance"); - ParseHelper_Node_Exit(); - // also convert degrees to radians. - als.Rotation.x = AI_MATH_PI_F * als.Rotation.x / 180.0f; - als.Rotation.y = AI_MATH_PI_F * als.Rotation.y / 180.0f; - als.Rotation.z = AI_MATH_PI_F * als.Rotation.z / 180.0f; - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// An object definition. -// Multi elements - Yes. -// Parent element - . -void AMFImporter::ParseNode_Object() -{ - std::string id; - CAMFImporter_NodeElement* ne( nullptr ); - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND; - - // create and if needed - define new geometry object. - ne = new CAMFImporter_NodeElement_Object(mNodeElement_Cur); - - CAMFImporter_NodeElement_Object& als = *((CAMFImporter_NodeElement_Object*)ne);// alias for convenience - - if(!id.empty()) als.ID = id; - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool col_read = false; - - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("object"); - if(XML_CheckNode_NameEqual("color")) - { - // Check if color already defined for object. - if(col_read) Throw_MoreThanOnceDefined("color", "Only one color can be defined for ."); - // read data and set flag about it - ParseNode_Color(); - col_read = true; - - continue; - } - - if(XML_CheckNode_NameEqual("mesh")) { ParseNode_Mesh(); continue; } - if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } - MACRO_NODECHECK_LOOPEND("object"); - ParseHelper_Node_Exit(); - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// Specify additional information about an entity. -// Multi elements - Yes. -// Parent element - , , , , . -// -// Reserved types are: -// "Name" - The alphanumeric label of the entity, to be used by the interpreter if interacting with the user. -// "Description" - A description of the content of the entity -// "URL" - A link to an external resource relating to the entity -// "Author" - Specifies the name(s) of the author(s) of the entity -// "Company" - Specifying the company generating the entity -// "CAD" - specifies the name of the originating CAD software and version -// "Revision" - specifies the revision of the entity -// "Tolerance" - specifies the desired manufacturing tolerance of the entity in entity's unit system -// "Volume" - specifies the total volume of the entity, in the entity's unit system, to be used for verification (object and volume only) -void AMFImporter::ParseNode_Metadata() -{ - std::string type, value; - CAMFImporter_NodeElement* ne( nullptr ); - - // read attribute - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("type", type, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND; - // and value of node. - value = mReader->getNodeData(); - // Create node element and assign read data. - ne = new CAMFImporter_NodeElement_Metadata(mNodeElement_Cur); - ((CAMFImporter_NodeElement_Metadata*)ne)->Type = type; - ((CAMFImporter_NodeElement_Metadata*)ne)->Value = value; - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -/*********************************************************************************************************************************************/ -/******************************************************** Functions: BaseImporter set ********************************************************/ -/*********************************************************************************************************************************************/ - -bool AMFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const -{ - const std::string extension = GetExtension(pFile); - - if ( extension == "amf" ) { - return true; - } - - if(!extension.length() || pCheckSig) - { - const char* tokens[] = { "& pExtensionList) -{ - pExtensionList.insert("amf"); -} - -const aiImporterDesc* AMFImporter::GetInfo () const -{ - return &Description; -} - -void AMFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) -{ - Clear();// delete old graph. - ParseFile(pFile, pIOHandler); - Postprocess_BuildScene(pScene); - // scene graph is ready, exit. -} - -}// namespace Assimp - -#endif // !ASSIMP_BUILD_NO_AMF_IMPORTER diff --git a/src/3rdparty/assimp/code/AMFImporter.hpp b/src/3rdparty/assimp/code/AMFImporter.hpp deleted file mode 100644 index 47ddc073b..000000000 --- a/src/3rdparty/assimp/code/AMFImporter.hpp +++ /dev/null @@ -1,563 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/// \file AMFImporter.hpp -/// \brief AMF-format files importer for Assimp. -/// \date 2016 -/// \author smal.root@gmail.com -// Thanks to acorn89 for support. - -#pragma once -#ifndef INCLUDED_AI_AMF_IMPORTER_H -#define INCLUDED_AI_AMF_IMPORTER_H - -#include "AMFImporter_Node.hpp" - -// Header files, Assimp. -#include -#include -#include "assimp/types.h" -#include "BaseImporter.h" -#include "irrXMLWrapper.h" - -// Header files, stdlib. -#include - -namespace Assimp -{ -/// \class AMFImporter -/// Class that holding scene graph which include: geometry, metadata, materials etc. -/// -/// Implementing features. -/// -/// Limitations. -/// -/// 1. When for texture mapping used set of source textures (r, g, b, a) not only one then attribute "tiled" for all set will be true if it true in any of -/// source textures. -/// Example. Triangle use for texture mapping three textures. Two of them has "tiled" set to false and one - set to true. In scene all three textures -/// will be tiled. -/// -/// Unsupported features: -/// 1. Node , formulas in and . For implementing this feature can be used expression parser "muParser" like in project -/// "amf_tools". -/// 2. Attribute "profile" in node . -/// 3. Curved geometry: , and children nodes of them. -/// 4. Attributes: "unit" and "version" in read but do nothing. -/// 5. stored only for root node . -/// 6. Color averaging of vertices for which 's set different colors. -/// -/// Supported nodes: -/// General: -/// ; ; and children , , , , , ; ; -/// -/// Geometry: -/// ; ; ; ; and children , , ; ; and children , , ; -/// -/// Material: -/// and children , , , ; ; ; -/// two variants of texture coordinates: -/// new - and children , , , , , -/// old - and children , , , , , -/// -class AMFImporter : public BaseImporter -{ - /***********************************************/ - /******************** Types ********************/ - /***********************************************/ - -private: - - struct SPP_Material;// forward declaration - - /// \struct SPP_Composite - /// Data type for postprocessing step. More suitable container for part of material's composition. - struct SPP_Composite - { - SPP_Material* Material;///< Pointer to material - part of composition. - std::string Formula;///< Formula for calculating ratio of \ref Material. - }; - - /// \struct SPP_Material - /// Data type for postprocessing step. More suitable container for material. - struct SPP_Material - { - std::string ID;///< Material ID. - std::list Metadata;///< Metadata of material. - CAMFImporter_NodeElement_Color* Color;///< Color of material. - std::list Composition;///< List of child materials if current material is composition of few another. - - /// \fn aiColor4D GetColor(const float pX, const float pY, const float pZ) const - /// Return color calculated for specified coordinate. - /// \param [in] pX - "x" coordinate. - /// \param [in] pY - "y" coordinate. - /// \param [in] pZ - "z" coordinate. - /// \return calculated color. - aiColor4D GetColor(const float pX, const float pY, const float pZ) const; - }; - - /// \struct SPP_Texture - /// Data type for post-processing step. More suitable container for texture. - struct SPP_Texture - { - std::string ID; - size_t Width, Height, Depth; - bool Tiled; - char FormatHint[ 9 ];// 8 for string + 1 for terminator. - uint8_t *Data; - }; - - /// \struct SComplexFace - /// Data type for post-processing step. Contain face data. - struct SComplexFace - { - aiFace Face;///< Face vertices. - const CAMFImporter_NodeElement_Color* Color;///< Face color. Equal to nullptr if color is not set for the face. - const CAMFImporter_NodeElement_TexMap* TexMap;///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face. - }; - - - - /***********************************************/ - /****************** Constants ******************/ - /***********************************************/ - -private: - - static const aiImporterDesc Description; - - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ - -private: - - CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element. - std::list mNodeElement_List;///< All elements of scene graph. - irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object - std::string mUnit; - std::list mMaterial_Converted;///< List of converted materials for postprocessing step. - std::list mTexture_Converted;///< List of converted textures for postprocessing step. - - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ - -private: - - /// \fn AMFImporter(const AMFImporter& pScene) - /// Disabled copy constructor. - AMFImporter(const AMFImporter& pScene); - - /// \fn AMFImporter& operator=(const AMFImporter& pScene) - /// Disabled assign operator. - AMFImporter& operator=(const AMFImporter& pScene); - - /// \fn void Clear() - /// Clear all temporary data. - void Clear(); - - /***********************************************/ - /************* Functions: find set *************/ - /***********************************************/ - - /// \fn bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, aiNode** pNode) const - /// Find specified node element in node elements list ( \ref mNodeElement_List). - /// \param [in] pID - ID(name) of requested node element. - /// \param [in] pType - type of node element. - /// \param [out] pNode - pointer to pointer to item found. - /// \return true - if the node element is found, else - false. - bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const; - - /// \fn bool Find_ConvertedNode(const std::string& pID, std::list& pNodeList, aiNode** pNode) const - /// Find requested aiNode in node list. - /// \param [in] pID - ID(name) of requested node. - /// \param [in] pNodeList - list of nodes where to find the node. - /// \param [out] pNode - pointer to pointer to item found. - /// \return true - if the node is found, else - false. - bool Find_ConvertedNode(const std::string& pID, std::list& pNodeList, aiNode** pNode) const; - - /// \fn bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const - /// Find material in list for converted materials. Use at postprocessing step. - /// \param [in] pID - material ID. - /// \param [out] pConvertedMaterial - pointer to found converted material (\ref SPP_Material). - /// \return true - if the material is found, else - false. - bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const; - - /// \fn bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A, uint32_t* pConvertedTextureIndex = nullptr) const - /// Find texture in list of converted textures. Use at postprocessing step, - /// \param [in] pID_R - ID of source "red" texture. - /// \param [in] pID_G - ID of source "green" texture. - /// \param [in] pID_B - ID of source "blue" texture. - /// \param [in] pID_A - ID of source "alpha" texture. Use empty string to find RGB-texture. - /// \param [out] pConvertedTextureIndex - pointer where index in list of found texture will be written. If equivalent to nullptr then nothing will be - /// written. - /// \return true - if the texture is found, else - false. - bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A, - uint32_t* pConvertedTextureIndex = nullptr) const; - - /***********************************************/ - /********* Functions: postprocess set **********/ - /***********************************************/ - - /// \fn void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector& pVertexCoordinateArray, std::vector& pVertexColorArray) const - /// Get data stored in and place it to arrays. - /// \param [in] pNodeElement - reference to node element which kept data. - /// \param [in] pVertexCoordinateArray - reference to vertices coordinates kept in . - /// \param [in] pVertexColorArray - reference to vertices colors for all & pVertexCoordinateArray, - std::vector& pVertexColorArray) const; - - /// \fn size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A) - /// Return converted texture ID which related to specified source textures ID's. If converted texture does not exist then it will be created and ID on new - /// converted texture will be returned. Conversion: set of textures from \ref CAMFImporter_NodeElement_Texture to one \ref SPP_Texture and place it - /// to converted textures list. - /// Any of source ID's can be absent(empty string) or even one ID only specified. But at least one ID must be specified. - /// \param [in] pID_R - ID of source "red" texture. - /// \param [in] pID_G - ID of source "green" texture. - /// \param [in] pID_B - ID of source "blue" texture. - /// \param [in] pID_A - ID of source "alpha" texture. - /// \return index of the texture in array of the converted textures. - size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A); - - /// \fn void PostprocessHelper_SplitFacesByTextureID(std::list& pInputList, std::list > pOutputList_Separated) - /// Separate input list by texture IDs. This step is needed because aiMesh can contain mesh which is use only one texture (or set: diffuse, bump etc). - /// \param [in] pInputList - input list with faces. Some of them can contain color or texture mapping, or both of them, or nothing. Will be cleared after - /// processing. - /// \param [out] pOutputList_Separated - output list of the faces lists. Separated faces list by used texture IDs. Will be cleared before processing. - void PostprocessHelper_SplitFacesByTextureID(std::list& pInputList, std::list >& pOutputList_Separated); - - /// \fn void Postprocess_AddMetadata(const std::list& pMetadataList, aiNode& pSceneNode) const - /// Check if child elements of node element is metadata and add it to scene node. - /// \param [in] pMetadataList - reference to list with collected metadata. - /// \param [out] pSceneNode - scene node in which metadata will be added. - void Postprocess_AddMetadata(const std::list& pMetadataList, aiNode& pSceneNode) const; - - /// \fn void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list& pMeshList, aiNode** pSceneNode) - /// To create aiMesh and aiNode for it from . - /// \param [in] pNodeElement - reference to node element which kept data. - /// \param [out] pMeshList - reference to a list with all aiMesh of the scene. - /// \param [out] pSceneNode - pointer to place where new aiNode will be created. - void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list& pMeshList, aiNode** pSceneNode); - - /// \fn void Postprocess_BuildMeshSet(const CAMFImporter_NodeElement_Mesh& pNodeElement, const std::vector& pVertexCoordinateArray, const std::vector& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor, std::list& pMeshList, aiNode& pSceneNode) - /// Create mesh for every in . - /// \param [in] pNodeElement - reference to node element which kept data. - /// \param [in] pVertexCoordinateArray - reference to vertices coordinates for all 's. - /// \param [in] pVertexColorArray - reference to vertices colors for all 's. If color for vertex is not set then corresponding member of array - /// contain nullptr. - /// \param [in] pObjectColor - pointer to colors for . If color is not set then argument contain nullptr. - /// \param [in] pMaterialList - reference to a list with defined materials. - /// \param [out] pMeshList - reference to a list with all aiMesh of the scene. - /// \param [out] pSceneNode - reference to aiNode which will own new aiMesh's. - void Postprocess_BuildMeshSet(const CAMFImporter_NodeElement_Mesh& pNodeElement, const std::vector& pVertexCoordinateArray, - const std::vector& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor, - std::list& pMeshList, aiNode& pSceneNode); - - /// \fn void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial) - /// Convert material from \ref CAMFImporter_NodeElement_Material to \ref SPP_Material. - /// \param [in] pMaterial - source CAMFImporter_NodeElement_Material. - void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial); - - /// \fn void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list& pNodeList) const - /// Create and add to aiNode's list new part of scene graph defined by . - /// \param [in] pConstellation - reference to node. - /// \param [out] pNodeList - reference to aiNode's list. - void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list& pNodeList) const; - - /// \fn void Postprocess_BuildScene() - /// Build Assimp scene graph in aiScene from collected data. - /// \param [out] pScene - pointer to aiScene where tree will be built. - void Postprocess_BuildScene(aiScene* pScene); - - /***********************************************/ - /************* Functions: throw set ************/ - /***********************************************/ - - /// \fn void Throw_CloseNotFound(const std::string& pNode) - /// Call that function when close tag of node not found and exception must be raised. - /// E.g.: - /// - /// - /// - /// \throw DeadlyImportError. - /// \param [in] pNode - node name in which exception happened. - void Throw_CloseNotFound(const std::string& pNode); - - /// \fn void Throw_IncorrectAttr(const std::string& pAttrName) - /// Call that function when attribute name is incorrect and exception must be raised. - /// \param [in] pAttrName - attribute name. - /// \throw DeadlyImportError. - void Throw_IncorrectAttr(const std::string& pAttrName); - - /// \fn void Throw_IncorrectAttrValue(const std::string& pAttrName) - /// Call that function when attribute value is incorrect and exception must be raised. - /// \param [in] pAttrName - attribute name. - /// \throw DeadlyImportError. - void Throw_IncorrectAttrValue(const std::string& pAttrName); - - /// \fn void Throw_MoreThanOnceDefined(const std::string& pNode, const std::string& pDescription) - /// Call that function when some type of nodes are defined twice or more when must be used only once and exception must be raised. - /// E.g.: - /// - /// ... - /// ... - /// - /// \throw DeadlyImportError. - /// \param [in] pNodeType - type of node which defined one more time. - /// \param [in] pDescription - message about error. E.g. what the node defined while exception raised. - void Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription); - - /// \fn void Throw_ID_NotFound(const std::string& pID) const - /// Call that function when referenced element ID are not found in graph and exception must be raised. - /// \param [in] pID - ID of of element which not found. - /// \throw DeadlyImportError. - void Throw_ID_NotFound(const std::string& pID) const; - - /***********************************************/ - /************** Functions: LOG set *************/ - /***********************************************/ - - /// \fn void LogInfo(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->info() - void LogInfo(const std::string& pMessage) { DefaultLogger::get()->info(pMessage); } - - /// \fn void LogWarning(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->warn() - void LogWarning(const std::string& pMessage) { DefaultLogger::get()->warn(pMessage); } - - /// \fn void LogError(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->error() - void LogError(const std::string& pMessage) { DefaultLogger::get()->error(pMessage); } - - /***********************************************/ - /************** Functions: XML set *************/ - /***********************************************/ - - /// \fn void XML_CheckNode_MustHaveChildren() - /// Check if current node have children: .... If not then exception will throwed. - void XML_CheckNode_MustHaveChildren(); - - /// \fn bool XML_CheckNode_NameEqual(const std::string& pNodeName) - /// Check if current node name is equal to pNodeName. - /// \param [in] pNodeName - name for checking. - /// return true if current node name is equal to pNodeName, else - false. - bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; } - - /// \fn void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName) - /// Skip unsupported node and report about that. Depend on node name can be skipped begin tag of node all whole node. - /// \param [in] pParentNodeName - parent node name. Used for reporting. - void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName); - - /// \fn bool XML_SearchNode(const std::string& pNodeName) - /// Search for specified node in file. XML file read pointer(mReader) will point to found node or file end after search is end. - /// \param [in] pNodeName - requested node name. - /// return true - if node is found, else - false. - bool XML_SearchNode(const std::string& pNodeName); - - /// \fn bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx) - /// Read attribute value. - /// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set). - /// \return read data. - bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx); - - /// \fn float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) - /// Read attribute value. - /// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set). - /// \return read data. - float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx); - - /// \fn uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx) - /// Read attribute value. - /// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set). - /// \return read data. - uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx); - - /// \fn float XML_ReadNode_GetVal_AsFloat() - /// Read node value. - /// \return read data. - float XML_ReadNode_GetVal_AsFloat(); - - /// \fn uint32_t XML_ReadNode_GetVal_AsU32() - /// Read node value. - /// \return read data. - uint32_t XML_ReadNode_GetVal_AsU32(); - - /// \fn void XML_ReadNode_GetVal_AsString(std::string& pValue) - /// Read node value. - /// \return read data. - void XML_ReadNode_GetVal_AsString(std::string& pValue); - - /***********************************************/ - /******** Functions: parse set private *********/ - /***********************************************/ - - /// \fn void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode) - /// Make pNode as current and enter deeper for parsing child nodes. At end \ref ParseHelper_Node_Exit must be called. - /// \param [in] pNode - new current node. - void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode); - - /// \fn void ParseHelper_Group_End() - /// This function must be called when exiting from grouping node. \ref ParseHelper_Group_Begin. - void ParseHelper_Node_Exit(); - - /// \fn void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString) - /// Attribute values of floating point types can take form ".x"(without leading zero). irrXMLReader can not read this form of values and it - /// must be converted to right form - "0.xxx". - /// \param [in] pInStr - pointer to input string which can contain incorrect form of values. - /// \param [out[ pOutString - output string with right form of values. - void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString); - - /// \fn void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector& pOutputData) const - /// Decode Base64-encoded data. - /// \param [in] pInputBase64 - reference to input Base64-encoded string. - /// \param [out] pOutputData - reference to output array for decoded data. - void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector& pOutputData) const; - - /// \fn void ParseNode_Root() - /// Parse node of the file. - void ParseNode_Root(); - - /******** Functions: top nodes *********/ - - /// \fn void ParseNode_Constellation() - /// Parse node of the file. - void ParseNode_Constellation(); - - /// \fn void ParseNode_Constellation() - /// Parse node of the file. - void ParseNode_Instance(); - - /// \fn void ParseNode_Material() - /// Parse node of the file. - void ParseNode_Material(); - - /// \fn void ParseNode_Metadata() - /// Parse node. - void ParseNode_Metadata(); - - /// \fn void ParseNode_Object() - /// Parse node of the file. - void ParseNode_Object(); - - /// \fn void ParseNode_Texture() - /// Parse node of the file. - void ParseNode_Texture(); - - /******** Functions: geometry nodes *********/ - - /// \fn void ParseNode_Coordinates() - /// Parse node of the file. - void ParseNode_Coordinates(); - - /// \fn void ParseNode_Edge() - /// Parse node of the file. - void ParseNode_Edge(); - - /// \fn void ParseNode_Mesh() - /// Parse node of the file. - void ParseNode_Mesh(); - - /// \fn void ParseNode_Triangle() - /// Parse node of the file. - void ParseNode_Triangle(); - - /// \fn void ParseNode_Vertex() - /// Parse node of the file. - void ParseNode_Vertex(); - - /// \fn void ParseNode_Vertices() - /// Parse node of the file. - void ParseNode_Vertices(); - - /// \fn void ParseNode_Volume() - /// Parse node of the file. - void ParseNode_Volume(); - - /******** Functions: material nodes *********/ - - /// \fn void ParseNode_Color() - /// Parse node of the file. - void ParseNode_Color(); - - /// \fn void ParseNode_TexMap(const bool pUseOldName = false) - /// Parse of node of the file. - /// \param [in] pUseOldName - if true then use old name of node(and children) - , instead of new name - . - void ParseNode_TexMap(const bool pUseOldName = false); - -public: - - /// \fn AMFImporter() - /// Default constructor. - AMFImporter() - : mNodeElement_Cur(nullptr), mReader(nullptr) - {} - - /// \fn ~AMFImporter() - /// Default destructor. - ~AMFImporter(); - - /***********************************************/ - /******** Functions: parse set, public *********/ - /***********************************************/ - - /// \fn void ParseFile(const std::string& pFile, IOSystem* pIOHandler) - /// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph. - /// Also exception can be throwed if trouble will found. - /// \param [in] pFile - name of file to be parsed. - /// \param [in] pIOHandler - pointer to IO helper object. - void ParseFile(const std::string& pFile, IOSystem* pIOHandler); - - /***********************************************/ - /********* Functions: BaseImporter set *********/ - /***********************************************/ - - bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const; - void GetExtensionList(std::set& pExtensionList); - void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler); - const aiImporterDesc* GetInfo ()const; - -};// class AMFImporter - -}// namespace Assimp - -#endif // INCLUDED_AI_AMF_IMPORTER_H diff --git a/src/3rdparty/assimp/code/AMFImporter_Geometry.cpp b/src/3rdparty/assimp/code/AMFImporter_Geometry.cpp deleted file mode 100644 index afba3f2bc..000000000 --- a/src/3rdparty/assimp/code/AMFImporter_Geometry.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/// \file AMFImporter_Geometry.cpp -/// \brief Parsing data from geometry nodes. -/// \date 2016 -/// \author smal.root@gmail.com - -#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER - -#include "AMFImporter.hpp" -#include "AMFImporter_Macro.hpp" - -namespace Assimp -{ - -// -// -// A 3D mesh hull. -// Multi elements - Yes. -// Parent element - . -void AMFImporter::ParseNode_Mesh() -{ -CAMFImporter_NodeElement* ne; - - // create new mesh object. - ne = new CAMFImporter_NodeElement_Mesh(mNodeElement_Cur); - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool vert_read = false; - - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("mesh"); - if(XML_CheckNode_NameEqual("vertices")) - { - // Check if data already defined. - if(vert_read) Throw_MoreThanOnceDefined("vertices", "Only one vertices set can be defined for ."); - // read data and set flag about it - ParseNode_Vertices(); - vert_read = true; - - continue; - } - - if(XML_CheckNode_NameEqual("volume")) { ParseNode_Volume(); continue; } - MACRO_NODECHECK_LOOPEND("mesh"); - ParseHelper_Node_Exit(); - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// The list of vertices to be used in defining triangles. -// Multi elements - No. -// Parent element - . -void AMFImporter::ParseNode_Vertices() -{ -CAMFImporter_NodeElement* ne; - - // create new mesh object. - ne = new CAMFImporter_NodeElement_Vertices(mNodeElement_Cur); - // Check for child nodes - if(!mReader->isEmptyElement()) - { - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("vertices"); - if(XML_CheckNode_NameEqual("vertex")) { ParseNode_Vertex(); continue; } - MACRO_NODECHECK_LOOPEND("vertices"); - ParseHelper_Node_Exit(); - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// A vertex to be referenced in triangles. -// Multi elements - Yes. -// Parent element - . -void AMFImporter::ParseNode_Vertex() -{ -CAMFImporter_NodeElement* ne; - - // create new mesh object. - ne = new CAMFImporter_NodeElement_Vertex(mNodeElement_Cur); - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool col_read = false; - bool coord_read = false; - - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("vertex"); - if(XML_CheckNode_NameEqual("color")) - { - // Check if data already defined. - if(col_read) Throw_MoreThanOnceDefined("color", "Only one color can be defined for ."); - // read data and set flag about it - ParseNode_Color(); - col_read = true; - - continue; - } - - if(XML_CheckNode_NameEqual("coordinates")) - { - // Check if data already defined. - if(coord_read) Throw_MoreThanOnceDefined("coordinates", "Only one coordinates set can be defined for ."); - // read data and set flag about it - ParseNode_Coordinates(); - coord_read = true; - - continue; - } - - if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } - MACRO_NODECHECK_LOOPEND("vertex"); - ParseHelper_Node_Exit(); - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// Specifies the 3D location of this vertex. -// Multi elements - No. -// Parent element - . -// -// Children elements: -// , , -// Multi elements - No. -// X, Y, or Z coordinate, respectively, of a vertex position in space. -void AMFImporter::ParseNode_Coordinates() -{ -CAMFImporter_NodeElement* ne; - - // create new color object. - ne = new CAMFImporter_NodeElement_Coordinates(mNodeElement_Cur); - - CAMFImporter_NodeElement_Coordinates& als = *((CAMFImporter_NodeElement_Coordinates*)ne);// alias for convenience - - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool read_flag[3] = { false, false, false }; - - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("coordinates"); - MACRO_NODECHECK_READCOMP_F("x", read_flag[0], als.Coordinate.x); - MACRO_NODECHECK_READCOMP_F("y", read_flag[1], als.Coordinate.y); - MACRO_NODECHECK_READCOMP_F("z", read_flag[2], als.Coordinate.z); - MACRO_NODECHECK_LOOPEND("coordinates"); - ParseHelper_Node_Exit(); - // check that all components was defined - if((read_flag[0] && read_flag[1] && read_flag[2]) == 0) throw DeadlyImportError("Not all coordinate's components are defined."); - - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// Defines a volume from the established vertex list. -// Multi elements - Yes. -// Parent element - . -void AMFImporter::ParseNode_Volume() -{ -std::string materialid; -std::string type; -CAMFImporter_NodeElement* ne; - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("materialid", materialid, mReader->getAttributeValue); - MACRO_ATTRREAD_CHECK_RET("type", type, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND; - - // create new object. - ne = new CAMFImporter_NodeElement_Volume(mNodeElement_Cur); - // and assign read data - ((CAMFImporter_NodeElement_Volume*)ne)->MaterialID = materialid; - ((CAMFImporter_NodeElement_Volume*)ne)->Type = type; - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool col_read = false; - - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("volume"); - if(XML_CheckNode_NameEqual("color")) - { - // Check if data already defined. - if(col_read) Throw_MoreThanOnceDefined("color", "Only one color can be defined for ."); - // read data and set flag about it - ParseNode_Color(); - col_read = true; - - continue; - } - - if(XML_CheckNode_NameEqual("triangle")) { ParseNode_Triangle(); continue; } - if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } - MACRO_NODECHECK_LOOPEND("volume"); - ParseHelper_Node_Exit(); - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// Defines a 3D triangle from three vertices, according to the right-hand rule (counter-clockwise when looking from the outside). -// Multi elements - Yes. -// Parent element - . -// -// Children elements: -// , , -// Multi elements - No. -// Index of the desired vertices in a triangle or edge. -void AMFImporter::ParseNode_Triangle() -{ -CAMFImporter_NodeElement* ne; - - // create new color object. - ne = new CAMFImporter_NodeElement_Triangle(mNodeElement_Cur); - - CAMFImporter_NodeElement_Triangle& als = *((CAMFImporter_NodeElement_Triangle*)ne);// alias for convenience - - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool col_read = false, tex_read = false; - bool read_flag[3] = { false, false, false }; - - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("triangle"); - if(XML_CheckNode_NameEqual("color")) - { - // Check if data already defined. - if(col_read) Throw_MoreThanOnceDefined("color", "Only one color can be defined for ."); - // read data and set flag about it - ParseNode_Color(); - col_read = true; - - continue; - } - - if(XML_CheckNode_NameEqual("texmap"))// new name of node: "texmap". - { - // Check if data already defined. - if(tex_read) Throw_MoreThanOnceDefined("texmap", "Only one texture coordinate can be defined for ."); - // read data and set flag about it - ParseNode_TexMap(); - tex_read = true; - - continue; - } - else if(XML_CheckNode_NameEqual("map"))// old name of node: "map". - { - // Check if data already defined. - if(tex_read) Throw_MoreThanOnceDefined("map", "Only one texture coordinate can be defined for ."); - // read data and set flag about it - ParseNode_TexMap(true); - tex_read = true; - - continue; - } - - MACRO_NODECHECK_READCOMP_U32("v1", read_flag[0], als.V[0]); - MACRO_NODECHECK_READCOMP_U32("v2", read_flag[1], als.V[1]); - MACRO_NODECHECK_READCOMP_U32("v3", read_flag[2], als.V[2]); - MACRO_NODECHECK_LOOPEND("triangle"); - ParseHelper_Node_Exit(); - // check that all components was defined - if((read_flag[0] && read_flag[1] && read_flag[2]) == 0) throw DeadlyImportError("Not all vertices of the triangle are defined."); - - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -}// namespace Assimp - -#endif // !ASSIMP_BUILD_NO_AMF_IMPORTER diff --git a/src/3rdparty/assimp/code/AMFImporter_Macro.hpp b/src/3rdparty/assimp/code/AMFImporter_Macro.hpp deleted file mode 100644 index b7c0f9863..000000000 --- a/src/3rdparty/assimp/code/AMFImporter_Macro.hpp +++ /dev/null @@ -1,165 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/// \file AMFImporter_Macro.hpp -/// \brief Useful macrodefines. -/// \date 2016 -/// \author smal.root@gmail.com - -#pragma once -#ifndef AMFIMPORTER_MACRO_HPP_INCLUDED -#define AMFIMPORTER_MACRO_HPP_INCLUDED - -/// \def MACRO_ATTRREAD_LOOPBEG -/// Begin of loop that read attributes values. -#define MACRO_ATTRREAD_LOOPBEG \ - for(int idx = 0, idx_end = mReader->getAttributeCount(); idx < idx_end; idx++) \ - { \ - std::string an(mReader->getAttributeName(idx)); - -/// \def MACRO_ATTRREAD_LOOPEND -/// End of loop that read attributes values. -#define MACRO_ATTRREAD_LOOPEND \ - Throw_IncorrectAttr(an); \ - } - -/// \def MACRO_ATTRREAD_LOOPEND_WSKIP -/// End of loop that read attributes values. Difference from \ref MACRO_ATTRREAD_LOOPEND in that: current macro skip unknown attributes, but -/// \ref MACRO_ATTRREAD_LOOPEND throw an exception. -#define MACRO_ATTRREAD_LOOPEND_WSKIP \ - continue; \ - } - -/// \def MACRO_ATTRREAD_CHECK_REF -/// Check curent attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then -/// "continue" will called. -/// \param [in] pAttrName - attribute name. -/// \param [out] pVarName - output variable name. -/// \param [in] pFunction - function which read attribute value and write it to pVarName. -#define MACRO_ATTRREAD_CHECK_REF(pAttrName, pVarName, pFunction) \ - if(an == pAttrName) \ - { \ - pFunction(idx, pVarName); \ - continue; \ - } - -/// \def MACRO_ATTRREAD_CHECK_RET -/// Check curent attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction. -/// If result was read then "continue" will called. -/// \param [in] pAttrName - attribute name. -/// \param [out] pVarName - output variable name. -/// \param [in] pFunction - function which read attribute value and write it to pVarName. -#define MACRO_ATTRREAD_CHECK_RET(pAttrName, pVarName, pFunction) \ - if(an == pAttrName) \ - { \ - pVarName = pFunction(idx); \ - continue; \ - } - -/// \def MACRO_NODECHECK_LOOPBEGIN(pNodeName) -/// Begin of loop of parsing child nodes. Do not add ';' at end. -/// \param [in] pNodeName - current node name. -#define MACRO_NODECHECK_LOOPBEGIN(pNodeName) \ - do { \ - bool close_found = false; \ - \ - while(mReader->read()) \ - { \ - if(mReader->getNodeType() == irr::io::EXN_ELEMENT) \ - { - -/// \def MACRO_NODECHECK_LOOPEND(pNodeName) -/// End of loop of parsing child nodes. -/// \param [in] pNodeName - current node name. -#define MACRO_NODECHECK_LOOPEND(pNodeName) \ - XML_CheckNode_SkipUnsupported(pNodeName); \ - }/* if(mReader->getNodeType() == irr::io::EXN_ELEMENT) */ \ - else if(mReader->getNodeType() == irr::io::EXN_ELEMENT_END) \ - { \ - if(XML_CheckNode_NameEqual(pNodeName)) \ - { \ - close_found = true; \ - \ - break; \ - } \ - }/* else if(mReader->getNodeType() == irr::io::EXN_ELEMENT_END) */ \ - }/* while(mReader->read()) */ \ - \ - if(!close_found) Throw_CloseNotFound(pNodeName); \ - \ - } while(false) - -/// \def MACRO_NODECHECK_READCOMP_F -/// Check curent node name and if it equal to requested then read value. Result write to output variable of type "float". -/// If result was read then "continue" will called. Also check if node data already read then raise exception. -/// \param [in] pNodeName - node name. -/// \param [in, out] pReadFlag - read flag. -/// \param [out] pVarName - output variable name. -#define MACRO_NODECHECK_READCOMP_F(pNodeName, pReadFlag, pVarName) \ - if(XML_CheckNode_NameEqual(pNodeName)) \ - { \ - /* Check if field already read before. */ \ - if(pReadFlag) Throw_MoreThanOnceDefined(pNodeName, "Only one component can be defined."); \ - /* Read color component and assign it to object. */ \ - pVarName = XML_ReadNode_GetVal_AsFloat(); \ - pReadFlag = true; \ - continue; \ - } - -/// \def MACRO_NODECHECK_READCOMP_U32 -/// Check curent node name and if it equal to requested then read value. Result write to output variable of type "uint32_t". -/// If result was read then "continue" will called. Also check if node data already read then raise exception. -/// \param [in] pNodeName - node name. -/// \param [in, out] pReadFlag - read flag. -/// \param [out] pVarName - output variable name. -#define MACRO_NODECHECK_READCOMP_U32(pNodeName, pReadFlag, pVarName) \ - if(XML_CheckNode_NameEqual(pNodeName)) \ - { \ - /* Check if field already read before. */ \ - if(pReadFlag) Throw_MoreThanOnceDefined(pNodeName, "Only one component can be defined."); \ - /* Read color component and assign it to object. */ \ - pVarName = XML_ReadNode_GetVal_AsU32(); \ - pReadFlag = true; \ - continue; \ - } - -#endif // AMFIMPORTER_MACRO_HPP_INCLUDED diff --git a/src/3rdparty/assimp/code/AMFImporter_Material.cpp b/src/3rdparty/assimp/code/AMFImporter_Material.cpp deleted file mode 100644 index d15099fac..000000000 --- a/src/3rdparty/assimp/code/AMFImporter_Material.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/// \file AMFImporter_Material.cpp -/// \brief Parsing data from material nodes. -/// \date 2016 -/// \author smal.root@gmail.com - -#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER - -#include "AMFImporter.hpp" -#include "AMFImporter_Macro.hpp" - -namespace Assimp -{ - -// , and . -// > -// -// A color definition. -// Multi elements - No. -// Parent element - , , , , . -// -// "profile" can be one of "sRGB", "AdobeRGB", "Wide-Gamut-RGB", "CIERGB", "CIELAB", or "CIEXYZ". -// Children elements: -// , , , -// Multi elements - No. -// Red, Greed, Blue and Alpha (transparency) component of a color in sRGB space, values ranging from 0 to 1. The -// values can be specified as constants, or as a formula depending on the coordinates. -void AMFImporter::ParseNode_Color() -{ -std::string profile; -CAMFImporter_NodeElement* ne; - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("profile", profile, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND; - - // create new color object. - ne = new CAMFImporter_NodeElement_Color(mNodeElement_Cur); - - CAMFImporter_NodeElement_Color& als = *((CAMFImporter_NodeElement_Color*)ne);// alias for convenience - - als.Profile = profile; - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool read_flag[4] = { false, false, false, false }; - - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("color"); - MACRO_NODECHECK_READCOMP_F("r", read_flag[0], als.Color.r); - MACRO_NODECHECK_READCOMP_F("g", read_flag[1], als.Color.g); - MACRO_NODECHECK_READCOMP_F("b", read_flag[2], als.Color.b); - MACRO_NODECHECK_READCOMP_F("a", read_flag[3], als.Color.a); - MACRO_NODECHECK_LOOPEND("color"); - ParseHelper_Node_Exit(); - // check that all components was defined - if(!(read_flag[0] && read_flag[1] && read_flag[2])) throw DeadlyImportError("Not all color components are defined."); - // check if is absent. Then manualy add "a == 1". - if(!read_flag[3]) als.Color.a = 1; - - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - als.Composed = false; - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// An available material. -// Multi elements - Yes. -// Parent element - . -void AMFImporter::ParseNode_Material() -{ -std::string id; -CAMFImporter_NodeElement* ne; - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND; - - // create new object. - ne = new CAMFImporter_NodeElement_Material(mNodeElement_Cur); - // and assign read data - ((CAMFImporter_NodeElement_Material*)ne)->ID = id; - // Check for child nodes - if(!mReader->isEmptyElement()) - { - bool col_read = false; - - ParseHelper_Node_Enter(ne); - MACRO_NODECHECK_LOOPBEGIN("material"); - if(XML_CheckNode_NameEqual("color")) - { - // Check if data already defined. - if(col_read) Throw_MoreThanOnceDefined("color", "Only one color can be defined for ."); - // read data and set flag about it - ParseNode_Color(); - col_read = true; - - continue; - } - - if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } - MACRO_NODECHECK_LOOPEND("material"); - ParseHelper_Node_Exit(); - }// if(!mReader->isEmptyElement()) - else - { - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else - - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// -// Specifies an texture data to be used as a map. Lists a sequence of Base64 values specifying values for pixels from left to right then top to bottom, -// then layer by layer. -// Multi elements - Yes. -// Parent element - . -void AMFImporter::ParseNode_Texture() -{ -std::string id; -uint32_t width = 0; -uint32_t height = 0; -uint32_t depth = 1; -std::string type; -bool tiled = false; -std::string enc64_data; -CAMFImporter_NodeElement* ne; - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue); - MACRO_ATTRREAD_CHECK_RET("width", width, XML_ReadNode_GetAttrVal_AsU32); - MACRO_ATTRREAD_CHECK_RET("height", height, XML_ReadNode_GetAttrVal_AsU32); - MACRO_ATTRREAD_CHECK_RET("depth", depth, XML_ReadNode_GetAttrVal_AsU32); - MACRO_ATTRREAD_CHECK_RET("type", type, mReader->getAttributeValue); - MACRO_ATTRREAD_CHECK_RET("tiled", tiled, XML_ReadNode_GetAttrVal_AsBool); - MACRO_ATTRREAD_LOOPEND; - - // create new texture object. - ne = new CAMFImporter_NodeElement_Texture(mNodeElement_Cur); - - CAMFImporter_NodeElement_Texture& als = *((CAMFImporter_NodeElement_Texture*)ne);// alias for convenience - - // Check for child nodes - if(!mReader->isEmptyElement()) XML_ReadNode_GetVal_AsString(enc64_data); - - // check that all components was defined - if(id.empty()) throw DeadlyImportError("ID for texture must be defined."); - if(width < 1) Throw_IncorrectAttrValue("width"); - if(height < 1) Throw_IncorrectAttrValue("height"); - if(depth < 1) Throw_IncorrectAttrValue("depth"); - if(type != "grayscale") Throw_IncorrectAttrValue("type"); - if(enc64_data.empty()) throw DeadlyImportError("Texture data not defined."); - // copy data - als.ID = id; - als.Width = width; - als.Height = height; - als.Depth = depth; - als.Tiled = tiled; - ParseHelper_Decode_Base64(enc64_data, als.Data); - // check data size - if((width * height * depth) != als.Data.size()) throw DeadlyImportError("Texture has incorrect data size."); - - mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. -} - -// -// , old name: -// Specifies texture coordinates for triangle. -// Multi elements - No. -// Parent element - . -// Children elements: -// , , , , , . Old name: , , , , , . -// Multi elements - No. -// Texture coordinates for every vertex of triangle. -void AMFImporter::ParseNode_TexMap(const bool pUseOldName) -{ -std::string rtexid, gtexid, btexid, atexid; -CAMFImporter_NodeElement* ne; - - // Read attributes for node . - MACRO_ATTRREAD_LOOPBEG; - MACRO_ATTRREAD_CHECK_RET("rtexid", rtexid, mReader->getAttributeValue); - MACRO_ATTRREAD_CHECK_RET("gtexid", gtexid, mReader->getAttributeValue); - MACRO_ATTRREAD_CHECK_RET("btexid", btexid, mReader->getAttributeValue); - MACRO_ATTRREAD_CHECK_RET("atexid", atexid, mReader->getAttributeValue); - MACRO_ATTRREAD_LOOPEND; - - // create new texture coordinates object. - ne = new CAMFImporter_NodeElement_TexMap(mNodeElement_Cur); - - CAMFImporter_NodeElement_TexMap& als = *((CAMFImporter_NodeElement_TexMap*)ne);// alias for convenience - // check data - if(rtexid.empty() && gtexid.empty() && btexid.empty()) throw DeadlyImportError("ParseNode_TexMap. At least one texture ID must be defined."); - // Check for children nodes - XML_CheckNode_MustHaveChildren(); - // read children nodes - bool read_flag[6] = { false, false, false, false, false, false }; - - ParseHelper_Node_Enter(ne); - if(!pUseOldName) - { - MACRO_NODECHECK_LOOPBEGIN("texmap"); - MACRO_NODECHECK_READCOMP_F("utex1", read_flag[0], als.TextureCoordinate[0].x); - MACRO_NODECHECK_READCOMP_F("utex2", read_flag[1], als.TextureCoordinate[1].x); - MACRO_NODECHECK_READCOMP_F("utex3", read_flag[2], als.TextureCoordinate[2].x); - MACRO_NODECHECK_READCOMP_F("vtex1", read_flag[3], als.TextureCoordinate[0].y); - MACRO_NODECHECK_READCOMP_F("vtex2", read_flag[4], als.TextureCoordinate[1].y); - MACRO_NODECHECK_READCOMP_F("vtex3", read_flag[5], als.TextureCoordinate[2].y); - MACRO_NODECHECK_LOOPEND("texmap"); - } - else - { - MACRO_NODECHECK_LOOPBEGIN("map"); - MACRO_NODECHECK_READCOMP_F("u1", read_flag[0], als.TextureCoordinate[0].x); - MACRO_NODECHECK_READCOMP_F("u2", read_flag[1], als.TextureCoordinate[1].x); - MACRO_NODECHECK_READCOMP_F("u3", read_flag[2], als.TextureCoordinate[2].x); - MACRO_NODECHECK_READCOMP_F("v1", read_flag[3], als.TextureCoordinate[0].y); - MACRO_NODECHECK_READCOMP_F("v2", read_flag[4], als.TextureCoordinate[1].y); - MACRO_NODECHECK_READCOMP_F("v3", read_flag[5], als.TextureCoordinate[2].y); - MACRO_NODECHECK_LOOPEND("map"); - }// if(!pUseOldName) else - - ParseHelper_Node_Exit(); - - // check that all components was defined - if(!(read_flag[0] && read_flag[1] && read_flag[2] && read_flag[3] && read_flag[4] && read_flag[5])) - throw DeadlyImportError("Not all texture coordinates are defined."); - - // copy attributes data - als.TextureID_R = rtexid; - als.TextureID_G = gtexid; - als.TextureID_B = btexid; - als.TextureID_A = atexid; - - mNodeElement_List.push_back(ne);// add to node element list because its a new object in graph. -} - -}// namespace Assimp - -#endif // !ASSIMP_BUILD_NO_AMF_IMPORTER diff --git a/src/3rdparty/assimp/code/AMFImporter_Node.hpp b/src/3rdparty/assimp/code/AMFImporter_Node.hpp deleted file mode 100644 index 522e6ccca..000000000 --- a/src/3rdparty/assimp/code/AMFImporter_Node.hpp +++ /dev/null @@ -1,400 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/// \file AMFImporter_Node.hpp -/// \brief Elements of scene graph. -/// \date 2016 -/// \author smal.root@gmail.com - -#pragma once -#ifndef INCLUDED_AI_AMF_IMPORTER_NODE_H -#define INCLUDED_AI_AMF_IMPORTER_NODE_H - -// Header files, stdlib. -#include -#include -#include - -// Header files, Assimp. -#include "assimp/types.h" -#include "assimp/scene.h" - -/// \class CAMFImporter_NodeElement -/// Base class for elements of nodes. -class CAMFImporter_NodeElement { - -public: - /// Define what data type contain node element. - enum EType { - ENET_Color, ///< Color element: . - ENET_Constellation,///< Grouping element: . - ENET_Coordinates, ///< Coordinates element: . - ENET_Edge, ///< Edge element: . - ENET_Instance, ///< Grouping element: . - ENET_Material, ///< Material element: . - ENET_Metadata, ///< Metadata element: . - ENET_Mesh, ///< Metadata element: . - ENET_Object, ///< Element which hold object: . - ENET_Root, ///< Root element: . - ENET_Triangle, ///< Triangle element: . - ENET_TexMap, ///< Texture coordinates element: or . - ENET_Texture, ///< Texture element: . - ENET_Vertex, ///< Vertex element: . - ENET_Vertices, ///< Vertex element: . - ENET_Volume, ///< Volume element: . - - ENET_Invalid ///< Element has invalid type and possible contain invalid data. - }; - - const EType Type;///< Type of element. - std::string ID;///< ID of element. - CAMFImporter_NodeElement* Parent;///< Parent element. If nullptr then this node is root. - std::list Child;///< Child elements. - -public: /// Destructor, virtual.. - virtual ~CAMFImporter_NodeElement() { - // empty - } - -private: - /// Disabled copy constructor. - CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement); - - /// Disabled assign operator. - CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement); - - /// Disabled default constructor. - CAMFImporter_NodeElement(); - -protected: - /// In constructor inheritor must set element type. - /// \param [in] pType - element type. - /// \param [in] pParent - parent element. - CAMFImporter_NodeElement(const EType pType, CAMFImporter_NodeElement* pParent) - : Type(pType) - , ID() - , Parent(pParent) - , Child() { - // empty - } -};// class IAMFImporter_NodeElement - -/// \struct CAMFImporter_NodeElement_Constellation -/// A collection of objects or constellations with specific relative locations. -struct CAMFImporter_NodeElement_Constellation : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Constellation, pParent) - {} - -};// struct CAMFImporter_NodeElement_Constellation - -/// \struct CAMFImporter_NodeElement_Instance -/// Part of constellation. -struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - - std::string ObjectID;///< ID of object for instantiation. - /// \var Delta - The distance of translation in the x, y, or z direction, respectively, in the referenced object's coordinate system, to - /// create an instance of the object in the current constellation. - aiVector3D Delta; - - /// \var Rotation - The rotation, in degrees, to rotate the referenced object about its x, y, and z axes, respectively, to create an - /// instance of the object in the current constellation. Rotations shall be executed in order of x first, then y, then z. - aiVector3D Rotation; - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Instance, pParent) - {} - -};// struct CAMFImporter_NodeElement_Instance - -/// \struct CAMFImporter_NodeElement_Metadata -/// Structure that define metadata node. -struct CAMFImporter_NodeElement_Metadata : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - - std::string Type;///< Type of "Value". - std::string Value;///< Value. - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Metadata, pParent) - {} - -};// struct CAMFImporter_NodeElement_Metadata - -/// \struct CAMFImporter_NodeElement_Root -/// Structure that define root node. -struct CAMFImporter_NodeElement_Root : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - - std::string Unit;///< The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron". - std::string Version;///< Version of format. - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Root, pParent) - {} - -};// struct CAMFImporter_NodeElement_Root - -/// \struct CAMFImporter_NodeElement_Color -/// Structure that define object node. -struct CAMFImporter_NodeElement_Color : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - - bool Composed;///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color. - std::string Color_Composed[4];///< By components formulas of composed color. [0..3] => RGBA. - aiColor4D Color;///< Constant color. - std::string Profile;///< The ICC color space used to interpret the three color channels , and .. - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Color, pParent) - {} - -};// struct CAMFImporter_NodeElement_Color - -/// \struct CAMFImporter_NodeElement_Material -/// Structure that define material node. -struct CAMFImporter_NodeElement_Material : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Material, pParent) - {} - -};// struct CAMFImporter_NodeElement_Material - -/// \struct CAMFImporter_NodeElement_Object -/// Structure that define object node. -struct CAMFImporter_NodeElement_Object : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Object, pParent) - {} - -};// struct CAMFImporter_NodeElement_Object - -/// \struct CAMFImporter_NodeElement_Mesh -/// Structure that define mesh node. -struct CAMFImporter_NodeElement_Mesh : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Mesh, pParent) - {} - -};// struct CAMFImporter_NodeElement_Mesh - -/// \struct CAMFImporter_NodeElement_Vertex -/// Structure that define vertex node. -struct CAMFImporter_NodeElement_Vertex : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Vertex, pParent) - {} - -};// struct CAMFImporter_NodeElement_Vertex - -/// \struct CAMFImporter_NodeElement_Edge -/// Structure that define edge node. -struct CAMFImporter_NodeElement_Edge : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Edge, pParent) - {} - -};// struct CAMFImporter_NodeElement_Vertex - -/// \struct CAMFImporter_NodeElement_Vertices -/// Structure that define vertices node. -struct CAMFImporter_NodeElement_Vertices : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Vertices, pParent) - {} - -};// struct CAMFImporter_NodeElement_Vertices - -/// \struct CAMFImporter_NodeElement_Volume -/// Structure that define volume node. -struct CAMFImporter_NodeElement_Volume : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - - std::string MaterialID;///< Which material to use. - std::string Type;///< What this volume describes can be “region” or “support”. If none specified, “object” is assumed. - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Volume, pParent) - {} - -};// struct CAMFImporter_NodeElement_Volume - -/// \struct CAMFImporter_NodeElement_Coordinates -/// Structure that define coordinates node. -struct CAMFImporter_NodeElement_Coordinates : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - - aiVector3D Coordinate;///< Coordinate. - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Coordinates, pParent) - {} - -};// struct CAMFImporter_NodeElement_Coordinates - -/// \struct CAMFImporter_NodeElement_TexMap -/// Structure that define texture coordinates node. -struct CAMFImporter_NodeElement_TexMap : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - - aiVector3D TextureCoordinate[3];///< Texture coordinates. - std::string TextureID_R;///< Texture ID for red color component. - std::string TextureID_G;///< Texture ID for green color component. - std::string TextureID_B;///< Texture ID for blue color component. - std::string TextureID_A;///< Texture ID for alpha color component. - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_TexMap, pParent) - {} - -};// struct CAMFImporter_NodeElement_TexMap - -/// \struct CAMFImporter_NodeElement_Triangle -/// Structure that define triangle node. -struct CAMFImporter_NodeElement_Triangle : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - - size_t V[3];///< Triangle vertices. - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Triangle, pParent) - {} - -};// struct CAMFImporter_NodeElement_Triangle - -/// Structure that define texture node. -struct CAMFImporter_NodeElement_Texture : public CAMFImporter_NodeElement { - size_t Width, Height, Depth;///< Size of the texture. - std::vector Data;///< Data of the texture. - bool Tiled; - - /// Constructor. - /// \param [in] pParent - pointer to parent node. - CAMFImporter_NodeElement_Texture(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Texture, pParent) - , Width( 0 ) - , Height( 0 ) - , Depth( 0 ) - , Data() - , Tiled( false ){ - // empty - } -};// struct CAMFImporter_NodeElement_Texture - -#endif // INCLUDED_AI_AMF_IMPORTER_NODE_H diff --git a/src/3rdparty/assimp/code/AMFImporter_Postprocess.cpp b/src/3rdparty/assimp/code/AMFImporter_Postprocess.cpp deleted file mode 100644 index 991eb97e7..000000000 --- a/src/3rdparty/assimp/code/AMFImporter_Postprocess.cpp +++ /dev/null @@ -1,976 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/// \file AMFImporter_Postprocess.cpp -/// \brief Convert built scenegraph and objects to Assimp scenegraph. -/// \date 2016 -/// \author smal.root@gmail.com - -#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER - -#include "AMFImporter.hpp" - -// Header files, Assimp. -#include -#include "StandardShapes.h" -#include "StringUtils.h" - -// Header files, stdlib. -#include - -namespace Assimp -{ - -aiColor4D AMFImporter::SPP_Material::GetColor(const float /*pX*/, const float /*pY*/, const float /*pZ*/) const -{ - aiColor4D tcol; - - // Check if stored data are supported. - if(Composition.size() != 0) - { - throw DeadlyImportError("IME. GetColor for composition"); - } - else if(Color->Composed) - { - throw DeadlyImportError("IME. GetColor, composed color"); - } - else - { - tcol = Color->Color; - } - - // Check if default color must be used - if((tcol.r == 0) && (tcol.g == 0) && (tcol.b == 0) && (tcol.a == 0)) - { - tcol.r = 0.5f; - tcol.g = 0.5f; - tcol.b = 0.5f; - tcol.a = 1; - } - - return tcol; -} - -void AMFImporter::PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector& pVertexCoordinateArray, - std::vector& pVertexColorArray) const -{ - CAMFImporter_NodeElement_Vertices* vn = nullptr; - size_t col_idx; - - // All data stored in "vertices", search for it. - for(CAMFImporter_NodeElement* ne_child: pNodeElement.Child) - { - if(ne_child->Type == CAMFImporter_NodeElement::ENET_Vertices) vn = (CAMFImporter_NodeElement_Vertices*)ne_child; - } - - // If "vertices" not found then no work for us. - if(vn == nullptr) return; - - pVertexCoordinateArray.reserve(vn->Child.size());// all coordinates stored as child and we need to reserve space for future push_back's. - pVertexColorArray.resize(vn->Child.size());// colors count equal vertices count. - col_idx = 0; - // Inside vertices collect all data and place to arrays - for(CAMFImporter_NodeElement* vn_child: vn->Child) - { - // vertices, colors - if(vn_child->Type == CAMFImporter_NodeElement::ENET_Vertex) - { - // by default clear color for current vertex - pVertexColorArray[col_idx] = nullptr; - - for(CAMFImporter_NodeElement* vtx: vn_child->Child) - { - if(vtx->Type == CAMFImporter_NodeElement::ENET_Coordinates) - { - pVertexCoordinateArray.push_back(((CAMFImporter_NodeElement_Coordinates*)vtx)->Coordinate); - - continue; - } - - if(vtx->Type == CAMFImporter_NodeElement::ENET_Color) - { - pVertexColorArray[col_idx] = (CAMFImporter_NodeElement_Color*)vtx; - - continue; - } - }// for(CAMFImporter_NodeElement* vtx: vn_child->Child) - - col_idx++; - }// if(vn_child->Type == CAMFImporter_NodeElement::ENET_Vertex) - }// for(CAMFImporter_NodeElement* vn_child: vn->Child) -} - -size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, - const std::string& pID_A) -{ - size_t TextureConverted_Index; - std::string TextureConverted_ID; - - // check input data - if(pID_R.empty() && pID_G.empty() && pID_B.empty() && pID_A.empty()) - throw DeadlyImportError("PostprocessHelper_GetTextureID_Or_Create. At least one texture ID must be defined."); - - // Create ID - TextureConverted_ID = pID_R + "_" + pID_G + "_" + pID_B + "_" + pID_A; - // Check if texture specified by set of IDs is converted already. - TextureConverted_Index = 0; - for(const SPP_Texture& tex_convd: mTexture_Converted) - { - if(tex_convd.ID == TextureConverted_ID) - return TextureConverted_Index; - else - TextureConverted_Index++; - } - - // - // Converted texture not found, create it. - // - CAMFImporter_NodeElement_Texture* src_texture[4]{nullptr}; - std::vector src_texture_4check; - SPP_Texture converted_texture; - - {// find all specified source textures - CAMFImporter_NodeElement* t_tex; - - // R - if(!pID_R.empty()) - { - if(!Find_NodeElement(pID_R, CAMFImporter_NodeElement::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_R); - - src_texture[0] = (CAMFImporter_NodeElement_Texture*)t_tex; - src_texture_4check.push_back((CAMFImporter_NodeElement_Texture*)t_tex); - } - else - { - src_texture[0] = nullptr; - } - - // G - if(!pID_G.empty()) - { - if(!Find_NodeElement(pID_G, CAMFImporter_NodeElement::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_G); - - src_texture[1] = (CAMFImporter_NodeElement_Texture*)t_tex; - src_texture_4check.push_back((CAMFImporter_NodeElement_Texture*)t_tex); - } - else - { - src_texture[1] = nullptr; - } - - // B - if(!pID_B.empty()) - { - if(!Find_NodeElement(pID_B, CAMFImporter_NodeElement::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_B); - - src_texture[2] = (CAMFImporter_NodeElement_Texture*)t_tex; - src_texture_4check.push_back((CAMFImporter_NodeElement_Texture*)t_tex); - } - else - { - src_texture[2] = nullptr; - } - - // A - if(!pID_A.empty()) - { - if(!Find_NodeElement(pID_A, CAMFImporter_NodeElement::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_A); - - src_texture[3] = (CAMFImporter_NodeElement_Texture*)t_tex; - src_texture_4check.push_back((CAMFImporter_NodeElement_Texture*)t_tex); - } - else - { - src_texture[3] = nullptr; - } - }// END: find all specified source textures - - // check that all textures has same size - if(src_texture_4check.size() > 1) - { - for (size_t i = 0, i_e = (src_texture_4check.size() - 1); i < i_e; i++) - { - if((src_texture_4check[i]->Width != src_texture_4check[i + 1]->Width) || (src_texture_4check[i]->Height != src_texture_4check[i + 1]->Height) || - (src_texture_4check[i]->Depth != src_texture_4check[i + 1]->Depth)) - { - throw DeadlyImportError("PostprocessHelper_GetTextureID_Or_Create. Source texture must has the same size."); - } - } - }// if(src_texture_4check.size() > 1) - - // set texture attributes - converted_texture.Width = src_texture_4check[0]->Width; - converted_texture.Height = src_texture_4check[0]->Height; - converted_texture.Depth = src_texture_4check[0]->Depth; - // if one of source texture is tiled then converted texture is tiled too. - converted_texture.Tiled = false; - for(uint8_t i = 0; i < src_texture_4check.size(); i++) converted_texture.Tiled |= src_texture_4check[i]->Tiled; - - // Create format hint. - strcpy(converted_texture.FormatHint, "rgba0000");// copy initial string. - if(!pID_R.empty()) converted_texture.FormatHint[4] = '8'; - if(!pID_G.empty()) converted_texture.FormatHint[5] = '8'; - if(!pID_B.empty()) converted_texture.FormatHint[6] = '8'; - if(!pID_A.empty()) converted_texture.FormatHint[7] = '8'; - - // - // Сopy data of textures. - // - size_t tex_size = 0; - size_t step = 0; - size_t off_g = 0; - size_t off_b = 0; - - // Calculate size of the target array and rule how data will be copied. - if(!pID_R.empty() && nullptr != src_texture[ 0 ] ) { - tex_size += src_texture[0]->Data.size(); step++, off_g++, off_b++; - } - if(!pID_G.empty() && nullptr != src_texture[ 1 ] ) { - tex_size += src_texture[1]->Data.size(); step++, off_b++; - } - if(!pID_B.empty() && nullptr != src_texture[ 2 ] ) { - tex_size += src_texture[2]->Data.size(); step++; - } - if(!pID_A.empty() && nullptr != src_texture[ 3 ] ) { - tex_size += src_texture[3]->Data.size(); step++; - } - - // Create target array. - converted_texture.Data = new uint8_t[tex_size]; - // And copy data - auto CopyTextureData = [&](const std::string& pID, const size_t pOffset, const size_t pStep, const uint8_t pSrcTexNum) -> void - { - if(!pID.empty()) - { - for(size_t idx_target = pOffset, idx_src = 0; idx_target < tex_size; idx_target += pStep, idx_src++) { - CAMFImporter_NodeElement_Texture* tex = src_texture[pSrcTexNum]; - ai_assert(tex); - converted_texture.Data[idx_target] = tex->Data.at(idx_src); - } - } - };// auto CopyTextureData = [&](const size_t pOffset, const size_t pStep, const uint8_t pSrcTexNum) -> void - - CopyTextureData(pID_R, 0, step, 0); - CopyTextureData(pID_G, off_g, step, 1); - CopyTextureData(pID_B, off_b, step, 2); - CopyTextureData(pID_A, step - 1, step, 3); - - // Store new converted texture ID - converted_texture.ID = TextureConverted_ID; - // Store new converted texture - mTexture_Converted.push_back(converted_texture); - - return TextureConverted_Index; -} - -void AMFImporter::PostprocessHelper_SplitFacesByTextureID(std::list& pInputList, std::list >& pOutputList_Separated) -{ - auto texmap_is_equal = [](const CAMFImporter_NodeElement_TexMap* pTexMap1, const CAMFImporter_NodeElement_TexMap* pTexMap2) -> bool - { - if((pTexMap1 == nullptr) && (pTexMap2 == nullptr)) return true; - if(pTexMap1 == nullptr) return false; - if(pTexMap2 == nullptr) return false; - - if(pTexMap1->TextureID_R != pTexMap2->TextureID_R) return false; - if(pTexMap1->TextureID_G != pTexMap2->TextureID_G) return false; - if(pTexMap1->TextureID_B != pTexMap2->TextureID_B) return false; - if(pTexMap1->TextureID_A != pTexMap2->TextureID_A) return false; - - return true; - }; - - pOutputList_Separated.clear(); - if(pInputList.size() == 0) return; - - do - { - SComplexFace face_start = pInputList.front(); - std::list face_list_cur; - - for(std::list::iterator it = pInputList.begin(), it_end = pInputList.end(); it != it_end;) - { - if(texmap_is_equal(face_start.TexMap, it->TexMap)) - { - auto it_old = it; - - it++; - face_list_cur.push_back(*it_old); - pInputList.erase(it_old); - } - else - { - it++; - } - } - - if(face_list_cur.size() > 0) pOutputList_Separated.push_back(face_list_cur); - - } while(pInputList.size() > 0); -} - -void AMFImporter::Postprocess_AddMetadata(const std::list& metadataList, aiNode& sceneNode) const -{ - if ( !metadataList.empty() ) - { - if(sceneNode.mMetaData != nullptr) throw DeadlyImportError("Postprocess. MetaData member in node are not nullptr. Something went wrong."); - - // copy collected metadata to output node. - sceneNode.mMetaData = aiMetadata::Alloc( static_cast(metadataList.size()) ); - size_t meta_idx( 0 ); - - for(const CAMFImporter_NodeElement_Metadata& metadata: metadataList) - { - sceneNode.mMetaData->Set(static_cast(meta_idx++), metadata.Type, aiString(metadata.Value)); - } - }// if(!metadataList.empty()) -} - -void AMFImporter::Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list& pMeshList, aiNode** pSceneNode) -{ -CAMFImporter_NodeElement_Color* object_color = nullptr; - - // create new aiNode and set name as has. - *pSceneNode = new aiNode; - (*pSceneNode)->mName = pNodeElement.ID; - // read mesh and color - for(const CAMFImporter_NodeElement* ne_child: pNodeElement.Child) - { - std::vector vertex_arr; - std::vector color_arr; - - // color for object - if(ne_child->Type == CAMFImporter_NodeElement::ENET_Color) object_color = (CAMFImporter_NodeElement_Color*)ne_child; - - if(ne_child->Type == CAMFImporter_NodeElement::ENET_Mesh) - { - // Create arrays from children of mesh: vertices. - PostprocessHelper_CreateMeshDataArray(*((CAMFImporter_NodeElement_Mesh*)ne_child), vertex_arr, color_arr); - // Use this arrays as a source when creating every aiMesh - Postprocess_BuildMeshSet(*((CAMFImporter_NodeElement_Mesh*)ne_child), vertex_arr, color_arr, object_color, pMeshList, **pSceneNode); - } - }// for(const CAMFImporter_NodeElement* ne_child: pNodeElement) -} - -void AMFImporter::Postprocess_BuildMeshSet(const CAMFImporter_NodeElement_Mesh& pNodeElement, const std::vector& pVertexCoordinateArray, - const std::vector& pVertexColorArray, - const CAMFImporter_NodeElement_Color* pObjectColor, std::list& pMeshList, aiNode& pSceneNode) -{ -std::list mesh_idx; - - // all data stored in "volume", search for it. - for(const CAMFImporter_NodeElement* ne_child: pNodeElement.Child) - { - const CAMFImporter_NodeElement_Color* ne_volume_color = nullptr; - const SPP_Material* cur_mat = nullptr; - - if(ne_child->Type == CAMFImporter_NodeElement::ENET_Volume) - { - /******************* Get faces *******************/ - const CAMFImporter_NodeElement_Volume* ne_volume = reinterpret_cast(ne_child); - - std::list complex_faces_list;// List of the faces of the volume. - std::list > complex_faces_toplist;// List of the face list for every mesh. - - // check if volume use material - if(!ne_volume->MaterialID.empty()) - { - if(!Find_ConvertedMaterial(ne_volume->MaterialID, &cur_mat)) Throw_ID_NotFound(ne_volume->MaterialID); - } - - // inside "volume" collect all data and place to arrays or create new objects - for(const CAMFImporter_NodeElement* ne_volume_child: ne_volume->Child) - { - // color for volume - if(ne_volume_child->Type == CAMFImporter_NodeElement::ENET_Color) - { - ne_volume_color = reinterpret_cast(ne_volume_child); - } - else if(ne_volume_child->Type == CAMFImporter_NodeElement::ENET_Triangle)// triangles, triangles colors - { - const CAMFImporter_NodeElement_Triangle& tri_al = *reinterpret_cast(ne_volume_child); - - SComplexFace complex_face; - - // initialize pointers - complex_face.Color = nullptr; - complex_face.TexMap = nullptr; - // get data from triangle children: color, texture coordinates. - if(tri_al.Child.size()) - { - for(const CAMFImporter_NodeElement* ne_triangle_child: tri_al.Child) - { - if(ne_triangle_child->Type == CAMFImporter_NodeElement::ENET_Color) - complex_face.Color = reinterpret_cast(ne_triangle_child); - else if(ne_triangle_child->Type == CAMFImporter_NodeElement::ENET_TexMap) - complex_face.TexMap = reinterpret_cast(ne_triangle_child); - } - }// if(tri_al.Child.size()) - - // create new face and store it. - complex_face.Face.mNumIndices = 3; - complex_face.Face.mIndices = new unsigned int[3]; - complex_face.Face.mIndices[0] = static_cast(tri_al.V[0]); - complex_face.Face.mIndices[1] = static_cast(tri_al.V[1]); - complex_face.Face.mIndices[2] = static_cast(tri_al.V[2]); - complex_faces_list.push_back(complex_face); - } - }// for(const CAMFImporter_NodeElement* ne_volume_child: ne_volume->Child) - - /**** Split faces list: one list per mesh ****/ - PostprocessHelper_SplitFacesByTextureID(complex_faces_list, complex_faces_toplist); - - /***** Create mesh for every faces list ******/ - for(std::list& face_list_cur: complex_faces_toplist) - { - auto VertexIndex_GetMinimal = [](const std::list& pFaceList, const size_t* pBiggerThan) -> size_t - { - size_t rv; - - if(pBiggerThan != nullptr) - { - bool found = false; - - for(const SComplexFace& face: pFaceList) - { - for(size_t idx_vert = 0; idx_vert < face.Face.mNumIndices; idx_vert++) - { - if(face.Face.mIndices[idx_vert] > *pBiggerThan) - { - rv = face.Face.mIndices[idx_vert]; - found = true; - - break; - } - } - - if(found) break; - } - - if(!found) return *pBiggerThan; - } - else - { - rv = pFaceList.front().Face.mIndices[0]; - }// if(pBiggerThan != nullptr) else - - for(const SComplexFace& face: pFaceList) - { - for(size_t vi = 0; vi < face.Face.mNumIndices; vi++) - { - if(face.Face.mIndices[vi] < rv) - { - if(pBiggerThan != nullptr) - { - if(face.Face.mIndices[vi] > *pBiggerThan) rv = face.Face.mIndices[vi]; - } - else - { - rv = face.Face.mIndices[vi]; - } - } - } - }// for(const SComplexFace& face: pFaceList) - - return rv; - };// auto VertexIndex_GetMinimal = [](const std::list& pFaceList, const size_t* pBiggerThan) -> size_t - - auto VertexIndex_Replace = [](std::list& pFaceList, const size_t pIdx_From, const size_t pIdx_To) -> void - { - for(const SComplexFace& face: pFaceList) - { - for(size_t vi = 0; vi < face.Face.mNumIndices; vi++) - { - if(face.Face.mIndices[vi] == pIdx_From) face.Face.mIndices[vi] = static_cast(pIdx_To); - } - } - };// auto VertexIndex_Replace = [](std::list& pFaceList, const size_t pIdx_From, const size_t pIdx_To) -> void - - auto Vertex_CalculateColor = [&](const size_t pIdx) -> aiColor4D - { - // Color priorities(In descending order): - // 1. triangle color; - // 2. vertex color; - // 3. volume color; - // 4. object color; - // 5. material; - // 6. default - invisible coat. - // - // Fill vertices colors in color priority list above that's points from 1 to 6. - if((pIdx < pVertexColorArray.size()) && (pVertexColorArray[pIdx] != nullptr))// check for vertex color - { - if(pVertexColorArray[pIdx]->Composed) - throw DeadlyImportError("IME: vertex color composed"); - else - return pVertexColorArray[pIdx]->Color; - } - else if(ne_volume_color != nullptr)// check for volume color - { - if(ne_volume_color->Composed) - throw DeadlyImportError("IME: volume color composed"); - else - return ne_volume_color->Color; - } - else if(pObjectColor != nullptr)// check for object color - { - if(pObjectColor->Composed) - throw DeadlyImportError("IME: object color composed"); - else - return pObjectColor->Color; - } - else if(cur_mat != nullptr)// check for material - { - return cur_mat->GetColor(pVertexCoordinateArray.at(pIdx).x, pVertexCoordinateArray.at(pIdx).y, pVertexCoordinateArray.at(pIdx).z); - } - else// set default color. - { - return {0, 0, 0, 0}; - }// if((vi < pVertexColorArray.size()) && (pVertexColorArray[vi] != nullptr)) else - - };// auto Vertex_CalculateColor = [&](const size_t pIdx) -> aiColor4D - - aiMesh* tmesh = new aiMesh; - - tmesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;// Only triangles is supported by AMF. - // - // set geometry and colors (vertices) - // - // copy faces/triangles - tmesh->mNumFaces = static_cast(face_list_cur.size()); - tmesh->mFaces = new aiFace[tmesh->mNumFaces]; - - // Create vertices list and optimize indices. Optimisation mean following.In AMF all volumes use one big list of vertices. And one volume - // can use only part of vertices list, for example: vertices list contain few thousands of vertices and volume use vertices 1, 3, 10. - // Do you need all this thousands of garbage? Of course no. So, optimisation step transformate sparse indices set to continuous. - size_t VertexCount_Max = tmesh->mNumFaces * 3;// 3 - triangles. - std::vector vert_arr, texcoord_arr; - std::vector col_arr; - - vert_arr.reserve(VertexCount_Max * 2);// "* 2" - see below TODO. - col_arr.reserve(VertexCount_Max * 2); - - {// fill arrays - size_t vert_idx_from, vert_idx_to; - - // first iteration. - vert_idx_to = 0; - vert_idx_from = VertexIndex_GetMinimal(face_list_cur, nullptr); - vert_arr.push_back(pVertexCoordinateArray.at(vert_idx_from)); - col_arr.push_back(Vertex_CalculateColor(vert_idx_from)); - if(vert_idx_from != vert_idx_to) VertexIndex_Replace(face_list_cur, vert_idx_from, vert_idx_to); - - // rest iterations - do - { - vert_idx_from = VertexIndex_GetMinimal(face_list_cur, &vert_idx_to); - if(vert_idx_from == vert_idx_to) break;// all indices are transferred, - - vert_arr.push_back(pVertexCoordinateArray.at(vert_idx_from)); - col_arr.push_back(Vertex_CalculateColor(vert_idx_from)); - vert_idx_to++; - if(vert_idx_from != vert_idx_to) VertexIndex_Replace(face_list_cur, vert_idx_from, vert_idx_to); - - } while(true); - }// fill arrays. END. - - // - // check if triangle colors are used and create additional faces if needed. - // - for(const SComplexFace& face_cur: face_list_cur) - { - if(face_cur.Color != nullptr) - { - aiColor4D face_color; - size_t vert_idx_new = vert_arr.size(); - - if(face_cur.Color->Composed) - throw DeadlyImportError("IME: face color composed"); - else - face_color = face_cur.Color->Color; - - for(size_t idx_ind = 0; idx_ind < face_cur.Face.mNumIndices; idx_ind++) - { - vert_arr.push_back(vert_arr.at(face_cur.Face.mIndices[idx_ind])); - col_arr.push_back(face_color); - face_cur.Face.mIndices[idx_ind] = static_cast(vert_idx_new++); - } - }// if(face_cur.Color != nullptr) - }// for(const SComplexFace& face_cur: face_list_cur) - - // - // if texture is used then copy texture coordinates too. - // - if(face_list_cur.front().TexMap != nullptr) - { - size_t idx_vert_new = vert_arr.size(); - ///TODO: clean unused vertices. "* 2": in certain cases - mesh full of triangle colors - vert_arr will contain duplicated vertices for - /// colored triangles and initial vertices (for colored vertices) which in real became unused. This part need more thinking about - /// optimisation. - bool* idx_vert_used; - - idx_vert_used = new bool[VertexCount_Max * 2]; - for(size_t i = 0, i_e = VertexCount_Max * 2; i < i_e; i++) idx_vert_used[i] = false; - - // This ID's will be used when set materials ID in scene. - tmesh->mMaterialIndex = static_cast(PostprocessHelper_GetTextureID_Or_Create(face_list_cur.front().TexMap->TextureID_R, - face_list_cur.front().TexMap->TextureID_G, - face_list_cur.front().TexMap->TextureID_B, - face_list_cur.front().TexMap->TextureID_A)); - texcoord_arr.resize(VertexCount_Max * 2); - for(const SComplexFace& face_cur: face_list_cur) - { - for(size_t idx_ind = 0; idx_ind < face_cur.Face.mNumIndices; idx_ind++) - { - const size_t idx_vert = face_cur.Face.mIndices[idx_ind]; - - if(!idx_vert_used[idx_vert]) - { - texcoord_arr.at(idx_vert) = face_cur.TexMap->TextureCoordinate[idx_ind]; - idx_vert_used[idx_vert] = true; - } - else if(texcoord_arr.at(idx_vert) != face_cur.TexMap->TextureCoordinate[idx_ind]) - { - // in that case one vertex is shared with many texture coordinates. We need to duplicate vertex with another texture - // coordinates. - vert_arr.push_back(vert_arr.at(idx_vert)); - col_arr.push_back(col_arr.at(idx_vert)); - texcoord_arr.at(idx_vert_new) = face_cur.TexMap->TextureCoordinate[idx_ind]; - face_cur.Face.mIndices[idx_ind] = static_cast(idx_vert_new++); - } - }// for(size_t idx_ind = 0; idx_ind < face_cur.Face.mNumIndices; idx_ind++) - }// for(const SComplexFace& face_cur: face_list_cur) - - delete [] idx_vert_used; - // shrink array - texcoord_arr.resize(idx_vert_new); - }// if(face_list_cur.front().TexMap != nullptr) - - // - // copy collected data to mesh - // - tmesh->mNumVertices = static_cast(vert_arr.size()); - tmesh->mVertices = new aiVector3D[tmesh->mNumVertices]; - tmesh->mColors[0] = new aiColor4D[tmesh->mNumVertices]; - - memcpy(tmesh->mVertices, vert_arr.data(), tmesh->mNumVertices * sizeof(aiVector3D)); - memcpy(tmesh->mColors[0], col_arr.data(), tmesh->mNumVertices * sizeof(aiColor4D)); - if(texcoord_arr.size() > 0) - { - tmesh->mTextureCoords[0] = new aiVector3D[tmesh->mNumVertices]; - memcpy(tmesh->mTextureCoords[0], texcoord_arr.data(), tmesh->mNumVertices * sizeof(aiVector3D)); - tmesh->mNumUVComponents[0] = 2;// U and V stored in "x", "y" of aiVector3D. - } - - size_t idx_face = 0; - for(const SComplexFace& face_cur: face_list_cur) tmesh->mFaces[idx_face++] = face_cur.Face; - - // store new aiMesh - mesh_idx.push_back(static_cast(pMeshList.size())); - pMeshList.push_back(tmesh); - }// for(const std::list& face_list_cur: complex_faces_toplist) - }// if(ne_child->Type == CAMFImporter_NodeElement::ENET_Volume) - }// for(const CAMFImporter_NodeElement* ne_child: pNodeElement.Child) - - // if meshes was created then assign new indices with current aiNode - if(mesh_idx.size() > 0) - { - std::list::const_iterator mit = mesh_idx.begin(); - - pSceneNode.mNumMeshes = static_cast(mesh_idx.size()); - pSceneNode.mMeshes = new unsigned int[pSceneNode.mNumMeshes]; - for(size_t i = 0; i < pSceneNode.mNumMeshes; i++) pSceneNode.mMeshes[i] = *mit++; - }// if(mesh_idx.size() > 0) -} - -void AMFImporter::Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial) -{ -SPP_Material new_mat; - - new_mat.ID = pMaterial.ID; - for(const CAMFImporter_NodeElement* mat_child: pMaterial.Child) - { - if(mat_child->Type == CAMFImporter_NodeElement::ENET_Color) - { - new_mat.Color = (CAMFImporter_NodeElement_Color*)mat_child; - } - else if(mat_child->Type == CAMFImporter_NodeElement::ENET_Metadata) - { - new_mat.Metadata.push_back((CAMFImporter_NodeElement_Metadata*)mat_child); - } - }// for(const CAMFImporter_NodeElement* mat_child; pMaterial.Child) - - // place converted material to special list - mMaterial_Converted.push_back(new_mat); -} - -void AMFImporter::Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list& pNodeList) const -{ -aiNode* con_node; -std::list ch_node; - - // We will build next hierarchy: - // aiNode as parent () for set of nodes as a children - // |- aiNode for transformation ( -> , ) - aiNode for pointing to object ("objectid") - // ... - // \_ aiNode for transformation ( -> , ) - aiNode for pointing to object ("objectid") - con_node = new aiNode; - con_node->mName = pConstellation.ID; - // Walk through children and search for instances of another objects, constellations. - for(const CAMFImporter_NodeElement* ne: pConstellation.Child) - { - aiMatrix4x4 tmat; - aiNode* t_node; - aiNode* found_node; - - if(ne->Type == CAMFImporter_NodeElement::ENET_Metadata) continue; - if(ne->Type != CAMFImporter_NodeElement::ENET_Instance) throw DeadlyImportError("Only nodes can be in ."); - - // create alias for conveniance - CAMFImporter_NodeElement_Instance& als = *((CAMFImporter_NodeElement_Instance*)ne); - // find referenced object - if(!Find_ConvertedNode(als.ObjectID, pNodeList, &found_node)) Throw_ID_NotFound(als.ObjectID); - - // create node for apllying transformation - t_node = new aiNode; - t_node->mParent = con_node; - // apply transformation - aiMatrix4x4::Translation(als.Delta, tmat), t_node->mTransformation *= tmat; - aiMatrix4x4::RotationX(als.Rotation.x, tmat), t_node->mTransformation *= tmat; - aiMatrix4x4::RotationY(als.Rotation.y, tmat), t_node->mTransformation *= tmat; - aiMatrix4x4::RotationZ(als.Rotation.z, tmat), t_node->mTransformation *= tmat; - // create array for one child node - t_node->mNumChildren = 1; - t_node->mChildren = new aiNode*[t_node->mNumChildren]; - SceneCombiner::Copy(&t_node->mChildren[0], found_node); - t_node->mChildren[0]->mParent = t_node; - ch_node.push_back(t_node); - }// for(const CAMFImporter_NodeElement* ne: pConstellation.Child) - - // copy found aiNode's as children - if(ch_node.size() == 0) throw DeadlyImportError(" must have at least one ."); - - size_t ch_idx = 0; - - con_node->mNumChildren = static_cast(ch_node.size()); - con_node->mChildren = new aiNode*[con_node->mNumChildren]; - for(aiNode* node: ch_node) con_node->mChildren[ch_idx++] = node; - - // and place "root" of node to node list - pNodeList.push_back(con_node); -} - -void AMFImporter::Postprocess_BuildScene(aiScene* pScene) -{ -std::list node_list; -std::list mesh_list; -std::list meta_list; - - // - // Because for AMF "material" is just complex colors mixing so aiMaterial will not be used. - // For building aiScene we are must to do few steps: - // at first creating root node for aiScene. - pScene->mRootNode = new aiNode; - pScene->mRootNode->mParent = nullptr; - pScene->mFlags |= AI_SCENE_FLAGS_ALLOW_SHARED; - // search for root() element - CAMFImporter_NodeElement* root_el = nullptr; - - for(CAMFImporter_NodeElement* ne: mNodeElement_List) - { - if(ne->Type != CAMFImporter_NodeElement::ENET_Root) continue; - - root_el = ne; - - break; - }// for(const CAMFImporter_NodeElement* ne: mNodeElement_List) - - // Check if root element are found. - if(root_el == nullptr) throw DeadlyImportError("Root() element not found."); - - // after that walk through children of root and collect data. Five types of nodes can be placed at top level - in : , , , - // and . But at first we must read and because they will be used in . can be read - // at any moment. - // - // 1. - // 2. will be converted later when processing triangles list. \sa Postprocess_BuildMeshSet - for(const CAMFImporter_NodeElement* root_child: root_el->Child) - { - if(root_child->Type == CAMFImporter_NodeElement::ENET_Material) Postprocess_BuildMaterial(*((CAMFImporter_NodeElement_Material*)root_child)); - } - - // After "appearance" nodes we must read because it will be used in -> . - // - // 3. - for(const CAMFImporter_NodeElement* root_child: root_el->Child) - { - if(root_child->Type == CAMFImporter_NodeElement::ENET_Object) - { - aiNode* tnode = nullptr; - - // for mesh and node must be built: object ID assigned to aiNode name and will be used in future for - Postprocess_BuildNodeAndObject(*((CAMFImporter_NodeElement_Object*)root_child), mesh_list, &tnode); - if(tnode != nullptr) node_list.push_back(tnode); - - } - }// for(const CAMFImporter_NodeElement* root_child: root_el->Child) - - // And finally read rest of nodes. - // - for(const CAMFImporter_NodeElement* root_child: root_el->Child) - { - // 4. - if(root_child->Type == CAMFImporter_NodeElement::ENET_Constellation) - { - // and at top of self abstraction use aiNode. So we can use only aiNode list for creating new aiNode's. - Postprocess_BuildConstellation(*((CAMFImporter_NodeElement_Constellation*)root_child), node_list); - } - - // 5, - if(root_child->Type == CAMFImporter_NodeElement::ENET_Metadata) meta_list.push_back((CAMFImporter_NodeElement_Metadata*)root_child); - }// for(const CAMFImporter_NodeElement* root_child: root_el->Child) - - // at now we can add collected metadata to root node - Postprocess_AddMetadata(meta_list, *pScene->mRootNode); - // - // Check constellation children - // - // As said in specification: - // "When multiple objects and constellations are defined in a single file, only the top level objects and constellations are available for printing." - // What that means? For example: if some object is used in constellation then you must show only constellation but not original object. - // And at this step we are checking that relations. -nl_clean_loop: - - if(node_list.size() > 1) - { - // walk through all nodes - for(std::list::iterator nl_it = node_list.begin(); nl_it != node_list.end(); nl_it++) - { - // and try to find them in another top nodes. - std::list::const_iterator next_it = nl_it; - - next_it++; - for(; next_it != node_list.end(); next_it++) - { - if((*next_it)->FindNode((*nl_it)->mName) != nullptr) - { - // if current top node(nl_it) found in another top node then erase it from node_list and restart search loop. - node_list.erase(nl_it); - - goto nl_clean_loop; - } - }// for(; next_it != node_list.end(); next_it++) - }// for(std::list::const_iterator nl_it = node_list.begin(); nl_it != node_list.end(); nl_it++) - } - - // - // move created objects to aiScene - // - // - // Nodes - if(node_list.size() > 0) - { - std::list::const_iterator nl_it = node_list.begin(); - - pScene->mRootNode->mNumChildren = static_cast(node_list.size()); - pScene->mRootNode->mChildren = new aiNode*[pScene->mRootNode->mNumChildren]; - for(size_t i = 0; i < pScene->mRootNode->mNumChildren; i++) - { - // Objects and constellation that must be showed placed at top of hierarchy in node. So all aiNode's in node_list must have - // mRootNode only as parent. - (*nl_it)->mParent = pScene->mRootNode; - pScene->mRootNode->mChildren[i] = *nl_it++; - } - }// if(node_list.size() > 0) - - // - // Meshes - if(mesh_list.size() > 0) - { - std::list::const_iterator ml_it = mesh_list.begin(); - - pScene->mNumMeshes = static_cast(mesh_list.size()); - pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; - for(size_t i = 0; i < pScene->mNumMeshes; i++) pScene->mMeshes[i] = *ml_it++; - }// if(mesh_list.size() > 0) - - // - // Textures - pScene->mNumTextures = static_cast(mTexture_Converted.size()); - if(pScene->mNumTextures > 0) - { - size_t idx; - - idx = 0; - pScene->mTextures = new aiTexture*[pScene->mNumTextures]; - for(const SPP_Texture& tex_convd: mTexture_Converted) - { - pScene->mTextures[idx] = new aiTexture; - pScene->mTextures[idx]->mWidth = static_cast(tex_convd.Width); - pScene->mTextures[idx]->mHeight = static_cast(tex_convd.Height); - pScene->mTextures[idx]->pcData = (aiTexel*)tex_convd.Data; - // texture format description. - strcpy(pScene->mTextures[idx]->achFormatHint, tex_convd.FormatHint); - idx++; - }// for(const SPP_Texture& tex_convd: mTexture_Converted) - - // Create materials for embedded textures. - idx = 0; - pScene->mNumMaterials = static_cast(mTexture_Converted.size()); - pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; - for(const SPP_Texture& tex_convd: mTexture_Converted) - { - const aiString texture_id(AI_EMBEDDED_TEXNAME_PREFIX + to_string(idx)); - const int mode = aiTextureOp_Multiply; - const int repeat = tex_convd.Tiled ? 1 : 0; - - pScene->mMaterials[idx] = new aiMaterial; - pScene->mMaterials[idx]->AddProperty(&texture_id, AI_MATKEY_TEXTURE_DIFFUSE(0)); - pScene->mMaterials[idx]->AddProperty(&mode, 1, AI_MATKEY_TEXOP_DIFFUSE(0)); - pScene->mMaterials[idx]->AddProperty(&repeat, 1, AI_MATKEY_MAPPINGMODE_U_DIFFUSE(0)); - pScene->mMaterials[idx]->AddProperty(&repeat, 1, AI_MATKEY_MAPPINGMODE_V_DIFFUSE(0)); - idx++; - } - }// if(pScene->mNumTextures > 0) -}// END: after that walk through children of root and collect data - -}// namespace Assimp - -#endif // !ASSIMP_BUILD_NO_AMF_IMPORTER diff --git a/src/3rdparty/assimp/code/ASELoader.cpp b/src/3rdparty/assimp/code/ASELoader.cpp deleted file mode 100644 index 65935f48f..000000000 --- a/src/3rdparty/assimp/code/ASELoader.cpp +++ /dev/null @@ -1,1328 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file ASELoader.cpp - * @brief Implementation of the ASE importer class - */ - -#ifndef ASSIMP_BUILD_NO_ASE_IMPORTER - -#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER - -// internal headers -#include "ASELoader.h" -#include "StringComparison.h" -#include "SkeletonMeshBuilder.h" -#include "TargetAnimation.h" -#include -#include -#include -#include -#include - -#include - -// utilities -#include "fast_atof.h" - -using namespace Assimp; -using namespace Assimp::ASE; - -static const aiImporterDesc desc = { - "ASE Importer", - "", - "", - "Similar to 3DS but text-encoded", - aiImporterFlags_SupportTextFlavour, - 0, - 0, - 0, - 0, - "ase ask" -}; - -// ------------------------------------------------------------------------------------------------ -// Constructor to be privately used by Importer -ASEImporter::ASEImporter() - : mParser(), - mBuffer(), - pcScene(), - configRecomputeNormals(), - noSkeletonMesh() -{} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -ASEImporter::~ASEImporter() -{} - -// ------------------------------------------------------------------------------------------------ -// Returns whether the class can handle the format of the given file. -bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const -{ - // check file extension - const std::string extension = GetExtension(pFile); - - if( extension == "ase" || extension == "ask") - return true; - - if ((!extension.length() || cs) && pIOHandler) { - const char* tokens[] = {"*3dsmax_asciiexport"}; - return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1); - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -// Loader meta information -const aiImporterDesc* ASEImporter::GetInfo () const -{ - return &desc; -} - -// ------------------------------------------------------------------------------------------------ -// Setup configuration options -void ASEImporter::SetupProperties(const Importer* pImp) -{ - configRecomputeNormals = (pImp->GetPropertyInteger( - AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS,1) ? true : false); - - noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; -} - -// ------------------------------------------------------------------------------------------------ -// Imports the given file into the given scene structure. -void ASEImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ - std::unique_ptr file( pIOHandler->Open( pFile, "rb")); - - // Check whether we can read from the file - if( file.get() == NULL) { - throw DeadlyImportError( "Failed to open ASE file " + pFile + "."); - } - - // Allocate storage and copy the contents of the file to a memory buffer - std::vector mBuffer2; - TextFileToBuffer(file.get(),mBuffer2); - - this->mBuffer = &mBuffer2[0]; - this->pcScene = pScene; - - // ------------------------------------------------------------------ - // Guess the file format by looking at the extension - // ASC is considered to be the older format 110, - // ASE is the actual version 200 (that is currently written by max) - // ------------------------------------------------------------------ - unsigned int defaultFormat; - std::string::size_type s = pFile.length()-1; - switch (pFile.c_str()[s]) { - - case 'C': - case 'c': - defaultFormat = AI_ASE_OLD_FILE_FORMAT; - break; - default: - defaultFormat = AI_ASE_NEW_FILE_FORMAT; - }; - - // Construct an ASE parser and parse the file - ASE::Parser parser(mBuffer,defaultFormat); - mParser = &parser; - mParser->Parse(); - - //------------------------------------------------------------------ - // Check whether we god at least one mesh. If we did - generate - // materials and copy meshes. - // ------------------------------------------------------------------ - if ( !mParser->m_vMeshes.empty()) { - - // If absolutely no material has been loaded from the file - // we need to generate a default material - GenerateDefaultMaterial(); - - // process all meshes - bool tookNormals = false; - std::vector avOutMeshes; - avOutMeshes.reserve(mParser->m_vMeshes.size()*2); - for (std::vector::iterator i = mParser->m_vMeshes.begin();i != mParser->m_vMeshes.end();++i) { - if ((*i).bSkip) { - continue; - } - BuildUniqueRepresentation(*i); - - // Need to generate proper vertex normals if necessary - if(GenerateNormals(*i)) { - tookNormals = true; - } - - // Convert all meshes to aiMesh objects - ConvertMeshes(*i,avOutMeshes); - } - if (tookNormals) { - DefaultLogger::get()->debug("ASE: Taking normals from the file. Use " - "the AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS setting if you " - "experience problems"); - } - - // Now build the output mesh list. Remove dummies - pScene->mNumMeshes = (unsigned int)avOutMeshes.size(); - aiMesh** pp = pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; - for (std::vector::const_iterator i = avOutMeshes.begin();i != avOutMeshes.end();++i) { - if (!(*i)->mNumFaces) { - continue; - } - *pp++ = *i; - } - pScene->mNumMeshes = (unsigned int)(pp - pScene->mMeshes); - - // Build final material indices (remove submaterials and setup - // the final list) - BuildMaterialIndices(); - } - - // ------------------------------------------------------------------ - // Copy all scene graph nodes - lights, cameras, dummies and meshes - // into one huge list. - //------------------------------------------------------------------ - std::vector nodes; - nodes.reserve(mParser->m_vMeshes.size() +mParser->m_vLights.size() - + mParser->m_vCameras.size() + mParser->m_vDummies.size()); - - // Lights - for (auto &light : mParser->m_vLights)nodes.push_back(&light); - // Cameras - for (auto &camera : mParser->m_vCameras)nodes.push_back(&camera); - // Meshes - for (auto &mesh : mParser->m_vMeshes)nodes.push_back(&mesh); - // Dummies - for (auto &dummy : mParser->m_vDummies)nodes.push_back(&dummy); - - // build the final node graph - BuildNodes(nodes); - - // build output animations - BuildAnimations(nodes); - - // build output cameras - BuildCameras(); - - // build output lights - BuildLights(); - - // ------------------------------------------------------------------ - // If we have no meshes use the SkeletonMeshBuilder helper class - // to build a mesh for the animation skeleton - // FIXME: very strange results - // ------------------------------------------------------------------ - if (!pScene->mNumMeshes) { - pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; - if (!noSkeletonMesh) { - SkeletonMeshBuilder skeleton(pScene); - } - } -} -// ------------------------------------------------------------------------------------------------ -void ASEImporter::GenerateDefaultMaterial() -{ - ai_assert(NULL != mParser); - - bool bHas = false; - for (std::vector::iterator i = mParser->m_vMeshes.begin();i != mParser->m_vMeshes.end();++i) { - if ((*i).bSkip)continue; - if (ASE::Face::DEFAULT_MATINDEX == (*i).iMaterialIndex) { - (*i).iMaterialIndex = (unsigned int)mParser->m_vMaterials.size(); - bHas = true; - } - } - if (bHas || mParser->m_vMaterials.empty()) { - // add a simple material without submaterials to the parser's list - mParser->m_vMaterials.push_back ( ASE::Material() ); - ASE::Material& mat = mParser->m_vMaterials.back(); - - mat.mDiffuse = aiColor3D(0.6f,0.6f,0.6f); - mat.mSpecular = aiColor3D(1.0f,1.0f,1.0f); - mat.mAmbient = aiColor3D(0.05f,0.05f,0.05f); - mat.mShading = Discreet3DS::Gouraud; - mat.mName = AI_DEFAULT_MATERIAL_NAME; - } -} - -// ------------------------------------------------------------------------------------------------ -void ASEImporter::BuildAnimations(const std::vector& nodes) -{ - // check whether we have at least one mesh which has animations - std::vector::const_iterator i = nodes.begin(); - unsigned int iNum = 0; - for (;i != nodes.end();++i) { - - // TODO: Implement Bezier & TCB support - if ((*i)->mAnim.mPositionType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Position controller uses Bezier/TCB keys. " - "This is not supported."); - } - if ((*i)->mAnim.mRotationType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Rotation controller uses Bezier/TCB keys. " - "This is not supported."); - } - if ((*i)->mAnim.mScalingType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Position controller uses Bezier/TCB keys. " - "This is not supported."); - } - - // We compare against 1 here - firstly one key is not - // really an animation and secondly MAX writes dummies - // that represent the node transformation. - if ((*i)->mAnim.akeyPositions.size()>1 || (*i)->mAnim.akeyRotations.size()>1 || (*i)->mAnim.akeyScaling.size()>1){ - ++iNum; - } - if ((*i)->mTargetAnim.akeyPositions.size() > 1 && is_not_qnan( (*i)->mTargetPosition.x )) { - ++iNum; - } - } - if (iNum) { - // Generate a new animation channel and setup everything for it - pcScene->mNumAnimations = 1; - pcScene->mAnimations = new aiAnimation*[1]; - aiAnimation* pcAnim = pcScene->mAnimations[0] = new aiAnimation(); - pcAnim->mNumChannels = iNum; - pcAnim->mChannels = new aiNodeAnim*[iNum]; - pcAnim->mTicksPerSecond = mParser->iFrameSpeed * mParser->iTicksPerFrame; - - iNum = 0; - - // Now iterate through all meshes and collect all data we can find - for (i = nodes.begin();i != nodes.end();++i) { - - ASE::BaseNode* me = *i; - if ( me->mTargetAnim.akeyPositions.size() > 1 && is_not_qnan( me->mTargetPosition.x )) { - // Generate an extra channel for the camera/light target. - // BuildNodes() does also generate an extra node, named - // .Target. - aiNodeAnim* nd = pcAnim->mChannels[iNum++] = new aiNodeAnim(); - nd->mNodeName.Set(me->mName + ".Target"); - - // If there is no input position channel we will need - // to supply the default position from the node's - // local transformation matrix. - /*TargetAnimationHelper helper; - if (me->mAnim.akeyPositions.empty()) - { - aiMatrix4x4& mat = (*i)->mTransform; - helper.SetFixedMainAnimationChannel(aiVector3D( - mat.a4, mat.b4, mat.c4)); - } - else helper.SetMainAnimationChannel (&me->mAnim.akeyPositions); - helper.SetTargetAnimationChannel (&me->mTargetAnim.akeyPositions); - - helper.Process(&me->mTargetAnim.akeyPositions);*/ - - // Allocate the key array and fill it - nd->mNumPositionKeys = (unsigned int) me->mTargetAnim.akeyPositions.size(); - nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys]; - - ::memcpy(nd->mPositionKeys,&me->mTargetAnim.akeyPositions[0], - nd->mNumPositionKeys * sizeof(aiVectorKey)); - } - - if (me->mAnim.akeyPositions.size() > 1 || me->mAnim.akeyRotations.size() > 1 || me->mAnim.akeyScaling.size() > 1) { - // Begin a new node animation channel for this node - aiNodeAnim* nd = pcAnim->mChannels[iNum++] = new aiNodeAnim(); - nd->mNodeName.Set(me->mName); - - // copy position keys - if (me->mAnim.akeyPositions.size() > 1 ) - { - // Allocate the key array and fill it - nd->mNumPositionKeys = (unsigned int) me->mAnim.akeyPositions.size(); - nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys]; - - ::memcpy(nd->mPositionKeys,&me->mAnim.akeyPositions[0], - nd->mNumPositionKeys * sizeof(aiVectorKey)); - } - // copy rotation keys - if (me->mAnim.akeyRotations.size() > 1 ) { - // Allocate the key array and fill it - nd->mNumRotationKeys = (unsigned int) me->mAnim.akeyRotations.size(); - nd->mRotationKeys = new aiQuatKey[nd->mNumRotationKeys]; - - // -------------------------------------------------------------------- - // Rotation keys are offsets to the previous keys. - // We have the quaternion representations of all - // of them, so we just need to concatenate all - // (unit-length) quaternions to get the absolute - // rotations. - // Rotation keys are ABSOLUTE for older files - // -------------------------------------------------------------------- - - aiQuaternion cur; - for (unsigned int a = 0; a < nd->mNumRotationKeys;++a) { - aiQuatKey q = me->mAnim.akeyRotations[a]; - - if (mParser->iFileFormat > 110) { - cur = (a ? cur*q.mValue : q.mValue); - q.mValue = cur.Normalize(); - } - nd->mRotationKeys[a] = q; - - // need this to get to Assimp quaternion conventions - nd->mRotationKeys[a].mValue.w *= -1.f; - } - } - // copy scaling keys - if (me->mAnim.akeyScaling.size() > 1 ) { - // Allocate the key array and fill it - nd->mNumScalingKeys = (unsigned int) me->mAnim.akeyScaling.size(); - nd->mScalingKeys = new aiVectorKey[nd->mNumScalingKeys]; - - ::memcpy(nd->mScalingKeys,&me->mAnim.akeyScaling[0], - nd->mNumScalingKeys * sizeof(aiVectorKey)); - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -// Build output cameras -void ASEImporter::BuildCameras() -{ - if (!mParser->m_vCameras.empty()) { - pcScene->mNumCameras = (unsigned int)mParser->m_vCameras.size(); - pcScene->mCameras = new aiCamera*[pcScene->mNumCameras]; - - for (unsigned int i = 0; i < pcScene->mNumCameras;++i) { - aiCamera* out = pcScene->mCameras[i] = new aiCamera(); - ASE::Camera& in = mParser->m_vCameras[i]; - - // copy members - out->mClipPlaneFar = in.mFar; - out->mClipPlaneNear = (in.mNear ? in.mNear : 0.1f); - out->mHorizontalFOV = in.mFOV; - - out->mName.Set(in.mName); - } - } -} - -// ------------------------------------------------------------------------------------------------ -// Build output lights -void ASEImporter::BuildLights() -{ - if (!mParser->m_vLights.empty()) { - pcScene->mNumLights = (unsigned int)mParser->m_vLights.size(); - pcScene->mLights = new aiLight*[pcScene->mNumLights]; - - for (unsigned int i = 0; i < pcScene->mNumLights;++i) { - aiLight* out = pcScene->mLights[i] = new aiLight(); - ASE::Light& in = mParser->m_vLights[i]; - - // The direction is encoded in the transformation matrix of the node. - // In 3DS MAX the light source points into negative Z direction if - // the node transformation is the identity. - out->mDirection = aiVector3D(0.f,0.f,-1.f); - - out->mName.Set(in.mName); - switch (in.mLightType) - { - case ASE::Light::TARGET: - out->mType = aiLightSource_SPOT; - out->mAngleInnerCone = AI_DEG_TO_RAD(in.mAngle); - out->mAngleOuterCone = (in.mFalloff ? AI_DEG_TO_RAD(in.mFalloff) : out->mAngleInnerCone); - break; - - case ASE::Light::DIRECTIONAL: - out->mType = aiLightSource_DIRECTIONAL; - break; - - default: - //case ASE::Light::OMNI: - out->mType = aiLightSource_POINT; - break; - }; - out->mColorDiffuse = out->mColorSpecular = in.mColor * in.mIntensity; - } - } -} - -// ------------------------------------------------------------------------------------------------ -void ASEImporter::AddNodes(const std::vector& nodes, - aiNode* pcParent,const char* szName) -{ - aiMatrix4x4 m; - AddNodes(nodes,pcParent,szName,m); -} - -// ------------------------------------------------------------------------------------------------ -// Add meshes to a given node -void ASEImporter::AddMeshes(const ASE::BaseNode* snode,aiNode* node) -{ - for (unsigned int i = 0; i < pcScene->mNumMeshes;++i) { - // Get the name of the mesh (the mesh instance has been temporarily stored in the third vertex color) - const aiMesh* pcMesh = pcScene->mMeshes[i]; - const ASE::Mesh* mesh = (const ASE::Mesh*)pcMesh->mColors[2]; - - if (mesh == snode) { - ++node->mNumMeshes; - } - } - - if(node->mNumMeshes) { - node->mMeshes = new unsigned int[node->mNumMeshes]; - for (unsigned int i = 0, p = 0; i < pcScene->mNumMeshes;++i) { - - const aiMesh* pcMesh = pcScene->mMeshes[i]; - const ASE::Mesh* mesh = (const ASE::Mesh*)pcMesh->mColors[2]; - if (mesh == snode) { - node->mMeshes[p++] = i; - - // Transform all vertices of the mesh back into their local space -> - // at the moment they are pretransformed - aiMatrix4x4 m = mesh->mTransform; - m.Inverse(); - - aiVector3D* pvCurPtr = pcMesh->mVertices; - const aiVector3D* pvEndPtr = pvCurPtr + pcMesh->mNumVertices; - while (pvCurPtr != pvEndPtr) { - *pvCurPtr = m * (*pvCurPtr); - pvCurPtr++; - } - - // Do the same for the normal vectors, if we have them. - // As always, inverse transpose. - if (pcMesh->mNormals) { - aiMatrix3x3 m3 = aiMatrix3x3( mesh->mTransform ); - m3.Transpose(); - - pvCurPtr = pcMesh->mNormals; - pvEndPtr = pvCurPtr + pcMesh->mNumVertices; - while (pvCurPtr != pvEndPtr) { - *pvCurPtr = m3 * (*pvCurPtr); - pvCurPtr++; - } - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -// Add child nodes to a given parent node -void ASEImporter::AddNodes (const std::vector& nodes, - aiNode* pcParent, const char* szName, - const aiMatrix4x4& mat) -{ - const size_t len = szName ? ::strlen(szName) : 0; - ai_assert(4 <= AI_MAX_NUMBER_OF_COLOR_SETS); - - // Receives child nodes for the pcParent node - std::vector apcNodes; - - // Now iterate through all nodes in the scene and search for one - // which has *us* as parent. - for (std::vector::const_iterator it = nodes.begin(), end = nodes.end(); it != end; ++it) { - const BaseNode* snode = *it; - if (szName) { - if (len != snode->mParent.length() || ::strcmp(szName,snode->mParent.c_str())) - continue; - } - else if (snode->mParent.length()) - continue; - - (*it)->mProcessed = true; - - // Allocate a new node and add it to the output data structure - apcNodes.push_back(new aiNode()); - aiNode* node = apcNodes.back(); - - node->mName.Set((snode->mName.length() ? snode->mName.c_str() : "Unnamed_Node")); - node->mParent = pcParent; - - // Setup the transformation matrix of the node - aiMatrix4x4 mParentAdjust = mat; - mParentAdjust.Inverse(); - node->mTransformation = mParentAdjust*snode->mTransform; - - // Add sub nodes - prevent stack overflow due to recursive parenting - if (node->mName != node->mParent->mName) { - AddNodes(nodes,node,node->mName.data,snode->mTransform); - } - - // Further processing depends on the type of the node - if (snode->mType == ASE::BaseNode::Mesh) { - // If the type of this node is "Mesh" we need to search - // the list of output meshes in the data structure for - // all those that belonged to this node once. This is - // slightly inconvinient here and a better solution should - // be used when this code is refactored next. - AddMeshes(snode,node); - } - else if (is_not_qnan( snode->mTargetPosition.x )) { - // If this is a target camera or light we generate a small - // child node which marks the position of the camera - // target (the direction information is contained in *this* - // node's animation track but the exact target position - // would be lost otherwise) - if (!node->mNumChildren) { - node->mChildren = new aiNode*[1]; - } - - aiNode* nd = new aiNode(); - - nd->mName.Set ( snode->mName + ".Target" ); - - nd->mTransformation.a4 = snode->mTargetPosition.x - snode->mTransform.a4; - nd->mTransformation.b4 = snode->mTargetPosition.y - snode->mTransform.b4; - nd->mTransformation.c4 = snode->mTargetPosition.z - snode->mTransform.c4; - - nd->mParent = node; - - // The .Target node is always the first child node - for (unsigned int m = 0; m < node->mNumChildren;++m) - node->mChildren[m+1] = node->mChildren[m]; - - node->mChildren[0] = nd; - node->mNumChildren++; - - // What we did is so great, it is at least worth a debug message - DefaultLogger::get()->debug("ASE: Generating separate target node ("+snode->mName+")"); - } - } - - // Allocate enough space for the child nodes - // We allocate one slot more in case this is a target camera/light - pcParent->mNumChildren = (unsigned int)apcNodes.size(); - if (pcParent->mNumChildren) { - pcParent->mChildren = new aiNode*[apcNodes.size()+1 /* PLUS ONE !!! */]; - - // now build all nodes for our nice new children - for (unsigned int p = 0; p < apcNodes.size();++p) - pcParent->mChildren[p] = apcNodes[p]; - } - return; -} - -// ------------------------------------------------------------------------------------------------ -// Build the output node graph -void ASEImporter::BuildNodes(std::vector& nodes) { - ai_assert(NULL != pcScene); - - // allocate the one and only root node - aiNode* root = pcScene->mRootNode = new aiNode(); - root->mName.Set(""); - - // Setup the coordinate system transformation - pcScene->mRootNode->mNumChildren = 1; - pcScene->mRootNode->mChildren = new aiNode*[1]; - aiNode* ch = pcScene->mRootNode->mChildren[0] = new aiNode(); - ch->mParent = root; - - // Change the transformation matrix of all nodes - for (BaseNode *node : nodes) { - aiMatrix4x4& m = node->mTransform; - m.Transpose(); // row-order vs column-order - } - - // add all nodes - AddNodes(nodes,ch,NULL); - - // now iterate through al nodes and find those that have not yet - // been added to the nodegraph (= their parent could not be recognized) - std::vector aiList; - for (std::vector::iterator it = nodes.begin(), end = nodes.end();it != end; ++it) { - if ((*it)->mProcessed) { - continue; - } - - // check whether our parent is known - bool bKnowParent = false; - - // search the list another time, starting *here* and try to find out whether - // there is a node that references *us* as a parent - for (std::vector::const_iterator it2 = nodes.begin();it2 != end; ++it2) { - if (it2 == it) { - continue; - } - - if ((*it2)->mName == (*it)->mParent) { - bKnowParent = true; - break; - } - } - if (!bKnowParent) { - aiList.push_back(*it); - } - } - - // Are there ane orphaned nodes? - if (!aiList.empty()) { - std::vector apcNodes; - apcNodes.reserve(aiList.size() + pcScene->mRootNode->mNumChildren); - - for (unsigned int i = 0; i < pcScene->mRootNode->mNumChildren;++i) - apcNodes.push_back(pcScene->mRootNode->mChildren[i]); - - delete[] pcScene->mRootNode->mChildren; - for (std::vector::/*const_*/iterator i = aiList.begin();i != aiList.end();++i) { - const ASE::BaseNode* src = *i; - - // The parent is not known, so we can assume that we must add - // this node to the root node of the whole scene - aiNode* pcNode = new aiNode(); - pcNode->mParent = pcScene->mRootNode; - pcNode->mName.Set(src->mName); - AddMeshes(src,pcNode); - AddNodes(nodes,pcNode,pcNode->mName.data); - apcNodes.push_back(pcNode); - } - - // Regenerate our output array - pcScene->mRootNode->mChildren = new aiNode*[apcNodes.size()]; - for (unsigned int i = 0; i < apcNodes.size();++i) - pcScene->mRootNode->mChildren[i] = apcNodes[i]; - - pcScene->mRootNode->mNumChildren = (unsigned int)apcNodes.size(); - } - - // Reset the third color set to NULL - we used this field to store a temporary pointer - for (unsigned int i = 0; i < pcScene->mNumMeshes;++i) - pcScene->mMeshes[i]->mColors[2] = NULL; - - // The root node should not have at least one child or the file is valid - if (!pcScene->mRootNode->mNumChildren) { - throw DeadlyImportError("ASE: No nodes loaded. The file is either empty or corrupt"); - } - - // Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system - pcScene->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); -} - -// ------------------------------------------------------------------------------------------------ -// Convert the imported data to the internal verbose representation -void ASEImporter::BuildUniqueRepresentation(ASE::Mesh& mesh) { - // allocate output storage - std::vector mPositions; - std::vector amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; - std::vector mVertexColors; - std::vector mNormals; - std::vector mBoneVertices; - - unsigned int iSize = (unsigned int)mesh.mFaces.size() * 3; - mPositions.resize(iSize); - - // optional texture coordinates - for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) { - if (!mesh.amTexCoords[i].empty()) { - amTexCoords[i].resize(iSize); - } - } - // optional vertex colors - if (!mesh.mVertexColors.empty()) { - mVertexColors.resize(iSize); - } - - // optional vertex normals (vertex normals can simply be copied) - if (!mesh.mNormals.empty()) { - mNormals.resize(iSize); - } - // bone vertices. There is no need to change the bone list - if (!mesh.mBoneVertices.empty()) { - mBoneVertices.resize(iSize); - } - - // iterate through all faces in the mesh - unsigned int iCurrent = 0, fi = 0; - for (std::vector::iterator i = mesh.mFaces.begin();i != mesh.mFaces.end();++i,++fi) { - for (unsigned int n = 0; n < 3;++n,++iCurrent) - { - mPositions[iCurrent] = mesh.mPositions[(*i).mIndices[n]]; - - // add texture coordinates - for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) { - if (mesh.amTexCoords[c].empty())break; - amTexCoords[c][iCurrent] = mesh.amTexCoords[c][(*i).amUVIndices[c][n]]; - } - // add vertex colors - if (!mesh.mVertexColors.empty()) { - mVertexColors[iCurrent] = mesh.mVertexColors[(*i).mColorIndices[n]]; - } - // add normal vectors - if (!mesh.mNormals.empty()) { - mNormals[iCurrent] = mesh.mNormals[fi*3+n]; - mNormals[iCurrent].Normalize(); - } - - // handle bone vertices - if ((*i).mIndices[n] < mesh.mBoneVertices.size()) { - // (sometimes this will cause bone verts to be duplicated - // however, I' quite sure Schrompf' JoinVerticesStep - // will fix that again ...) - mBoneVertices[iCurrent] = mesh.mBoneVertices[(*i).mIndices[n]]; - } - (*i).mIndices[n] = iCurrent; - } - } - - // replace the old arrays - mesh.mNormals = mNormals; - mesh.mPositions = mPositions; - mesh.mVertexColors = mVertexColors; - - for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) - mesh.amTexCoords[c] = amTexCoords[c]; -} - -// ------------------------------------------------------------------------------------------------ -// Copy a texture from the ASE structs to the output material -void CopyASETexture(aiMaterial& mat, ASE::Texture& texture, aiTextureType type) -{ - // Setup the texture name - aiString tex; - tex.Set( texture.mMapName); - mat.AddProperty( &tex, AI_MATKEY_TEXTURE(type,0)); - - // Setup the texture blend factor - if (is_not_qnan(texture.mTextureBlend)) - mat.AddProperty( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0)); - - // Setup texture UV transformations - mat.AddProperty(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0)); -} - -// ------------------------------------------------------------------------------------------------ -// Convert from ASE material to output material -void ASEImporter::ConvertMaterial(ASE::Material& mat) -{ - // LARGE TODO: Much code her is copied from 3DS ... join them maybe? - - // Allocate the output material - mat.pcInstance = new aiMaterial(); - - // At first add the base ambient color of the - // scene to the material - mat.mAmbient.r += mParser->m_clrAmbient.r; - mat.mAmbient.g += mParser->m_clrAmbient.g; - mat.mAmbient.b += mParser->m_clrAmbient.b; - - aiString name; - name.Set( mat.mName); - mat.pcInstance->AddProperty( &name, AI_MATKEY_NAME); - - // material colors - mat.pcInstance->AddProperty( &mat.mAmbient, 1, AI_MATKEY_COLOR_AMBIENT); - mat.pcInstance->AddProperty( &mat.mDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE); - mat.pcInstance->AddProperty( &mat.mSpecular, 1, AI_MATKEY_COLOR_SPECULAR); - mat.pcInstance->AddProperty( &mat.mEmissive, 1, AI_MATKEY_COLOR_EMISSIVE); - - // shininess - if (0.0f != mat.mSpecularExponent && 0.0f != mat.mShininessStrength) - { - mat.pcInstance->AddProperty( &mat.mSpecularExponent, 1, AI_MATKEY_SHININESS); - mat.pcInstance->AddProperty( &mat.mShininessStrength, 1, AI_MATKEY_SHININESS_STRENGTH); - } - // If there is no shininess, we can disable phong lighting - else if (D3DS::Discreet3DS::Metal == mat.mShading || - D3DS::Discreet3DS::Phong == mat.mShading || - D3DS::Discreet3DS::Blinn == mat.mShading) - { - mat.mShading = D3DS::Discreet3DS::Gouraud; - } - - // opacity - mat.pcInstance->AddProperty( &mat.mTransparency,1,AI_MATKEY_OPACITY); - - // Two sided rendering? - if (mat.mTwoSided) - { - int i = 1; - mat.pcInstance->AddProperty(&i,1,AI_MATKEY_TWOSIDED); - } - - // shading mode - aiShadingMode eShading = aiShadingMode_NoShading; - switch (mat.mShading) - { - case D3DS::Discreet3DS::Flat: - eShading = aiShadingMode_Flat; break; - case D3DS::Discreet3DS::Phong : - eShading = aiShadingMode_Phong; break; - case D3DS::Discreet3DS::Blinn : - eShading = aiShadingMode_Blinn; break; - - // I don't know what "Wire" shading should be, - // assume it is simple lambertian diffuse (L dot N) shading - case D3DS::Discreet3DS::Wire: - { - // set the wireframe flag - unsigned int iWire = 1; - mat.pcInstance->AddProperty( (int*)&iWire,1,AI_MATKEY_ENABLE_WIREFRAME); - } - case D3DS::Discreet3DS::Gouraud: - eShading = aiShadingMode_Gouraud; break; - case D3DS::Discreet3DS::Metal : - eShading = aiShadingMode_CookTorrance; break; - } - mat.pcInstance->AddProperty( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL); - - // DIFFUSE texture - if( mat.sTexDiffuse.mMapName.length() > 0) - CopyASETexture(*mat.pcInstance,mat.sTexDiffuse, aiTextureType_DIFFUSE); - - // SPECULAR texture - if( mat.sTexSpecular.mMapName.length() > 0) - CopyASETexture(*mat.pcInstance,mat.sTexSpecular, aiTextureType_SPECULAR); - - // AMBIENT texture - if( mat.sTexAmbient.mMapName.length() > 0) - CopyASETexture(*mat.pcInstance,mat.sTexAmbient, aiTextureType_AMBIENT); - - // OPACITY texture - if( mat.sTexOpacity.mMapName.length() > 0) - CopyASETexture(*mat.pcInstance,mat.sTexOpacity, aiTextureType_OPACITY); - - // EMISSIVE texture - if( mat.sTexEmissive.mMapName.length() > 0) - CopyASETexture(*mat.pcInstance,mat.sTexEmissive, aiTextureType_EMISSIVE); - - // BUMP texture - if( mat.sTexBump.mMapName.length() > 0) - CopyASETexture(*mat.pcInstance,mat.sTexBump, aiTextureType_HEIGHT); - - // SHININESS texture - if( mat.sTexShininess.mMapName.length() > 0) - CopyASETexture(*mat.pcInstance,mat.sTexShininess, aiTextureType_SHININESS); - - // store the name of the material itself, too - if( mat.mName.length() > 0) { - aiString tex;tex.Set( mat.mName); - mat.pcInstance->AddProperty( &tex, AI_MATKEY_NAME); - } - return; -} - -// ------------------------------------------------------------------------------------------------ -// Build output meshes -void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, std::vector& avOutMeshes) -{ - // validate the material index of the mesh - if (mesh.iMaterialIndex >= mParser->m_vMaterials.size()) { - mesh.iMaterialIndex = (unsigned int)mParser->m_vMaterials.size()-1; - DefaultLogger::get()->warn("Material index is out of range"); - } - - // If the material the mesh is assigned to is consisting of submeshes, split it - if (!mParser->m_vMaterials[mesh.iMaterialIndex].avSubMaterials.empty()) { - std::vector vSubMaterials = mParser-> - m_vMaterials[mesh.iMaterialIndex].avSubMaterials; - - std::vector* aiSplit = new std::vector[vSubMaterials.size()]; - - // build a list of all faces per submaterial - for (unsigned int i = 0; i < mesh.mFaces.size();++i) { - // check range - if (mesh.mFaces[i].iMaterial >= vSubMaterials.size()) { - DefaultLogger::get()->warn("Submaterial index is out of range"); - - // use the last material instead - aiSplit[vSubMaterials.size()-1].push_back(i); - } - else aiSplit[mesh.mFaces[i].iMaterial].push_back(i); - } - - // now generate submeshes - for (unsigned int p = 0; p < vSubMaterials.size();++p) { - if (!aiSplit[p].empty()) { - - aiMesh* p_pcOut = new aiMesh(); - p_pcOut->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - - // let the sub material index - p_pcOut->mMaterialIndex = p; - - // we will need this material - mParser->m_vMaterials[mesh.iMaterialIndex].avSubMaterials[p].bNeed = true; - - // store the real index here ... color channel 3 - p_pcOut->mColors[3] = (aiColor4D*)(uintptr_t)mesh.iMaterialIndex; - - // store a pointer to the mesh in color channel 2 - p_pcOut->mColors[2] = (aiColor4D*) &mesh; - avOutMeshes.push_back(p_pcOut); - - // convert vertices - p_pcOut->mNumVertices = (unsigned int)aiSplit[p].size()*3; - p_pcOut->mNumFaces = (unsigned int)aiSplit[p].size(); - - // receive output vertex weights - std::vector > *avOutputBones = NULL; - if (!mesh.mBones.empty()) { - avOutputBones = new std::vector >[mesh.mBones.size()]; - } - - // allocate enough storage for faces - p_pcOut->mFaces = new aiFace[p_pcOut->mNumFaces]; - - unsigned int iBase = 0,iIndex; - if (p_pcOut->mNumVertices) { - p_pcOut->mVertices = new aiVector3D[p_pcOut->mNumVertices]; - p_pcOut->mNormals = new aiVector3D[p_pcOut->mNumVertices]; - for (unsigned int q = 0; q < aiSplit[p].size();++q) { - - iIndex = aiSplit[p][q]; - - p_pcOut->mFaces[q].mIndices = new unsigned int[3]; - p_pcOut->mFaces[q].mNumIndices = 3; - - for (unsigned int t = 0; t < 3;++t, ++iBase) { - const uint32_t iIndex2 = mesh.mFaces[iIndex].mIndices[t]; - - p_pcOut->mVertices[iBase] = mesh.mPositions [iIndex2]; - p_pcOut->mNormals [iBase] = mesh.mNormals [iIndex2]; - - // convert bones, if existing - if (!mesh.mBones.empty()) { - ai_assert(avOutputBones); - // check whether there is a vertex weight for this vertex index - if (iIndex2 < mesh.mBoneVertices.size()) { - - for (std::vector >::const_iterator - blubb = mesh.mBoneVertices[iIndex2].mBoneWeights.begin(); - blubb != mesh.mBoneVertices[iIndex2].mBoneWeights.end();++blubb) { - - // NOTE: illegal cases have already been filtered out - avOutputBones[(*blubb).first].push_back(std::pair( - iBase,(*blubb).second)); - } - } - } - p_pcOut->mFaces[q].mIndices[t] = iBase; - } - } - } - // convert texture coordinates (up to AI_MAX_NUMBER_OF_TEXTURECOORDS sets supported) - for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) { - if (!mesh.amTexCoords[c].empty()) - { - p_pcOut->mTextureCoords[c] = new aiVector3D[p_pcOut->mNumVertices]; - iBase = 0; - for (unsigned int q = 0; q < aiSplit[p].size();++q) { - iIndex = aiSplit[p][q]; - for (unsigned int t = 0; t < 3;++t) { - p_pcOut->mTextureCoords[c][iBase++] = mesh.amTexCoords[c][mesh.mFaces[iIndex].mIndices[t]]; - } - } - // Setup the number of valid vertex components - p_pcOut->mNumUVComponents[c] = mesh.mNumUVComponents[c]; - } - } - - // Convert vertex colors (only one set supported) - if (!mesh.mVertexColors.empty()){ - p_pcOut->mColors[0] = new aiColor4D[p_pcOut->mNumVertices]; - iBase = 0; - for (unsigned int q = 0; q < aiSplit[p].size();++q) { - iIndex = aiSplit[p][q]; - for (unsigned int t = 0; t < 3;++t) { - p_pcOut->mColors[0][iBase++] = mesh.mVertexColors[mesh.mFaces[iIndex].mIndices[t]]; - } - } - } - // Copy bones - if (!mesh.mBones.empty()) { - p_pcOut->mNumBones = 0; - for (unsigned int mrspock = 0; mrspock < mesh.mBones.size();++mrspock) - if (!avOutputBones[mrspock].empty())p_pcOut->mNumBones++; - - p_pcOut->mBones = new aiBone* [ p_pcOut->mNumBones ]; - aiBone** pcBone = p_pcOut->mBones; - for (unsigned int mrspock = 0; mrspock < mesh.mBones.size();++mrspock) - { - if (!avOutputBones[mrspock].empty()) { - // we will need this bone. add it to the output mesh and - // add all per-vertex weights - aiBone* pc = *pcBone = new aiBone(); - pc->mName.Set(mesh.mBones[mrspock].mName); - - pc->mNumWeights = (unsigned int)avOutputBones[mrspock].size(); - pc->mWeights = new aiVertexWeight[pc->mNumWeights]; - - for (unsigned int captainkirk = 0; captainkirk < pc->mNumWeights;++captainkirk) - { - const std::pair& ref = avOutputBones[mrspock][captainkirk]; - pc->mWeights[captainkirk].mVertexId = ref.first; - pc->mWeights[captainkirk].mWeight = ref.second; - } - ++pcBone; - } - } - // delete allocated storage - delete[] avOutputBones; - } - } - } - // delete storage - delete[] aiSplit; - } - else - { - // Otherwise we can simply copy the data to one output mesh - // This codepath needs less memory and uses fast memcpy()s - // to do the actual copying. So I think it is worth the - // effort here. - - aiMesh* p_pcOut = new aiMesh(); - p_pcOut->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - - // set an empty sub material index - p_pcOut->mMaterialIndex = ASE::Face::DEFAULT_MATINDEX; - mParser->m_vMaterials[mesh.iMaterialIndex].bNeed = true; - - // store the real index here ... in color channel 3 - p_pcOut->mColors[3] = (aiColor4D*)(uintptr_t)mesh.iMaterialIndex; - - // store a pointer to the mesh in color channel 2 - p_pcOut->mColors[2] = (aiColor4D*) &mesh; - avOutMeshes.push_back(p_pcOut); - - // If the mesh hasn't faces or vertices, there are two cases - // possible: 1. the model is invalid. 2. This is a dummy - // helper object which we are going to remove later ... - if (mesh.mFaces.empty() || mesh.mPositions.empty()) { - return; - } - - // convert vertices - p_pcOut->mNumVertices = (unsigned int)mesh.mPositions.size(); - p_pcOut->mNumFaces = (unsigned int)mesh.mFaces.size(); - - // allocate enough storage for faces - p_pcOut->mFaces = new aiFace[p_pcOut->mNumFaces]; - - // copy vertices - p_pcOut->mVertices = new aiVector3D[mesh.mPositions.size()]; - memcpy(p_pcOut->mVertices,&mesh.mPositions[0], - mesh.mPositions.size() * sizeof(aiVector3D)); - - // copy normals - p_pcOut->mNormals = new aiVector3D[mesh.mNormals.size()]; - memcpy(p_pcOut->mNormals,&mesh.mNormals[0], - mesh.mNormals.size() * sizeof(aiVector3D)); - - // copy texture coordinates - for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) { - if (!mesh.amTexCoords[c].empty()) { - p_pcOut->mTextureCoords[c] = new aiVector3D[mesh.amTexCoords[c].size()]; - memcpy(p_pcOut->mTextureCoords[c],&mesh.amTexCoords[c][0], - mesh.amTexCoords[c].size() * sizeof(aiVector3D)); - - // setup the number of valid vertex components - p_pcOut->mNumUVComponents[c] = mesh.mNumUVComponents[c]; - } - } - - // copy vertex colors - if (!mesh.mVertexColors.empty()) { - p_pcOut->mColors[0] = new aiColor4D[mesh.mVertexColors.size()]; - memcpy(p_pcOut->mColors[0],&mesh.mVertexColors[0], - mesh.mVertexColors.size() * sizeof(aiColor4D)); - } - - // copy faces - for (unsigned int iFace = 0; iFace < p_pcOut->mNumFaces;++iFace) { - p_pcOut->mFaces[iFace].mNumIndices = 3; - p_pcOut->mFaces[iFace].mIndices = new unsigned int[3]; - - // copy indices - p_pcOut->mFaces[iFace].mIndices[0] = mesh.mFaces[iFace].mIndices[0]; - p_pcOut->mFaces[iFace].mIndices[1] = mesh.mFaces[iFace].mIndices[1]; - p_pcOut->mFaces[iFace].mIndices[2] = mesh.mFaces[iFace].mIndices[2]; - } - - // copy vertex bones - if (!mesh.mBones.empty() && !mesh.mBoneVertices.empty()) { - std::vector > avBonesOut( mesh.mBones.size() ); - - // find all vertex weights for this bone - unsigned int quak = 0; - for (std::vector::const_iterator harrypotter = mesh.mBoneVertices.begin(); - harrypotter != mesh.mBoneVertices.end();++harrypotter,++quak) { - - for (std::vector >::const_iterator - ronaldweasley = (*harrypotter).mBoneWeights.begin(); - ronaldweasley != (*harrypotter).mBoneWeights.end();++ronaldweasley) - { - aiVertexWeight weight; - weight.mVertexId = quak; - weight.mWeight = (*ronaldweasley).second; - avBonesOut[(*ronaldweasley).first].push_back(weight); - } - } - - // now build a final bone list - p_pcOut->mNumBones = 0; - for (unsigned int jfkennedy = 0; jfkennedy < mesh.mBones.size();++jfkennedy) - if (!avBonesOut[jfkennedy].empty())p_pcOut->mNumBones++; - - p_pcOut->mBones = new aiBone*[p_pcOut->mNumBones]; - aiBone** pcBone = p_pcOut->mBones; - for (unsigned int jfkennedy = 0; jfkennedy < mesh.mBones.size();++jfkennedy) { - if (!avBonesOut[jfkennedy].empty()) { - aiBone* pc = *pcBone = new aiBone(); - pc->mName.Set(mesh.mBones[jfkennedy].mName); - pc->mNumWeights = (unsigned int)avBonesOut[jfkennedy].size(); - pc->mWeights = new aiVertexWeight[pc->mNumWeights]; - ::memcpy(pc->mWeights,&avBonesOut[jfkennedy][0], - sizeof(aiVertexWeight) * pc->mNumWeights); - ++pcBone; - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -// Setup proper material indices and build output materials -void ASEImporter::BuildMaterialIndices() -{ - ai_assert(NULL != pcScene); - - // iterate through all materials and check whether we need them - for (unsigned int iMat = 0; iMat < mParser->m_vMaterials.size();++iMat) - { - ASE::Material& mat = mParser->m_vMaterials[iMat]; - if (mat.bNeed) { - // Convert it to the aiMaterial layout - ConvertMaterial(mat); - ++pcScene->mNumMaterials; - } - for (unsigned int iSubMat = 0; iSubMat < mat.avSubMaterials.size();++iSubMat) - { - ASE::Material& submat = mat.avSubMaterials[iSubMat]; - if (submat.bNeed) { - // Convert it to the aiMaterial layout - ConvertMaterial(submat); - ++pcScene->mNumMaterials; - } - } - } - - // allocate the output material array - pcScene->mMaterials = new aiMaterial*[pcScene->mNumMaterials]; - D3DS::Material** pcIntMaterials = new D3DS::Material*[pcScene->mNumMaterials]; - - unsigned int iNum = 0; - for (unsigned int iMat = 0; iMat < mParser->m_vMaterials.size();++iMat) { - ASE::Material& mat = mParser->m_vMaterials[iMat]; - if (mat.bNeed) - { - ai_assert(NULL != mat.pcInstance); - pcScene->mMaterials[iNum] = mat.pcInstance; - - // Store the internal material, too - pcIntMaterials[iNum] = &mat; - - // Iterate through all meshes and search for one which is using - // this top-level material index - for (unsigned int iMesh = 0; iMesh < pcScene->mNumMeshes;++iMesh) - { - aiMesh* mesh = pcScene->mMeshes[iMesh]; - if (ASE::Face::DEFAULT_MATINDEX == mesh->mMaterialIndex && - iMat == (uintptr_t)mesh->mColors[3]) - { - mesh->mMaterialIndex = iNum; - mesh->mColors[3] = NULL; - } - } - iNum++; - } - for (unsigned int iSubMat = 0; iSubMat < mat.avSubMaterials.size();++iSubMat) { - ASE::Material& submat = mat.avSubMaterials[iSubMat]; - if (submat.bNeed) { - ai_assert(NULL != submat.pcInstance); - pcScene->mMaterials[iNum] = submat.pcInstance; - - // Store the internal material, too - pcIntMaterials[iNum] = &submat; - - // Iterate through all meshes and search for one which is using - // this sub-level material index - for (unsigned int iMesh = 0; iMesh < pcScene->mNumMeshes;++iMesh) { - aiMesh* mesh = pcScene->mMeshes[iMesh]; - - if (iSubMat == mesh->mMaterialIndex && iMat == (uintptr_t)mesh->mColors[3]) { - mesh->mMaterialIndex = iNum; - mesh->mColors[3] = NULL; - } - } - iNum++; - } - } - } - - // Dekete our temporary array - delete[] pcIntMaterials; -} - -// ------------------------------------------------------------------------------------------------ -// Generate normal vectors basing on smoothing groups -bool ASEImporter::GenerateNormals(ASE::Mesh& mesh) { - - if (!mesh.mNormals.empty() && !configRecomputeNormals) - { - // Check whether there are only uninitialized normals. If there are - // some, skip all normals from the file and compute them on our own - for (std::vector::const_iterator qq = mesh.mNormals.begin();qq != mesh.mNormals.end();++qq) { - if ((*qq).x || (*qq).y || (*qq).z) - { - return true; - } - } - } - // The array is reused. - ComputeNormalsWithSmoothingsGroups(mesh); - return false; -} - -#endif // ASSIMP_BUILD_NO_3DS_IMPORTER - -#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER diff --git a/src/3rdparty/assimp/code/ASELoader.h b/src/3rdparty/assimp/code/ASELoader.h deleted file mode 100644 index 8a8d4faa4..000000000 --- a/src/3rdparty/assimp/code/ASELoader.h +++ /dev/null @@ -1,207 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file ASELoader.h - * @brief Definition of the .ASE importer class. - */ -#ifndef AI_ASELOADER_H_INCLUDED -#define AI_ASELOADER_H_INCLUDED - -#include "BaseImporter.h" -#include -#include "ASEParser.h" - -struct aiNode; - -namespace Assimp { - -#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER - -// -------------------------------------------------------------------------------- -/** Importer class for the 3DS ASE ASCII format. - * - */ -class ASEImporter : public BaseImporter { -public: - ASEImporter(); - ~ASEImporter(); - - // ------------------------------------------------------------------- - /** Returns whether the class can handle the format of the given file. - * See BaseImporter::CanRead() for details. - */ - bool CanRead( const std::string& pFile, IOSystem* pIOHandler, - bool checkSig) const; - -protected: - - // ------------------------------------------------------------------- - /** Return importer meta information. - * See #BaseImporter::GetInfo for the details - */ - const aiImporterDesc* GetInfo () const; - - - // ------------------------------------------------------------------- - /** Imports the given file into the given scene structure. - * See BaseImporter::InternReadFile() for details - */ - void InternReadFile( const std::string& pFile, aiScene* pScene, - IOSystem* pIOHandler); - - - // ------------------------------------------------------------------- - /** Called prior to ReadFile(). - * The function is a request to the importer to update its configuration - * basing on the Importer's configuration property list. - */ - void SetupProperties(const Importer* pImp); - - -private: - - // ------------------------------------------------------------------- - /** Generate normal vectors basing on smoothing groups - * (in some cases the normal are already contained in the file) - * \param mesh Mesh to work on - * \return false if the normals have been recomputed - */ - bool GenerateNormals(ASE::Mesh& mesh); - - - // ------------------------------------------------------------------- - /** Create valid vertex/normal/UV/color/face lists. - * All elements are unique, faces have only one set of indices - * after this step occurs. - * \param mesh Mesh to work on - */ - void BuildUniqueRepresentation(ASE::Mesh& mesh); - - - /** Create one-material-per-mesh meshes ;-) - * \param mesh Mesh to work with - * \param Receives the list of all created meshes - */ - void ConvertMeshes(ASE::Mesh& mesh, std::vector& avOut); - - - // ------------------------------------------------------------------- - /** Convert a material to a aiMaterial object - * \param mat Input material - */ - void ConvertMaterial(ASE::Material& mat); - - - // ------------------------------------------------------------------- - /** Setup the final material indices for each mesh - */ - void BuildMaterialIndices(); - - - // ------------------------------------------------------------------- - /** Build the node graph - */ - void BuildNodes(std::vector& nodes); - - - // ------------------------------------------------------------------- - /** Build output cameras - */ - void BuildCameras(); - - - // ------------------------------------------------------------------- - /** Build output lights - */ - void BuildLights(); - - - // ------------------------------------------------------------------- - /** Build output animations - */ - void BuildAnimations(const std::vector& nodes); - - - // ------------------------------------------------------------------- - /** Add sub nodes to a node - * \param pcParent parent node to be filled - * \param szName Name of the parent node - * \param matrix Current transform - */ - void AddNodes(const std::vector& nodes, - aiNode* pcParent,const char* szName); - - void AddNodes(const std::vector& nodes, - aiNode* pcParent,const char* szName, - const aiMatrix4x4& matrix); - - void AddMeshes(const ASE::BaseNode* snode,aiNode* node); - - // ------------------------------------------------------------------- - /** Generate a default material and add it to the parser's list - * Called if no material has been found in the file (rare for ASE, - * but not impossible) - */ - void GenerateDefaultMaterial(); - -protected: - - /** Parser instance */ - ASE::Parser* mParser; - - /** Buffer to hold the loaded file */ - char* mBuffer; - - /** Scene to be filled */ - aiScene* pcScene; - - /** Config options: Recompute the normals in every case - WA - for 3DS Max broken ASE normal export */ - bool configRecomputeNormals; - bool noSkeletonMesh; -}; - -#endif // ASSIMP_BUILD_NO_3DS_IMPORTER - -} // end of namespace Assimp - - -#endif // AI_3DSIMPORTER_H_INC diff --git a/src/3rdparty/assimp/code/ASEParser.cpp b/src/3rdparty/assimp/code/ASEParser.cpp deleted file mode 100644 index 7de80a2d8..000000000 --- a/src/3rdparty/assimp/code/ASEParser.cpp +++ /dev/null @@ -1,2157 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file ASEParser.cpp - * @brief Implementation of the ASE parser class - */ - - -#ifndef ASSIMP_BUILD_NO_ASE_IMPORTER -#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER - -// internal headers -#include "TextureTransform.h" -#include "ASELoader.h" -#include "fast_atof.h" -#include - -using namespace Assimp; -using namespace Assimp::ASE; - - -// ------------------------------------------------------------------------------------------------ -// Begin an ASE parsing function - -#define AI_ASE_PARSER_INIT() \ - int iDepth = 0; - -// ------------------------------------------------------------------------------------------------ -// Handle a "top-level" section in the file. EOF is no error in this case. - -#define AI_ASE_HANDLE_TOP_LEVEL_SECTION() \ - else if ('{' == *filePtr)iDepth++; \ - else if ('}' == *filePtr) \ - { \ - if (0 == --iDepth) \ - { \ - ++filePtr; \ - SkipToNextToken(); \ - return; \ - } \ - } \ - else if ('\0' == *filePtr) \ - { \ - return; \ - } \ - if(IsLineEnd(*filePtr) && !bLastWasEndLine) \ - { \ - ++iLineNumber; \ - bLastWasEndLine = true; \ - } else bLastWasEndLine = false; \ - ++filePtr; - -// ------------------------------------------------------------------------------------------------ -// Handle a nested section in the file. EOF is an error in this case -// @param level "Depth" of the section -// @param msg Full name of the section (including the asterisk) - -#define AI_ASE_HANDLE_SECTION(level, msg) \ - if ('{' == *filePtr)iDepth++; \ - else if ('}' == *filePtr) \ - { \ - if (0 == --iDepth) \ - { \ - ++filePtr; \ - SkipToNextToken(); \ - return; \ - } \ - } \ - else if ('\0' == *filePtr) \ - { \ - LogError("Encountered unexpected EOL while parsing a " msg \ - " chunk (Level " level ")"); \ - } \ - if(IsLineEnd(*filePtr) && !bLastWasEndLine) \ - { \ - ++iLineNumber; \ - bLastWasEndLine = true; \ - } else bLastWasEndLine = false; \ - ++filePtr; - -// ------------------------------------------------------------------------------------------------ -Parser::Parser (const char* szFile, unsigned int fileFormatDefault) -{ - ai_assert(NULL != szFile); - filePtr = szFile; - iFileFormat = fileFormatDefault; - - // make sure that the color values are invalid - m_clrBackground.r = get_qnan(); - m_clrAmbient.r = get_qnan(); - - // setup some default values - iLineNumber = 0; - iFirstFrame = 0; - iLastFrame = 0; - iFrameSpeed = 30; // use 30 as default value for this property - iTicksPerFrame = 1; // use 1 as default value for this property - bLastWasEndLine = false; // need to handle \r\n seqs due to binary file mapping -} - -// ------------------------------------------------------------------------------------------------ -void Parser::LogWarning(const char* szWarn) -{ - ai_assert(NULL != szWarn); - - char szTemp[1024]; -#if _MSC_VER >= 1400 - sprintf_s(szTemp, "Line %u: %s",iLineNumber,szWarn); -#else - ai_snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn); -#endif - - // output the warning to the logger ... - DefaultLogger::get()->warn(szTemp); -} - -// ------------------------------------------------------------------------------------------------ -void Parser::LogInfo(const char* szWarn) -{ - ai_assert(NULL != szWarn); - - char szTemp[1024]; -#if _MSC_VER >= 1400 - sprintf_s(szTemp,"Line %u: %s",iLineNumber,szWarn); -#else - ai_snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn); -#endif - - // output the information to the logger ... - DefaultLogger::get()->info(szTemp); -} - -// ------------------------------------------------------------------------------------------------ -AI_WONT_RETURN void Parser::LogError(const char* szWarn) -{ - ai_assert(NULL != szWarn); - - char szTemp[1024]; -#if _MSC_VER >= 1400 - sprintf_s(szTemp,"Line %u: %s",iLineNumber,szWarn); -#else - ai_snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn); -#endif - - // throw an exception - throw DeadlyImportError(szTemp); -} - -// ------------------------------------------------------------------------------------------------ -bool Parser::SkipToNextToken() -{ - while (true) - { - char me = *filePtr; - - // increase the line number counter if necessary - if (IsLineEnd(me) && !bLastWasEndLine) - { - ++iLineNumber; - bLastWasEndLine = true; - } - else bLastWasEndLine = false; - if ('*' == me || '}' == me || '{' == me)return true; - if ('\0' == me)return false; - - ++filePtr; - } -} - -// ------------------------------------------------------------------------------------------------ -bool Parser::SkipSection() -{ - // must handle subsections ... - int iCnt = 0; - while (true) - { - if ('}' == *filePtr) - { - --iCnt; - if (0 == iCnt) - { - // go to the next valid token ... - ++filePtr; - SkipToNextToken(); - return true; - } - } - else if ('{' == *filePtr) - { - ++iCnt; - } - else if ('\0' == *filePtr) - { - LogWarning("Unable to parse block: Unexpected EOF, closing bracket \'}\' was expected [#1]"); - return false; - } - else if(IsLineEnd(*filePtr))++iLineNumber; - ++filePtr; - } -} - -// ------------------------------------------------------------------------------------------------ -void Parser::Parse() -{ - AI_ASE_PARSER_INIT(); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Version should be 200. Validate this ... - if (TokenMatch(filePtr,"3DSMAX_ASCIIEXPORT",18)) - { - unsigned int fmt; - ParseLV4MeshLong(fmt); - - if (fmt > 200) - { - LogWarning("Unknown file format version: *3DSMAX_ASCIIEXPORT should \ - be <= 200"); - } - // ************************************************************* - // - fmt will be 0 if we're unable to read the version number - // there are some faulty files without a version number ... - // in this case we'll guess the exact file format by looking - // at the file extension (ASE, ASK, ASC) - // ************************************************************* - - if (fmt)iFileFormat = fmt; - continue; - } - // main scene information - if (TokenMatch(filePtr,"SCENE",5)) - { - ParseLV1SceneBlock(); - continue; - } - // "group" - no implementation yet, in facte - // we're just ignoring them for the moment - if (TokenMatch(filePtr,"GROUP",5)) - { - Parse(); - continue; - } - // material list - if (TokenMatch(filePtr,"MATERIAL_LIST",13)) - { - ParseLV1MaterialListBlock(); - continue; - } - // geometric object (mesh) - if (TokenMatch(filePtr,"GEOMOBJECT",10)) - - { - m_vMeshes.push_back(Mesh()); - ParseLV1ObjectBlock(m_vMeshes.back()); - continue; - } - // helper object = dummy in the hierarchy - if (TokenMatch(filePtr,"HELPEROBJECT",12)) - - { - m_vDummies.push_back(Dummy()); - ParseLV1ObjectBlock(m_vDummies.back()); - continue; - } - // light object - if (TokenMatch(filePtr,"LIGHTOBJECT",11)) - - { - m_vLights.push_back(Light()); - ParseLV1ObjectBlock(m_vLights.back()); - continue; - } - // camera object - if (TokenMatch(filePtr,"CAMERAOBJECT",12)) - { - m_vCameras.push_back(Camera()); - ParseLV1ObjectBlock(m_vCameras.back()); - continue; - } - // comment - print it on the console - if (TokenMatch(filePtr,"COMMENT",7)) - { - std::string out = ""; - ParseString(out,"*COMMENT"); - LogInfo(("Comment: " + out).c_str()); - continue; - } - // ASC bone weights - if (AI_ASE_IS_OLD_FILE_FORMAT() && TokenMatch(filePtr,"MESH_SOFTSKINVERTS",18)) - { - ParseLV1SoftSkinBlock(); - } - } - AI_ASE_HANDLE_TOP_LEVEL_SECTION(); - } - return; -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV1SoftSkinBlock() -{ - // TODO: fix line counting here - - // ************************************************************** - // The soft skin block is formatted differently. There are no - // nested sections supported and the single elements aren't - // marked by keywords starting with an asterisk. - - /** - FORMAT BEGIN - - *MESH_SOFTSKINVERTS { - - - - [for times:] - [for times:] - } - - FORMAT END - */ - // ************************************************************** - while (true) - { - if (*filePtr == '}' ) {++filePtr;return;} - else if (*filePtr == '\0') return; - else if (*filePtr == '{' ) ++filePtr; - - else // if (!IsSpace(*filePtr) && !IsLineEnd(*filePtr)) - { - ASE::Mesh* curMesh = NULL; - unsigned int numVerts = 0; - - const char* sz = filePtr; - while (!IsSpaceOrNewLine(*filePtr))++filePtr; - - const unsigned int diff = (unsigned int)(filePtr-sz); - if (diff) - { - std::string name = std::string(sz,diff); - for (std::vector::iterator it = m_vMeshes.begin(); - it != m_vMeshes.end(); ++it) - { - if ((*it).mName == name) - { - curMesh = & (*it); - break; - } - } - if (!curMesh) - { - LogWarning("Encountered unknown mesh in *MESH_SOFTSKINVERTS section"); - - // Skip the mesh data - until we find a new mesh - // or the end of the *MESH_SOFTSKINVERTS section - while (true) - { - SkipSpacesAndLineEnd(&filePtr); - if (*filePtr == '}') - {++filePtr;return;} - else if (!IsNumeric(*filePtr)) - break; - - SkipLine(&filePtr); - } - } - else - { - SkipSpacesAndLineEnd(&filePtr); - ParseLV4MeshLong(numVerts); - - // Reserve enough storage - curMesh->mBoneVertices.reserve(numVerts); - - for (unsigned int i = 0; i < numVerts;++i) - { - SkipSpacesAndLineEnd(&filePtr); - unsigned int numWeights; - ParseLV4MeshLong(numWeights); - - curMesh->mBoneVertices.push_back(ASE::BoneVertex()); - ASE::BoneVertex& vert = curMesh->mBoneVertices.back(); - - // Reserve enough storage - vert.mBoneWeights.reserve(numWeights); - - for (unsigned int w = 0; w < numWeights;++w) - { - std::string bone; - ParseString(bone,"*MESH_SOFTSKINVERTS.Bone"); - - // Find the bone in the mesh's list - std::pair me; - me.first = -1; - - for (unsigned int n = 0; n < curMesh->mBones.size();++n) - { - if (curMesh->mBones[n].mName == bone) - { - me.first = n; - break; - } - } - if (-1 == me.first) - { - // We don't have this bone yet, so add it to the list - me.first = (int)curMesh->mBones.size(); - curMesh->mBones.push_back(ASE::Bone(bone)); - } - ParseLV4MeshFloat( me.second ); - - // Add the new bone weight to list - vert.mBoneWeights.push_back(me); - } - } - } - } - } - ++filePtr; - SkipSpacesAndLineEnd(&filePtr); - } -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV1SceneBlock() -{ - AI_ASE_PARSER_INIT(); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - if (TokenMatch(filePtr,"SCENE_BACKGROUND_STATIC",23)) - - { - // parse a color triple and assume it is really the bg color - ParseLV4MeshFloatTriple( &m_clrBackground.r ); - continue; - } - if (TokenMatch(filePtr,"SCENE_AMBIENT_STATIC",20)) - - { - // parse a color triple and assume it is really the bg color - ParseLV4MeshFloatTriple( &m_clrAmbient.r ); - continue; - } - if (TokenMatch(filePtr,"SCENE_FIRSTFRAME",16)) - { - ParseLV4MeshLong(iFirstFrame); - continue; - } - if (TokenMatch(filePtr,"SCENE_LASTFRAME",15)) - { - ParseLV4MeshLong(iLastFrame); - continue; - } - if (TokenMatch(filePtr,"SCENE_FRAMESPEED",16)) - { - ParseLV4MeshLong(iFrameSpeed); - continue; - } - if (TokenMatch(filePtr,"SCENE_TICKSPERFRAME",19)) - { - ParseLV4MeshLong(iTicksPerFrame); - continue; - } - } - AI_ASE_HANDLE_TOP_LEVEL_SECTION(); - } -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV1MaterialListBlock() -{ - AI_ASE_PARSER_INIT(); - - unsigned int iMaterialCount = 0; - unsigned int iOldMaterialCount = (unsigned int)m_vMaterials.size(); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - if (TokenMatch(filePtr,"MATERIAL_COUNT",14)) - { - ParseLV4MeshLong(iMaterialCount); - - // now allocate enough storage to hold all materials - m_vMaterials.resize(iOldMaterialCount+iMaterialCount); - continue; - } - if (TokenMatch(filePtr,"MATERIAL",8)) - { - unsigned int iIndex = 0; - ParseLV4MeshLong(iIndex); - - if (iIndex >= iMaterialCount) - { - LogWarning("Out of range: material index is too large"); - iIndex = iMaterialCount-1; - } - - // get a reference to the material - Material& sMat = m_vMaterials[iIndex+iOldMaterialCount]; - // parse the material block - ParseLV2MaterialBlock(sMat); - continue; - } - } - AI_ASE_HANDLE_TOP_LEVEL_SECTION(); - } -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV2MaterialBlock(ASE::Material& mat) -{ - AI_ASE_PARSER_INIT(); - - unsigned int iNumSubMaterials = 0; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - if (TokenMatch(filePtr,"MATERIAL_NAME",13)) - { - if (!ParseString(mat.mName,"*MATERIAL_NAME")) - SkipToNextToken(); - continue; - } - // ambient material color - if (TokenMatch(filePtr,"MATERIAL_AMBIENT",16)) - { - ParseLV4MeshFloatTriple(&mat.mAmbient.r); - continue; - } - // diffuse material color - if (TokenMatch(filePtr,"MATERIAL_DIFFUSE",16) ) - { - ParseLV4MeshFloatTriple(&mat.mDiffuse.r); - continue; - } - // specular material color - if (TokenMatch(filePtr,"MATERIAL_SPECULAR",17)) - { - ParseLV4MeshFloatTriple(&mat.mSpecular.r); - continue; - } - // material shading type - if (TokenMatch(filePtr,"MATERIAL_SHADING",16)) - { - if (TokenMatch(filePtr,"Blinn",5)) - { - mat.mShading = Discreet3DS::Blinn; - } - else if (TokenMatch(filePtr,"Phong",5)) - { - mat.mShading = Discreet3DS::Phong; - } - else if (TokenMatch(filePtr,"Flat",4)) - { - mat.mShading = Discreet3DS::Flat; - } - else if (TokenMatch(filePtr,"Wire",4)) - { - mat.mShading = Discreet3DS::Wire; - } - else - { - // assume gouraud shading - mat.mShading = Discreet3DS::Gouraud; - SkipToNextToken(); - } - continue; - } - // material transparency - if (TokenMatch(filePtr,"MATERIAL_TRANSPARENCY",21)) - { - ParseLV4MeshFloat(mat.mTransparency); - mat.mTransparency = ai_real( 1.0 ) - mat.mTransparency; - continue; - } - // material self illumination - if (TokenMatch(filePtr,"MATERIAL_SELFILLUM",18)) - { - ai_real f = 0.0; - ParseLV4MeshFloat(f); - - mat.mEmissive.r = f; - mat.mEmissive.g = f; - mat.mEmissive.b = f; - continue; - } - // material shininess - if (TokenMatch(filePtr,"MATERIAL_SHINE",14) ) - { - ParseLV4MeshFloat(mat.mSpecularExponent); - mat.mSpecularExponent *= 15; - continue; - } - // two-sided material - if (TokenMatch(filePtr,"MATERIAL_TWOSIDED",17) ) - { - mat.mTwoSided = true; - continue; - } - // material shininess strength - if (TokenMatch(filePtr,"MATERIAL_SHINESTRENGTH",22)) - { - ParseLV4MeshFloat(mat.mShininessStrength); - continue; - } - // diffuse color map - if (TokenMatch(filePtr,"MAP_DIFFUSE",11)) - { - // parse the texture block - ParseLV3MapBlock(mat.sTexDiffuse); - continue; - } - // ambient color map - if (TokenMatch(filePtr,"MAP_AMBIENT",11)) - { - // parse the texture block - ParseLV3MapBlock(mat.sTexAmbient); - continue; - } - // specular color map - if (TokenMatch(filePtr,"MAP_SPECULAR",12)) - { - // parse the texture block - ParseLV3MapBlock(mat.sTexSpecular); - continue; - } - // opacity map - if (TokenMatch(filePtr,"MAP_OPACITY",11)) - { - // parse the texture block - ParseLV3MapBlock(mat.sTexOpacity); - continue; - } - // emissive map - if (TokenMatch(filePtr,"MAP_SELFILLUM",13)) - { - // parse the texture block - ParseLV3MapBlock(mat.sTexEmissive); - continue; - } - // bump map - if (TokenMatch(filePtr,"MAP_BUMP",8)) - { - // parse the texture block - ParseLV3MapBlock(mat.sTexBump); - } - // specular/shininess map - if (TokenMatch(filePtr,"MAP_SHINESTRENGTH",17)) - { - // parse the texture block - ParseLV3MapBlock(mat.sTexShininess); - continue; - } - // number of submaterials - if (TokenMatch(filePtr,"NUMSUBMTLS",10)) - { - ParseLV4MeshLong(iNumSubMaterials); - - // allocate enough storage - mat.avSubMaterials.resize(iNumSubMaterials); - } - // submaterial chunks - if (TokenMatch(filePtr,"SUBMATERIAL",11)) - { - - unsigned int iIndex = 0; - ParseLV4MeshLong(iIndex); - - if (iIndex >= iNumSubMaterials) - { - LogWarning("Out of range: submaterial index is too large"); - iIndex = iNumSubMaterials-1; - } - - // get a reference to the material - Material& sMat = mat.avSubMaterials[iIndex]; - - // parse the material block - ParseLV2MaterialBlock(sMat); - continue; - } - } - AI_ASE_HANDLE_SECTION("2","*MATERIAL"); - } -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MapBlock(Texture& map) -{ - AI_ASE_PARSER_INIT(); - - // *********************************************************** - // *BITMAP should not be there if *MAP_CLASS is not BITMAP, - // but we need to expect that case ... if the path is - // empty the texture won't be used later. - // *********************************************************** - bool parsePath = true; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - // type of map - if (TokenMatch(filePtr,"MAP_CLASS" ,9)) - { - std::string temp; - if(!ParseString(temp,"*MAP_CLASS")) - SkipToNextToken(); - if (temp != "Bitmap" && temp != "Normal Bump") - { - DefaultLogger::get()->warn("ASE: Skipping unknown map type: " + temp); - parsePath = false; - } - continue; - } - // path to the texture - if (parsePath && TokenMatch(filePtr,"BITMAP" ,6)) - { - if(!ParseString(map.mMapName,"*BITMAP")) - SkipToNextToken(); - - if (map.mMapName == "None") - { - // Files with 'None' as map name are produced by - // an Maja to ASE exporter which name I forgot .. - DefaultLogger::get()->warn("ASE: Skipping invalid map entry"); - map.mMapName = ""; - } - - continue; - } - // offset on the u axis - if (TokenMatch(filePtr,"UVW_U_OFFSET" ,12)) - { - ParseLV4MeshFloat(map.mOffsetU); - continue; - } - // offset on the v axis - if (TokenMatch(filePtr,"UVW_V_OFFSET" ,12)) - { - ParseLV4MeshFloat(map.mOffsetV); - continue; - } - // tiling on the u axis - if (TokenMatch(filePtr,"UVW_U_TILING" ,12)) - { - ParseLV4MeshFloat(map.mScaleU); - continue; - } - // tiling on the v axis - if (TokenMatch(filePtr,"UVW_V_TILING" ,12)) - { - ParseLV4MeshFloat(map.mScaleV); - continue; - } - // rotation around the z-axis - if (TokenMatch(filePtr,"UVW_ANGLE" ,9)) - { - ParseLV4MeshFloat(map.mRotation); - continue; - } - // map blending factor - if (TokenMatch(filePtr,"MAP_AMOUNT" ,10)) - { - ParseLV4MeshFloat(map.mTextureBlend); - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MAP_XXXXXX"); - } - return; -} - -// ------------------------------------------------------------------------------------------------ -bool Parser::ParseString(std::string& out,const char* szName) -{ - char szBuffer[1024]; - if (!SkipSpaces(&filePtr)) - { - - ai_snprintf(szBuffer, 1024, "Unable to parse %s block: Unexpected EOL",szName); - LogWarning(szBuffer); - return false; - } - // there must be '"' - if ('\"' != *filePtr) - { - - ai_snprintf(szBuffer, 1024, "Unable to parse %s block: Strings are expected " - "to be enclosed in double quotation marks",szName); - LogWarning(szBuffer); - return false; - } - ++filePtr; - const char* sz = filePtr; - while (true) - { - if ('\"' == *sz)break; - else if ('\0' == *sz) - { - ai_snprintf(szBuffer, 1024, "Unable to parse %s block: Strings are expected to " - "be enclosed in double quotation marks but EOF was reached before " - "a closing quotation mark was encountered",szName); - LogWarning(szBuffer); - return false; - } - sz++; - } - out = std::string(filePtr,(uintptr_t)sz-(uintptr_t)filePtr); - filePtr = sz+1; - return true; -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV1ObjectBlock(ASE::BaseNode& node) -{ - AI_ASE_PARSER_INIT(); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // first process common tokens such as node name and transform - // name of the mesh/node - if (TokenMatch(filePtr,"NODE_NAME" ,9)) - { - if(!ParseString(node.mName,"*NODE_NAME")) - SkipToNextToken(); - continue; - } - // name of the parent of the node - if (TokenMatch(filePtr,"NODE_PARENT" ,11) ) - { - if(!ParseString(node.mParent,"*NODE_PARENT")) - SkipToNextToken(); - continue; - } - // transformation matrix of the node - if (TokenMatch(filePtr,"NODE_TM" ,7)) - { - ParseLV2NodeTransformBlock(node); - continue; - } - // animation data of the node - if (TokenMatch(filePtr,"TM_ANIMATION" ,12)) - { - ParseLV2AnimationBlock(node); - continue; - } - - if (node.mType == BaseNode::Light) - { - // light settings - if (TokenMatch(filePtr,"LIGHT_SETTINGS" ,14)) - { - ParseLV2LightSettingsBlock((ASE::Light&)node); - continue; - } - // type of the light source - if (TokenMatch(filePtr,"LIGHT_TYPE" ,10)) - { - if (!ASSIMP_strincmp("omni",filePtr,4)) - { - ((ASE::Light&)node).mLightType = ASE::Light::OMNI; - } - else if (!ASSIMP_strincmp("target",filePtr,6)) - { - ((ASE::Light&)node).mLightType = ASE::Light::TARGET; - } - else if (!ASSIMP_strincmp("free",filePtr,4)) - { - ((ASE::Light&)node).mLightType = ASE::Light::FREE; - } - else if (!ASSIMP_strincmp("directional",filePtr,11)) - { - ((ASE::Light&)node).mLightType = ASE::Light::DIRECTIONAL; - } - else - { - LogWarning("Unknown kind of light source"); - } - continue; - } - } - else if (node.mType == BaseNode::Camera) - { - // Camera settings - if (TokenMatch(filePtr,"CAMERA_SETTINGS" ,15)) - { - ParseLV2CameraSettingsBlock((ASE::Camera&)node); - continue; - } - else if (TokenMatch(filePtr,"CAMERA_TYPE" ,11)) - { - if (!ASSIMP_strincmp("target",filePtr,6)) - { - ((ASE::Camera&)node).mCameraType = ASE::Camera::TARGET; - } - else if (!ASSIMP_strincmp("free",filePtr,4)) - { - ((ASE::Camera&)node).mCameraType = ASE::Camera::FREE; - } - else - { - LogWarning("Unknown kind of camera"); - } - continue; - } - } - else if (node.mType == BaseNode::Mesh) - { - // mesh data - // FIX: Older files use MESH_SOFTSKIN - if (TokenMatch(filePtr,"MESH" ,4) || - TokenMatch(filePtr,"MESH_SOFTSKIN",13)) - { - ParseLV2MeshBlock((ASE::Mesh&)node); - continue; - } - // mesh material index - if (TokenMatch(filePtr,"MATERIAL_REF" ,12)) - { - ParseLV4MeshLong(((ASE::Mesh&)node).iMaterialIndex); - continue; - } - } - } - AI_ASE_HANDLE_TOP_LEVEL_SECTION(); - } - return; -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV2CameraSettingsBlock(ASE::Camera& camera) -{ - AI_ASE_PARSER_INIT(); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - if (TokenMatch(filePtr,"CAMERA_NEAR" ,11)) - { - ParseLV4MeshFloat(camera.mNear); - continue; - } - if (TokenMatch(filePtr,"CAMERA_FAR" ,10)) - { - ParseLV4MeshFloat(camera.mFar); - continue; - } - if (TokenMatch(filePtr,"CAMERA_FOV" ,10)) - { - ParseLV4MeshFloat(camera.mFOV); - continue; - } - } - AI_ASE_HANDLE_SECTION("2","CAMERA_SETTINGS"); - } - return; -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV2LightSettingsBlock(ASE::Light& light) -{ - AI_ASE_PARSER_INIT(); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - if (TokenMatch(filePtr,"LIGHT_COLOR" ,11)) - { - ParseLV4MeshFloatTriple(&light.mColor.r); - continue; - } - if (TokenMatch(filePtr,"LIGHT_INTENS" ,12)) - { - ParseLV4MeshFloat(light.mIntensity); - continue; - } - if (TokenMatch(filePtr,"LIGHT_HOTSPOT" ,13)) - { - ParseLV4MeshFloat(light.mAngle); - continue; - } - if (TokenMatch(filePtr,"LIGHT_FALLOFF" ,13)) - { - ParseLV4MeshFloat(light.mFalloff); - continue; - } - } - AI_ASE_HANDLE_SECTION("2","LIGHT_SETTINGS"); - } - return; -} - -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV2AnimationBlock(ASE::BaseNode& mesh) -{ - AI_ASE_PARSER_INIT(); - - ASE::Animation* anim = &mesh.mAnim; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - if (TokenMatch(filePtr,"NODE_NAME" ,9)) - { - std::string temp; - if(!ParseString(temp,"*NODE_NAME")) - SkipToNextToken(); - - // If the name of the node contains .target it - // represents an animated camera or spot light - // target. - if (std::string::npos != temp.find(".Target")) - { - if ((mesh.mType != BaseNode::Camera || ((ASE::Camera&)mesh).mCameraType != ASE::Camera::TARGET) && - ( mesh.mType != BaseNode::Light || ((ASE::Light&)mesh).mLightType != ASE::Light::TARGET)) - { - - DefaultLogger::get()->error("ASE: Found target animation channel " - "but the node is neither a camera nor a spot light"); - anim = NULL; - } - else anim = &mesh.mTargetAnim; - } - continue; - } - - // position keyframes - if (TokenMatch(filePtr,"CONTROL_POS_TRACK" ,17) || - TokenMatch(filePtr,"CONTROL_POS_BEZIER" ,18) || - TokenMatch(filePtr,"CONTROL_POS_TCB" ,15)) - { - if (!anim)SkipSection(); - else ParseLV3PosAnimationBlock(*anim); - continue; - } - // scaling keyframes - if (TokenMatch(filePtr,"CONTROL_SCALE_TRACK" ,19) || - TokenMatch(filePtr,"CONTROL_SCALE_BEZIER" ,20) || - TokenMatch(filePtr,"CONTROL_SCALE_TCB" ,17)) - { - if (!anim || anim == &mesh.mTargetAnim) - { - // Target animation channels may have no rotation channels - DefaultLogger::get()->error("ASE: Ignoring scaling channel in target animation"); - SkipSection(); - } - else ParseLV3ScaleAnimationBlock(*anim); - continue; - } - // rotation keyframes - if (TokenMatch(filePtr,"CONTROL_ROT_TRACK" ,17) || - TokenMatch(filePtr,"CONTROL_ROT_BEZIER" ,18) || - TokenMatch(filePtr,"CONTROL_ROT_TCB" ,15)) - { - if (!anim || anim == &mesh.mTargetAnim) - { - // Target animation channels may have no rotation channels - DefaultLogger::get()->error("ASE: Ignoring rotation channel in target animation"); - SkipSection(); - } - else ParseLV3RotAnimationBlock(*anim); - continue; - } - } - AI_ASE_HANDLE_SECTION("2","TM_ANIMATION"); - } -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3ScaleAnimationBlock(ASE::Animation& anim) -{ - AI_ASE_PARSER_INIT(); - unsigned int iIndex; - - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - bool b = false; - - // For the moment we're just reading the three floats - - // we ignore the additional information for bezier's and TCBs - - // simple scaling keyframe - if (TokenMatch(filePtr,"CONTROL_SCALE_SAMPLE" ,20)) - { - b = true; - anim.mScalingType = ASE::Animation::TRACK; - } - - // Bezier scaling keyframe - if (TokenMatch(filePtr,"CONTROL_BEZIER_SCALE_KEY" ,24)) - { - b = true; - anim.mScalingType = ASE::Animation::BEZIER; - } - // TCB scaling keyframe - if (TokenMatch(filePtr,"CONTROL_TCB_SCALE_KEY" ,21)) - { - b = true; - anim.mScalingType = ASE::Animation::TCB; - } - if (b) - { - anim.akeyScaling.push_back(aiVectorKey()); - aiVectorKey& key = anim.akeyScaling.back(); - ParseLV4MeshFloatTriple(&key.mValue.x,iIndex); - key.mTime = (double)iIndex; - } - } - AI_ASE_HANDLE_SECTION("3","*CONTROL_POS_TRACK"); - } -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3PosAnimationBlock(ASE::Animation& anim) -{ - AI_ASE_PARSER_INIT(); - unsigned int iIndex; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - bool b = false; - - // For the moment we're just reading the three floats - - // we ignore the additional information for bezier's and TCBs - - // simple scaling keyframe - if (TokenMatch(filePtr,"CONTROL_POS_SAMPLE" ,18)) - { - b = true; - anim.mPositionType = ASE::Animation::TRACK; - } - - // Bezier scaling keyframe - if (TokenMatch(filePtr,"CONTROL_BEZIER_POS_KEY" ,22)) - { - b = true; - anim.mPositionType = ASE::Animation::BEZIER; - } - // TCB scaling keyframe - if (TokenMatch(filePtr,"CONTROL_TCB_POS_KEY" ,19)) - { - b = true; - anim.mPositionType = ASE::Animation::TCB; - } - if (b) - { - anim.akeyPositions.push_back(aiVectorKey()); - aiVectorKey& key = anim.akeyPositions.back(); - ParseLV4MeshFloatTriple(&key.mValue.x,iIndex); - key.mTime = (double)iIndex; - } - } - AI_ASE_HANDLE_SECTION("3","*CONTROL_POS_TRACK"); - } -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3RotAnimationBlock(ASE::Animation& anim) -{ - AI_ASE_PARSER_INIT(); - unsigned int iIndex; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - bool b = false; - - // For the moment we're just reading the floats - - // we ignore the additional information for bezier's and TCBs - - // simple scaling keyframe - if (TokenMatch(filePtr,"CONTROL_ROT_SAMPLE" ,18)) - { - b = true; - anim.mRotationType = ASE::Animation::TRACK; - } - - // Bezier scaling keyframe - if (TokenMatch(filePtr,"CONTROL_BEZIER_ROT_KEY" ,22)) - { - b = true; - anim.mRotationType = ASE::Animation::BEZIER; - } - // TCB scaling keyframe - if (TokenMatch(filePtr,"CONTROL_TCB_ROT_KEY" ,19)) - { - b = true; - anim.mRotationType = ASE::Animation::TCB; - } - if (b) - { - anim.akeyRotations.push_back(aiQuatKey()); - aiQuatKey& key = anim.akeyRotations.back(); - aiVector3D v;ai_real f; - ParseLV4MeshFloatTriple(&v.x,iIndex); - ParseLV4MeshFloat(f); - key.mTime = (double)iIndex; - key.mValue = aiQuaternion(v,f); - } - } - AI_ASE_HANDLE_SECTION("3","*CONTROL_ROT_TRACK"); - } -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV2NodeTransformBlock(ASE::BaseNode& mesh) -{ - AI_ASE_PARSER_INIT(); - int mode = 0; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - // name of the node - if (TokenMatch(filePtr,"NODE_NAME" ,9)) - { - std::string temp; - if(!ParseString(temp,"*NODE_NAME")) - SkipToNextToken(); - - std::string::size_type s; - if (temp == mesh.mName) - { - mode = 1; - } - else if (std::string::npos != (s = temp.find(".Target")) && - mesh.mName == temp.substr(0,s)) - { - // This should be either a target light or a target camera - if ( (mesh.mType == BaseNode::Light && ((ASE::Light&)mesh) .mLightType == ASE::Light::TARGET) || - (mesh.mType == BaseNode::Camera && ((ASE::Camera&)mesh).mCameraType == ASE::Camera::TARGET)) - { - mode = 2; - } - else DefaultLogger::get()->error("ASE: Ignoring target transform, " - "this is no spot light or target camera"); - } - else - { - DefaultLogger::get()->error("ASE: Unknown node transformation: " + temp); - // mode = 0 - } - continue; - } - if (mode) - { - // fourth row of the transformation matrix - and also the - // only information here that is interesting for targets - if (TokenMatch(filePtr,"TM_ROW3" ,7)) - { - ParseLV4MeshFloatTriple((mode == 1 ? mesh.mTransform[3] : &mesh.mTargetPosition.x)); - continue; - } - if (mode == 1) - { - // first row of the transformation matrix - if (TokenMatch(filePtr,"TM_ROW0" ,7)) - { - ParseLV4MeshFloatTriple(mesh.mTransform[0]); - continue; - } - // second row of the transformation matrix - if (TokenMatch(filePtr,"TM_ROW1" ,7)) - { - ParseLV4MeshFloatTriple(mesh.mTransform[1]); - continue; - } - // third row of the transformation matrix - if (TokenMatch(filePtr,"TM_ROW2" ,7)) - { - ParseLV4MeshFloatTriple(mesh.mTransform[2]); - continue; - } - // inherited position axes - if (TokenMatch(filePtr,"INHERIT_POS" ,11)) - { - unsigned int aiVal[3]; - ParseLV4MeshLongTriple(aiVal); - - for (unsigned int i = 0; i < 3;++i) - mesh.inherit.abInheritPosition[i] = aiVal[i] != 0; - continue; - } - // inherited rotation axes - if (TokenMatch(filePtr,"INHERIT_ROT" ,11)) - { - unsigned int aiVal[3]; - ParseLV4MeshLongTriple(aiVal); - - for (unsigned int i = 0; i < 3;++i) - mesh.inherit.abInheritRotation[i] = aiVal[i] != 0; - continue; - } - // inherited scaling axes - if (TokenMatch(filePtr,"INHERIT_SCL" ,11)) - { - unsigned int aiVal[3]; - ParseLV4MeshLongTriple(aiVal); - - for (unsigned int i = 0; i < 3;++i) - mesh.inherit.abInheritScaling[i] = aiVal[i] != 0; - continue; - } - } - } - } - AI_ASE_HANDLE_SECTION("2","*NODE_TM"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - - unsigned int iNumVertices = 0; - unsigned int iNumFaces = 0; - unsigned int iNumTVertices = 0; - unsigned int iNumTFaces = 0; - unsigned int iNumCVertices = 0; - unsigned int iNumCFaces = 0; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - // Number of vertices in the mesh - if (TokenMatch(filePtr,"MESH_NUMVERTEX" ,14)) - { - ParseLV4MeshLong(iNumVertices); - continue; - } - // Number of texture coordinates in the mesh - if (TokenMatch(filePtr,"MESH_NUMTVERTEX" ,15)) - { - ParseLV4MeshLong(iNumTVertices); - continue; - } - // Number of vertex colors in the mesh - if (TokenMatch(filePtr,"MESH_NUMCVERTEX" ,15)) - { - ParseLV4MeshLong(iNumCVertices); - continue; - } - // Number of regular faces in the mesh - if (TokenMatch(filePtr,"MESH_NUMFACES" ,13)) - { - ParseLV4MeshLong(iNumFaces); - continue; - } - // Number of UVWed faces in the mesh - if (TokenMatch(filePtr,"MESH_NUMTVFACES" ,15)) - { - ParseLV4MeshLong(iNumTFaces); - continue; - } - // Number of colored faces in the mesh - if (TokenMatch(filePtr,"MESH_NUMCVFACES" ,15)) - { - ParseLV4MeshLong(iNumCFaces); - continue; - } - // mesh vertex list block - if (TokenMatch(filePtr,"MESH_VERTEX_LIST" ,16)) - { - ParseLV3MeshVertexListBlock(iNumVertices,mesh); - continue; - } - // mesh face list block - if (TokenMatch(filePtr,"MESH_FACE_LIST" ,14)) - { - ParseLV3MeshFaceListBlock(iNumFaces,mesh); - continue; - } - // mesh texture vertex list block - if (TokenMatch(filePtr,"MESH_TVERTLIST" ,14)) - { - ParseLV3MeshTListBlock(iNumTVertices,mesh); - continue; - } - // mesh texture face block - if (TokenMatch(filePtr,"MESH_TFACELIST" ,14)) - { - ParseLV3MeshTFaceListBlock(iNumTFaces,mesh); - continue; - } - // mesh color vertex list block - if (TokenMatch(filePtr,"MESH_CVERTLIST" ,14)) - { - ParseLV3MeshCListBlock(iNumCVertices,mesh); - continue; - } - // mesh color face block - if (TokenMatch(filePtr,"MESH_CFACELIST" ,14)) - { - ParseLV3MeshCFaceListBlock(iNumCFaces,mesh); - continue; - } - // mesh normals - if (TokenMatch(filePtr,"MESH_NORMALS" ,12)) - { - ParseLV3MeshNormalListBlock(mesh); - continue; - } - // another mesh UV channel ... - if (TokenMatch(filePtr,"MESH_MAPPINGCHANNEL" ,19)) { - unsigned int iIndex( 0 ); - ParseLV4MeshLong(iIndex); - if ( 0 == iIndex ) { - LogWarning( "Mapping channel has an invalid index. Skipping UV channel" ); - // skip it ... - SkipSection(); - } else { - if ( iIndex < 2 ) { - LogWarning( "Mapping channel has an invalid index. Skipping UV channel" ); - // skip it ... - SkipSection(); - } - if ( iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS ) { - LogWarning( "Too many UV channels specified. Skipping channel .." ); - // skip it ... - SkipSection(); - } else { - // parse the mapping channel - ParseLV3MappingChannel( iIndex - 1, mesh ); - } - continue; - } - } - // mesh animation keyframe. Not supported - if (TokenMatch(filePtr,"MESH_ANIMATION" ,14)) - { - - LogWarning("Found *MESH_ANIMATION element in ASE/ASK file. " - "Keyframe animation is not supported by Assimp, this element " - "will be ignored"); - //SkipSection(); - continue; - } - if (TokenMatch(filePtr,"MESH_WEIGHTS" ,12)) - { - ParseLV3MeshWeightsBlock(mesh);continue; - } - } - AI_ASE_HANDLE_SECTION("2","*MESH"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MeshWeightsBlock(ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - - unsigned int iNumVertices = 0, iNumBones = 0; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Number of bone vertices ... - if (TokenMatch(filePtr,"MESH_NUMVERTEX" ,14)) - { - ParseLV4MeshLong(iNumVertices); - continue; - } - // Number of bones - if (TokenMatch(filePtr,"MESH_NUMBONE" ,12)) - { - ParseLV4MeshLong(iNumBones); - continue; - } - // parse the list of bones - if (TokenMatch(filePtr,"MESH_BONE_LIST" ,14)) - { - ParseLV4MeshBones(iNumBones,mesh); - continue; - } - // parse the list of bones vertices - if (TokenMatch(filePtr,"MESH_BONE_VERTEX_LIST" ,21) ) - { - ParseLV4MeshBonesVertices(iNumVertices,mesh); - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_WEIGHTS"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshBones(unsigned int iNumBones,ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - mesh.mBones.resize(iNumBones); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Mesh bone with name ... - if (TokenMatch(filePtr,"MESH_BONE_NAME" ,14)) - { - // parse an index ... - if(SkipSpaces(&filePtr)) - { - unsigned int iIndex = strtoul10(filePtr,&filePtr); - if (iIndex >= iNumBones) - { - LogWarning("Bone index is out of bounds"); - continue; - } - if (!ParseString(mesh.mBones[iIndex].mName,"*MESH_BONE_NAME")) - SkipToNextToken(); - continue; - } - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_BONE_LIST"); - } -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshBonesVertices(unsigned int iNumVertices,ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - mesh.mBoneVertices.resize(iNumVertices); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Mesh bone vertex - if (TokenMatch(filePtr,"MESH_BONE_VERTEX" ,16)) - { - // read the vertex index - unsigned int iIndex = strtoul10(filePtr,&filePtr); - if (iIndex >= mesh.mPositions.size()) - { - iIndex = (unsigned int)mesh.mPositions.size()-1; - LogWarning("Bone vertex index is out of bounds. Using the largest valid " - "bone vertex index instead"); - } - - // --- ignored - ai_real afVert[3]; - ParseLV4MeshFloatTriple(afVert); - - std::pair pairOut; - while (true) - { - // first parse the bone index ... - if (!SkipSpaces(&filePtr))break; - pairOut.first = strtoul10(filePtr,&filePtr); - - // then parse the vertex weight - if (!SkipSpaces(&filePtr))break; - filePtr = fast_atoreal_move(filePtr,pairOut.second); - - // -1 marks unused entries - if (-1 != pairOut.first) - { - mesh.mBoneVertices[iIndex].mBoneWeights.push_back(pairOut); - } - } - continue; - } - } - AI_ASE_HANDLE_SECTION("4","*MESH_BONE_VERTEX"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MeshVertexListBlock( - unsigned int iNumVertices, ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - - // allocate enough storage in the array - mesh.mPositions.resize(iNumVertices); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Vertex entry - if (TokenMatch(filePtr,"MESH_VERTEX" ,11)) - { - - aiVector3D vTemp; - unsigned int iIndex; - ParseLV4MeshFloatTriple(&vTemp.x,iIndex); - - if (iIndex >= iNumVertices) - { - LogWarning("Invalid vertex index. It will be ignored"); - } - else mesh.mPositions[iIndex] = vTemp; - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_VERTEX_LIST"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MeshFaceListBlock(unsigned int iNumFaces, ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - - // allocate enough storage in the face array - mesh.mFaces.resize(iNumFaces); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Face entry - if (TokenMatch(filePtr,"MESH_FACE" ,9)) - { - - ASE::Face mFace; - ParseLV4MeshFace(mFace); - - if (mFace.iFace >= iNumFaces) - { - LogWarning("Face has an invalid index. It will be ignored"); - } - else mesh.mFaces[mFace.iFace] = mFace; - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_FACE_LIST"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MeshTListBlock(unsigned int iNumVertices, - ASE::Mesh& mesh, unsigned int iChannel) -{ - AI_ASE_PARSER_INIT(); - - // allocate enough storage in the array - mesh.amTexCoords[iChannel].resize(iNumVertices); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Vertex entry - if (TokenMatch(filePtr,"MESH_TVERT" ,10)) - { - aiVector3D vTemp; - unsigned int iIndex; - ParseLV4MeshFloatTriple(&vTemp.x,iIndex); - - if (iIndex >= iNumVertices) - { - LogWarning("Tvertex has an invalid index. It will be ignored"); - } - else mesh.amTexCoords[iChannel][iIndex] = vTemp; - - if (0.0f != vTemp.z) - { - // we need 3 coordinate channels - mesh.mNumUVComponents[iChannel] = 3; - } - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_TVERT_LIST"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MeshTFaceListBlock(unsigned int iNumFaces, - ASE::Mesh& mesh, unsigned int iChannel) -{ - AI_ASE_PARSER_INIT(); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Face entry - if (TokenMatch(filePtr,"MESH_TFACE" ,10)) - { - unsigned int aiValues[3]; - unsigned int iIndex = 0; - - ParseLV4MeshLongTriple(aiValues,iIndex); - if (iIndex >= iNumFaces || iIndex >= mesh.mFaces.size()) - { - LogWarning("UV-Face has an invalid index. It will be ignored"); - } - else - { - // copy UV indices - mesh.mFaces[iIndex].amUVIndices[iChannel][0] = aiValues[0]; - mesh.mFaces[iIndex].amUVIndices[iChannel][1] = aiValues[1]; - mesh.mFaces[iIndex].amUVIndices[iChannel][2] = aiValues[2]; - } - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_TFACE_LIST"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MappingChannel(unsigned int iChannel, ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - - unsigned int iNumTVertices = 0; - unsigned int iNumTFaces = 0; - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Number of texture coordinates in the mesh - if (TokenMatch(filePtr,"MESH_NUMTVERTEX" ,15)) - { - ParseLV4MeshLong(iNumTVertices); - continue; - } - // Number of UVWed faces in the mesh - if (TokenMatch(filePtr,"MESH_NUMTVFACES" ,15)) - { - ParseLV4MeshLong(iNumTFaces); - continue; - } - // mesh texture vertex list block - if (TokenMatch(filePtr,"MESH_TVERTLIST" ,14)) - { - ParseLV3MeshTListBlock(iNumTVertices,mesh,iChannel); - continue; - } - // mesh texture face block - if (TokenMatch(filePtr,"MESH_TFACELIST" ,14)) - { - ParseLV3MeshTFaceListBlock(iNumTFaces,mesh, iChannel); - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_MAPPING_CHANNEL"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MeshCListBlock(unsigned int iNumVertices, ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - - // allocate enough storage in the array - mesh.mVertexColors.resize(iNumVertices); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Vertex entry - if (TokenMatch(filePtr,"MESH_VERTCOL" ,12)) - { - aiColor4D vTemp; - vTemp.a = 1.0f; - unsigned int iIndex; - ParseLV4MeshFloatTriple(&vTemp.r,iIndex); - - if (iIndex >= iNumVertices) - { - LogWarning("Vertex color has an invalid index. It will be ignored"); - } - else mesh.mVertexColors[iIndex] = vTemp; - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_CVERTEX_LIST"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MeshCFaceListBlock(unsigned int iNumFaces, ASE::Mesh& mesh) -{ - AI_ASE_PARSER_INIT(); - while (true) - { - if ('*' == *filePtr) - { - ++filePtr; - - // Face entry - if (TokenMatch(filePtr,"MESH_CFACE" ,10)) - { - unsigned int aiValues[3]; - unsigned int iIndex = 0; - - ParseLV4MeshLongTriple(aiValues,iIndex); - if (iIndex >= iNumFaces || iIndex >= mesh.mFaces.size()) - { - LogWarning("UV-Face has an invalid index. It will be ignored"); - } - else - { - // copy color indices - mesh.mFaces[iIndex].mColorIndices[0] = aiValues[0]; - mesh.mFaces[iIndex].mColorIndices[1] = aiValues[1]; - mesh.mFaces[iIndex].mColorIndices[2] = aiValues[2]; - } - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_CFACE_LIST"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh& sMesh) -{ - AI_ASE_PARSER_INIT(); - - // Allocate enough storage for the normals - sMesh.mNormals.resize(sMesh.mFaces.size()*3,aiVector3D( 0.f, 0.f, 0.f )); - unsigned int index, faceIdx = UINT_MAX; - - // FIXME: rewrite this and find out how to interpret the normals - // correctly. This is crap. - - // Smooth the vertex and face normals together. The result - // will be edgy then, but otherwise everything would be soft ... - while (true) { - if ('*' == *filePtr) { - ++filePtr; - if (faceIdx != UINT_MAX && TokenMatch(filePtr,"MESH_VERTEXNORMAL",17)) { - aiVector3D vNormal; - ParseLV4MeshFloatTriple(&vNormal.x,index); - if (faceIdx >= sMesh.mFaces.size()) - continue; - - // Make sure we assign it to the correct face - const ASE::Face& face = sMesh.mFaces[faceIdx]; - if (index == face.mIndices[0]) - index = 0; - else if (index == face.mIndices[1]) - index = 1; - else if (index == face.mIndices[2]) - index = 2; - else { - DefaultLogger::get()->error("ASE: Invalid vertex index in MESH_VERTEXNORMAL section"); - continue; - } - // We'll renormalize later - sMesh.mNormals[faceIdx*3+index] += vNormal; - continue; - } - if (TokenMatch(filePtr,"MESH_FACENORMAL",15)) { - aiVector3D vNormal; - ParseLV4MeshFloatTriple(&vNormal.x,faceIdx); - - if (faceIdx >= sMesh.mFaces.size()) { - DefaultLogger::get()->error("ASE: Invalid vertex index in MESH_FACENORMAL section"); - continue; - } - - // We'll renormalize later - sMesh.mNormals[faceIdx*3] += vNormal; - sMesh.mNormals[faceIdx*3+1] += vNormal; - sMesh.mNormals[faceIdx*3+2] += vNormal; - continue; - } - } - AI_ASE_HANDLE_SECTION("3","*MESH_NORMALS"); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshFace(ASE::Face& out) -{ - // skip spaces and tabs - if(!SkipSpaces(&filePtr)) - { - LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL [#1]"); - SkipToNextToken(); - return; - } - - // parse the face index - out.iFace = strtoul10(filePtr,&filePtr); - - // next character should be ':' - if(!SkipSpaces(&filePtr)) - { - // FIX: there are some ASE files which haven't got : here .... - LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL. \':\' expected [#2]"); - SkipToNextToken(); - return; - } - // FIX: There are some ASE files which haven't got ':' here - if(':' == *filePtr)++filePtr; - - // Parse all mesh indices - for (unsigned int i = 0; i < 3;++i) - { - unsigned int iIndex = 0; - if(!SkipSpaces(&filePtr)) - { - LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL"); - SkipToNextToken(); - return; - } - switch (*filePtr) - { - case 'A': - case 'a': - break; - case 'B': - case 'b': - iIndex = 1; - break; - case 'C': - case 'c': - iIndex = 2; - break; - default: - LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL. " - "A,B or C expected [#3]"); - SkipToNextToken(); - return; - }; - ++filePtr; - - // next character should be ':' - if(!SkipSpaces(&filePtr) || ':' != *filePtr) - { - LogWarning("Unable to parse *MESH_FACE Element: " - "Unexpected EOL. \':\' expected [#2]"); - SkipToNextToken(); - return; - } - - ++filePtr; - if(!SkipSpaces(&filePtr)) - { - LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL. " - "Vertex index ecpected [#4]"); - SkipToNextToken(); - return; - } - out.mIndices[iIndex] = strtoul10(filePtr,&filePtr); - } - - // now we need to skip the AB, BC, CA blocks. - while (true) - { - if ('*' == *filePtr)break; - if (IsLineEnd(*filePtr)) - { - //iLineNumber++; - return; - } - filePtr++; - } - - // parse the smoothing group of the face - if (TokenMatch(filePtr,"*MESH_SMOOTHING",15)) - { - if(!SkipSpaces(&filePtr)) - { - LogWarning("Unable to parse *MESH_SMOOTHING Element: " - "Unexpected EOL. Smoothing group(s) expected [#5]"); - SkipToNextToken(); - return; - } - - // Parse smoothing groups until we don't anymore see commas - // FIX: There needn't always be a value, sad but true - while (true) - { - if (*filePtr < '9' && *filePtr >= '0') - { - out.iSmoothGroup |= (1 << strtoul10(filePtr,&filePtr)); - } - SkipSpaces(&filePtr); - if (',' != *filePtr) - { - break; - } - ++filePtr; - SkipSpaces(&filePtr); - } - } - - // *MESH_MTLID is optional, too - while (true) - { - if ('*' == *filePtr)break; - if (IsLineEnd(*filePtr)) - { - return; - } - filePtr++; - } - - if (TokenMatch(filePtr,"*MESH_MTLID",11)) - { - if(!SkipSpaces(&filePtr)) - { - LogWarning("Unable to parse *MESH_MTLID Element: Unexpected EOL. " - "Material index expected [#6]"); - SkipToNextToken(); - return; - } - out.iMaterial = strtoul10(filePtr,&filePtr); - } - return; -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshLongTriple(unsigned int* apOut) -{ - ai_assert(NULL != apOut); - - for (unsigned int i = 0; i < 3;++i) - ParseLV4MeshLong(apOut[i]); -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshLongTriple(unsigned int* apOut, unsigned int& rIndexOut) -{ - ai_assert(NULL != apOut); - - // parse the index - ParseLV4MeshLong(rIndexOut); - - // parse the three others - ParseLV4MeshLongTriple(apOut); -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshFloatTriple(ai_real* apOut, unsigned int& rIndexOut) -{ - ai_assert(NULL != apOut); - - // parse the index - ParseLV4MeshLong(rIndexOut); - - // parse the three others - ParseLV4MeshFloatTriple(apOut); -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshFloatTriple(ai_real* apOut) -{ - ai_assert(NULL != apOut); - - for (unsigned int i = 0; i < 3;++i) - ParseLV4MeshFloat(apOut[i]); -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshFloat(ai_real& fOut) -{ - // skip spaces and tabs - if(!SkipSpaces(&filePtr)) - { - // LOG - LogWarning("Unable to parse float: unexpected EOL [#1]"); - fOut = 0.0; - ++iLineNumber; - return; - } - // parse the first float - filePtr = fast_atoreal_move(filePtr,fOut); -} -// ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshLong(unsigned int& iOut) -{ - // Skip spaces and tabs - if(!SkipSpaces(&filePtr)) - { - // LOG - LogWarning("Unable to parse long: unexpected EOL [#1]"); - iOut = 0; - ++iLineNumber; - return; - } - // parse the value - iOut = strtoul10(filePtr,&filePtr); -} - -#endif // ASSIMP_BUILD_NO_3DS_IMPORTER - -#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER diff --git a/src/3rdparty/assimp/code/ASEParser.h b/src/3rdparty/assimp/code/ASEParser.h deleted file mode 100644 index db64f2a16..000000000 --- a/src/3rdparty/assimp/code/ASEParser.h +++ /dev/null @@ -1,669 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - - -/** @file Defines the helper data structures for importing ASE files */ -#ifndef AI_ASEFILEHELPER_H_INC -#define AI_ASEFILEHELPER_H_INC - -// public ASSIMP headers -#include -#include -#include - -#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER - -// for some helper routines like IsSpace() -#include "ParsingUtils.h" -#include "qnan.h" - -// ASE is quite similar to 3ds. We can reuse some structures -#include "3DSLoader.h" - -namespace Assimp { -namespace ASE { - -using namespace D3DS; - -// --------------------------------------------------------------------------- -/** Helper structure representing an ASE material */ -struct Material : public D3DS::Material -{ - //! Default constructor - Material() : pcInstance(NULL), bNeed (false) - {} - - //! Contains all sub materials of this material - std::vector avSubMaterials; - - //! aiMaterial object - aiMaterial* pcInstance; - - //! Can we remove this material? - bool bNeed; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent an ASE file face */ -struct Face : public FaceWithSmoothingGroup -{ - //! Default constructor. Initializes everything with 0 - Face() - { - mColorIndices[0] = mColorIndices[1] = mColorIndices[2] = 0; - for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) - { - amUVIndices[i][0] = amUVIndices[i][1] = amUVIndices[i][2] = 0; - } - - iMaterial = DEFAULT_MATINDEX; - iFace = 0; - } - - //! special value to indicate that no material index has - //! been assigned to a face. The default material index - //! will replace this value later. - static const unsigned int DEFAULT_MATINDEX = 0xFFFFFFFF; - - - - //! Indices into each list of texture coordinates - unsigned int amUVIndices[AI_MAX_NUMBER_OF_TEXTURECOORDS][3]; - - //! Index into the list of vertex colors - unsigned int mColorIndices[3]; - - //! (Sub)Material index to be assigned to this face - unsigned int iMaterial; - - //! Index of the face. It is not specified whether it is - //! a requirement of the file format that all faces are - //! written in sequential order, so we have to expect this case - unsigned int iFace; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent an ASE file bone */ -struct Bone -{ - //! Constructor - Bone() - { - static int iCnt = 0; - - // Generate a default name for the bone - char szTemp[128]; - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - } - - //! Construction from an existing name - explicit Bone( const std::string& name) - : mName (name) - {} - - //! Name of the bone - std::string mName; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent an ASE file bone vertex */ -struct BoneVertex -{ - //! Bone and corresponding vertex weight. - //! -1 for unrequired bones .... - std::vector > mBoneWeights; - - //! Position of the bone vertex. - //! MUST be identical to the vertex position - //aiVector3D mPosition; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent an ASE file animation */ -struct Animation -{ - enum Type - { - TRACK = 0x0, - BEZIER = 0x1, - TCB = 0x2 - } mRotationType, mScalingType, mPositionType; - - Animation() - : mRotationType (TRACK) - , mScalingType (TRACK) - , mPositionType (TRACK) - {} - - //! List of track rotation keyframes - std::vector< aiQuatKey > akeyRotations; - - //! List of track position keyframes - std::vector< aiVectorKey > akeyPositions; - - //! List of track scaling keyframes - std::vector< aiVectorKey > akeyScaling; - -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent the inheritance information of an ASE node */ -struct InheritanceInfo -{ - //! Default constructor - InheritanceInfo() - { - // set the inheritance flag for all axes by default to true - for (unsigned int i = 0; i < 3;++i) - abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true; - } - - //! Inherit the parent's position?, axis order is x,y,z - bool abInheritPosition[3]; - - //! Inherit the parent's rotation?, axis order is x,y,z - bool abInheritRotation[3]; - - //! Inherit the parent's scaling?, axis order is x,y,z - bool abInheritScaling[3]; -}; - -// --------------------------------------------------------------------------- -/** Represents an ASE file node. Base class for mesh, light and cameras */ -struct BaseNode -{ - enum Type {Light, Camera, Mesh, Dummy} mType; - - //! Constructor. Creates a default name for the node - explicit BaseNode(Type _mType) - : mType (_mType) - , mProcessed (false) - { - // generate a default name for the node - static int iCnt = 0; - char szTemp[128]; // should be sufficiently large - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - - // Set mTargetPosition to qnan - const ai_real qnan = get_qnan(); - mTargetPosition.x = qnan; - } - - //! Name of the mesh - std::string mName; - - //! Name of the parent of the node - //! "" if there is no parent ... - std::string mParent; - - //! Transformation matrix of the node - aiMatrix4x4 mTransform; - - //! Target position (target lights and cameras) - aiVector3D mTargetPosition; - - //! Specifies which axes transformations a node inherits - //! from its parent ... - InheritanceInfo inherit; - - //! Animation channels for the node - Animation mAnim; - - //! Needed for lights and cameras: target animation channel - //! Should contain position keys only. - Animation mTargetAnim; - - bool mProcessed; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent an ASE file mesh */ -struct Mesh : public MeshWithSmoothingGroups, public BaseNode -{ - //! Constructor. - Mesh() - : BaseNode (BaseNode::Mesh) - , bSkip (false) - { - // use 2 texture vertex components by default - for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) - this->mNumUVComponents[c] = 2; - - // setup the default material index by default - iMaterialIndex = Face::DEFAULT_MATINDEX; - } - - //! List of all texture coordinate sets - std::vector amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; - - //! List of all vertex color sets. - std::vector mVertexColors; - - //! List of all bone vertices - std::vector mBoneVertices; - - //! List of all bones - std::vector mBones; - - //! Material index of the mesh - unsigned int iMaterialIndex; - - //! Number of vertex components for each UVW set - unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS]; - - //! used internally - bool bSkip; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent an ASE light source */ -struct Light : public BaseNode -{ - enum LightType - { - OMNI, - TARGET, - FREE, - DIRECTIONAL - }; - - //! Constructor. - Light() - : BaseNode (BaseNode::Light) - , mLightType (OMNI) - , mColor (1.f,1.f,1.f) - , mIntensity (1.f) // light is white by default - , mAngle (45.f) - , mFalloff (0.f) - { - } - - LightType mLightType; - aiColor3D mColor; - ai_real mIntensity; - ai_real mAngle; // in degrees - ai_real mFalloff; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent an ASE camera */ -struct Camera : public BaseNode -{ - enum CameraType - { - FREE, - TARGET - }; - - //! Constructor - Camera() - : BaseNode (BaseNode::Camera) - , mFOV (0.75f) // in radians - , mNear (0.1f) - , mFar (1000.f) // could be zero - , mCameraType (FREE) - { - } - - ai_real mFOV, mNear, mFar; - CameraType mCameraType; -}; - -// --------------------------------------------------------------------------- -/** Helper structure to represent an ASE helper object (dummy) */ -struct Dummy : public BaseNode -{ - //! Constructor - Dummy() - : BaseNode (BaseNode::Dummy) - { - } -}; - -// Parameters to Parser::Parse() -#define AI_ASE_NEW_FILE_FORMAT 200 -#define AI_ASE_OLD_FILE_FORMAT 110 - -// Internally we're a little bit more tolerant -#define AI_ASE_IS_NEW_FILE_FORMAT() (iFileFormat >= 200) -#define AI_ASE_IS_OLD_FILE_FORMAT() (iFileFormat < 200) - -// ------------------------------------------------------------------------------- -/** \brief Class to parse ASE files - */ -class Parser -{ - -private: - - Parser() {} - -public: - - // ------------------------------------------------------------------- - //! Construct a parser from a given input file which is - //! guaranted to be terminated with zero. - //! @param szFile Input file - //! @param fileFormatDefault Assumed file format version. If the - //! file format is specified in the file the new value replaces - //! the default value. - Parser (const char* szFile, unsigned int fileFormatDefault); - - // ------------------------------------------------------------------- - //! Parses the file into the parsers internal representation - void Parse(); - - -private: - - // ------------------------------------------------------------------- - //! Parse the *SCENE block in a file - void ParseLV1SceneBlock(); - - // ------------------------------------------------------------------- - //! Parse the *MESH_SOFTSKINVERTS block in a file - void ParseLV1SoftSkinBlock(); - - // ------------------------------------------------------------------- - //! Parse the *MATERIAL_LIST block in a file - void ParseLV1MaterialListBlock(); - - // ------------------------------------------------------------------- - //! Parse a *OBJECT block in a file - //! \param mesh Node to be filled - void ParseLV1ObjectBlock(BaseNode& mesh); - - // ------------------------------------------------------------------- - //! Parse a *MATERIAL blocks in a material list - //! \param mat Material structure to be filled - void ParseLV2MaterialBlock(Material& mat); - - // ------------------------------------------------------------------- - //! Parse a *NODE_TM block in a file - //! \param mesh Node (!) object to be filled - void ParseLV2NodeTransformBlock(BaseNode& mesh); - - // ------------------------------------------------------------------- - //! Parse a *TM_ANIMATION block in a file - //! \param mesh Mesh object to be filled - void ParseLV2AnimationBlock(BaseNode& mesh); - void ParseLV3PosAnimationBlock(ASE::Animation& anim); - void ParseLV3ScaleAnimationBlock(ASE::Animation& anim); - void ParseLV3RotAnimationBlock(ASE::Animation& anim); - - // ------------------------------------------------------------------- - //! Parse a *MESH block in a file - //! \param mesh Mesh object to be filled - void ParseLV2MeshBlock(Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse a *LIGHT_SETTINGS block in a file - //! \param light Light object to be filled - void ParseLV2LightSettingsBlock(Light& light); - - // ------------------------------------------------------------------- - //! Parse a *CAMERA_SETTINGS block in a file - //! \param cam Camera object to be filled - void ParseLV2CameraSettingsBlock(Camera& cam); - - // ------------------------------------------------------------------- - //! Parse the *MAP_XXXXXX blocks in a material - //! \param map Texture structure to be filled - void ParseLV3MapBlock(Texture& map); - - // ------------------------------------------------------------------- - //! Parse a *MESH_VERTEX_LIST block in a file - //! \param iNumVertices Value of *MESH_NUMVERTEX, if present. - //! Otherwise zero. This is used to check the consistency of the file. - //! A warning is sent to the logger if the validations fails. - //! \param mesh Mesh object to be filled - void ParseLV3MeshVertexListBlock( - unsigned int iNumVertices,Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse a *MESH_FACE_LIST block in a file - //! \param iNumFaces Value of *MESH_NUMFACES, if present. - //! Otherwise zero. This is used to check the consistency of the file. - //! A warning is sent to the logger if the validations fails. - //! \param mesh Mesh object to be filled - void ParseLV3MeshFaceListBlock( - unsigned int iNumFaces,Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse a *MESH_TVERT_LIST block in a file - //! \param iNumVertices Value of *MESH_NUMTVERTEX, if present. - //! Otherwise zero. This is used to check the consistency of the file. - //! A warning is sent to the logger if the validations fails. - //! \param mesh Mesh object to be filled - //! \param iChannel Output UVW channel - void ParseLV3MeshTListBlock( - unsigned int iNumVertices,Mesh& mesh, unsigned int iChannel = 0); - - // ------------------------------------------------------------------- - //! Parse a *MESH_TFACELIST block in a file - //! \param iNumFaces Value of *MESH_NUMTVFACES, if present. - //! Otherwise zero. This is used to check the consistency of the file. - //! A warning is sent to the logger if the validations fails. - //! \param mesh Mesh object to be filled - //! \param iChannel Output UVW channel - void ParseLV3MeshTFaceListBlock( - unsigned int iNumFaces,Mesh& mesh, unsigned int iChannel = 0); - - // ------------------------------------------------------------------- - //! Parse an additional mapping channel - //! (specified via *MESH_MAPPINGCHANNEL) - //! \param iChannel Channel index to be filled - //! \param mesh Mesh object to be filled - void ParseLV3MappingChannel( - unsigned int iChannel, Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse a *MESH_CVERTLIST block in a file - //! \param iNumVertices Value of *MESH_NUMCVERTEX, if present. - //! Otherwise zero. This is used to check the consistency of the file. - //! A warning is sent to the logger if the validations fails. - //! \param mesh Mesh object to be filled - void ParseLV3MeshCListBlock( - unsigned int iNumVertices, Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse a *MESH_CFACELIST block in a file - //! \param iNumFaces Value of *MESH_NUMCVFACES, if present. - //! Otherwise zero. This is used to check the consistency of the file. - //! A warning is sent to the logger if the validations fails. - //! \param mesh Mesh object to be filled - void ParseLV3MeshCFaceListBlock( - unsigned int iNumFaces, Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse a *MESH_NORMALS block in a file - //! \param mesh Mesh object to be filled - void ParseLV3MeshNormalListBlock(Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse a *MESH_WEIGHTSblock in a file - //! \param mesh Mesh object to be filled - void ParseLV3MeshWeightsBlock(Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse the bone list of a file - //! \param mesh Mesh object to be filled - //! \param iNumBones Number of bones in the mesh - void ParseLV4MeshBones(unsigned int iNumBones,Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse the bone vertices list of a file - //! \param mesh Mesh object to be filled - //! \param iNumVertices Number of vertices to be parsed - void ParseLV4MeshBonesVertices(unsigned int iNumVertices,Mesh& mesh); - - // ------------------------------------------------------------------- - //! Parse a *MESH_FACE block in a file - //! \param out receive the face data - void ParseLV4MeshFace(ASE::Face& out); - - // ------------------------------------------------------------------- - //! Parse a *MESH_VERT block in a file - //! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...) - //! \param apOut Output buffer (3 floats) - //! \param rIndexOut Output index - void ParseLV4MeshFloatTriple(ai_real* apOut, unsigned int& rIndexOut); - - // ------------------------------------------------------------------- - //! Parse a *MESH_VERT block in a file - //! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...) - //! \param apOut Output buffer (3 floats) - void ParseLV4MeshFloatTriple(ai_real* apOut); - - // ------------------------------------------------------------------- - //! Parse a *MESH_TFACE block in a file - //! (also works for MESH_CFACE) - //! \param apOut Output buffer (3 ints) - //! \param rIndexOut Output index - void ParseLV4MeshLongTriple(unsigned int* apOut, unsigned int& rIndexOut); - - // ------------------------------------------------------------------- - //! Parse a *MESH_TFACE block in a file - //! (also works for MESH_CFACE) - //! \param apOut Output buffer (3 ints) - void ParseLV4MeshLongTriple(unsigned int* apOut); - - // ------------------------------------------------------------------- - //! Parse a single float element - //! \param fOut Output float - void ParseLV4MeshFloat(ai_real& fOut); - - // ------------------------------------------------------------------- - //! Parse a single int element - //! \param iOut Output integer - void ParseLV4MeshLong(unsigned int& iOut); - - // ------------------------------------------------------------------- - //! Skip everything to the next: '*' or '\0' - bool SkipToNextToken(); - - // ------------------------------------------------------------------- - //! Skip the current section until the token after the closing }. - //! This function handles embedded subsections correctly - bool SkipSection(); - - // ------------------------------------------------------------------- - //! Output a warning to the logger - //! \param szWarn Warn message - void LogWarning(const char* szWarn); - - // ------------------------------------------------------------------- - //! Output a message to the logger - //! \param szWarn Message - void LogInfo(const char* szWarn); - - // ------------------------------------------------------------------- - //! Output an error to the logger - //! \param szWarn Error message - AI_WONT_RETURN void LogError(const char* szWarn) AI_WONT_RETURN_SUFFIX; - - // ------------------------------------------------------------------- - //! Parse a string, enclosed in double quotation marks - //! \param out Output string - //! \param szName Name of the enclosing element -> used in error - //! messages. - //! \return false if an error occurred - bool ParseString(std::string& out,const char* szName); - -public: - - //! Pointer to current data - const char* filePtr; - - //! background color to be passed to the viewer - //! QNAN if none was found - aiColor3D m_clrBackground; - - //! Base ambient color to be passed to all materials - //! QNAN if none was found - aiColor3D m_clrAmbient; - - //! List of all materials found in the file - std::vector m_vMaterials; - - //! List of all meshes found in the file - std::vector m_vMeshes; - - //! List of all dummies found in the file - std::vector m_vDummies; - - //! List of all lights found in the file - std::vector m_vLights; - - //! List of all cameras found in the file - std::vector m_vCameras; - - //! Current line in the file - unsigned int iLineNumber; - - //! First frame - unsigned int iFirstFrame; - - //! Last frame - unsigned int iLastFrame; - - //! Frame speed - frames per second - unsigned int iFrameSpeed; - - //! Ticks per frame - unsigned int iTicksPerFrame; - - //! true if the last character read was an end-line character - bool bLastWasEndLine; - - //! File format version - unsigned int iFileFormat; -}; - - -} // Namespace ASE -} // Namespace ASSIMP - -#endif // ASSIMP_BUILD_NO_3DS_IMPORTER - -#endif // !! include guard diff --git a/src/3rdparty/assimp/code/AssbinExporter.cpp b/src/3rdparty/assimp/code/AssbinExporter.cpp deleted file mode 100644 index bcac2e08f..000000000 --- a/src/3rdparty/assimp/code/AssbinExporter.cpp +++ /dev/null @@ -1,822 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ -/** @file AssbinExporter.cpp - * ASSBIN exporter main code - */ -#include "assbin_chunks.h" -#include -#include -#include -#include -#include "ProcessHelper.h" -#include "Exceptional.h" - -#ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include -#else -# include "../contrib/zlib/zlib.h" -#endif - -#include - - -#ifndef ASSIMP_BUILD_NO_EXPORT -#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER - -using namespace Assimp; - -namespace Assimp { - -template -size_t Write(IOStream * stream, const T& v) -{ - return stream->Write( &v, sizeof(T), 1 ); -} - - -// ----------------------------------------------------------------------------------- -// Serialize an aiString -template <> -inline size_t Write(IOStream * stream, const aiString& s) -{ - const size_t s2 = (uint32_t)s.length; - stream->Write(&s,4,1); - stream->Write(s.data,s2,1); - return s2+4; -} - -// ----------------------------------------------------------------------------------- -// Serialize an unsigned int as uint32_t -template <> -inline size_t Write(IOStream * stream, const unsigned int& w) -{ - const uint32_t t = (uint32_t)w; - if (w > t) { - // this shouldn't happen, integers in Assimp data structures never exceed 2^32 - throw new DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion"); - } - - stream->Write(&t,4,1); - return 4; -} - -// ----------------------------------------------------------------------------------- -// Serialize an unsigned int as uint16_t -template <> -inline size_t Write(IOStream * stream, const uint16_t& w) -{ - static_assert(sizeof(uint16_t)==2, "sizeof(uint16_t)==2"); - stream->Write(&w,2,1); - return 2; -} - -// ----------------------------------------------------------------------------------- -// Serialize a float -template <> -inline size_t Write(IOStream * stream, const float& f) -{ - static_assert(sizeof(float)==4, "sizeof(float)==4"); - stream->Write(&f,4,1); - return 4; -} - -// ----------------------------------------------------------------------------------- -// Serialize a double -template <> -inline size_t Write(IOStream * stream, const double& f) -{ - static_assert(sizeof(double)==8, "sizeof(double)==8"); - stream->Write(&f,8,1); - return 8; -} - -// ----------------------------------------------------------------------------------- -// Serialize a vec3 -template <> -inline size_t Write(IOStream * stream, const aiVector3D& v) -{ - size_t t = Write(stream,v.x); - t += Write(stream,v.y); - t += Write(stream,v.z); - return t; -} - -// ----------------------------------------------------------------------------------- -// Serialize a color value -template <> -inline size_t Write(IOStream * stream, const aiColor3D& v) -{ - size_t t = Write(stream,v.r); - t += Write(stream,v.g); - t += Write(stream,v.b); - return t; -} - -// ----------------------------------------------------------------------------------- -// Serialize a color value -template <> -inline size_t Write(IOStream * stream, const aiColor4D& v) -{ - size_t t = Write(stream,v.r); - t += Write(stream,v.g); - t += Write(stream,v.b); - t += Write(stream,v.a); - return t; -} - -// ----------------------------------------------------------------------------------- -// Serialize a quaternion -template <> -inline size_t Write(IOStream * stream, const aiQuaternion& v) -{ - size_t t = Write(stream,v.w); - t += Write(stream,v.x); - t += Write(stream,v.y); - t += Write(stream,v.z); - ai_assert(t == 16); - return 16; -} - - -// ----------------------------------------------------------------------------------- -// Serialize a vertex weight -template <> -inline size_t Write(IOStream * stream, const aiVertexWeight& v) -{ - size_t t = Write(stream,v.mVertexId); - return t+Write(stream,v.mWeight); -} - -// ----------------------------------------------------------------------------------- -// Serialize a mat4x4 -template <> -inline size_t Write(IOStream * stream, const aiMatrix4x4& m) -{ - for (unsigned int i = 0; i < 4;++i) { - for (unsigned int i2 = 0; i2 < 4;++i2) { - Write(stream,m[i][i2]); - } - } - return 64; -} - -// ----------------------------------------------------------------------------------- -// Serialize an aiVectorKey -template <> -inline size_t Write(IOStream * stream, const aiVectorKey& v) -{ - const size_t t = Write(stream,v.mTime); - return t + Write(stream,v.mValue); -} - -// ----------------------------------------------------------------------------------- -// Serialize an aiQuatKey -template <> -inline size_t Write(IOStream * stream, const aiQuatKey& v) -{ - const size_t t = Write(stream,v.mTime); - return t + Write(stream,v.mValue); -} - -template -inline size_t WriteBounds(IOStream * stream, const T* in, unsigned int size) -{ - T minc,maxc; - ArrayBounds(in,size,minc,maxc); - - const size_t t = Write(stream,minc); - return t + Write(stream,maxc); -} - -// We use this to write out non-byte arrays so that we write using the specializations. -// This way we avoid writing out extra bytes that potentially come from struct alignment. -template -inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size) -{ - size_t n = 0; - for (unsigned int i=0; i(stream,in[i]); - return n; -} - - // ---------------------------------------------------------------------------------- - /** @class AssbinChunkWriter - * @brief Chunk writer mechanism for the .assbin file structure - * - * This is a standard in-memory IOStream (most of the code is based on BlobIOStream), - * the difference being that this takes another IOStream as a "container" in the - * constructor, and when it is destroyed, it appends the magic number, the chunk size, - * and the chunk contents to the container stream. This allows relatively easy chunk - * chunk construction, even recursively. - */ - class AssbinChunkWriter : public IOStream - { - private: - - uint8_t* buffer; - uint32_t magic; - IOStream * container; - size_t cur_size, cursor, initial; - - private: - // ------------------------------------------------------------------- - void Grow(size_t need = 0) - { - size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) )); - - const uint8_t* const old = buffer; - buffer = new uint8_t[new_size]; - - if (old) { - memcpy(buffer,old,cur_size); - delete[] old; - } - - cur_size = new_size; - } - - public: - - AssbinChunkWriter( IOStream * container, uint32_t magic, size_t initial = 4096) - : buffer(NULL), magic(magic), container(container), cur_size(0), cursor(0), initial(initial) - { - } - - virtual ~AssbinChunkWriter() - { - if (container) { - container->Write( &magic, sizeof(uint32_t), 1 ); - container->Write( &cursor, sizeof(uint32_t), 1 ); - container->Write( buffer, 1, cursor ); - } - if (buffer) delete[] buffer; - } - - void * GetBufferPointer() { return buffer; } - - // ------------------------------------------------------------------- - virtual size_t Read(void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) { return 0; } - virtual aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) { return aiReturn_FAILURE; } - virtual size_t Tell() const { return cursor; } - virtual void Flush() { } - - virtual size_t FileSize() const - { - return cursor; - } - - // ------------------------------------------------------------------- - virtual size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) - { - pSize *= pCount; - if (cursor + pSize > cur_size) { - Grow(cursor + pSize); - } - - memcpy(buffer+cursor, pvBuffer, pSize); - cursor += pSize; - - return pCount; - } - - }; - - // ---------------------------------------------------------------------------------- - /** @class AssbinExport - * @brief Assbin exporter class - * - * This class performs the .assbin exporting, and is responsible for the file layout. - */ - class AssbinExport - { - private: - bool shortened; - bool compressed; - - protected: - - // ----------------------------------------------------------------------------------- - void WriteBinaryNode( IOStream * container, const aiNode* node) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODE ); - - unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0); - - Write(&chunk,node->mName); - Write(&chunk,node->mTransformation); - Write(&chunk,node->mNumChildren); - Write(&chunk,node->mNumMeshes); - Write(&chunk,nb_metadata); - - for (unsigned int i = 0; i < node->mNumMeshes;++i) { - Write(&chunk,node->mMeshes[i]); - } - - for (unsigned int i = 0; i < node->mNumChildren;++i) { - WriteBinaryNode( &chunk, node->mChildren[i] ); - } - - for (unsigned int i = 0; i < nb_metadata; ++i) { - const aiString& key = node->mMetaData->mKeys[i]; - aiMetadataType type = node->mMetaData->mValues[i].mType; - void* value = node->mMetaData->mValues[i].mData; - - Write(&chunk, key); - Write(&chunk, type); - - switch (type) { - case AI_BOOL: - Write(&chunk, *((bool*) value)); - break; - case AI_INT32: - Write(&chunk, *((int32_t*) value)); - break; - case AI_UINT64: - Write(&chunk, *((uint64_t*) value)); - break; - case AI_FLOAT: - Write(&chunk, *((float*) value)); - break; - case AI_DOUBLE: - Write(&chunk, *((double*) value)); - break; - case AI_AISTRING: - Write(&chunk, *((aiString*) value)); - break; - case AI_AIVECTOR3D: - Write(&chunk, *((aiVector3D*) value)); - break; -#ifdef SWIG - case FORCE_32BIT: -#endif // SWIG - default: - break; - } - } - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryTexture(IOStream * container, const aiTexture* tex) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AITEXTURE ); - - Write(&chunk,tex->mWidth); - Write(&chunk,tex->mHeight); - chunk.Write( tex->achFormatHint, sizeof(char), 4 ); - - if(!shortened) { - if (!tex->mHeight) { - chunk.Write(tex->pcData,1,tex->mWidth); - } - else { - chunk.Write(tex->pcData,1,tex->mWidth*tex->mHeight*4); - } - } - - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryBone(IOStream * container, const aiBone* b) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIBONE ); - - Write(&chunk,b->mName); - Write(&chunk,b->mNumWeights); - Write(&chunk,b->mOffsetMatrix); - - // for the moment we write dumb min/max values for the bones, too. - // maybe I'll add a better, hash-like solution later - if (shortened) { - WriteBounds(&chunk,b->mWeights,b->mNumWeights); - } // else write as usual - else WriteArray(&chunk,b->mWeights,b->mNumWeights); - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryMesh(IOStream * container, const aiMesh* mesh) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMESH ); - - Write(&chunk,mesh->mPrimitiveTypes); - Write(&chunk,mesh->mNumVertices); - Write(&chunk,mesh->mNumFaces); - Write(&chunk,mesh->mNumBones); - Write(&chunk,mesh->mMaterialIndex); - - // first of all, write bits for all existent vertex components - unsigned int c = 0; - if (mesh->mVertices) { - c |= ASSBIN_MESH_HAS_POSITIONS; - } - if (mesh->mNormals) { - c |= ASSBIN_MESH_HAS_NORMALS; - } - if (mesh->mTangents && mesh->mBitangents) { - c |= ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS; - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { - if (!mesh->mTextureCoords[n]) { - break; - } - c |= ASSBIN_MESH_HAS_TEXCOORD(n); - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) { - if (!mesh->mColors[n]) { - break; - } - c |= ASSBIN_MESH_HAS_COLOR(n); - } - Write(&chunk,c); - - aiVector3D minVec, maxVec; - if (mesh->mVertices) { - if (shortened) { - WriteBounds(&chunk,mesh->mVertices,mesh->mNumVertices); - } // else write as usual - else WriteArray(&chunk,mesh->mVertices,mesh->mNumVertices); - } - if (mesh->mNormals) { - if (shortened) { - WriteBounds(&chunk,mesh->mNormals,mesh->mNumVertices); - } // else write as usual - else WriteArray(&chunk,mesh->mNormals,mesh->mNumVertices); - } - if (mesh->mTangents && mesh->mBitangents) { - if (shortened) { - WriteBounds(&chunk,mesh->mTangents,mesh->mNumVertices); - WriteBounds(&chunk,mesh->mBitangents,mesh->mNumVertices); - } // else write as usual - else { - WriteArray(&chunk,mesh->mTangents,mesh->mNumVertices); - WriteArray(&chunk,mesh->mBitangents,mesh->mNumVertices); - } - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) { - if (!mesh->mColors[n]) - break; - - if (shortened) { - WriteBounds(&chunk,mesh->mColors[n],mesh->mNumVertices); - } // else write as usual - else WriteArray(&chunk,mesh->mColors[n],mesh->mNumVertices); - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { - if (!mesh->mTextureCoords[n]) - break; - - // write number of UV components - Write(&chunk,mesh->mNumUVComponents[n]); - - if (shortened) { - WriteBounds(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices); - } // else write as usual - else WriteArray(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices); - } - - // write faces. There are no floating-point calculations involved - // in these, so we can write a simple hash over the face data - // to the dump file. We generate a single 32 Bit hash for 512 faces - // using Assimp's standard hashing function. - if (shortened) { - unsigned int processed = 0; - for (unsigned int job;(job = std::min(mesh->mNumFaces-processed,512u));processed += job) { - - uint32_t hash = 0; - for (unsigned int a = 0; a < job;++a) { - - const aiFace& f = mesh->mFaces[processed+a]; - uint32_t tmp = f.mNumIndices; - hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); - for (unsigned int i = 0; i < f.mNumIndices; ++i) { - static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff"); - tmp = static_cast( f.mIndices[i] ); - hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); - } - } - Write(&chunk,hash); - } - } - else // else write as usual - { - // if there are less than 2^16 vertices, we can simply use 16 bit integers ... - for (unsigned int i = 0; i < mesh->mNumFaces;++i) { - const aiFace& f = mesh->mFaces[i]; - - static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff"); - Write(&chunk,f.mNumIndices); - - for (unsigned int a = 0; a < f.mNumIndices;++a) { - if (mesh->mNumVertices < (1u<<16)) { - Write(&chunk,f.mIndices[a]); - } - else Write(&chunk,f.mIndices[a]); - } - } - } - - // write bones - if (mesh->mNumBones) { - for (unsigned int a = 0; a < mesh->mNumBones;++a) { - const aiBone* b = mesh->mBones[a]; - WriteBinaryBone(&chunk,b); - } - } - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryMaterialProperty(IOStream * container, const aiMaterialProperty* prop) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIALPROPERTY ); - - Write(&chunk,prop->mKey); - Write(&chunk,prop->mSemantic); - Write(&chunk,prop->mIndex); - - Write(&chunk,prop->mDataLength); - Write(&chunk,(unsigned int)prop->mType); - chunk.Write(prop->mData,1,prop->mDataLength); - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryMaterial(IOStream * container, const aiMaterial* mat) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIAL); - - Write(&chunk,mat->mNumProperties); - for (unsigned int i = 0; i < mat->mNumProperties;++i) { - WriteBinaryMaterialProperty( &chunk, mat->mProperties[i]); - } - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryNodeAnim(IOStream * container, const aiNodeAnim* nd) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODEANIM ); - - Write(&chunk,nd->mNodeName); - Write(&chunk,nd->mNumPositionKeys); - Write(&chunk,nd->mNumRotationKeys); - Write(&chunk,nd->mNumScalingKeys); - Write(&chunk,nd->mPreState); - Write(&chunk,nd->mPostState); - - if (nd->mPositionKeys) { - if (shortened) { - WriteBounds(&chunk,nd->mPositionKeys,nd->mNumPositionKeys); - - } // else write as usual - else WriteArray(&chunk,nd->mPositionKeys,nd->mNumPositionKeys); - } - if (nd->mRotationKeys) { - if (shortened) { - WriteBounds(&chunk,nd->mRotationKeys,nd->mNumRotationKeys); - - } // else write as usual - else WriteArray(&chunk,nd->mRotationKeys,nd->mNumRotationKeys); - } - if (nd->mScalingKeys) { - if (shortened) { - WriteBounds(&chunk,nd->mScalingKeys,nd->mNumScalingKeys); - - } // else write as usual - else WriteArray(&chunk,nd->mScalingKeys,nd->mNumScalingKeys); - } - } - - - // ----------------------------------------------------------------------------------- - void WriteBinaryAnim( IOStream * container, const aiAnimation* anim ) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIANIMATION ); - - Write(&chunk,anim->mName); - Write(&chunk,anim->mDuration); - Write(&chunk,anim->mTicksPerSecond); - Write(&chunk,anim->mNumChannels); - - for (unsigned int a = 0; a < anim->mNumChannels;++a) { - const aiNodeAnim* nd = anim->mChannels[a]; - WriteBinaryNodeAnim(&chunk,nd); - } - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryLight( IOStream * container, const aiLight* l ) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AILIGHT ); - - Write(&chunk,l->mName); - Write(&chunk,l->mType); - - if (l->mType != aiLightSource_DIRECTIONAL) { - Write(&chunk,l->mAttenuationConstant); - Write(&chunk,l->mAttenuationLinear); - Write(&chunk,l->mAttenuationQuadratic); - } - - Write(&chunk,l->mColorDiffuse); - Write(&chunk,l->mColorSpecular); - Write(&chunk,l->mColorAmbient); - - if (l->mType == aiLightSource_SPOT) { - Write(&chunk,l->mAngleInnerCone); - Write(&chunk,l->mAngleOuterCone); - } - - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryCamera( IOStream * container, const aiCamera* cam ) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AICAMERA ); - - Write(&chunk,cam->mName); - Write(&chunk,cam->mPosition); - Write(&chunk,cam->mLookAt); - Write(&chunk,cam->mUp); - Write(&chunk,cam->mHorizontalFOV); - Write(&chunk,cam->mClipPlaneNear); - Write(&chunk,cam->mClipPlaneFar); - Write(&chunk,cam->mAspect); - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryScene( IOStream * container, const aiScene* scene) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AISCENE ); - - // basic scene information - Write(&chunk,scene->mFlags); - Write(&chunk,scene->mNumMeshes); - Write(&chunk,scene->mNumMaterials); - Write(&chunk,scene->mNumAnimations); - Write(&chunk,scene->mNumTextures); - Write(&chunk,scene->mNumLights); - Write(&chunk,scene->mNumCameras); - - // write node graph - WriteBinaryNode( &chunk, scene->mRootNode ); - - // write all meshes - for (unsigned int i = 0; i < scene->mNumMeshes;++i) { - const aiMesh* mesh = scene->mMeshes[i]; - WriteBinaryMesh( &chunk,mesh); - } - - // write materials - for (unsigned int i = 0; i< scene->mNumMaterials; ++i) { - const aiMaterial* mat = scene->mMaterials[i]; - WriteBinaryMaterial(&chunk,mat); - } - - // write all animations - for (unsigned int i = 0; i < scene->mNumAnimations;++i) { - const aiAnimation* anim = scene->mAnimations[i]; - WriteBinaryAnim(&chunk,anim); - } - - - // write all textures - for (unsigned int i = 0; i < scene->mNumTextures;++i) { - const aiTexture* mesh = scene->mTextures[i]; - WriteBinaryTexture(&chunk,mesh); - } - - // write lights - for (unsigned int i = 0; i < scene->mNumLights;++i) { - const aiLight* l = scene->mLights[i]; - WriteBinaryLight(&chunk,l); - } - - // write cameras - for (unsigned int i = 0; i < scene->mNumCameras;++i) { - const aiCamera* cam = scene->mCameras[i]; - WriteBinaryCamera(&chunk,cam); - } - - } - - public: - AssbinExport() - : shortened(false), compressed(false) // temporary settings until properties are introduced for exporters - { - } - - // ----------------------------------------------------------------------------------- - // Write a binary model dump - void WriteBinaryDump(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene) - { - IOStream * out = pIOSystem->Open( pFile, "wb" ); - if (!out) return; - - time_t tt = time(NULL); - tm* p = gmtime(&tt); - - // header - char s[64]; - memset( s, 0, 64 ); -#if _MSC_VER >= 1400 - sprintf_s(s,"ASSIMP.binary-dump.%s",asctime(p)); -#else - ai_snprintf(s,64,"ASSIMP.binary-dump.%s",asctime(p)); -#endif - out->Write( s, 44, 1 ); - // == 44 bytes - - Write( out, ASSBIN_VERSION_MAJOR ); - Write( out, ASSBIN_VERSION_MINOR ); - Write( out, aiGetVersionRevision() ); - Write( out, aiGetCompileFlags() ); - Write( out, shortened ); - Write( out, compressed ); - // == 20 bytes - - char buff[256]; - strncpy(buff,pFile,256); - out->Write(buff,sizeof(char),256); - - char cmd[] = "\0"; - strncpy(buff,cmd,128); - out->Write(buff,sizeof(char),128); - - // leave 64 bytes free for future extensions - memset(buff,0xcd,64); - out->Write(buff,sizeof(char),64); - // == 435 bytes - - // ==== total header size: 512 bytes - ai_assert( out->Tell() == ASSBIN_HEADER_LENGTH ); - - // Up to here the data is uncompressed. For compressed files, the rest - // is compressed using standard DEFLATE from zlib. - if (compressed) - { - AssbinChunkWriter uncompressedStream( NULL, 0 ); - WriteBinaryScene( &uncompressedStream, pScene ); - - uLongf uncompressedSize = static_cast(uncompressedStream.Tell()); - uLongf compressedSize = (uLongf)(uncompressedStream.Tell() * 1.001 + 12.); - uint8_t* compressedBuffer = new uint8_t[ compressedSize ]; - - compress2( compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9 ); - - out->Write( &uncompressedSize, sizeof(uint32_t), 1 ); - out->Write( compressedBuffer, sizeof(char), compressedSize ); - - delete[] compressedBuffer; - } - else - { - WriteBinaryScene( out, pScene ); - } - - pIOSystem->Close( out ); - } - }; - -void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) -{ - AssbinExport exporter; - exporter.WriteBinaryDump( pFile, pIOSystem, pScene ); -} -} // end of namespace Assimp - -#endif // ASSIMP_BUILD_NO_ASSBIN_EXPORTER -#endif // ASSIMP_BUILD_NO_EXPORT diff --git a/src/3rdparty/assimp/code/AssbinExporter.h b/src/3rdparty/assimp/code/AssbinExporter.h deleted file mode 100644 index 55bb9fc82..000000000 --- a/src/3rdparty/assimp/code/AssbinExporter.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file AssbinExporter.h - * ASSBIN Exporter Main Header - */ -#ifndef AI_ASSBINEXPORTER_H_INC -#define AI_ASSBINEXPORTER_H_INC - -// nothing really needed here - reserved for future use like properties - -#endif diff --git a/src/3rdparty/assimp/code/AssbinLoader.cpp b/src/3rdparty/assimp/code/AssbinLoader.cpp deleted file mode 100644 index a7044c119..000000000 --- a/src/3rdparty/assimp/code/AssbinLoader.cpp +++ /dev/null @@ -1,740 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file AssbinLoader.cpp - * @brief Implementation of the .assbin importer class - * - * see assbin_chunks.h - */ - -#ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER - -// internal headers -#include "AssbinLoader.h" -#include "assbin_chunks.h" -#include "MemoryIOWrapper.h" -#include -#include -#include -#include - -#ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include -#else -# include -#endif - -using namespace Assimp; - -static const aiImporterDesc desc = { - ".assbin Importer", - "Gargaj / Conspiracy", - "", - "", - aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_SupportCompressedFlavour, - 0, - 0, - 0, - 0, - "assbin" -}; - -const aiImporterDesc* AssbinImporter::GetInfo() const -{ - return &desc; -} - -bool AssbinImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/ ) const -{ - IOStream * in = pIOHandler->Open(pFile); - if (!in) - return false; - - char s[32]; - in->Read( s, sizeof(char), 32 ); - - pIOHandler->Close(in); - - return strncmp( s, "ASSIMP.binary-dump.", 19 ) == 0; -} - -template -T Read(IOStream * stream) -{ - T t; - stream->Read( &t, sizeof(T), 1 ); - return t; -} - -template <> -aiVector3D Read(IOStream * stream) -{ - aiVector3D v; - v.x = Read(stream); - v.y = Read(stream); - v.z = Read(stream); - return v; -} - -template <> -aiColor4D Read(IOStream * stream) -{ - aiColor4D c; - c.r = Read(stream); - c.g = Read(stream); - c.b = Read(stream); - c.a = Read(stream); - return c; -} - -template <> -aiQuaternion Read(IOStream * stream) -{ - aiQuaternion v; - v.w = Read(stream); - v.x = Read(stream); - v.y = Read(stream); - v.z = Read(stream); - return v; -} - -template <> -aiString Read(IOStream * stream) -{ - aiString s; - stream->Read(&s.length,4,1); - stream->Read(s.data,s.length,1); - s.data[s.length] = 0; - return s; -} - -template <> -aiVertexWeight Read(IOStream * stream) -{ - aiVertexWeight w; - w.mVertexId = Read(stream); - w.mWeight = Read(stream); - return w; -} - -template <> -aiMatrix4x4 Read(IOStream * stream) -{ - aiMatrix4x4 m; - for (unsigned int i = 0; i < 4;++i) { - for (unsigned int i2 = 0; i2 < 4;++i2) { - m[i][i2] = Read(stream); - } - } - return m; -} - -template <> -aiVectorKey Read(IOStream * stream) -{ - aiVectorKey v; - v.mTime = Read(stream); - v.mValue = Read(stream); - return v; -} - -template <> -aiQuatKey Read(IOStream * stream) -{ - aiQuatKey v; - v.mTime = Read(stream); - v.mValue = Read(stream); - return v; -} - -template -void ReadArray(IOStream * stream, T * out, unsigned int size) -{ - for (unsigned int i=0; i(stream); -} - -template void ReadBounds( IOStream * stream, T* /*p*/, unsigned int n ) -{ - // not sure what to do here, the data isn't really useful. - stream->Seek( sizeof(T) * n, aiOrigin_CUR ); -} - -void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent ) { - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AINODE); - /*uint32_t size =*/ Read(stream); - - *node = new aiNode(); - - (*node)->mName = Read(stream); - (*node)->mTransformation = Read(stream); - (*node)->mNumChildren = Read(stream); - (*node)->mNumMeshes = Read(stream); - unsigned int nb_metadata = Read(stream); - - if(parent) { - (*node)->mParent = parent; - } - - if ((*node)->mNumMeshes) { - (*node)->mMeshes = new unsigned int[(*node)->mNumMeshes]; - for (unsigned int i = 0; i < (*node)->mNumMeshes; ++i) { - (*node)->mMeshes[i] = Read(stream); - } - } - - if ((*node)->mNumChildren) { - (*node)->mChildren = new aiNode*[(*node)->mNumChildren]; - for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) { - ReadBinaryNode( stream, &(*node)->mChildren[i], *node ); - } - } - - if ( nb_metadata > 0 ) { - (*node)->mMetaData = aiMetadata::Alloc(nb_metadata); - for (unsigned int i = 0; i < nb_metadata; ++i) { - (*node)->mMetaData->mKeys[i] = Read(stream); - (*node)->mMetaData->mValues[i].mType = (aiMetadataType) Read(stream); - void* data( nullptr ); - - switch ((*node)->mMetaData->mValues[i].mType) { - case AI_BOOL: - data = new bool(Read(stream)); - break; - case AI_INT32: - data = new int32_t(Read(stream)); - break; - case AI_UINT64: - data = new uint64_t(Read(stream)); - break; - case AI_FLOAT: - data = new float(Read(stream)); - break; - case AI_DOUBLE: - data = new double(Read(stream)); - break; - case AI_AISTRING: - data = new aiString(Read(stream)); - break; - case AI_AIVECTOR3D: - data = new aiVector3D(Read(stream)); - break; -#ifndef SWIG - case FORCE_32BIT: -#endif // SWIG - default: - break; - } - - (*node)->mMetaData->mValues[i].mData = data; - } - } -} - -// ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIBONE); - /*uint32_t size =*/ Read(stream); - - b->mName = Read(stream); - b->mNumWeights = Read(stream); - b->mOffsetMatrix = Read(stream); - - // for the moment we write dumb min/max values for the bones, too. - // maybe I'll add a better, hash-like solution later - if (shortened) - { - ReadBounds(stream,b->mWeights,b->mNumWeights); - } // else write as usual - else - { - b->mWeights = new aiVertexWeight[b->mNumWeights]; - ReadArray(stream,b->mWeights,b->mNumWeights); - } -} - - -void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIMESH); - /*uint32_t size =*/ Read(stream); - - mesh->mPrimitiveTypes = Read(stream); - mesh->mNumVertices = Read(stream); - mesh->mNumFaces = Read(stream); - mesh->mNumBones = Read(stream); - mesh->mMaterialIndex = Read(stream); - - // first of all, write bits for all existent vertex components - unsigned int c = Read(stream); - - if (c & ASSBIN_MESH_HAS_POSITIONS) - { - if (shortened) { - ReadBounds(stream,mesh->mVertices,mesh->mNumVertices); - } // else write as usual - else - { - mesh->mVertices = new aiVector3D[mesh->mNumVertices]; - ReadArray(stream,mesh->mVertices,mesh->mNumVertices); - } - } - if (c & ASSBIN_MESH_HAS_NORMALS) - { - if (shortened) { - ReadBounds(stream,mesh->mNormals,mesh->mNumVertices); - } // else write as usual - else - { - mesh->mNormals = new aiVector3D[mesh->mNumVertices]; - ReadArray(stream,mesh->mNormals,mesh->mNumVertices); - } - } - if (c & ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS) - { - if (shortened) { - ReadBounds(stream,mesh->mTangents,mesh->mNumVertices); - ReadBounds(stream,mesh->mBitangents,mesh->mNumVertices); - } // else write as usual - else - { - mesh->mTangents = new aiVector3D[mesh->mNumVertices]; - ReadArray(stream,mesh->mTangents,mesh->mNumVertices); - mesh->mBitangents = new aiVector3D[mesh->mNumVertices]; - ReadArray(stream,mesh->mBitangents,mesh->mNumVertices); - } - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) - { - if (!(c & ASSBIN_MESH_HAS_COLOR(n))) - break; - - if (shortened) - { - ReadBounds(stream,mesh->mColors[n],mesh->mNumVertices); - } // else write as usual - else - { - mesh->mColors[n] = new aiColor4D[mesh->mNumVertices]; - ReadArray(stream,mesh->mColors[n],mesh->mNumVertices); - } - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) - { - if (!(c & ASSBIN_MESH_HAS_TEXCOORD(n))) - break; - - // write number of UV components - mesh->mNumUVComponents[n] = Read(stream); - - if (shortened) { - ReadBounds(stream,mesh->mTextureCoords[n],mesh->mNumVertices); - } // else write as usual - else - { - mesh->mTextureCoords[n] = new aiVector3D[mesh->mNumVertices]; - ReadArray(stream,mesh->mTextureCoords[n],mesh->mNumVertices); - } - } - - // write faces. There are no floating-point calculations involved - // in these, so we can write a simple hash over the face data - // to the dump file. We generate a single 32 Bit hash for 512 faces - // using Assimp's standard hashing function. - if (shortened) { - Read(stream); - } - else // else write as usual - { - // if there are less than 2^16 vertices, we can simply use 16 bit integers ... - mesh->mFaces = new aiFace[mesh->mNumFaces]; - for (unsigned int i = 0; i < mesh->mNumFaces;++i) { - aiFace& f = mesh->mFaces[i]; - - static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff"); - f.mNumIndices = Read(stream); - f.mIndices = new unsigned int[f.mNumIndices]; - - for (unsigned int a = 0; a < f.mNumIndices;++a) { - if (mesh->mNumVertices < (1u<<16)) - { - f.mIndices[a] = Read(stream); - } - else - { - f.mIndices[a] = Read(stream); - } - } - } - } - - // write bones - if (mesh->mNumBones) { - mesh->mBones = new C_STRUCT aiBone*[mesh->mNumBones]; - for (unsigned int a = 0; a < mesh->mNumBones;++a) { - mesh->mBones[a] = new aiBone(); - ReadBinaryBone(stream,mesh->mBones[a]); - } - } -} - -void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY); - /*uint32_t size =*/ Read(stream); - - prop->mKey = Read(stream); - prop->mSemantic = Read(stream); - prop->mIndex = Read(stream); - - prop->mDataLength = Read(stream); - prop->mType = (aiPropertyTypeInfo)Read(stream); - prop->mData = new char [ prop->mDataLength ]; - stream->Read(prop->mData,1,prop->mDataLength); -} - -// ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIAL); - /*uint32_t size =*/ Read(stream); - - mat->mNumAllocated = mat->mNumProperties = Read(stream); - if (mat->mNumProperties) - { - if (mat->mProperties) - { - delete[] mat->mProperties; - } - mat->mProperties = new aiMaterialProperty*[mat->mNumProperties]; - for (unsigned int i = 0; i < mat->mNumProperties;++i) { - mat->mProperties[i] = new aiMaterialProperty(); - ReadBinaryMaterialProperty( stream, mat->mProperties[i]); - } - } -} - -// ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AINODEANIM); - /*uint32_t size =*/ Read(stream); - - nd->mNodeName = Read(stream); - nd->mNumPositionKeys = Read(stream); - nd->mNumRotationKeys = Read(stream); - nd->mNumScalingKeys = Read(stream); - nd->mPreState = (aiAnimBehaviour)Read(stream); - nd->mPostState = (aiAnimBehaviour)Read(stream); - - if (nd->mNumPositionKeys) { - if (shortened) { - ReadBounds(stream,nd->mPositionKeys,nd->mNumPositionKeys); - - } // else write as usual - else { - nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys]; - ReadArray(stream,nd->mPositionKeys,nd->mNumPositionKeys); - } - } - if (nd->mNumRotationKeys) { - if (shortened) { - ReadBounds(stream,nd->mRotationKeys,nd->mNumRotationKeys); - - } // else write as usual - else - { - nd->mRotationKeys = new aiQuatKey[nd->mNumRotationKeys]; - ReadArray(stream,nd->mRotationKeys,nd->mNumRotationKeys); - } - } - if (nd->mNumScalingKeys) { - if (shortened) { - ReadBounds(stream,nd->mScalingKeys,nd->mNumScalingKeys); - - } // else write as usual - else - { - nd->mScalingKeys = new aiVectorKey[nd->mNumScalingKeys]; - ReadArray(stream,nd->mScalingKeys,nd->mNumScalingKeys); - } - } -} - - -// ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIANIMATION); - /*uint32_t size =*/ Read(stream); - - anim->mName = Read (stream); - anim->mDuration = Read (stream); - anim->mTicksPerSecond = Read (stream); - anim->mNumChannels = Read(stream); - - if (anim->mNumChannels) - { - anim->mChannels = new aiNodeAnim*[ anim->mNumChannels ]; - for (unsigned int a = 0; a < anim->mNumChannels;++a) { - anim->mChannels[a] = new aiNodeAnim(); - ReadBinaryNodeAnim(stream,anim->mChannels[a]); - } - } -} - -void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AITEXTURE); - /*uint32_t size =*/ Read(stream); - - tex->mWidth = Read(stream); - tex->mHeight = Read(stream); - stream->Read( tex->achFormatHint, sizeof(char), 4 ); - - if(!shortened) { - if (!tex->mHeight) { - tex->pcData = new aiTexel[ tex->mWidth ]; - stream->Read(tex->pcData,1,tex->mWidth); - } - else { - tex->pcData = new aiTexel[ tex->mWidth*tex->mHeight ]; - stream->Read(tex->pcData,1,tex->mWidth*tex->mHeight*4); - } - } - -} - -// ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AILIGHT); - /*uint32_t size =*/ Read(stream); - - l->mName = Read(stream); - l->mType = (aiLightSourceType)Read(stream); - - if (l->mType != aiLightSource_DIRECTIONAL) { - l->mAttenuationConstant = Read(stream); - l->mAttenuationLinear = Read(stream); - l->mAttenuationQuadratic = Read(stream); - } - - l->mColorDiffuse = Read(stream); - l->mColorSpecular = Read(stream); - l->mColorAmbient = Read(stream); - - if (l->mType == aiLightSource_SPOT) { - l->mAngleInnerCone = Read(stream); - l->mAngleOuterCone = Read(stream); - } - -} - -// ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AICAMERA); - /*uint32_t size =*/ Read(stream); - - cam->mName = Read(stream); - cam->mPosition = Read(stream); - cam->mLookAt = Read(stream); - cam->mUp = Read(stream); - cam->mHorizontalFOV = Read(stream); - cam->mClipPlaneNear = Read(stream); - cam->mClipPlaneFar = Read(stream); - cam->mAspect = Read(stream); -} - -void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AISCENE); - /*uint32_t size =*/ Read(stream); - - scene->mFlags = Read(stream); - scene->mNumMeshes = Read(stream); - scene->mNumMaterials = Read(stream); - scene->mNumAnimations = Read(stream); - scene->mNumTextures = Read(stream); - scene->mNumLights = Read(stream); - scene->mNumCameras = Read(stream); - - // Read node graph - scene->mRootNode = new aiNode[1]; - ReadBinaryNode( stream, &scene->mRootNode, (aiNode*)NULL ); - - // Read all meshes - if (scene->mNumMeshes) - { - scene->mMeshes = new aiMesh*[scene->mNumMeshes]; - for (unsigned int i = 0; i < scene->mNumMeshes;++i) { - scene->mMeshes[i] = new aiMesh(); - ReadBinaryMesh( stream,scene->mMeshes[i]); - } - } - - // Read materials - if (scene->mNumMaterials) - { - scene->mMaterials = new aiMaterial*[scene->mNumMaterials]; - for (unsigned int i = 0; i< scene->mNumMaterials; ++i) { - scene->mMaterials[i] = new aiMaterial(); - ReadBinaryMaterial(stream,scene->mMaterials[i]); - } - } - - // Read all animations - if (scene->mNumAnimations) - { - scene->mAnimations = new aiAnimation*[scene->mNumAnimations]; - for (unsigned int i = 0; i < scene->mNumAnimations;++i) { - scene->mAnimations[i] = new aiAnimation(); - ReadBinaryAnim(stream,scene->mAnimations[i]); - } - } - - // Read all textures - if (scene->mNumTextures) - { - scene->mTextures = new aiTexture*[scene->mNumTextures]; - for (unsigned int i = 0; i < scene->mNumTextures;++i) { - scene->mTextures[i] = new aiTexture(); - ReadBinaryTexture(stream,scene->mTextures[i]); - } - } - - // Read lights - if (scene->mNumLights) - { - scene->mLights = new aiLight*[scene->mNumLights]; - for (unsigned int i = 0; i < scene->mNumLights;++i) { - scene->mLights[i] = new aiLight(); - ReadBinaryLight(stream,scene->mLights[i]); - } - } - - // Read cameras - if (scene->mNumCameras) - { - scene->mCameras = new aiCamera*[scene->mNumCameras]; - for (unsigned int i = 0; i < scene->mNumCameras;++i) { - scene->mCameras[i] = new aiCamera(); - ReadBinaryCamera(stream,scene->mCameras[i]); - } - } - -} - -void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler ) -{ - IOStream * stream = pIOHandler->Open(pFile,"rb"); - if (!stream) - return; - - stream->Seek( 44, aiOrigin_CUR ); // signature - - /*unsigned int versionMajor =*/ Read(stream); - /*unsigned int versionMinor =*/ Read(stream); - /*unsigned int versionRevision =*/ Read(stream); - /*unsigned int compileFlags =*/ Read(stream); - - shortened = Read(stream) > 0; - compressed = Read(stream) > 0; - - if (shortened) - throw DeadlyImportError( "Shortened binaries are not supported!" ); - - stream->Seek( 256, aiOrigin_CUR ); // original filename - stream->Seek( 128, aiOrigin_CUR ); // options - stream->Seek( 64, aiOrigin_CUR ); // padding - - if (compressed) - { - uLongf uncompressedSize = Read(stream); - uLongf compressedSize = static_cast(stream->FileSize() - stream->Tell()); - - unsigned char * compressedData = new unsigned char[ compressedSize ]; - stream->Read( compressedData, 1, compressedSize ); - - unsigned char * uncompressedData = new unsigned char[ uncompressedSize ]; - - uncompress( uncompressedData, &uncompressedSize, compressedData, compressedSize ); - - MemoryIOStream io( uncompressedData, uncompressedSize ); - - ReadBinaryScene(&io,pScene); - - delete[] uncompressedData; - delete[] compressedData; - } - else - { - ReadBinaryScene(stream,pScene); - } - - pIOHandler->Close(stream); -} - -#endif // !! ASSIMP_BUILD_NO_ASSBIN_IMPORTER diff --git a/src/3rdparty/assimp/code/AssbinLoader.h b/src/3rdparty/assimp/code/AssbinLoader.h deleted file mode 100644 index 2eb7a6488..000000000 --- a/src/3rdparty/assimp/code/AssbinLoader.h +++ /dev/null @@ -1,104 +0,0 @@ - -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file AssbinLoader.h - * @brief .assbin File format loader - */ -#ifndef AI_ASSBINIMPORTER_H_INC -#define AI_ASSBINIMPORTER_H_INC - -#include "BaseImporter.h" - -struct aiMesh; -struct aiNode; -struct aiBone; -struct aiMaterial; -struct aiMaterialProperty; -struct aiNodeAnim; -struct aiAnimation; -struct aiTexture; -struct aiLight; -struct aiCamera; - -#ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER - -namespace Assimp { - -// --------------------------------------------------------------------------------- -/** Importer class for 3D Studio r3 and r4 3DS files - */ -class AssbinImporter : public BaseImporter -{ -private: - bool shortened; - bool compressed; - -public: - virtual bool CanRead( - const std::string& pFile, - IOSystem* pIOHandler, - bool checkSig - ) const; - virtual const aiImporterDesc* GetInfo() const; - virtual void InternReadFile( - const std::string& pFile, - aiScene* pScene, - IOSystem* pIOHandler - ); - void ReadBinaryScene( IOStream * stream, aiScene* pScene ); - void ReadBinaryNode( IOStream * stream, aiNode** mRootNode, aiNode* parent ); - void ReadBinaryMesh( IOStream * stream, aiMesh* mesh ); - void ReadBinaryBone( IOStream * stream, aiBone* bone ); - void ReadBinaryMaterial(IOStream * stream, aiMaterial* mat); - void ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop); - void ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd); - void ReadBinaryAnim( IOStream * stream, aiAnimation* anim ); - void ReadBinaryTexture(IOStream * stream, aiTexture* tex); - void ReadBinaryLight( IOStream * stream, aiLight* l ); - void ReadBinaryCamera( IOStream * stream, aiCamera* cam ); -}; - -} // end of namespace Assimp - -#endif // !! ASSIMP_BUILD_NO_ASSBIN_IMPORTER - -#endif // AI_ASSBINIMPORTER_H_INC diff --git a/src/3rdparty/assimp/code/Assimp.cpp b/src/3rdparty/assimp/code/Assimp.cpp deleted file mode 100644 index 9269f905e..000000000 --- a/src/3rdparty/assimp/code/Assimp.cpp +++ /dev/null @@ -1,694 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ -/** @file Assimp.cpp - * @brief Implementation of the Plain-C API - */ - -#include -#include -#include -#include -#include -#include - -#include "GenericProperty.h" -#include "CInterfaceIOWrapper.h" -#include "Importer.h" -#include "Exceptional.h" -#include "ScenePrivate.h" -#include "BaseImporter.h" -#include - -// ------------------------------------------------------------------------------------------------ -#ifndef ASSIMP_BUILD_SINGLETHREADED -# include -# include -#endif -// ------------------------------------------------------------------------------------------------ -using namespace Assimp; - -namespace Assimp { - // underlying structure for aiPropertyStore - typedef BatchLoader::PropertyMap PropertyMap; - - /** Stores the LogStream objects for all active C log streams */ - struct mpred { - bool operator () (const aiLogStream& s0, const aiLogStream& s1) const { - return s0.callback LogStreamMap; - - /** Stores the LogStream objects allocated by #aiGetPredefinedLogStream */ - typedef std::list PredefLogStreamMap; - - /** Local storage of all active log streams */ - static LogStreamMap gActiveLogStreams; - - /** Local storage of LogStreams allocated by #aiGetPredefinedLogStream */ - static PredefLogStreamMap gPredefinedStreams; - - /** Error message of the last failed import process */ - static std::string gLastErrorString; - - /** Verbose logging active or not? */ - static aiBool gVerboseLogging = false; - - /** will return all registered importers. */ - void GetImporterInstanceList(std::vector< BaseImporter* >& out); - - /** will delete all registered importers. */ - void DeleteImporterInstanceList(std::vector< BaseImporter* >& out); -} // namespace assimp - - -#ifndef ASSIMP_BUILD_SINGLETHREADED -/** Global mutex to manage the access to the log-stream map */ -static std::mutex gLogStreamMutex; -#endif - - -// ------------------------------------------------------------------------------------------------ -// Custom LogStream implementation for the C-API -class LogToCallbackRedirector : public LogStream { -public: - explicit LogToCallbackRedirector(const aiLogStream& s) - : stream (s) { - ai_assert(NULL != s.callback); - } - - ~LogToCallbackRedirector() { -#ifndef ASSIMP_BUILD_SINGLETHREADED - std::lock_guard lock(gLogStreamMutex); -#endif - // (HACK) Check whether the 'stream.user' pointer points to a - // custom LogStream allocated by #aiGetPredefinedLogStream. - // In this case, we need to delete it, too. Of course, this - // might cause strange problems, but the chance is quite low. - - PredefLogStreamMap::iterator it = std::find(gPredefinedStreams.begin(), - gPredefinedStreams.end(), (Assimp::LogStream*)stream.user); - - if (it != gPredefinedStreams.end()) { - delete *it; - gPredefinedStreams.erase(it); - } - } - - /** @copydoc LogStream::write */ - void write(const char* message) { - stream.callback(message,stream.user); - } - -private: - aiLogStream stream; -}; - -// ------------------------------------------------------------------------------------------------ -void ReportSceneNotFoundError() { - DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. " - "The C-API does not accept scenes produced by the C++ API and vice versa"); - - ai_assert(false); -} - -// ------------------------------------------------------------------------------------------------ -// Reads the given file and returns its content. -const aiScene* aiImportFile( const char* pFile, unsigned int pFlags) { - return aiImportFileEx(pFile,pFlags,NULL); -} - -// ------------------------------------------------------------------------------------------------ -const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags, aiFileIO* pFS) { - return aiImportFileExWithProperties(pFile, pFlags, pFS, NULL); -} - -// ------------------------------------------------------------------------------------------------ -const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFlags, - aiFileIO* pFS, const aiPropertyStore* props) { - ai_assert(NULL != pFile); - - const aiScene* scene = NULL; - ASSIMP_BEGIN_EXCEPTION_REGION(); - - // create an Importer for this file - Assimp::Importer* imp = new Assimp::Importer(); - - // copy properties - if(props) { - const PropertyMap* pp = reinterpret_cast(props); - ImporterPimpl* pimpl = imp->Pimpl(); - pimpl->mIntProperties = pp->ints; - pimpl->mFloatProperties = pp->floats; - pimpl->mStringProperties = pp->strings; - pimpl->mMatrixProperties = pp->matrices; - } - // setup a custom IO system if necessary - if (pFS) { - imp->SetIOHandler( new CIOSystemWrapper (pFS) ); - } - - // and have it read the file - scene = imp->ReadFile( pFile, pFlags); - - // if succeeded, store the importer in the scene and keep it alive - if( scene) { - ScenePrivateData* priv = const_cast( ScenePriv(scene) ); - priv->mOrigImporter = imp; - } else { - // if failed, extract error code and destroy the import - gLastErrorString = imp->GetErrorString(); - delete imp; - } - - // return imported data. If the import failed the pointer is NULL anyways - ASSIMP_END_EXCEPTION_REGION(const aiScene*); - - return scene; -} - -// ------------------------------------------------------------------------------------------------ -const aiScene* aiImportFileFromMemory( - const char* pBuffer, - unsigned int pLength, - unsigned int pFlags, - const char* pHint) -{ - return aiImportFileFromMemoryWithProperties(pBuffer, pLength, pFlags, pHint, NULL); -} - -// ------------------------------------------------------------------------------------------------ -const aiScene* aiImportFileFromMemoryWithProperties( - const char* pBuffer, - unsigned int pLength, - unsigned int pFlags, - const char* pHint, - const aiPropertyStore* props) -{ - ai_assert( NULL != pBuffer ); - ai_assert( 0 != pLength ); - - const aiScene* scene = NULL; - ASSIMP_BEGIN_EXCEPTION_REGION(); - - // create an Importer for this file - Assimp::Importer* imp = new Assimp::Importer(); - - // copy properties - if(props) { - const PropertyMap* pp = reinterpret_cast(props); - ImporterPimpl* pimpl = imp->Pimpl(); - pimpl->mIntProperties = pp->ints; - pimpl->mFloatProperties = pp->floats; - pimpl->mStringProperties = pp->strings; - pimpl->mMatrixProperties = pp->matrices; - } - - // and have it read the file from the memory buffer - scene = imp->ReadFileFromMemory( pBuffer, pLength, pFlags,pHint); - - // if succeeded, store the importer in the scene and keep it alive - if( scene) { - ScenePrivateData* priv = const_cast( ScenePriv(scene) ); - priv->mOrigImporter = imp; - } - else { - // if failed, extract error code and destroy the import - gLastErrorString = imp->GetErrorString(); - delete imp; - } - // return imported data. If the import failed the pointer is NULL anyways - ASSIMP_END_EXCEPTION_REGION(const aiScene*); - return scene; -} - -// ------------------------------------------------------------------------------------------------ -// Releases all resources associated with the given import process. -void aiReleaseImport( const aiScene* pScene) -{ - if (!pScene) { - return; - } - - ASSIMP_BEGIN_EXCEPTION_REGION(); - - // find the importer associated with this data - const ScenePrivateData* priv = ScenePriv(pScene); - if( !priv || !priv->mOrigImporter) { - delete pScene; - } - else { - // deleting the Importer also deletes the scene - // Note: the reason that this is not written as 'delete priv->mOrigImporter' - // is a suspected bug in gcc 4.4+ (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52339) - Importer* importer = priv->mOrigImporter; - delete importer; - } - - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API const aiScene* aiApplyPostProcessing(const aiScene* pScene, - unsigned int pFlags) -{ - const aiScene* sc = NULL; - - - ASSIMP_BEGIN_EXCEPTION_REGION(); - - // find the importer associated with this data - const ScenePrivateData* priv = ScenePriv(pScene); - if( !priv || !priv->mOrigImporter) { - ReportSceneNotFoundError(); - return NULL; - } - - sc = priv->mOrigImporter->ApplyPostProcessing(pFlags); - - if (!sc) { - aiReleaseImport(pScene); - return NULL; - } - - ASSIMP_END_EXCEPTION_REGION(const aiScene*); - return sc; -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API const aiScene *aiApplyCustomizedPostProcessing( const aiScene *scene, - BaseProcess* process, - bool requestValidation ) { - const aiScene* sc( NULL ); - - ASSIMP_BEGIN_EXCEPTION_REGION(); - - // find the importer associated with this data - const ScenePrivateData* priv = ScenePriv( scene ); - if ( NULL == priv || NULL == priv->mOrigImporter ) { - ReportSceneNotFoundError(); - return NULL; - } - - sc = priv->mOrigImporter->ApplyCustomizedPostProcessing( process, requestValidation ); - - if ( !sc ) { - aiReleaseImport( scene ); - return NULL; - } - - ASSIMP_END_EXCEPTION_REGION( const aiScene* ); - - return sc; -} - -// ------------------------------------------------------------------------------------------------ -void CallbackToLogRedirector (const char* msg, char* dt) -{ - ai_assert( NULL != msg ); - ai_assert( NULL != dt ); - LogStream* s = (LogStream*)dt; - - s->write(msg); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream,const char* file) -{ - aiLogStream sout; - - ASSIMP_BEGIN_EXCEPTION_REGION(); - LogStream* stream = LogStream::createDefaultStream(pStream,file); - if (!stream) { - sout.callback = NULL; - sout.user = NULL; - } - else { - sout.callback = &CallbackToLogRedirector; - sout.user = (char*)stream; - } - gPredefinedStreams.push_back(stream); - ASSIMP_END_EXCEPTION_REGION(aiLogStream); - return sout; -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiAttachLogStream( const aiLogStream* stream ) -{ - ASSIMP_BEGIN_EXCEPTION_REGION(); - -#ifndef ASSIMP_BUILD_SINGLETHREADED - std::lock_guard lock(gLogStreamMutex); -#endif - - LogStream* lg = new LogToCallbackRedirector(*stream); - gActiveLogStreams[*stream] = lg; - - if (DefaultLogger::isNullLogger()) { - DefaultLogger::create(NULL,(gVerboseLogging == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL)); - } - DefaultLogger::get()->attachStream(lg); - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream) -{ - ASSIMP_BEGIN_EXCEPTION_REGION(); - -#ifndef ASSIMP_BUILD_SINGLETHREADED - std::lock_guard lock(gLogStreamMutex); -#endif - // find the log-stream associated with this data - LogStreamMap::iterator it = gActiveLogStreams.find( *stream); - // it should be there... else the user is playing fools with us - if( it == gActiveLogStreams.end()) { - return AI_FAILURE; - } - DefaultLogger::get()->detatchStream( it->second ); - delete it->second; - - gActiveLogStreams.erase( it); - - if (gActiveLogStreams.empty()) { - DefaultLogger::kill(); - } - ASSIMP_END_EXCEPTION_REGION(aiReturn); - return AI_SUCCESS; -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiDetachAllLogStreams(void) -{ - ASSIMP_BEGIN_EXCEPTION_REGION(); -#ifndef ASSIMP_BUILD_SINGLETHREADED - std::lock_guard lock(gLogStreamMutex); -#endif - Logger *logger( DefaultLogger::get() ); - if ( NULL == logger ) { - return; - } - - for (LogStreamMap::iterator it = gActiveLogStreams.begin(); it != gActiveLogStreams.end(); ++it) { - logger->detatchStream( it->second ); - delete it->second; - } - gActiveLogStreams.clear(); - DefaultLogger::kill(); - - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiEnableVerboseLogging(aiBool d) -{ - if (!DefaultLogger::isNullLogger()) { - DefaultLogger::get()->setLogSeverity((d == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL)); - } - gVerboseLogging = d; -} - -// ------------------------------------------------------------------------------------------------ -// Returns the error text of the last failed import process. -const char* aiGetErrorString() -{ - return gLastErrorString.c_str(); -} - -// ----------------------------------------------------------------------------------------------- -// Return the description of a importer given its index -const aiImporterDesc* aiGetImportFormatDescription( size_t pIndex) -{ - return Importer().GetImporterInfo(pIndex); -} - -// ----------------------------------------------------------------------------------------------- -// Return the number of importers -size_t aiGetImportFormatCount(void) -{ - return Importer().GetImporterCount(); -} - -// ------------------------------------------------------------------------------------------------ -// Returns the error text of the last failed import process. -aiBool aiIsExtensionSupported(const char* szExtension) -{ - ai_assert(NULL != szExtension); - aiBool candoit=AI_FALSE; - ASSIMP_BEGIN_EXCEPTION_REGION(); - - // FIXME: no need to create a temporary Importer instance just for that .. - Assimp::Importer tmp; - candoit = tmp.IsExtensionSupported(std::string(szExtension)) ? AI_TRUE : AI_FALSE; - - ASSIMP_END_EXCEPTION_REGION(aiBool); - return candoit; -} - -// ------------------------------------------------------------------------------------------------ -// Get a list of all file extensions supported by ASSIMP -void aiGetExtensionList(aiString* szOut) -{ - ai_assert(NULL != szOut); - ASSIMP_BEGIN_EXCEPTION_REGION(); - - // FIXME: no need to create a temporary Importer instance just for that .. - Assimp::Importer tmp; - tmp.GetExtensionList(*szOut); - - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -// Get the memory requirements for a particular import. -void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn, - C_STRUCT aiMemoryInfo* in) -{ - ASSIMP_BEGIN_EXCEPTION_REGION(); - - // find the importer associated with this data - const ScenePrivateData* priv = ScenePriv(pIn); - if( !priv || !priv->mOrigImporter) { - ReportSceneNotFoundError(); - return; - } - - return priv->mOrigImporter->GetMemoryRequirements(*in); - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API aiPropertyStore* aiCreatePropertyStore(void) -{ - return reinterpret_cast( new PropertyMap() ); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiReleasePropertyStore(aiPropertyStore* p) -{ - delete reinterpret_cast(p); -} - -// ------------------------------------------------------------------------------------------------ -// Importer::SetPropertyInteger -ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szName, int value) -{ - ASSIMP_BEGIN_EXCEPTION_REGION(); - PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->ints,szName,value); - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -// Importer::SetPropertyFloat -ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName, ai_real value) -{ - ASSIMP_BEGIN_EXCEPTION_REGION(); - PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->floats,szName,value); - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -// Importer::SetPropertyString -ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName, - const C_STRUCT aiString* st) -{ - if (!st) { - return; - } - ASSIMP_BEGIN_EXCEPTION_REGION(); - PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->strings,szName,std::string(st->C_Str())); - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -// Importer::SetPropertyMatrix -ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName, - const C_STRUCT aiMatrix4x4* mat) -{ - if (!mat) { - return; - } - ASSIMP_BEGIN_EXCEPTION_REGION(); - PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->matrices,szName,*mat); - ASSIMP_END_EXCEPTION_REGION(void); -} - -// ------------------------------------------------------------------------------------------------ -// Rotation matrix to quaternion -ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion* quat,const aiMatrix3x3* mat) -{ - ai_assert( NULL != quat ); - ai_assert( NULL != mat ); - *quat = aiQuaternion(*mat); -} - -// ------------------------------------------------------------------------------------------------ -// Matrix decomposition -ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4* mat,aiVector3D* scaling, - aiQuaternion* rotation, - aiVector3D* position) -{ - ai_assert( NULL != rotation ); - ai_assert( NULL != position ); - ai_assert( NULL != scaling ); - ai_assert( NULL != mat ); - mat->Decompose(*scaling,*rotation,*position); -} - -// ------------------------------------------------------------------------------------------------ -// Matrix transpose -ASSIMP_API void aiTransposeMatrix3(aiMatrix3x3* mat) -{ - ai_assert(NULL != mat); - mat->Transpose(); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4* mat) -{ - ai_assert(NULL != mat); - mat->Transpose(); -} - -// ------------------------------------------------------------------------------------------------ -// Vector transformation -ASSIMP_API void aiTransformVecByMatrix3(aiVector3D* vec, - const aiMatrix3x3* mat) -{ - ai_assert( NULL != mat ); - ai_assert( NULL != vec); - *vec *= (*mat); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiTransformVecByMatrix4(aiVector3D* vec, - const aiMatrix4x4* mat) -{ - ai_assert( NULL != mat ); - ai_assert( NULL != vec ); - - *vec *= (*mat); -} - -// ------------------------------------------------------------------------------------------------ -// Matrix multiplication -ASSIMP_API void aiMultiplyMatrix4( - aiMatrix4x4* dst, - const aiMatrix4x4* src) -{ - ai_assert( NULL != dst ); - ai_assert( NULL != src ); - *dst = (*dst) * (*src); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiMultiplyMatrix3( - aiMatrix3x3* dst, - const aiMatrix3x3* src) -{ - ai_assert( NULL != dst ); - ai_assert( NULL != src ); - *dst = (*dst) * (*src); -} - -// ------------------------------------------------------------------------------------------------ -// Matrix identity -ASSIMP_API void aiIdentityMatrix3( - aiMatrix3x3* mat) -{ - ai_assert(NULL != mat); - *mat = aiMatrix3x3(); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiIdentityMatrix4( - aiMatrix4x4* mat) -{ - ai_assert(NULL != mat); - *mat = aiMatrix4x4(); -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API C_STRUCT const aiImporterDesc* aiGetImporterDesc( const char *extension ) { - if( NULL == extension ) { - return NULL; - } - const aiImporterDesc *desc( NULL ); - std::vector< BaseImporter* > out; - GetImporterInstanceList( out ); - for( size_t i = 0; i < out.size(); ++i ) { - if( 0 == strncmp( out[ i ]->GetInfo()->mFileExtensions, extension, strlen( extension ) ) ) { - desc = out[ i ]->GetInfo(); - break; - } - } - - DeleteImporterInstanceList(out); - - return desc; -} - -// ------------------------------------------------------------------------------------------------ diff --git a/src/3rdparty/assimp/code/AssimpCExport.cpp b/src/3rdparty/assimp/code/AssimpCExport.cpp deleted file mode 100644 index b8d3264a1..000000000 --- a/src/3rdparty/assimp/code/AssimpCExport.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file AssimpCExport.cpp -Assimp C export interface. See Exporter.cpp for some notes. -*/ - -#ifndef ASSIMP_BUILD_NO_EXPORT - -#include "CInterfaceIOWrapper.h" -#include -#include "ScenePrivate.h" -#include - -using namespace Assimp; - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API size_t aiGetExportFormatCount(void) -{ - return Exporter().GetExportFormatCount(); -} - - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index) -{ - // Note: this is valid as the index always pertains to a built-in exporter, - // for which the returned structure is guaranteed to be of static storage duration. - Exporter exporter; - const aiExportFormatDesc* orig( exporter.GetExportFormatDescription( index ) ); - if (NULL == orig) { - return NULL; - } - - aiExportFormatDesc *desc = new aiExportFormatDesc; - desc->description = new char[ strlen( orig->description ) + 1 ](); - ::strncpy( (char*) desc->description, orig->description, strlen( orig->description ) ); - desc->fileExtension = new char[ strlen( orig->fileExtension ) + 1 ](); - ::strncpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) ); - desc->id = new char[ strlen( orig->id ) + 1 ](); - ::strncpy( ( char* ) desc->id, orig->id, strlen( orig->id ) ); - - return desc; -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiReleaseExportFormatDescription( const aiExportFormatDesc *desc ) { - if (NULL == desc) { - return; - } - - delete [] desc->description; - delete [] desc->fileExtension; - delete [] desc->id; - delete desc; -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) -{ - if (!pOut || !pIn) { - return; - } - - SceneCombiner::CopyScene(pOut,pIn,true); - ScenePriv(*pOut)->mIsCopy = true; -} - - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn) -{ - // note: aiReleaseImport() is also able to delete scene copies, but in addition - // it also handles scenes with import metadata. - delete pIn; -} - - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API aiReturn aiExportScene( const aiScene* pScene, const char* pFormatId, const char* pFileName, unsigned int pPreprocessing ) -{ - return ::aiExportSceneEx(pScene,pFormatId,pFileName,NULL,pPreprocessing); -} - - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API aiReturn aiExportSceneEx( const aiScene* pScene, const char* pFormatId, const char* pFileName, aiFileIO* pIO, unsigned int pPreprocessing ) -{ - Exporter exp; - - if (pIO) { - exp.SetIOHandler(new CIOSystemWrapper(pIO)); - } - return exp.Export(pScene,pFormatId,pFileName,pPreprocessing); -} - - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing ) -{ - Exporter exp; - if (!exp.ExportToBlob(pScene,pFormatId,pPreprocessing)) { - return NULL; - } - const aiExportDataBlob* blob = exp.GetOrphanedBlob(); - ai_assert(blob); - - return blob; -} - -// ------------------------------------------------------------------------------------------------ -ASSIMP_API C_STRUCT void aiReleaseExportBlob( const aiExportDataBlob* pData ) -{ - delete pData; -} - -#endif // !ASSIMP_BUILD_NO_EXPORT diff --git a/src/3rdparty/assimp/code/AssxmlExporter.cpp b/src/3rdparty/assimp/code/AssxmlExporter.cpp deleted file mode 100644 index 90ed66701..000000000 --- a/src/3rdparty/assimp/code/AssxmlExporter.cpp +++ /dev/null @@ -1,648 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ -/** @file AssxmlExporter.cpp - * ASSXML exporter main code - */ -#include -#include -#include "ProcessHelper.h" -#include -#include -#include - -#ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include -#else -# include -#endif - -#include -#include - -#ifndef ASSIMP_BUILD_NO_EXPORT -#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER - -using namespace Assimp; - -namespace Assimp { - -namespace AssxmlExport { - -// ----------------------------------------------------------------------------------- -static int ioprintf( IOStream * io, const char *format, ... ) { - using namespace std; - if ( nullptr == io ) { - return -1; - } - - static const int Size = 4096; - char sz[ Size ]; - ::memset( sz, '\0', Size ); - va_list va; - va_start( va, format ); - const unsigned int nSize = vsnprintf( sz, Size-1, format, va ); - ai_assert( nSize < Size ); - va_end( va ); - - io->Write( sz, sizeof(char), nSize ); - - return nSize; -} - -// ----------------------------------------------------------------------------------- -// Convert a name to standard XML format -static void ConvertName(aiString& out, const aiString& in) { - out.length = 0; - for (unsigned int i = 0; i < in.length; ++i) { - switch (in.data[i]) { - case '<': - out.Append("<");break; - case '>': - out.Append(">");break; - case '&': - out.Append("&");break; - case '\"': - out.Append(""");break; - case '\'': - out.Append("'");break; - default: - out.data[out.length++] = in.data[i]; - } - } - out.data[out.length] = 0; -} - -// ----------------------------------------------------------------------------------- -// Write a single node as text dump -static void WriteNode(const aiNode* node, IOStream * io, unsigned int depth) { - char prefix[512]; - for (unsigned int i = 0; i < depth;++i) - prefix[i] = '\t'; - prefix[depth] = '\0'; - - const aiMatrix4x4& m = node->mTransformation; - - aiString name; - ConvertName(name,node->mName); - ioprintf(io,"%s \n" - "%s\t \n" - "%s\t\t%0 6f %0 6f %0 6f %0 6f\n" - "%s\t\t%0 6f %0 6f %0 6f %0 6f\n" - "%s\t\t%0 6f %0 6f %0 6f %0 6f\n" - "%s\t\t%0 6f %0 6f %0 6f %0 6f\n" - "%s\t \n", - prefix,name.data,prefix, - prefix,m.a1,m.a2,m.a3,m.a4, - prefix,m.b1,m.b2,m.b3,m.b4, - prefix,m.c1,m.c2,m.c3,m.c4, - prefix,m.d1,m.d2,m.d3,m.d4,prefix); - - if (node->mNumMeshes) { - ioprintf(io, "%s\t\n%s\t", - prefix,node->mNumMeshes,prefix); - - for (unsigned int i = 0; i < node->mNumMeshes;++i) { - ioprintf(io,"%i ",node->mMeshes[i]); - } - ioprintf(io,"\n%s\t\n",prefix); - } - - if (node->mNumChildren) { - ioprintf(io,"%s\t\n", - prefix,node->mNumChildren); - - for (unsigned int i = 0; i < node->mNumChildren;++i) { - WriteNode(node->mChildren[i],io,depth+2); - } - ioprintf(io,"%s\t\n",prefix); - } - ioprintf(io,"%s\n",prefix); -} - - -// ----------------------------------------------------------------------------------- -// Some chuncks of text will need to be encoded for XML -// http://stackoverflow.com/questions/5665231/most-efficient-way-to-escape-xml-html-in-c-string#5665377 -static std::string encodeXML(const std::string& data) { - std::string buffer; - buffer.reserve(data.size()); - for(size_t pos = 0; pos != data.size(); ++pos) { - switch(data[pos]) { - case '&': buffer.append("&"); break; - case '\"': buffer.append("""); break; - case '\'': buffer.append("'"); break; - case '<': buffer.append("<"); break; - case '>': buffer.append(">"); break; - default: buffer.append(&data[pos], 1); break; - } - } - return buffer; -} - -// ----------------------------------------------------------------------------------- -// Write a text model dump -static -void WriteDump(const aiScene* scene, IOStream* io, bool shortened) { - time_t tt = ::time( NULL ); - tm* p = ::gmtime( &tt ); - ai_assert( nullptr != p ); - - // write header - std::string header( - "\n" - "\n\n" - "" - " \n\n" - "\n" - ); - - const unsigned int majorVersion( aiGetVersionMajor() ); - const unsigned int minorVersion( aiGetVersionMinor() ); - const unsigned int rev( aiGetVersionRevision() ); - const char *curtime( asctime( p ) ); - ioprintf( io, header.c_str(), majorVersion, minorVersion, rev, curtime, scene->mFlags, 0 ); - - // write the node graph - WriteNode(scene->mRootNode, io, 0); - -#if 0 - // write cameras - for (unsigned int i = 0; i < scene->mNumCameras;++i) { - aiCamera* cam = scene->mCameras[i]; - ConvertName(name,cam->mName); - - // camera header - ioprintf(io,"\t\n" - "\t\t %0 8f %0 8f %0 8f \n" - "\t\t %0 8f %0 8f %0 8f \n" - "\t\t %0 8f %0 8f %0 8f \n" - "\t\t %f \n" - "\t\t %f \n" - "\t\t %f \n" - "\t\t %f \n" - "\t\n", - name.data, - cam->mUp.x,cam->mUp.y,cam->mUp.z, - cam->mLookAt.x,cam->mLookAt.y,cam->mLookAt.z, - cam->mPosition.x,cam->mPosition.y,cam->mPosition.z, - cam->mHorizontalFOV,cam->mAspect,cam->mClipPlaneNear,cam->mClipPlaneFar,i); - } - - // write lights - for (unsigned int i = 0; i < scene->mNumLights;++i) { - aiLight* l = scene->mLights[i]; - ConvertName(name,l->mName); - - // light header - ioprintf(io,"\t type=\"%s\"\n" - "\t\t %0 8f %0 8f %0 8f \n" - "\t\t %0 8f %0 8f %0 8f \n" - "\t\t %0 8f %0 8f %0 8f \n", - name.data, - (l->mType == aiLightSource_DIRECTIONAL ? "directional" : - (l->mType == aiLightSource_POINT ? "point" : "spot" )), - l->mColorDiffuse.r, l->mColorDiffuse.g, l->mColorDiffuse.b, - l->mColorSpecular.r,l->mColorSpecular.g,l->mColorSpecular.b, - l->mColorAmbient.r, l->mColorAmbient.g, l->mColorAmbient.b); - - if (l->mType != aiLightSource_DIRECTIONAL) { - ioprintf(io, - "\t\t %0 8f %0 8f %0 8f \n" - "\t\t %f \n" - "\t\t %f \n" - "\t\t %f \n", - l->mPosition.x,l->mPosition.y,l->mPosition.z, - l->mAttenuationConstant,l->mAttenuationLinear,l->mAttenuationQuadratic); - } - - if (l->mType != aiLightSource_POINT) { - ioprintf(io, - "\t\t %0 8f %0 8f %0 8f \n", - l->mDirection.x,l->mDirection.y,l->mDirection.z); - } - - if (l->mType == aiLightSource_SPOT) { - ioprintf(io, - "\t\t %f \n" - "\t\t %f \n", - l->mAngleOuterCone,l->mAngleInnerCone); - } - ioprintf(io,"\t\n"); - } -#endif - aiString name; - - // write textures - if (scene->mNumTextures) { - ioprintf(io,"\n",scene->mNumTextures); - for (unsigned int i = 0; i < scene->mNumTextures;++i) { - aiTexture* tex = scene->mTextures[i]; - bool compressed = (tex->mHeight == 0); - - // mesh header - ioprintf(io,"\t \n", - (compressed ? -1 : tex->mWidth),(compressed ? -1 : tex->mHeight), - (compressed ? "true" : "false")); - - if (compressed) { - ioprintf(io,"\t\t \n",tex->mWidth); - - if (!shortened) { - for (unsigned int n = 0; n < tex->mWidth;++n) { - ioprintf(io,"\t\t\t%2x",reinterpret_cast(tex->pcData)[n]); - if (n && !(n % 50)) { - ioprintf(io,"\n"); - } - } - } - } - else if (!shortened){ - ioprintf(io,"\t\t \n",tex->mWidth*tex->mHeight*4); - - // const unsigned int width = (unsigned int)std::log10((double)std::max(tex->mHeight,tex->mWidth))+1; - for (unsigned int y = 0; y < tex->mHeight;++y) { - for (unsigned int x = 0; x < tex->mWidth;++x) { - aiTexel* tx = tex->pcData + y*tex->mWidth+x; - unsigned int r = tx->r,g=tx->g,b=tx->b,a=tx->a; - ioprintf(io,"\t\t\t%2x %2x %2x %2x",r,g,b,a); - - // group by four for readability - if ( 0 == ( x + y*tex->mWidth ) % 4 ) { - ioprintf( io, "\n" ); - } - } - } - } - ioprintf(io,"\t\t\n\t\n"); - } - ioprintf(io,"\n"); - } - - // write materials - if (scene->mNumMaterials) { - ioprintf(io,"\n",scene->mNumMaterials); - for (unsigned int i = 0; i< scene->mNumMaterials; ++i) { - const aiMaterial* mat = scene->mMaterials[i]; - - ioprintf(io,"\t\n"); - ioprintf(io,"\t\t\n",mat->mNumProperties); - for (unsigned int n = 0; n < mat->mNumProperties;++n) { - - const aiMaterialProperty* prop = mat->mProperties[n]; - const char* sz = ""; - if (prop->mType == aiPTI_Float) { - sz = "float"; - } - else if (prop->mType == aiPTI_Integer) { - sz = "integer"; - } - else if (prop->mType == aiPTI_String) { - sz = "string"; - } - else if (prop->mType == aiPTI_Buffer) { - sz = "binary_buffer"; - } - - ioprintf(io,"\t\t\tmKey.data, sz, - ::TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex); - - if (prop->mType == aiPTI_Float) { - ioprintf(io," size=\"%i\">\n\t\t\t\t", - static_cast(prop->mDataLength/sizeof(float))); - - for (unsigned int p = 0; p < prop->mDataLength/sizeof(float);++p) { - ioprintf(io,"%f ",*((float*)(prop->mData+p*sizeof(float)))); - } - } - else if (prop->mType == aiPTI_Integer) { - ioprintf(io," size=\"%i\">\n\t\t\t\t", - static_cast(prop->mDataLength/sizeof(int))); - - for (unsigned int p = 0; p < prop->mDataLength/sizeof(int);++p) { - ioprintf(io,"%i ",*((int*)(prop->mData+p*sizeof(int)))); - } - } - else if (prop->mType == aiPTI_Buffer) { - ioprintf(io," size=\"%i\">\n\t\t\t\t", - static_cast(prop->mDataLength)); - - for (unsigned int p = 0; p < prop->mDataLength;++p) { - ioprintf(io,"%2x ",prop->mData[p]); - if (p && 0 == p%30) { - ioprintf(io,"\n\t\t\t\t"); - } - } - } - else if (prop->mType == aiPTI_String) { - ioprintf(io,">\n\t\t\t\t\"%s\"",encodeXML(prop->mData+4).c_str() /* skip length */); - } - ioprintf(io,"\n\t\t\t\n"); - } - ioprintf(io,"\t\t\n"); - ioprintf(io,"\t\n"); - } - ioprintf(io,"\n"); - } - - // write animations - if (scene->mNumAnimations) { - ioprintf(io,"\n",scene->mNumAnimations); - for (unsigned int i = 0; i < scene->mNumAnimations;++i) { - aiAnimation* anim = scene->mAnimations[i]; - - // anim header - ConvertName(name,anim->mName); - ioprintf(io,"\t\n", - name.data, anim->mDuration, anim->mTicksPerSecond); - - // write bone animation channels - if (anim->mNumChannels) { - ioprintf(io,"\t\t\n",anim->mNumChannels); - for (unsigned int n = 0; n < anim->mNumChannels;++n) { - aiNodeAnim* nd = anim->mChannels[n]; - - // node anim header - ConvertName(name,nd->mNodeName); - ioprintf(io,"\t\t\t\n",name.data); - - if (!shortened) { - // write position keys - if (nd->mNumPositionKeys) { - ioprintf(io,"\t\t\t\t\n",nd->mNumPositionKeys); - for (unsigned int a = 0; a < nd->mNumPositionKeys;++a) { - aiVectorKey* vc = nd->mPositionKeys+a; - ioprintf(io,"\t\t\t\t\t\n" - "\t\t\t\t\t\t%0 8f %0 8f %0 8f\n\t\t\t\t\t\n", - vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z); - } - ioprintf(io,"\t\t\t\t\n"); - } - - // write scaling keys - if (nd->mNumScalingKeys) { - ioprintf(io,"\t\t\t\t\n",nd->mNumScalingKeys); - for (unsigned int a = 0; a < nd->mNumScalingKeys;++a) { - aiVectorKey* vc = nd->mScalingKeys+a; - ioprintf(io,"\t\t\t\t\t\n" - "\t\t\t\t\t\t%0 8f %0 8f %0 8f\n\t\t\t\t\t\n", - vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z); - } - ioprintf(io,"\t\t\t\t\n"); - } - - // write rotation keys - if (nd->mNumRotationKeys) { - ioprintf(io,"\t\t\t\t\n",nd->mNumRotationKeys); - for (unsigned int a = 0; a < nd->mNumRotationKeys;++a) { - aiQuatKey* vc = nd->mRotationKeys+a; - ioprintf(io,"\t\t\t\t\t\n" - "\t\t\t\t\t\t%0 8f %0 8f %0 8f %0 8f\n\t\t\t\t\t\n", - vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z,vc->mValue.w); - } - ioprintf(io,"\t\t\t\t\n"); - } - } - ioprintf(io,"\t\t\t\n"); - } - ioprintf(io,"\t\t\n"); - } - ioprintf(io,"\t\n"); - } - ioprintf(io,"\n"); - } - - // write meshes - if (scene->mNumMeshes) { - ioprintf(io,"\n",scene->mNumMeshes); - for (unsigned int i = 0; i < scene->mNumMeshes;++i) { - aiMesh* mesh = scene->mMeshes[i]; - // const unsigned int width = (unsigned int)std::log10((double)mesh->mNumVertices)+1; - - // mesh header - ioprintf(io,"\t\n", - (mesh->mPrimitiveTypes & aiPrimitiveType_POINT ? "points" : ""), - (mesh->mPrimitiveTypes & aiPrimitiveType_LINE ? "lines" : ""), - (mesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE ? "triangles" : ""), - (mesh->mPrimitiveTypes & aiPrimitiveType_POLYGON ? "polygons" : ""), - mesh->mMaterialIndex); - - // bones - if (mesh->mNumBones) { - ioprintf(io,"\t\t\n",mesh->mNumBones); - - for (unsigned int n = 0; n < mesh->mNumBones;++n) { - aiBone* bone = mesh->mBones[n]; - - ConvertName(name,bone->mName); - // bone header - ioprintf(io,"\t\t\t\n" - "\t\t\t\t \n" - "\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n" - "\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n" - "\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n" - "\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n" - "\t\t\t\t \n", - name.data, - bone->mOffsetMatrix.a1,bone->mOffsetMatrix.a2,bone->mOffsetMatrix.a3,bone->mOffsetMatrix.a4, - bone->mOffsetMatrix.b1,bone->mOffsetMatrix.b2,bone->mOffsetMatrix.b3,bone->mOffsetMatrix.b4, - bone->mOffsetMatrix.c1,bone->mOffsetMatrix.c2,bone->mOffsetMatrix.c3,bone->mOffsetMatrix.c4, - bone->mOffsetMatrix.d1,bone->mOffsetMatrix.d2,bone->mOffsetMatrix.d3,bone->mOffsetMatrix.d4); - - if (!shortened && bone->mNumWeights) { - ioprintf(io,"\t\t\t\t\n",bone->mNumWeights); - - // bone weights - for (unsigned int a = 0; a < bone->mNumWeights;++a) { - aiVertexWeight* wght = bone->mWeights+a; - - ioprintf(io,"\t\t\t\t\t\n\t\t\t\t\t\t%f\n\t\t\t\t\t\n", - wght->mVertexId,wght->mWeight); - } - ioprintf(io,"\t\t\t\t\n"); - } - ioprintf(io,"\t\t\t\n"); - } - ioprintf(io,"\t\t\n"); - } - - // faces - if (!shortened && mesh->mNumFaces) { - ioprintf(io,"\t\t\n",mesh->mNumFaces); - for (unsigned int n = 0; n < mesh->mNumFaces; ++n) { - aiFace& f = mesh->mFaces[n]; - ioprintf(io,"\t\t\t\n" - "\t\t\t\t",f.mNumIndices); - - for (unsigned int j = 0; j < f.mNumIndices;++j) - ioprintf(io,"%i ",f.mIndices[j]); - - ioprintf(io,"\n\t\t\t\n"); - } - ioprintf(io,"\t\t\n"); - } - - // vertex positions - if (mesh->HasPositions()) { - ioprintf(io,"\t\t \n",mesh->mNumVertices); - if (!shortened) { - for (unsigned int n = 0; n < mesh->mNumVertices; ++n) { - ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n", - mesh->mVertices[n].x, - mesh->mVertices[n].y, - mesh->mVertices[n].z); - } - } - ioprintf(io,"\t\t\n"); - } - - // vertex normals - if (mesh->HasNormals()) { - ioprintf(io,"\t\t \n",mesh->mNumVertices); - if (!shortened) { - for (unsigned int n = 0; n < mesh->mNumVertices; ++n) { - ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n", - mesh->mNormals[n].x, - mesh->mNormals[n].y, - mesh->mNormals[n].z); - } - } - else { - } - ioprintf(io,"\t\t\n"); - } - - // vertex tangents and bitangents - if (mesh->HasTangentsAndBitangents()) { - ioprintf(io,"\t\t \n",mesh->mNumVertices); - if (!shortened) { - for (unsigned int n = 0; n < mesh->mNumVertices; ++n) { - ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n", - mesh->mTangents[n].x, - mesh->mTangents[n].y, - mesh->mTangents[n].z); - } - } - ioprintf(io,"\t\t\n"); - - ioprintf(io,"\t\t \n",mesh->mNumVertices); - if (!shortened) { - for (unsigned int n = 0; n < mesh->mNumVertices; ++n) { - ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n", - mesh->mBitangents[n].x, - mesh->mBitangents[n].y, - mesh->mBitangents[n].z); - } - } - ioprintf(io,"\t\t\n"); - } - - // texture coordinates - for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { - if (!mesh->mTextureCoords[a]) - break; - - ioprintf(io,"\t\t \n",mesh->mNumVertices, - a,mesh->mNumUVComponents[a]); - - if (!shortened) { - if (mesh->mNumUVComponents[a] == 3) { - for (unsigned int n = 0; n < mesh->mNumVertices; ++n) { - ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n", - mesh->mTextureCoords[a][n].x, - mesh->mTextureCoords[a][n].y, - mesh->mTextureCoords[a][n].z); - } - } - else { - for (unsigned int n = 0; n < mesh->mNumVertices; ++n) { - ioprintf(io,"\t\t%0 8f %0 8f\n", - mesh->mTextureCoords[a][n].x, - mesh->mTextureCoords[a][n].y); - } - } - } - ioprintf(io,"\t\t\n"); - } - - // vertex colors - for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) { - if (!mesh->mColors[a]) - break; - ioprintf(io,"\t\t \n",mesh->mNumVertices,a); - if (!shortened) { - for (unsigned int n = 0; n < mesh->mNumVertices; ++n) { - ioprintf(io,"\t\t%0 8f %0 8f %0 8f %0 8f\n", - mesh->mColors[a][n].r, - mesh->mColors[a][n].g, - mesh->mColors[a][n].b, - mesh->mColors[a][n].a); - } - } - ioprintf(io,"\t\t\n"); - } - ioprintf(io,"\t\n"); - } - ioprintf(io,"\n"); - } - ioprintf(io,"\n"); -} - -} // end of namespace AssxmlExport - -void ExportSceneAssxml(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) -{ - IOStream * out = pIOSystem->Open( pFile, "wt" ); - if (!out) return; - - bool shortened = false; - AssxmlExport::WriteDump( pScene, out, shortened ); - - pIOSystem->Close( out ); -} - -} // end of namespace Assimp - -#endif // ASSIMP_BUILD_NO_ASSXML_EXPORTER -#endif // ASSIMP_BUILD_NO_EXPORT diff --git a/src/3rdparty/assimp/code/AssxmlExporter.h b/src/3rdparty/assimp/code/AssxmlExporter.h deleted file mode 100644 index 9694f74a3..000000000 --- a/src/3rdparty/assimp/code/AssxmlExporter.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file AssxmlExporter.h - * ASSXML Exporter Main Header - */ -#ifndef AI_ASSXMLEXPORTER_H_INC -#define AI_ASSXMLEXPORTER_H_INC - -// nothing really needed here - reserved for future use like properties - -#endif diff --git a/src/3rdparty/assimp/code/B3DImporter.cpp b/src/3rdparty/assimp/code/B3DImporter.cpp deleted file mode 100644 index bc888fb66..000000000 --- a/src/3rdparty/assimp/code/B3DImporter.cpp +++ /dev/null @@ -1,719 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file B3DImporter.cpp - * @brief Implementation of the b3d importer class - */ - - -#ifndef ASSIMP_BUILD_NO_B3D_IMPORTER - -// internal headers -#include "B3DImporter.h" -#include "TextureTransform.h" -#include "ConvertToLHProcess.h" -#include "StringUtils.h" -#include -#include -#include -#include -#include -#include - -using namespace Assimp; -using namespace std; - -static const aiImporterDesc desc = { - "BlitzBasic 3D Importer", - "", - "", - "http://www.blitzbasic.com/", - aiImporterFlags_SupportBinaryFlavour, - 0, - 0, - 0, - 0, - "b3d" -}; - -// (fixme, Aramis) quick workaround to get rid of all those signed to unsigned warnings -#ifdef _MSC_VER -# pragma warning (disable: 4018) -#endif - -//#define DEBUG_B3D - -template -void DeleteAllBarePointers(std::vector& x) -{ - for(auto p : x) - { - delete p; - } -} - -B3DImporter::~B3DImporter() -{ - DeleteAllBarePointers(_animations); -} - -// ------------------------------------------------------------------------------------------------ -bool B3DImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const{ - - size_t pos=pFile.find_last_of( '.' ); - if( pos==string::npos ) return false; - - string ext=pFile.substr( pos+1 ); - if( ext.size()!=3 ) return false; - - return (ext[0]=='b' || ext[0]=='B') && (ext[1]=='3') && (ext[2]=='d' || ext[2]=='D'); -} - -// ------------------------------------------------------------------------------------------------ -// Loader meta information -const aiImporterDesc* B3DImporter::GetInfo () const -{ - return &desc; -} - -#ifdef DEBUG_B3D - extern "C"{ void _stdcall AllocConsole(); } -#endif -// ------------------------------------------------------------------------------------------------ -void B3DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler){ - -#ifdef DEBUG_B3D - AllocConsole(); - freopen( "conin$","r",stdin ); - freopen( "conout$","w",stdout ); - freopen( "conout$","w",stderr ); - cout<<"Hello world from the B3DImporter!"< file( pIOHandler->Open( pFile)); - - // Check whether we can read from the file - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open B3D file " + pFile + "."); - - // check whether the .b3d file is large enough to contain - // at least one chunk. - size_t fileSize = file->FileSize(); - if( fileSize<8 ) throw DeadlyImportError( "B3D File is too small."); - - _pos=0; - _buf.resize( fileSize ); - file->Read( &_buf[0],1,fileSize ); - _stack.clear(); - - ReadBB3D( pScene ); -} - -// ------------------------------------------------------------------------------------------------ -AI_WONT_RETURN void B3DImporter::Oops(){ - throw DeadlyImportError( "B3D Importer - INTERNAL ERROR" ); -} - -// ------------------------------------------------------------------------------------------------ -AI_WONT_RETURN void B3DImporter::Fail( string str ){ -#ifdef DEBUG_B3D - cout<<"Error in B3D file data: "< -T *B3DImporter::to_array( const vector &v ){ - if( v.empty() ) { - return 0; - } - T *p=new T[ v.size() ]; - for( size_t i=0;i8 ){ - Fail( "Bad texture count" ); - } - while( ChunkSize() ){ - string name=ReadString(); - aiVector3D color=ReadVec3(); - float alpha=ReadFloat(); - float shiny=ReadFloat(); - /*int blend=**/ReadInt(); - int fx=ReadInt(); - - aiMaterial *mat=new aiMaterial; - _materials.push_back( mat ); - - // Name - aiString ainame( name ); - mat->AddProperty( &ainame,AI_MATKEY_NAME ); - - // Diffuse color - mat->AddProperty( &color,1,AI_MATKEY_COLOR_DIFFUSE ); - - // Opacity - mat->AddProperty( &alpha,1,AI_MATKEY_OPACITY ); - - // Specular color - aiColor3D speccolor( shiny,shiny,shiny ); - mat->AddProperty( &speccolor,1,AI_MATKEY_COLOR_SPECULAR ); - - // Specular power - float specpow=shiny*128; - mat->AddProperty( &specpow,1,AI_MATKEY_SHININESS ); - - // Double sided - if( fx & 0x10 ){ - int i=1; - mat->AddProperty( &i,1,AI_MATKEY_TWOSIDED ); - } - - //Textures - for( int i=0;i=0 && texid>=static_cast(_textures.size())) ){ - Fail( "Bad texture id" ); - } - if( i==0 && texid>=0 ){ - aiString texname( _textures[texid] ); - mat->AddProperty( &texname,AI_MATKEY_TEXTURE_DIFFUSE(0) ); - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -void B3DImporter::ReadVRTS(){ - _vflags=ReadInt(); - _tcsets=ReadInt(); - _tcsize=ReadInt(); - if( _tcsets<0 || _tcsets>4 || _tcsize<0 || _tcsize>4 ){ - Fail( "Bad texcoord data" ); - } - - int sz=12+(_vflags&1?12:0)+(_vflags&2?16:0)+(_tcsets*_tcsize*4); - int n_verts=ChunkSize()/sz; - - int v0=static_cast(_vertices.size()); - _vertices.resize( v0+n_verts ); - - for( int i=0;i=(int)_materials.size() ){ -#ifdef DEBUG_B3D - cout<<"material id="<mMaterialIndex=matid; - mesh->mNumFaces=0; - mesh->mPrimitiveTypes=aiPrimitiveType_TRIANGLE; - - int n_tris=ChunkSize()/12; - aiFace *face=mesh->mFaces=new aiFace[n_tris]; - - for( int i=0;i=(int)_vertices.size() || i1<0 || i1>=(int)_vertices.size() || i2<0 || i2>=(int)_vertices.size() ){ -#ifdef DEBUG_B3D - cout<<"Bad triangle index: i0="<mNumIndices=3; - face->mIndices=new unsigned[3]; - face->mIndices[0]=i0; - face->mIndices[1]=i1; - face->mIndices[2]=i2; - ++mesh->mNumFaces; - ++face; - } -} - -// ------------------------------------------------------------------------------------------------ -void B3DImporter::ReadMESH(){ - /*int matid=*/ReadInt(); - - int v0= static_cast(_vertices.size()); - - while( ChunkSize() ){ - string t=ReadChunk(); - if( t=="VRTS" ){ - ReadVRTS(); - }else if( t=="TRIS" ){ - ReadTRIS( v0 ); - } - ExitChunk(); - } -} - -// ------------------------------------------------------------------------------------------------ -void B3DImporter::ReadBONE( int id ){ - while( ChunkSize() ){ - int vertex=ReadInt(); - float weight=ReadFloat(); - if( vertex<0 || vertex>=(int)_vertices.size() ){ - Fail( "Bad vertex index" ); - } - - Vertex &v=_vertices[vertex]; - int i; - for( i=0;i<4;++i ){ - if( !v.weights[i] ){ - v.bones[i]=id; - v.weights[i]=weight; - break; - } - } -#ifdef DEBUG_B3D - if( i==4 ){ - cout<<"Too many bone weights"< trans,scale; - vector rot; - int flags=ReadInt(); - while( ChunkSize() ){ - int frame=ReadInt(); - if( flags & 1 ){ - trans.push_back( aiVectorKey( frame,ReadVec3() ) ); - } - if( flags & 2 ){ - scale.push_back( aiVectorKey( frame,ReadVec3() ) ); - } - if( flags & 4 ){ - rot.push_back( aiQuatKey( frame,ReadQuat() ) ); - } - } - - if( flags & 1 ){ - nodeAnim->mNumPositionKeys=static_cast(trans.size()); - nodeAnim->mPositionKeys=to_array( trans ); - } - - if( flags & 2 ){ - nodeAnim->mNumScalingKeys=static_cast(scale.size()); - nodeAnim->mScalingKeys=to_array( scale ); - } - - if( flags & 4 ){ - nodeAnim->mNumRotationKeys=static_cast(rot.size()); - nodeAnim->mRotationKeys=to_array( rot ); - } -} - -// ------------------------------------------------------------------------------------------------ -void B3DImporter::ReadANIM(){ - /*int flags=*/ReadInt(); - int frames=ReadInt(); - float fps=ReadFloat(); - - aiAnimation *anim=new aiAnimation; - _animations.push_back( anim ); - - anim->mDuration=frames; - anim->mTicksPerSecond=fps; -} - -// ------------------------------------------------------------------------------------------------ -aiNode *B3DImporter::ReadNODE( aiNode *parent ){ - - string name=ReadString(); - aiVector3D t=ReadVec3(); - aiVector3D s=ReadVec3(); - aiQuaternion r=ReadQuat(); - - aiMatrix4x4 trans,scale,rot; - - aiMatrix4x4::Translation( t,trans ); - aiMatrix4x4::Scaling( s,scale ); - rot=aiMatrix4x4( r.GetMatrix() ); - - aiMatrix4x4 tform=trans * rot * scale; - - int nodeid=static_cast(_nodes.size()); - - aiNode *node=new aiNode( name ); - _nodes.push_back( node ); - - node->mParent=parent; - node->mTransformation=tform; - - aiNodeAnim *nodeAnim=0; - vector meshes; - vector children; - - while( ChunkSize() ){ - string t=ReadChunk(); - if( t=="MESH" ){ - unsigned int n= static_cast(_meshes.size()); - ReadMESH(); - for( unsigned int i=n;i(_meshes.size());++i ){ - meshes.push_back( i ); - } - }else if( t=="BONE" ){ - ReadBONE( nodeid ); - }else if( t=="ANIM" ){ - ReadANIM(); - }else if( t=="KEYS" ){ - if( !nodeAnim ){ - nodeAnim=new aiNodeAnim; - _nodeAnims.push_back( nodeAnim ); - nodeAnim->mNodeName=node->mName; - } - ReadKEYS( nodeAnim ); - }else if( t=="NODE" ){ - aiNode *child=ReadNODE( node ); - children.push_back( child ); - } - ExitChunk(); - } - - node->mNumMeshes= static_cast(meshes.size()); - node->mMeshes=to_array( meshes ); - - node->mNumChildren=static_cast(children.size()); - node->mChildren=to_array( children ); - - return node; -} - -// ------------------------------------------------------------------------------------------------ -void B3DImporter::ReadBB3D( aiScene *scene ){ - - _textures.clear(); - - _materials.clear(); - - _vertices.clear(); - - _meshes.clear(); - - DeleteAllBarePointers(_nodes); - _nodes.clear(); - - _nodeAnims.clear(); - - DeleteAllBarePointers(_animations); - _animations.clear(); - - string t=ReadChunk(); - if( t=="BB3D" ){ - int version=ReadInt(); - - if (!DefaultLogger::isNullLogger()) { - char dmp[128]; - ai_snprintf(dmp, 128, "B3D file format version: %i",version); - DefaultLogger::get()->info(dmp); - } - - while( ChunkSize() ){ - string t=ReadChunk(); - if( t=="TEXS" ){ - ReadTEXS(); - }else if( t=="BRUS" ){ - ReadBRUS(); - }else if( t=="NODE" ){ - ReadNODE( 0 ); - } - ExitChunk(); - } - } - ExitChunk(); - - if( !_nodes.size() ) Fail( "No nodes" ); - - if( !_meshes.size() ) Fail( "No meshes" ); - - //Fix nodes/meshes/bones - for(size_t i=0;i<_nodes.size();++i ){ - aiNode *node=_nodes[i]; - - for( size_t j=0;jmNumMeshes;++j ){ - aiMesh *mesh=_meshes[node->mMeshes[j]]; - - int n_tris=mesh->mNumFaces; - int n_verts=mesh->mNumVertices=n_tris * 3; - - aiVector3D *mv=mesh->mVertices=new aiVector3D[ n_verts ],*mn=0,*mc=0; - if( _vflags & 1 ) mn=mesh->mNormals=new aiVector3D[ n_verts ]; - if( _tcsets ) mc=mesh->mTextureCoords[0]=new aiVector3D[ n_verts ]; - - aiFace *face=mesh->mFaces; - - vector< vector > vweights( _nodes.size() ); - - for( int i=0;imIndices[j]]; - - *mv++=v.vertex; - if( mn ) *mn++=v.normal; - if( mc ) *mc++=v.texcoords; - - face->mIndices[j]=i+j; - - for( int k=0;k<4;++k ){ - if( !v.weights[k] ) break; - - int bone=v.bones[k]; - float weight=v.weights[k]; - - vweights[bone].push_back( aiVertexWeight(i+j,weight) ); - } - } - ++face; - } - - vector bones; - for(size_t i=0;i &weights=vweights[i]; - if( !weights.size() ) continue; - - aiBone *bone=new aiBone; - bones.push_back( bone ); - - aiNode *bnode=_nodes[i]; - - bone->mName=bnode->mName; - bone->mNumWeights= static_cast(weights.size()); - bone->mWeights=to_array( weights ); - - aiMatrix4x4 mat=bnode->mTransformation; - while( bnode->mParent ){ - bnode=bnode->mParent; - mat=bnode->mTransformation * mat; - } - bone->mOffsetMatrix=mat.Inverse(); - } - mesh->mNumBones= static_cast(bones.size()); - mesh->mBones=to_array( bones ); - } - } - - //nodes - scene->mRootNode=_nodes[0]; - - //material - if( !_materials.size() ){ - _materials.push_back( new aiMaterial ); - } - scene->mNumMaterials= static_cast(_materials.size()); - scene->mMaterials=to_array( _materials ); - - //meshes - scene->mNumMeshes= static_cast(_meshes.size()); - scene->mMeshes=to_array( _meshes ); - - //animations - if( _animations.size()==1 && _nodeAnims.size() ){ - - aiAnimation *anim=_animations.back(); - anim->mNumChannels=static_cast(_nodeAnims.size()); - anim->mChannels=to_array( _nodeAnims ); - - scene->mNumAnimations=static_cast(_animations.size()); - scene->mAnimations=to_array( _animations ); - } - - // convert to RH - MakeLeftHandedProcess makeleft; - makeleft.Execute( scene ); - - FlipWindingOrderProcess flip; - flip.Execute( scene ); -} - -#endif // !! ASSIMP_BUILD_NO_B3D_IMPORTER diff --git a/src/3rdparty/assimp/code/B3DImporter.h b/src/3rdparty/assimp/code/B3DImporter.h deleted file mode 100644 index 94644edd4..000000000 --- a/src/3rdparty/assimp/code/B3DImporter.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file Definition of the .b3d importer class. */ - -#ifndef AI_B3DIMPORTER_H_INC -#define AI_B3DIMPORTER_H_INC - -#include -#include -#include -#include "BaseImporter.h" - -#include - -struct aiNodeAnim; -struct aiNode; -struct aiAnimation; - -namespace Assimp{ - -class B3DImporter : public BaseImporter{ -public: - B3DImporter() = default; - virtual ~B3DImporter(); - - virtual bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const; - -protected: - - virtual const aiImporterDesc* GetInfo () const; - virtual void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler); - -private: - - int ReadByte(); - int ReadInt(); - float ReadFloat(); - aiVector2D ReadVec2(); - aiVector3D ReadVec3(); - aiQuaternion ReadQuat(); - std::string ReadString(); - std::string ReadChunk(); - void ExitChunk(); - unsigned ChunkSize(); - - template - T *to_array( const std::vector &v ); - - struct Vertex{ - aiVector3D vertex; - aiVector3D normal; - aiVector3D texcoords; - unsigned char bones[4]; - float weights[4]; - }; - - AI_WONT_RETURN void Oops() AI_WONT_RETURN_SUFFIX; - AI_WONT_RETURN void Fail( std::string str ) AI_WONT_RETURN_SUFFIX; - - void ReadTEXS(); - void ReadBRUS(); - - void ReadVRTS(); - void ReadTRIS( int v0 ); - void ReadMESH(); - void ReadBONE( int id ); - void ReadKEYS( aiNodeAnim *nodeAnim ); - void ReadANIM(); - - aiNode *ReadNODE( aiNode *parent ); - - void ReadBB3D( aiScene *scene ); - - unsigned _pos; -// unsigned _size; - std::vector _buf; - std::vector _stack; - - std::vector _textures; - std::vector _materials; - - int _vflags,_tcsets,_tcsize; - std::vector _vertices; - - std::vector _nodes; - std::vector _meshes; - std::vector _nodeAnims; - std::vector _animations; -}; - -} - -#endif diff --git a/src/3rdparty/assimp/code/BVHLoader.cpp b/src/3rdparty/assimp/code/BVHLoader.cpp deleted file mode 100644 index c20cbec4e..000000000 --- a/src/3rdparty/assimp/code/BVHLoader.cpp +++ /dev/null @@ -1,545 +0,0 @@ -/** Implementation of the BVH loader */ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - - -#ifndef ASSIMP_BUILD_NO_BVH_IMPORTER - -#include "BVHLoader.h" -#include "fast_atof.h" -#include "SkeletonMeshBuilder.h" -#include -#include -#include "TinyFormatter.h" -#include -#include -#include - -using namespace Assimp; -using namespace Assimp::Formatter; - -static const aiImporterDesc desc = { - "BVH Importer (MoCap)", - "", - "", - "", - aiImporterFlags_SupportTextFlavour, - 0, - 0, - 0, - 0, - "bvh" -}; - -// ------------------------------------------------------------------------------------------------ -// Constructor to be privately used by Importer -BVHLoader::BVHLoader() - : mLine(), - mAnimTickDuration(), - mAnimNumFrames(), - noSkeletonMesh() -{} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -BVHLoader::~BVHLoader() -{} - -// ------------------------------------------------------------------------------------------------ -// Returns whether the class can handle the format of the given file. -bool BVHLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const -{ - // check file extension - const std::string extension = GetExtension(pFile); - - if( extension == "bvh") - return true; - - if ((!extension.length() || cs) && pIOHandler) { - const char* tokens[] = {"HIERARCHY"}; - return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1); - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -void BVHLoader::SetupProperties(const Importer* pImp) -{ - noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; -} - -// ------------------------------------------------------------------------------------------------ -// Loader meta information -const aiImporterDesc* BVHLoader::GetInfo () const -{ - return &desc; -} - -// ------------------------------------------------------------------------------------------------ -// Imports the given file into the given scene structure. -void BVHLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) -{ - mFileName = pFile; - - // read file into memory - std::unique_ptr file( pIOHandler->Open( pFile)); - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open file " + pFile + "."); - - size_t fileSize = file->FileSize(); - if( fileSize == 0) - throw DeadlyImportError( "File is too small."); - - mBuffer.resize( fileSize); - file->Read( &mBuffer.front(), 1, fileSize); - - // start reading - mReader = mBuffer.begin(); - mLine = 1; - ReadStructure( pScene); - - if (!noSkeletonMesh) { - // build a dummy mesh for the skeleton so that we see something at least - SkeletonMeshBuilder meshBuilder( pScene); - } - - // construct an animation from all the motion data we read - CreateAnimation( pScene); -} - -// ------------------------------------------------------------------------------------------------ -// Reads the file -void BVHLoader::ReadStructure( aiScene* pScene) -{ - // first comes hierarchy - std::string header = GetNextToken(); - if( header != "HIERARCHY") - ThrowException( "Expected header string \"HIERARCHY\"."); - ReadHierarchy( pScene); - - // then comes the motion data - std::string motion = GetNextToken(); - if( motion != "MOTION") - ThrowException( "Expected beginning of motion data \"MOTION\"."); - ReadMotion( pScene); -} - -// ------------------------------------------------------------------------------------------------ -// Reads the hierarchy -void BVHLoader::ReadHierarchy( aiScene* pScene) -{ - std::string root = GetNextToken(); - if( root != "ROOT") - ThrowException( "Expected root node \"ROOT\"."); - - // Go read the hierarchy from here - pScene->mRootNode = ReadNode(); -} - -// ------------------------------------------------------------------------------------------------ -// Reads a node and recursively its childs and returns the created node; -aiNode* BVHLoader::ReadNode() -{ - // first token is name - std::string nodeName = GetNextToken(); - if( nodeName.empty() || nodeName == "{") - ThrowException( format() << "Expected node name, but found \"" << nodeName << "\"." ); - - // then an opening brace should follow - std::string openBrace = GetNextToken(); - if( openBrace != "{") - ThrowException( format() << "Expected opening brace \"{\", but found \"" << openBrace << "\"." ); - - // Create a node - aiNode* node = new aiNode( nodeName); - std::vector childNodes; - - // and create an bone entry for it - mNodes.push_back( Node( node)); - Node& internNode = mNodes.back(); - - // now read the node's contents - while( 1) - { - std::string token = GetNextToken(); - - // node offset to parent node - if( token == "OFFSET") - ReadNodeOffset( node); - else if( token == "CHANNELS") - ReadNodeChannels( internNode); - else if( token == "JOINT") - { - // child node follows - aiNode* child = ReadNode(); - child->mParent = node; - childNodes.push_back( child); - } - else if( token == "End") - { - // The real symbol is "End Site". Second part comes in a separate token - std::string siteToken = GetNextToken(); - if( siteToken != "Site") - ThrowException( format() << "Expected \"End Site\" keyword, but found \"" << token << " " << siteToken << "\"." ); - - aiNode* child = ReadEndSite( nodeName); - child->mParent = node; - childNodes.push_back( child); - } - else if( token == "}") - { - // we're done with that part of the hierarchy - break; - } else - { - // everything else is a parse error - ThrowException( format() << "Unknown keyword \"" << token << "\"." ); - } - } - - // add the child nodes if there are any - if( childNodes.size() > 0) - { - node->mNumChildren = static_cast(childNodes.size()); - node->mChildren = new aiNode*[node->mNumChildren]; - std::copy( childNodes.begin(), childNodes.end(), node->mChildren); - } - - // and return the sub-hierarchy we built here - return node; -} - -// ------------------------------------------------------------------------------------------------ -// Reads an end node and returns the created node. -aiNode* BVHLoader::ReadEndSite( const std::string& pParentName) -{ - // check opening brace - std::string openBrace = GetNextToken(); - if( openBrace != "{") - ThrowException( format() << "Expected opening brace \"{\", but found \"" << openBrace << "\"."); - - // Create a node - aiNode* node = new aiNode( "EndSite_" + pParentName); - - // now read the node's contents. Only possible entry is "OFFSET" - while( 1) - { - std::string token = GetNextToken(); - - // end node's offset - if( token == "OFFSET") - { - ReadNodeOffset( node); - } - else if( token == "}") - { - // we're done with the end node - break; - } else - { - // everything else is a parse error - ThrowException( format() << "Unknown keyword \"" << token << "\"." ); - } - } - - // and return the sub-hierarchy we built here - return node; -} -// ------------------------------------------------------------------------------------------------ -// Reads a node offset for the given node -void BVHLoader::ReadNodeOffset( aiNode* pNode) -{ - // Offset consists of three floats to read - aiVector3D offset; - offset.x = GetNextTokenAsFloat(); - offset.y = GetNextTokenAsFloat(); - offset.z = GetNextTokenAsFloat(); - - // build a transformation matrix from it - pNode->mTransformation = aiMatrix4x4( 1.0f, 0.0f, 0.0f, offset.x, 0.0f, 1.0f, 0.0f, offset.y, - 0.0f, 0.0f, 1.0f, offset.z, 0.0f, 0.0f, 0.0f, 1.0f); -} - -// ------------------------------------------------------------------------------------------------ -// Reads the animation channels for the given node -void BVHLoader::ReadNodeChannels( BVHLoader::Node& pNode) -{ - // number of channels. Use the float reader because we're lazy - float numChannelsFloat = GetNextTokenAsFloat(); - unsigned int numChannels = (unsigned int) numChannelsFloat; - - for( unsigned int a = 0; a < numChannels; a++) - { - std::string channelToken = GetNextToken(); - - if( channelToken == "Xposition") - pNode.mChannels.push_back( Channel_PositionX); - else if( channelToken == "Yposition") - pNode.mChannels.push_back( Channel_PositionY); - else if( channelToken == "Zposition") - pNode.mChannels.push_back( Channel_PositionZ); - else if( channelToken == "Xrotation") - pNode.mChannels.push_back( Channel_RotationX); - else if( channelToken == "Yrotation") - pNode.mChannels.push_back( Channel_RotationY); - else if( channelToken == "Zrotation") - pNode.mChannels.push_back( Channel_RotationZ); - else - ThrowException( format() << "Invalid channel specifier \"" << channelToken << "\"." ); - } -} - -// ------------------------------------------------------------------------------------------------ -// Reads the motion data -void BVHLoader::ReadMotion( aiScene* /*pScene*/) -{ - // Read number of frames - std::string tokenFrames = GetNextToken(); - if( tokenFrames != "Frames:") - ThrowException( format() << "Expected frame count \"Frames:\", but found \"" << tokenFrames << "\"."); - - float numFramesFloat = GetNextTokenAsFloat(); - mAnimNumFrames = (unsigned int) numFramesFloat; - - // Read frame duration - std::string tokenDuration1 = GetNextToken(); - std::string tokenDuration2 = GetNextToken(); - if( tokenDuration1 != "Frame" || tokenDuration2 != "Time:") - ThrowException( format() << "Expected frame duration \"Frame Time:\", but found \"" << tokenDuration1 << " " << tokenDuration2 << "\"." ); - - mAnimTickDuration = GetNextTokenAsFloat(); - - // resize value vectors for each node - for( std::vector::iterator it = mNodes.begin(); it != mNodes.end(); ++it) - it->mChannelValues.reserve( it->mChannels.size() * mAnimNumFrames); - - // now read all the data and store it in the corresponding node's value vector - for( unsigned int frame = 0; frame < mAnimNumFrames; ++frame) - { - // on each line read the values for all nodes - for( std::vector::iterator it = mNodes.begin(); it != mNodes.end(); ++it) - { - // get as many values as the node has channels - for( unsigned int c = 0; c < it->mChannels.size(); ++c) - it->mChannelValues.push_back( GetNextTokenAsFloat()); - } - - // after one frame worth of values for all nodes there should be a newline, but we better don't rely on it - } -} - -// ------------------------------------------------------------------------------------------------ -// Retrieves the next token -std::string BVHLoader::GetNextToken() -{ - // skip any preceding whitespace - while( mReader != mBuffer.end()) - { - if( !isspace( *mReader)) - break; - - // count lines - if( *mReader == '\n') - mLine++; - - ++mReader; - } - - // collect all chars till the next whitespace. BVH is easy in respect to that. - std::string token; - while( mReader != mBuffer.end()) - { - if( isspace( *mReader)) - break; - - token.push_back( *mReader); - ++mReader; - - // little extra logic to make sure braces are counted correctly - if( token == "{" || token == "}") - break; - } - - // empty token means end of file, which is just fine - return token; -} - -// ------------------------------------------------------------------------------------------------ -// Reads the next token as a float -float BVHLoader::GetNextTokenAsFloat() -{ - std::string token = GetNextToken(); - if( token.empty()) - ThrowException( "Unexpected end of file while trying to read a float"); - - // check if the float is valid by testing if the atof() function consumed every char of the token - const char* ctoken = token.c_str(); - float result = 0.0f; - ctoken = fast_atoreal_move( ctoken, result); - - if( ctoken != token.c_str() + token.length()) - ThrowException( format() << "Expected a floating point number, but found \"" << token << "\"." ); - - return result; -} - -// ------------------------------------------------------------------------------------------------ -// Aborts the file reading with an exception -AI_WONT_RETURN void BVHLoader::ThrowException( const std::string& pError) -{ - throw DeadlyImportError( format() << mFileName << ":" << mLine << " - " << pError); -} - -// ------------------------------------------------------------------------------------------------ -// Constructs an animation for the motion data and stores it in the given scene -void BVHLoader::CreateAnimation( aiScene* pScene) -{ - // create the animation - pScene->mNumAnimations = 1; - pScene->mAnimations = new aiAnimation*[1]; - aiAnimation* anim = new aiAnimation; - pScene->mAnimations[0] = anim; - - // put down the basic parameters - anim->mName.Set( "Motion"); - anim->mTicksPerSecond = 1.0 / double( mAnimTickDuration); - anim->mDuration = double( mAnimNumFrames - 1); - - // now generate the tracks for all nodes - anim->mNumChannels = static_cast(mNodes.size()); - anim->mChannels = new aiNodeAnim*[anim->mNumChannels]; - - // FIX: set the array elements to NULL to ensure proper deletion if an exception is thrown - for (unsigned int i = 0; i < anim->mNumChannels;++i) - anim->mChannels[i] = NULL; - - for( unsigned int a = 0; a < anim->mNumChannels; a++) - { - const Node& node = mNodes[a]; - const std::string nodeName = std::string( node.mNode->mName.data ); - aiNodeAnim* nodeAnim = new aiNodeAnim; - anim->mChannels[a] = nodeAnim; - nodeAnim->mNodeName.Set( nodeName); - - // translational part, if given - if( node.mChannels.size() == 6) - { - nodeAnim->mNumPositionKeys = mAnimNumFrames; - nodeAnim->mPositionKeys = new aiVectorKey[mAnimNumFrames]; - aiVectorKey* poskey = nodeAnim->mPositionKeys; - for( unsigned int fr = 0; fr < mAnimNumFrames; ++fr) - { - poskey->mTime = double( fr); - - // Now compute all translations in the right order - for( unsigned int channel = 0; channel < 3; ++channel) - { - switch( node.mChannels[channel]) - { - case Channel_PositionX: poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + channel]; break; - case Channel_PositionY: poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + channel]; break; - case Channel_PositionZ: poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + channel]; break; - default: throw DeadlyImportError( "Unexpected animation channel setup at node " + nodeName ); - } - } - ++poskey; - } - } else - { - // if no translation part is given, put a default sequence - aiVector3D nodePos( node.mNode->mTransformation.a4, node.mNode->mTransformation.b4, node.mNode->mTransformation.c4); - nodeAnim->mNumPositionKeys = 1; - nodeAnim->mPositionKeys = new aiVectorKey[1]; - nodeAnim->mPositionKeys[0].mTime = 0.0; - nodeAnim->mPositionKeys[0].mValue = nodePos; - } - - // rotation part. Always present. First find value offsets - { - unsigned int rotOffset = 0; - if( node.mChannels.size() == 6) - { - // Offset all further calculations - rotOffset = 3; - } - - // Then create the number of rotation keys - nodeAnim->mNumRotationKeys = mAnimNumFrames; - nodeAnim->mRotationKeys = new aiQuatKey[mAnimNumFrames]; - aiQuatKey* rotkey = nodeAnim->mRotationKeys; - for( unsigned int fr = 0; fr < mAnimNumFrames; ++fr) - { - aiMatrix4x4 temp; - aiMatrix3x3 rotMatrix; - - for( unsigned int channel = 0; channel < 3; ++channel) - { - // translate ZXY euler angels into a quaternion - const float angle = node.mChannelValues[fr * node.mChannels.size() + rotOffset + channel] * float( AI_MATH_PI) / 180.0f; - - // Compute rotation transformations in the right order - switch (node.mChannels[rotOffset+channel]) - { - case Channel_RotationX: aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp); break; - case Channel_RotationY: aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp); break; - case Channel_RotationZ: aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp); break; - default: throw DeadlyImportError( "Unexpected animation channel setup at node " + nodeName ); - } - } - - rotkey->mTime = double( fr); - rotkey->mValue = aiQuaternion( rotMatrix); - ++rotkey; - } - } - - // scaling part. Always just a default track - { - nodeAnim->mNumScalingKeys = 1; - nodeAnim->mScalingKeys = new aiVectorKey[1]; - nodeAnim->mScalingKeys[0].mTime = 0.0; - nodeAnim->mScalingKeys[0].mValue.Set( 1.0f, 1.0f, 1.0f); - } - } -} - -#endif // !! ASSIMP_BUILD_NO_BVH_IMPORTER diff --git a/src/3rdparty/assimp/code/BVHLoader.h b/src/3rdparty/assimp/code/BVHLoader.h deleted file mode 100644 index 6a89e1aaf..000000000 --- a/src/3rdparty/assimp/code/BVHLoader.h +++ /dev/null @@ -1,172 +0,0 @@ -/** Defines the BHV motion capturing loader class */ - -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file BVHLoader.h - * @brief Biovision BVH import - */ - -#ifndef AI_BVHLOADER_H_INC -#define AI_BVHLOADER_H_INC - -#include "BaseImporter.h" - -struct aiNode; - -namespace Assimp -{ - -// -------------------------------------------------------------------------------- -/** Loader class to read Motion Capturing data from a .bvh file. - * - * This format only contains a hierarchy of joints and a series of keyframes for - * the hierarchy. It contains no actual mesh data, but we generate a dummy mesh - * inside the loader just to be able to see something. -*/ -class BVHLoader : public BaseImporter -{ - - /** Possible animation channels for which the motion data holds the values */ - enum ChannelType - { - Channel_PositionX, - Channel_PositionY, - Channel_PositionZ, - Channel_RotationX, - Channel_RotationY, - Channel_RotationZ - }; - - /** Collected list of node. Will be bones of the dummy mesh some day, addressed by their array index */ - struct Node - { - const aiNode* mNode; - std::vector mChannels; - std::vector mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames - - Node() { } - explicit Node( const aiNode* pNode) : mNode( pNode) { } - }; - -public: - - BVHLoader(); - ~BVHLoader(); - -public: - /** Returns whether the class can handle the format of the given file. - * See BaseImporter::CanRead() for details. */ - bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const; - - void SetupProperties(const Importer* pImp); - const aiImporterDesc* GetInfo () const; - -protected: - - - /** Imports the given file into the given scene structure. - * See BaseImporter::InternReadFile() for details - */ - void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler); - -protected: - /** Reads the file */ - void ReadStructure( aiScene* pScene); - - /** Reads the hierarchy */ - void ReadHierarchy( aiScene* pScene); - - /** Reads a node and recursively its childs and returns the created node. */ - aiNode* ReadNode(); - - /** Reads an end node and returns the created node. */ - aiNode* ReadEndSite( const std::string& pParentName); - - /** Reads a node offset for the given node */ - void ReadNodeOffset( aiNode* pNode); - - /** Reads the animation channels into the given node */ - void ReadNodeChannels( BVHLoader::Node& pNode); - - /** Reads the motion data */ - void ReadMotion( aiScene* pScene); - - /** Retrieves the next token */ - std::string GetNextToken(); - - /** Reads the next token as a float */ - float GetNextTokenAsFloat(); - - /** Aborts the file reading with an exception */ - AI_WONT_RETURN void ThrowException( const std::string& pError) AI_WONT_RETURN_SUFFIX; - - /** Constructs an animation for the motion data and stores it in the given scene */ - void CreateAnimation( aiScene* pScene); - -protected: - /** Filename, for a verbose error message */ - std::string mFileName; - - /** Buffer to hold the loaded file */ - std::vector mBuffer; - - /** Next char to read from the buffer */ - std::vector::const_iterator mReader; - - /** Current line, for error messages */ - unsigned int mLine; - - /** Collected list of nodes. Will be bones of the dummy mesh some day, addressed by their array index. - * Also contain the motion data for the node's channels - */ - std::vector mNodes; - - /** basic Animation parameters */ - float mAnimTickDuration; - unsigned int mAnimNumFrames; - - bool noSkeletonMesh; -}; - -} // end of namespace Assimp - -#endif // AI_BVHLOADER_H_INC diff --git a/src/3rdparty/assimp/code/BaseImporter.cpp b/src/3rdparty/assimp/code/BaseImporter.cpp deleted file mode 100644 index b9b9eeb71..000000000 --- a/src/3rdparty/assimp/code/BaseImporter.cpp +++ /dev/null @@ -1,601 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file BaseImporter.cpp - * @brief Implementation of BaseImporter - */ - -#include "BaseImporter.h" -#include "FileSystemFilter.h" -#include "Importer.h" -#include "ByteSwapper.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Assimp; - -// ------------------------------------------------------------------------------------------------ -// Constructor to be privately used by Importer -BaseImporter::BaseImporter() -: m_progress() -{ - // nothing to do here -} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -BaseImporter::~BaseImporter() -{ - // nothing to do here -} - -// ------------------------------------------------------------------------------------------------ -// Imports the given file and returns the imported data. -aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) -{ - m_progress = pImp->GetProgressHandler(); - ai_assert(m_progress); - - // Gather configuration properties for this run - SetupProperties( pImp ); - - // Construct a file system filter to improve our success ratio at reading external files - FileSystemFilter filter(pFile,pIOHandler); - - // create a scene object to hold the data - std::unique_ptr sc(new aiScene()); - - // dispatch importing - try - { - InternReadFile( pFile, sc.get(), &filter); - - } catch( const std::exception& err ) { - // extract error description - m_ErrorText = err.what(); - DefaultLogger::get()->error(m_ErrorText); - return NULL; - } - - // return what we gathered from the import. - return sc.release(); -} - -// ------------------------------------------------------------------------------------------------ -void BaseImporter::SetupProperties(const Importer* /*pImp*/) -{ - // the default implementation does nothing -} - -// ------------------------------------------------------------------------------------------------ -void BaseImporter::GetExtensionList(std::set& extensions) -{ - const aiImporterDesc* desc = GetInfo(); - ai_assert(desc != NULL); - - const char* ext = desc->mFileExtensions; - ai_assert(ext != NULL); - - const char* last = ext; - do { - if (!*ext || *ext == ' ') { - extensions.insert(std::string(last,ext-last)); - ai_assert(ext-last > 0); - last = ext; - while(*last == ' ') { - ++last; - } - } - } - while(*ext++); -} - -// ------------------------------------------------------------------------------------------------ -/*static*/ bool BaseImporter::SearchFileHeaderForToken( IOSystem* pIOHandler, - const std::string& pFile, - const char** tokens, - unsigned int numTokens, - unsigned int searchBytes /* = 200 */, - bool tokensSol /* false */) -{ - ai_assert( NULL != tokens ); - ai_assert( 0 != numTokens ); - ai_assert( 0 != searchBytes); - - if (!pIOHandler) - return false; - - std::unique_ptr pStream (pIOHandler->Open(pFile)); - if (pStream.get() ) { - // read 200 characters from the file - std::unique_ptr _buffer (new char[searchBytes+1 /* for the '\0' */]); - char* buffer = _buffer.get(); - if( NULL == buffer ) { - return false; - } - - const size_t read = pStream->Read(buffer,1,searchBytes); - if( !read ) { - return false; - } - - for( size_t i = 0; i < read; ++i ) { - buffer[ i ] = ::tolower( buffer[ i ] ); - } - - // It is not a proper handling of unicode files here ... - // ehm ... but it works in most cases. - char* cur = buffer,*cur2 = buffer,*end = &buffer[read]; - while (cur != end) { - if( *cur ) { - *cur2++ = *cur; - } - ++cur; - } - *cur2 = '\0'; - - for (unsigned int i = 0; i < numTokens;++i) { - ai_assert(NULL != tokens[i]); - const char* r = strstr(buffer,tokens[i]); - if( !r ) { - continue; - } - // We got a match, either we don't care where it is, or it happens to - // be in the beginning of the file / line - if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') { - DefaultLogger::get()->debug(std::string("Found positive match for header keyword: ") + tokens[i]); - return true; - } - } - } - - return false; -} - -// ------------------------------------------------------------------------------------------------ -// Simple check for file extension -/*static*/ bool BaseImporter::SimpleExtensionCheck (const std::string& pFile, - const char* ext0, - const char* ext1, - const char* ext2) -{ - std::string::size_type pos = pFile.find_last_of('.'); - - // no file extension - can't read - if( pos == std::string::npos) - return false; - - const char* ext_real = & pFile[ pos+1 ]; - if( !ASSIMP_stricmp(ext_real,ext0) ) - return true; - - // check for other, optional, file extensions - if (ext1 && !ASSIMP_stricmp(ext_real,ext1)) - return true; - - if (ext2 && !ASSIMP_stricmp(ext_real,ext2)) - return true; - - return false; -} - -// ------------------------------------------------------------------------------------------------ -// Get file extension from path -/*static*/ std::string BaseImporter::GetExtension (const std::string& pFile) -{ - std::string::size_type pos = pFile.find_last_of('.'); - - // no file extension at all - if( pos == std::string::npos) - return ""; - - std::string ret = pFile.substr(pos+1); - std::transform(ret.begin(),ret.end(),ret.begin(),::tolower); // thanks to Andy Maloney for the hint - return ret; -} - -// ------------------------------------------------------------------------------------------------ -// Check for magic bytes at the beginning of the file. -/* static */ bool BaseImporter::CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile, - const void* _magic, unsigned int num, unsigned int offset, unsigned int size) -{ - ai_assert(size <= 16 && _magic); - - if (!pIOHandler) { - return false; - } - union { - const char* magic; - const uint16_t* magic_u16; - const uint32_t* magic_u32; - }; - magic = reinterpret_cast(_magic); - std::unique_ptr pStream (pIOHandler->Open(pFile)); - if (pStream.get() ) { - - // skip to offset - pStream->Seek(offset,aiOrigin_SET); - - // read 'size' characters from the file - union { - char data[16]; - uint16_t data_u16[8]; - uint32_t data_u32[4]; - }; - if(size != pStream->Read(data,1,size)) { - return false; - } - - for (unsigned int i = 0; i < num; ++i) { - // also check against big endian versions of tokens with size 2,4 - // that's just for convenience, the chance that we cause conflicts - // is quite low and it can save some lines and prevent nasty bugs - if (2 == size) { - uint16_t rev = *magic_u16; - ByteSwap::Swap(&rev); - if (data_u16[0] == *magic_u16 || data_u16[0] == rev) { - return true; - } - } - else if (4 == size) { - uint32_t rev = *magic_u32; - ByteSwap::Swap(&rev); - if (data_u32[0] == *magic_u32 || data_u32[0] == rev) { - return true; - } - } - else { - // any length ... just compare - if(!memcmp(magic,data,size)) { - return true; - } - } - magic += size; - } - } - return false; -} - -#include "../contrib/utf8cpp/source/utf8.h" - -// ------------------------------------------------------------------------------------------------ -// Convert to UTF8 data -void BaseImporter::ConvertToUTF8(std::vector& data) -{ - //ConversionResult result; - if(data.size() < 8) { - throw DeadlyImportError("File is too small"); - } - - // UTF 8 with BOM - if((uint8_t)data[0] == 0xEF && (uint8_t)data[1] == 0xBB && (uint8_t)data[2] == 0xBF) { - DefaultLogger::get()->debug("Found UTF-8 BOM ..."); - - std::copy(data.begin()+3,data.end(),data.begin()); - data.resize(data.size()-3); - return; - } - - - // UTF 32 BE with BOM - if(*((uint32_t*)&data.front()) == 0xFFFE0000) { - - // swap the endianness .. - for(uint32_t* p = (uint32_t*)&data.front(), *end = (uint32_t*)&data.back(); p <= end; ++p) { - AI_SWAP4P(p); - } - } - - // UTF 32 LE with BOM - if(*((uint32_t*)&data.front()) == 0x0000FFFE) { - DefaultLogger::get()->debug("Found UTF-32 BOM ..."); - - std::vector output; - int *ptr = (int*)&data[ 0 ]; - int *end = ptr + ( data.size() / sizeof(int) ) +1; - utf8::utf32to8( ptr, end, back_inserter(output)); - return; - } - - // UTF 16 BE with BOM - if(*((uint16_t*)&data.front()) == 0xFFFE) { - - // swap the endianness .. - for(uint16_t* p = (uint16_t*)&data.front(), *end = (uint16_t*)&data.back(); p <= end; ++p) { - ByteSwap::Swap2(p); - } - } - - // UTF 16 LE with BOM - if(*((uint16_t*)&data.front()) == 0xFEFF) { - DefaultLogger::get()->debug("Found UTF-16 BOM ..."); - - std::vector output; - utf8::utf16to8(data.begin(), data.end(), back_inserter(output)); - return; - } -} - -// ------------------------------------------------------------------------------------------------ -// Convert to UTF8 data to ISO-8859-1 -void BaseImporter::ConvertUTF8toISO8859_1(std::string& data) -{ - size_t size = data.size(); - size_t i = 0, j = 0; - - while(i < size) { - if ((unsigned char) data[i] < (size_t) 0x80) { - data[j] = data[i]; - } else if(i < size - 1) { - if((unsigned char) data[i] == 0xC2) { - data[j] = data[++i]; - } else if((unsigned char) data[i] == 0xC3) { - data[j] = ((unsigned char) data[++i] + 0x40); - } else { - std::stringstream stream; - - stream << "UTF8 code " << std::hex << data[i] << data[i + 1] << " can not be converted into ISA-8859-1."; - - DefaultLogger::get()->error(stream.str()); - - data[j++] = data[i++]; - data[j] = data[i]; - } - } else { - DefaultLogger::get()->error("UTF8 code but only one character remaining"); - - data[j] = data[i]; - } - - i++; j++; - } - - data.resize(j); -} - -// ------------------------------------------------------------------------------------------------ -void BaseImporter::TextFileToBuffer(IOStream* stream, - std::vector& data, - TextFileMode mode) -{ - ai_assert(NULL != stream); - - const size_t fileSize = stream->FileSize(); - if (mode == FORBID_EMPTY) { - if(!fileSize) { - throw DeadlyImportError("File is empty"); - } - } - - data.reserve(fileSize+1); - data.resize(fileSize); - if(fileSize > 0) { - if(fileSize != stream->Read( &data[0], 1, fileSize)) { - throw DeadlyImportError("File read error"); - } - - ConvertToUTF8(data); - } - - // append a binary zero to simplify string parsing - data.push_back(0); -} - -// ------------------------------------------------------------------------------------------------ -namespace Assimp { - // Represents an import request - struct LoadRequest { - LoadRequest(const std::string& _file, unsigned int _flags,const BatchLoader::PropertyMap* _map, unsigned int _id) - : file(_file) - , flags(_flags) - , refCnt(1) - , scene(NULL) - , loaded(false) - , id(_id) { - if ( _map ) { - map = *_map; - } - } - - bool operator== ( const std::string& f ) const { - return file == f; - } - - const std::string file; - unsigned int flags; - unsigned int refCnt; - aiScene *scene; - bool loaded; - BatchLoader::PropertyMap map; - unsigned int id; - }; -} - -// ------------------------------------------------------------------------------------------------ -// BatchLoader::pimpl data structure -struct Assimp::BatchData { - BatchData( IOSystem* pIO, bool validate ) - : pIOSystem( pIO ) - , pImporter( nullptr ) - , next_id(0xffff) - , validate( validate ) { - ai_assert( NULL != pIO ); - - pImporter = new Importer(); - pImporter->SetIOHandler( pIO ); - } - - ~BatchData() { - pImporter->SetIOHandler( NULL ); /* get pointer back into our possession */ - delete pImporter; - } - - // IO system to be used for all imports - IOSystem* pIOSystem; - - // Importer used to load all meshes - Importer* pImporter; - - // List of all imports - std::list requests; - - // Base path - std::string pathBase; - - // Id for next item - unsigned int next_id; - - // Validation enabled state - bool validate; -}; - -typedef std::list::iterator LoadReqIt; - -// ------------------------------------------------------------------------------------------------ -BatchLoader::BatchLoader(IOSystem* pIO, bool validate ) -{ - ai_assert(NULL != pIO); - - m_data = new BatchData( pIO, validate ); -} - -// ------------------------------------------------------------------------------------------------ -BatchLoader::~BatchLoader() -{ - // delete all scenes what have not been polled by the user - for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) { - delete (*it).scene; - } - delete m_data; -} - -// ------------------------------------------------------------------------------------------------ -void BatchLoader::setValidation( bool enabled ) { - m_data->validate = enabled; -} - -// ------------------------------------------------------------------------------------------------ -bool BatchLoader::getValidation() const { - return m_data->validate; -} - -// ------------------------------------------------------------------------------------------------ -unsigned int BatchLoader::AddLoadRequest(const std::string& file, - unsigned int steps /*= 0*/, const PropertyMap* map /*= NULL*/) -{ - ai_assert(!file.empty()); - - // check whether we have this loading request already - for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) { - // Call IOSystem's path comparison function here - if ( m_data->pIOSystem->ComparePaths((*it).file,file)) { - if (map) { - if ( !( ( *it ).map == *map ) ) { - continue; - } - } - else if ( !( *it ).map.empty() ) { - continue; - } - - (*it).refCnt++; - return (*it).id; - } - } - - // no, we don't have it. So add it to the queue ... - m_data->requests.push_back(LoadRequest(file,steps,map, m_data->next_id)); - return m_data->next_id++; -} - -// ------------------------------------------------------------------------------------------------ -aiScene* BatchLoader::GetImport( unsigned int which ) -{ - for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) { - if ((*it).id == which && (*it).loaded) { - aiScene* sc = (*it).scene; - if (!(--(*it).refCnt)) { - m_data->requests.erase(it); - } - return sc; - } - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -void BatchLoader::LoadAll() -{ - // no threaded implementation for the moment - for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) { - // force validation in debug builds - unsigned int pp = (*it).flags; - if ( m_data->validate ) { - pp |= aiProcess_ValidateDataStructure; - } - - // setup config properties if necessary - ImporterPimpl* pimpl = m_data->pImporter->Pimpl(); - pimpl->mFloatProperties = (*it).map.floats; - pimpl->mIntProperties = (*it).map.ints; - pimpl->mStringProperties = (*it).map.strings; - pimpl->mMatrixProperties = (*it).map.matrices; - - if (!DefaultLogger::isNullLogger()) - { - DefaultLogger::get()->info("%%% BEGIN EXTERNAL FILE %%%"); - DefaultLogger::get()->info("File: " + (*it).file); - } - m_data->pImporter->ReadFile((*it).file,pp); - (*it).scene = m_data->pImporter->GetOrphanedScene(); - (*it).loaded = true; - - DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%"); - } -} diff --git a/src/3rdparty/assimp/code/BaseImporter.h b/src/3rdparty/assimp/code/BaseImporter.h deleted file mode 100644 index b424d2f83..000000000 --- a/src/3rdparty/assimp/code/BaseImporter.h +++ /dev/null @@ -1,361 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file Definition of the base class for all importer worker classes. */ -#ifndef INCLUDED_AI_BASEIMPORTER_H -#define INCLUDED_AI_BASEIMPORTER_H - -#include "Exceptional.h" - -#include -#include -#include -#include - -struct aiScene; -struct aiImporterDesc; - -namespace Assimp { - -class Importer; -class IOSystem; -class BaseProcess; -class SharedPostProcessInfo; -class IOStream; - -// utility to do char4 to uint32 in a portable manner -#define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \ - (string[1] << 16) + (string[2] << 8) + string[3])) - - -// --------------------------------------------------------------------------- -/** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface - * for all importer worker classes. - * - * The interface defines two functions: CanRead() is used to check if the - * importer can handle the format of the given file. If an implementation of - * this function returns true, the importer then calls ReadFile() which - * imports the given file. ReadFile is not overridable, it just calls - * InternReadFile() and catches any ImportErrorException that might occur. - */ -class ASSIMP_API BaseImporter -{ - friend class Importer; - -public: - - /** Constructor to be privately used by #Importer */ - BaseImporter(); - - /** Destructor, private as well */ - virtual ~BaseImporter(); - -public: - // ------------------------------------------------------------------- - /** Returns whether the class can handle the format of the given file. - * - * The implementation should be as quick as possible. A check for - * the file extension is enough. If no suitable loader is found with - * this strategy, CanRead() is called again, the 'checkSig' parameter - * set to true this time. Now the implementation is expected to - * perform a full check of the file structure, possibly searching the - * first bytes of the file for magic identifiers or keywords. - * - * @param pFile Path and file name of the file to be examined. - * @param pIOHandler The IO handler to use for accessing any file. - * @param checkSig Set to true if this method is called a second time. - * This time, the implementation may take more time to examine the - * contents of the file to be loaded for magic bytes, keywords, etc - * to be able to load files with unknown/not existent file extensions. - * @return true if the class can read this file, false if not. - */ - virtual bool CanRead( - const std::string& pFile, - IOSystem* pIOHandler, - bool checkSig - ) const = 0; - - // ------------------------------------------------------------------- - /** Imports the given file and returns the imported data. - * If the import succeeds, ownership of the data is transferred to - * the caller. If the import fails, NULL is returned. The function - * takes care that any partially constructed data is destroyed - * beforehand. - * - * @param pImp #Importer object hosting this loader. - * @param pFile Path of the file to be imported. - * @param pIOHandler IO-Handler used to open this and possible other files. - * @return The imported data or NULL if failed. If it failed a - * human-readable error description can be retrieved by calling - * GetErrorText() - * - * @note This function is not intended to be overridden. Implement - * InternReadFile() to do the import. If an exception is thrown somewhere - * in InternReadFile(), this function will catch it and transform it into - * a suitable response to the caller. - */ - aiScene* ReadFile( - const Importer* pImp, - const std::string& pFile, - IOSystem* pIOHandler - ); - - // ------------------------------------------------------------------- - /** Returns the error description of the last error that occurred. - * @return A description of the last error that occurred. An empty - * string if there was no error. - */ - const std::string& GetErrorText() const { - return m_ErrorText; - } - - // ------------------------------------------------------------------- - /** Called prior to ReadFile(). - * The function is a request to the importer to update its configuration - * basing on the Importer's configuration property list. - * @param pImp Importer instance - */ - virtual void SetupProperties( - const Importer* pImp - ); - - // ------------------------------------------------------------------- - /** Called by #Importer::GetImporterInfo to get a description of - * some loader features. Importers must provide this information. */ - virtual const aiImporterDesc* GetInfo() const = 0; - - // ------------------------------------------------------------------- - /** Called by #Importer::GetExtensionList for each loaded importer. - * Take the extension list contained in the structure returned by - * #GetInfo and insert all file extensions into the given set. - * @param extension set to collect file extensions in*/ - void GetExtensionList(std::set& extensions); - -protected: - - // ------------------------------------------------------------------- - /** Imports the given file into the given scene structure. The - * function is expected to throw an ImportErrorException if there is - * an error. If it terminates normally, the data in aiScene is - * expected to be correct. Override this function to implement the - * actual importing. - *
- * The output scene must meet the following requirements:
- *
    - *
  • At least a root node must be there, even if its only purpose - * is to reference one mesh.
  • - *
  • aiMesh::mPrimitiveTypes may be 0. The types of primitives - * in the mesh are determined automatically in this case.
  • - *
  • the vertex data is stored in a pseudo-indexed "verbose" format. - * In fact this means that every vertex that is referenced by - * a face is unique. Or the other way round: a vertex index may - * not occur twice in a single aiMesh.
  • - *
  • aiAnimation::mDuration may be -1. Assimp determines the length - * of the animation automatically in this case as the length of - * the longest animation channel.
  • - *
  • aiMesh::mBitangents may be NULL if tangents and normals are - * given. In this case bitangents are computed as the cross product - * between normal and tangent.
  • - *
  • There needn't be a material. If none is there a default material - * is generated. However, it is recommended practice for loaders - * to generate a default material for yourself that matches the - * default material setting for the file format better than Assimp's - * generic default material. Note that default materials *should* - * be named AI_DEFAULT_MATERIAL_NAME if they're just color-shaded - * or AI_DEFAULT_TEXTURED_MATERIAL_NAME if they define a (dummy) - * texture.
  • - *
- * If the AI_SCENE_FLAGS_INCOMPLETE-Flag is not set:
    - *
  • at least one mesh must be there
  • - *
  • there may be no meshes with 0 vertices or faces
  • - *
- * This won't be checked (except by the validation step): Assimp will - * crash if one of the conditions is not met! - * - * @param pFile Path of the file to be imported. - * @param pScene The scene object to hold the imported data. - * NULL is not a valid parameter. - * @param pIOHandler The IO handler to use for any file access. - * NULL is not a valid parameter. */ - virtual void InternReadFile( - const std::string& pFile, - aiScene* pScene, - IOSystem* pIOHandler - ) = 0; - -public: // static utilities - - // ------------------------------------------------------------------- - /** A utility for CanRead(). - * - * The function searches the header of a file for a specific token - * and returns true if this token is found. This works for text - * files only. There is a rudimentary handling of UNICODE files. - * The comparison is case independent. - * - * @param pIOSystem IO System to work with - * @param file File name of the file - * @param tokens List of tokens to search for - * @param numTokens Size of the token array - * @param searchBytes Number of bytes to be searched for the tokens. - */ - static bool SearchFileHeaderForToken( - IOSystem* pIOSystem, - const std::string& file, - const char** tokens, - unsigned int numTokens, - unsigned int searchBytes = 200, - bool tokensSol = false); - - // ------------------------------------------------------------------- - /** @brief Check whether a file has a specific file extension - * @param pFile Input file - * @param ext0 Extension to check for. Lowercase characters only, no dot! - * @param ext1 Optional second extension - * @param ext2 Optional third extension - * @note Case-insensitive - */ - static bool SimpleExtensionCheck ( - const std::string& pFile, - const char* ext0, - const char* ext1 = NULL, - const char* ext2 = NULL); - - // ------------------------------------------------------------------- - /** @brief Extract file extension from a string - * @param pFile Input file - * @return Extension without trailing dot, all lowercase - */ - static std::string GetExtension ( - const std::string& pFile); - - // ------------------------------------------------------------------- - /** @brief Check whether a file starts with one or more magic tokens - * @param pFile Input file - * @param pIOHandler IO system to be used - * @param magic n magic tokens - * @params num Size of magic - * @param offset Offset from file start where tokens are located - * @param Size of one token, in bytes. Maximally 16 bytes. - * @return true if one of the given tokens was found - * - * @note For convenience, the check is also performed for the - * byte-swapped variant of all tokens (big endian). Only for - * tokens of size 2,4. - */ - static bool CheckMagicToken( - IOSystem* pIOHandler, - const std::string& pFile, - const void* magic, - unsigned int num, - unsigned int offset = 0, - unsigned int size = 4); - - // ------------------------------------------------------------------- - /** An utility for all text file loaders. It converts a file to our - * UTF8 character set. Errors are reported, but ignored. - * - * @param data File buffer to be converted to UTF8 data. The buffer - * is resized as appropriate. */ - static void ConvertToUTF8( - std::vector& data); - - // ------------------------------------------------------------------- - /** An utility for all text file loaders. It converts a file from our - * UTF8 character set back to ISO-8859-1. Errors are reported, but ignored. - * - * @param data File buffer to be converted from UTF8 to ISO-8859-1. The buffer - * is resized as appropriate. */ - static void ConvertUTF8toISO8859_1( - std::string& data); - - // ------------------------------------------------------------------- - /// @brief Enum to define, if empty files are ok or not. - enum TextFileMode { - ALLOW_EMPTY, - FORBID_EMPTY - }; - - // ------------------------------------------------------------------- - /** Utility for text file loaders which copies the contents of the - * file into a memory buffer and converts it to our UTF8 - * representation. - * @param stream Stream to read from. - * @param data Output buffer to be resized and filled with the - * converted text file data. The buffer is terminated with - * a binary 0. - * @param mode Whether it is OK to load empty text files. */ - static void TextFileToBuffer( - IOStream* stream, - std::vector& data, - TextFileMode mode = FORBID_EMPTY); - - // ------------------------------------------------------------------- - /** Utility function to move a std::vector into a aiScene array - * @param vec The vector to be moved - * @param out The output pointer to the allocated array. - * @param numOut The output count of elements copied. */ - template - AI_FORCE_INLINE - static void CopyVector( - std::vector& vec, - T*& out, - unsigned int& outLength) - { - outLength = unsigned(vec.size()); - if (outLength) { - out = new T[outLength]; - std::swap_ranges(vec.begin(), vec.end(), out); - } - } - -protected: - /// Error description in case there was one. - std::string m_ErrorText; - /// Currently set progress handler. - ProgressHandler* m_progress; -}; - - - -} // end of namespace Assimp - -#endif // AI_BASEIMPORTER_H_INC diff --git a/src/3rdparty/assimp/code/BaseProcess.cpp b/src/3rdparty/assimp/code/BaseProcess.cpp deleted file mode 100644 index 9e175d315..000000000 --- a/src/3rdparty/assimp/code/BaseProcess.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file Implementation of BaseProcess */ - -#include "BaseImporter.h" -#include "BaseProcess.h" -#include -#include -#include "Importer.h" - -using namespace Assimp; - -// ------------------------------------------------------------------------------------------------ -// Constructor to be privately used by Importer -BaseProcess::BaseProcess() -: shared() -, progress() -{ -} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -BaseProcess::~BaseProcess() -{ - // nothing to do here -} - -// ------------------------------------------------------------------------------------------------ -void BaseProcess::ExecuteOnScene( Importer* pImp) -{ - ai_assert(NULL != pImp && NULL != pImp->Pimpl()->mScene); - - progress = pImp->GetProgressHandler(); - ai_assert(progress); - - SetupProperties( pImp ); - - // catch exceptions thrown inside the PostProcess-Step - try - { - Execute(pImp->Pimpl()->mScene); - - } catch( const std::exception& err ) { - - // extract error description - pImp->Pimpl()->mErrorString = err.what(); - DefaultLogger::get()->error(pImp->Pimpl()->mErrorString); - - // and kill the partially imported data - delete pImp->Pimpl()->mScene; - pImp->Pimpl()->mScene = NULL; - } -} - -// ------------------------------------------------------------------------------------------------ -void BaseProcess::SetupProperties(const Importer* /*pImp*/) -{ - // the default implementation does nothing -} - -// ------------------------------------------------------------------------------------------------ -bool BaseProcess::RequireVerboseFormat() const -{ - return true; -} - diff --git a/src/3rdparty/assimp/code/BaseProcess.h b/src/3rdparty/assimp/code/BaseProcess.h deleted file mode 100644 index aa873f717..000000000 --- a/src/3rdparty/assimp/code/BaseProcess.h +++ /dev/null @@ -1,293 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file Base class of all import post processing steps */ -#ifndef INCLUDED_AI_BASEPROCESS_H -#define INCLUDED_AI_BASEPROCESS_H - -#include -#include "GenericProperty.h" - -struct aiScene; - -namespace Assimp { - -class Importer; - -// --------------------------------------------------------------------------- -/** Helper class to allow post-processing steps to interact with each other. - * - * The class maintains a simple property list that can be used by pp-steps - * to provide additional information to other steps. This is primarily - * intended for cross-step optimizations. - */ -class SharedPostProcessInfo -{ -public: - - struct Base - { - virtual ~Base() - {} - }; - - //! Represents data that is allocated on the heap, thus needs to be deleted - template - struct THeapData : public Base - { - explicit THeapData(T* in) - : data (in) - {} - - ~THeapData() - { - delete data; - } - T* data; - }; - - //! Represents static, by-value data not allocated on the heap - template - struct TStaticData : public Base - { - explicit TStaticData(T in) - : data (in) - {} - - ~TStaticData() - {} - - T data; - }; - - // some typedefs for cleaner code - typedef unsigned int KeyType; - typedef std::map PropertyMap; - -public: - - //! Destructor - ~SharedPostProcessInfo() - { - Clean(); - } - - //! Remove all stored properties from the table - void Clean() - { - // invoke the virtual destructor for all stored properties - for (PropertyMap::iterator it = pmap.begin(), end = pmap.end(); - it != end; ++it) - { - delete (*it).second; - } - pmap.clear(); - } - - //! Add a heap property to the list - template - void AddProperty( const char* name, T* in ){ - AddProperty(name,(Base*)new THeapData(in)); - } - - //! Add a static by-value property to the list - template - void AddProperty( const char* name, T in ){ - AddProperty(name,(Base*)new TStaticData(in)); - } - - - //! Get a heap property - template - bool GetProperty( const char* name, T*& out ) const - { - THeapData* t = (THeapData*)GetPropertyInternal(name); - if(!t) - { - out = NULL; - return false; - } - out = t->data; - return true; - } - - //! Get a static, by-value property - template - bool GetProperty( const char* name, T& out ) const - { - TStaticData* t = (TStaticData*)GetPropertyInternal(name); - if(!t)return false; - out = t->data; - return true; - } - - //! Remove a property of a specific type - void RemoveProperty( const char* name) { - SetGenericPropertyPtr(pmap,name,NULL); - } - -private: - - void AddProperty( const char* name, Base* data) { - SetGenericPropertyPtr(pmap,name,data); - } - - Base* GetPropertyInternal( const char* name) const { - return GetGenericProperty(pmap,name,NULL); - } - -private: - - //! Map of all stored properties - PropertyMap pmap; -}; - -#if 0 - -// --------------------------------------------------------------------------- -/** @brief Represents a dependency table for a postprocessing steps. - * - * For future use. - */ - struct PPDependencyTable - { - unsigned int execute_me_before_these; - unsigned int execute_me_after_these; - unsigned int only_if_these_are_not_specified; - unsigned int mutually_exclusive_with; - }; - -#endif - - -#define AI_SPP_SPATIAL_SORT "$Spat" - -// --------------------------------------------------------------------------- -/** The BaseProcess defines a common interface for all post processing steps. - * A post processing step is run after a successful import if the caller - * specified the corresponding flag when calling ReadFile(). - * Enum #aiPostProcessSteps defines which flags are available. - * After a successful import the Importer iterates over its internal array - * of processes and calls IsActive() on each process to evaluate if the step - * should be executed. If the function returns true, the class' Execute() - * function is called subsequently. - */ -class ASSIMP_API_WINONLY BaseProcess -{ - friend class Importer; - -public: - - /** Constructor to be privately used by Importer */ - BaseProcess(); - - /** Destructor, private as well */ - virtual ~BaseProcess(); - -public: - - // ------------------------------------------------------------------- - /** Returns whether the processing step is present in the given flag. - * @param pFlags The processing flags the importer was called with. A - * bitwise combination of #aiPostProcessSteps. - * @return true if the process is present in this flag fields, - * false if not. - */ - virtual bool IsActive( unsigned int pFlags) const = 0; - - // ------------------------------------------------------------------- - /** Check whether this step expects its input vertex data to be - * in verbose format. */ - virtual bool RequireVerboseFormat() const; - - // ------------------------------------------------------------------- - /** Executes the post processing step on the given imported data. - * The function deletes the scene if the postprocess step fails ( - * the object pointer will be set to NULL). - * @param pImp Importer instance (pImp->mScene must be valid) - */ - void ExecuteOnScene( Importer* pImp); - - // ------------------------------------------------------------------- - /** Called prior to ExecuteOnScene(). - * The function is a request to the process to update its configuration - * basing on the Importer's configuration property list. - */ - virtual void SetupProperties(const Importer* pImp); - - // ------------------------------------------------------------------- - /** Executes the post processing step on the given imported data. - * A process should throw an ImportErrorException* if it fails. - * This method must be implemented by deriving classes. - * @param pScene The imported data to work at. - */ - virtual void Execute( aiScene* pScene) = 0; - - - // ------------------------------------------------------------------- - /** Assign a new SharedPostProcessInfo to the step. This object - * allows multiple postprocess steps to share data. - * @param sh May be NULL - */ - inline void SetSharedData(SharedPostProcessInfo* sh) { - shared = sh; - } - - // ------------------------------------------------------------------- - /** Get the shared data that is assigned to the step. - */ - inline SharedPostProcessInfo* GetSharedData() { - return shared; - } - -protected: - - /** See the doc of #SharedPostProcessInfo for more details */ - SharedPostProcessInfo* shared; - - /** Currently active progress handler */ - ProgressHandler* progress; -}; - - -} // end of namespace Assimp - -#endif // AI_BASEPROCESS_H_INC diff --git a/src/3rdparty/assimp/code/Bitmap.cpp b/src/3rdparty/assimp/code/Bitmap.cpp deleted file mode 100644 index 76994513e..000000000 --- a/src/3rdparty/assimp/code/Bitmap.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file Bitmap.cpp - * @brief Defines bitmap format helper for textures - * - * Used for file formats which embed their textures into the model file. - */ - - -#include "Bitmap.h" -#include -#include -#include "ByteSwapper.h" - -namespace Assimp { - - void Bitmap::Save(aiTexture* texture, IOStream* file) { - if(file != NULL) { - Header header; - DIB dib; - - dib.size = DIB::dib_size; - dib.width = texture->mWidth; - dib.height = texture->mHeight; - dib.planes = 1; - dib.bits_per_pixel = 8 * mBytesPerPixel; - dib.compression = 0; - dib.image_size = (((dib.width * mBytesPerPixel) + 3) & 0x0000FFFC) * dib.height; - dib.x_resolution = 0; - dib.y_resolution = 0; - dib.nb_colors = 0; - dib.nb_important_colors = 0; - - header.type = 0x4D42; // 'BM' - header.offset = Header::header_size + DIB::dib_size; - header.size = header.offset + dib.image_size; - header.reserved1 = 0; - header.reserved2 = 0; - - WriteHeader(header, file); - WriteDIB(dib, file); - WriteData(texture, file); - } - } - - template - inline std::size_t Copy(uint8_t* data, T& field) { -#ifdef AI_BUILD_BIG_ENDIAN - T field_swapped=AI_BE(field); - std::memcpy(data, &field_swapped, sizeof(field)); return sizeof(field); -#else - std::memcpy(data, &AI_BE(field), sizeof(field)); return sizeof(field); -#endif - } - - void Bitmap::WriteHeader(Header& header, IOStream* file) { - uint8_t data[Header::header_size]; - - std::size_t offset = 0; - - offset += Copy(&data[offset], header.type); - offset += Copy(&data[offset], header.size); - offset += Copy(&data[offset], header.reserved1); - offset += Copy(&data[offset], header.reserved2); - Copy(&data[offset], header.offset); - - file->Write(data, Header::header_size, 1); - } - - void Bitmap::WriteDIB(DIB& dib, IOStream* file) { - uint8_t data[DIB::dib_size]; - - std::size_t offset = 0; - - offset += Copy(&data[offset], dib.size); - offset += Copy(&data[offset], dib.width); - offset += Copy(&data[offset], dib.height); - offset += Copy(&data[offset], dib.planes); - offset += Copy(&data[offset], dib.bits_per_pixel); - offset += Copy(&data[offset], dib.compression); - offset += Copy(&data[offset], dib.image_size); - offset += Copy(&data[offset], dib.x_resolution); - offset += Copy(&data[offset], dib.y_resolution); - offset += Copy(&data[offset], dib.nb_colors); - Copy(&data[offset], dib.nb_important_colors); - - file->Write(data, DIB::dib_size, 1); - } - - void Bitmap::WriteData(aiTexture* texture, IOStream* file) { - static const std::size_t padding_offset = 4; - static const uint8_t padding_data[padding_offset] = {0x0, 0x0, 0x0, 0x0}; - - unsigned int padding = (padding_offset - ((mBytesPerPixel * texture->mWidth) % padding_offset)) % padding_offset; - uint8_t pixel[mBytesPerPixel]; - - for(std::size_t i = 0; i < texture->mHeight; ++i) { - for(std::size_t j = 0; j < texture->mWidth; ++j) { - const aiTexel& texel = texture->pcData[(texture->mHeight - i - 1) * texture->mWidth + j]; // Bitmap files are stored in bottom-up format - - pixel[0] = texel.r; - pixel[1] = texel.g; - pixel[2] = texel.b; - pixel[3] = texel.a; - - file->Write(pixel, mBytesPerPixel, 1); - } - - file->Write(padding_data, padding, 1); - } - } - -} diff --git a/src/3rdparty/assimp/code/Bitmap.h b/src/3rdparty/assimp/code/Bitmap.h deleted file mode 100644 index 96c994dbe..000000000 --- a/src/3rdparty/assimp/code/Bitmap.h +++ /dev/null @@ -1,123 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file Bitmap.h - * @brief Defines bitmap format helper for textures - * - * Used for file formats which embed their textures into the model file. - */ - -#ifndef AI_BITMAP_H_INC -#define AI_BITMAP_H_INC - -#include -#include - -struct aiTexture; - -namespace Assimp { - -class IOStream; - -class Bitmap { -protected: - - struct Header { - uint16_t type; - uint32_t size; - uint16_t reserved1; - uint16_t reserved2; - uint32_t offset; - - // We define the struct size because sizeof(Header) might return a wrong result because of structure padding. - // Moreover, we must use this ugly and error prone syntax because Visual Studio neither support constexpr or sizeof(name_of_field). - static const std::size_t header_size = - sizeof(uint16_t) + // type - sizeof(uint32_t) + // size - sizeof(uint16_t) + // reserved1 - sizeof(uint16_t) + // reserved2 - sizeof(uint32_t); // offset - }; - - struct DIB { - uint32_t size; - int32_t width; - int32_t height; - uint16_t planes; - uint16_t bits_per_pixel; - uint32_t compression; - uint32_t image_size; - int32_t x_resolution; - int32_t y_resolution; - uint32_t nb_colors; - uint32_t nb_important_colors; - - // We define the struct size because sizeof(DIB) might return a wrong result because of structure padding. - // Moreover, we must use this ugly and error prone syntax because Visual Studio neither support constexpr or sizeof(name_of_field). - static const std::size_t dib_size = - sizeof(uint32_t) + // size - sizeof(int32_t) + // width - sizeof(int32_t) + // height - sizeof(uint16_t) + // planes - sizeof(uint16_t) + // bits_per_pixel - sizeof(uint32_t) + // compression - sizeof(uint32_t) + // image_size - sizeof(int32_t) + // x_resolution - sizeof(int32_t) + // y_resolution - sizeof(uint32_t) + // nb_colors - sizeof(uint32_t); // nb_important_colors - }; - - static const std::size_t mBytesPerPixel = 4; - -public: - static void Save(aiTexture* texture, IOStream* file); - -protected: - static void WriteHeader(Header& header, IOStream* file); - static void WriteDIB(DIB& dib, IOStream* file); - static void WriteData(aiTexture* texture, IOStream* file); -}; - -} - -#endif // AI_BITMAP_H_INC diff --git a/src/3rdparty/assimp/code/BlenderBMesh.cpp b/src/3rdparty/assimp/code/BlenderBMesh.cpp deleted file mode 100644 index 8a13819a6..000000000 --- a/src/3rdparty/assimp/code/BlenderBMesh.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2013, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file BlenderBMesh.cpp - * @brief Conversion of Blender's new BMesh stuff - */ - - -#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER - -#include "BlenderDNA.h" -#include "BlenderScene.h" -#include "BlenderBMesh.h" -#include "BlenderTessellator.h" - -namespace Assimp -{ - template< > const char* LogFunctions< BlenderBMeshConverter >::Prefix() - { - static auto prefix = "BLEND_BMESH: "; - return prefix; - } -} - -using namespace Assimp; -using namespace Assimp::Blender; -using namespace Assimp::Formatter; - -// ------------------------------------------------------------------------------------------------ -BlenderBMeshConverter::BlenderBMeshConverter( const Mesh* mesh ): - BMesh( mesh ), - triMesh( NULL ) -{ -} - -// ------------------------------------------------------------------------------------------------ -BlenderBMeshConverter::~BlenderBMeshConverter( ) -{ - DestroyTriMesh( ); -} - -// ------------------------------------------------------------------------------------------------ -bool BlenderBMeshConverter::ContainsBMesh( ) const -{ - // TODO - Should probably do some additional verification here - return BMesh->totpoly && BMesh->totloop && BMesh->totvert; -} - -// ------------------------------------------------------------------------------------------------ -const Mesh* BlenderBMeshConverter::TriangulateBMesh( ) -{ - AssertValidMesh( ); - AssertValidSizes( ); - PrepareTriMesh( ); - - for ( int i = 0; i < BMesh->totpoly; ++i ) - { - const MPoly& poly = BMesh->mpoly[ i ]; - ConvertPolyToFaces( poly ); - } - - return triMesh; -} - -// ------------------------------------------------------------------------------------------------ -void BlenderBMeshConverter::AssertValidMesh( ) -{ - if ( !ContainsBMesh( ) ) - { - ThrowException( "BlenderBMeshConverter requires a BMesh with \"polygons\" - please call BlenderBMeshConverter::ContainsBMesh to check this first" ); - } -} - -// ------------------------------------------------------------------------------------------------ -void BlenderBMeshConverter::AssertValidSizes( ) -{ - if ( BMesh->totpoly != static_cast( BMesh->mpoly.size( ) ) ) - { - ThrowException( "BMesh poly array has incorrect size" ); - } - if ( BMesh->totloop != static_cast( BMesh->mloop.size( ) ) ) - { - ThrowException( "BMesh loop array has incorrect size" ); - } -} - -// ------------------------------------------------------------------------------------------------ -void BlenderBMeshConverter::PrepareTriMesh( ) -{ - if ( triMesh ) - { - DestroyTriMesh( ); - } - - triMesh = new Mesh( *BMesh ); - triMesh->totface = 0; - triMesh->mface.clear( ); -} - -// ------------------------------------------------------------------------------------------------ -void BlenderBMeshConverter::DestroyTriMesh( ) -{ - delete triMesh; - triMesh = NULL; -} - -// ------------------------------------------------------------------------------------------------ -void BlenderBMeshConverter::ConvertPolyToFaces( const MPoly& poly ) -{ - const MLoop* polyLoop = &BMesh->mloop[ poly.loopstart ]; - - if ( poly.totloop == 3 || poly.totloop == 4 ) - { - AddFace( polyLoop[ 0 ].v, polyLoop[ 1 ].v, polyLoop[ 2 ].v, poly.totloop == 4 ? polyLoop[ 3 ].v : 0 ); - - // UVs are optional, so only convert when present. - if ( BMesh->mloopuv.size() ) - { - if ( (poly.loopstart + poly.totloop ) > static_cast( BMesh->mloopuv.size() ) ) - { - ThrowException( "BMesh uv loop array has incorrect size" ); - } - const MLoopUV* loopUV = &BMesh->mloopuv[ poly.loopstart ]; - AddTFace( loopUV[ 0 ].uv, loopUV[ 1 ].uv, loopUV[ 2 ].uv, poly.totloop == 4 ? loopUV[ 3 ].uv : 0 ); - } - } - else if ( poly.totloop > 4 ) - { -#if ASSIMP_BLEND_WITH_GLU_TESSELLATE - BlenderTessellatorGL tessGL( *this ); - tessGL.Tessellate( polyLoop, poly.totloop, triMesh->mvert ); -#elif ASSIMP_BLEND_WITH_POLY_2_TRI - BlenderTessellatorP2T tessP2T( *this ); - tessP2T.Tessellate( polyLoop, poly.totloop, triMesh->mvert ); -#endif - } -} - -// ------------------------------------------------------------------------------------------------ -void BlenderBMeshConverter::AddFace( int v1, int v2, int v3, int v4 ) -{ - MFace face; - face.v1 = v1; - face.v2 = v2; - face.v3 = v3; - face.v4 = v4; - // TODO - Work out how materials work - face.mat_nr = 0; - triMesh->mface.push_back( face ); - triMesh->totface = static_cast(triMesh->mface.size( )); -} - -// ------------------------------------------------------------------------------------------------ -void BlenderBMeshConverter::AddTFace( const float* uv1, const float *uv2, const float *uv3, const float* uv4 ) -{ - MTFace mtface; - memcpy( &mtface.uv[ 0 ], uv1, sizeof(float) * 2 ); - memcpy( &mtface.uv[ 1 ], uv2, sizeof(float) * 2 ); - memcpy( &mtface.uv[ 2 ], uv3, sizeof(float) * 2 ); - - if ( uv4 ) - { - memcpy( &mtface.uv[ 3 ], uv4, sizeof(float) * 2 ); - } - - triMesh->mtface.push_back( mtface ); -} - -#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER diff --git a/src/3rdparty/assimp/code/BlenderBMesh.h b/src/3rdparty/assimp/code/BlenderBMesh.h deleted file mode 100644 index 0d58b818c..000000000 --- a/src/3rdparty/assimp/code/BlenderBMesh.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2013, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file BlenderBMesh.h - * @brief Conversion of Blender's new BMesh stuff - */ -#ifndef INCLUDED_AI_BLEND_BMESH_H -#define INCLUDED_AI_BLEND_BMESH_H - -#include "LogAux.h" - -namespace Assimp -{ - // TinyFormatter.h - namespace Formatter - { - template < typename T,typename TR, typename A > class basic_formatter; - typedef class basic_formatter< char, std::char_traits< char >, std::allocator< char > > format; - } - - // BlenderScene.h - namespace Blender - { - struct Mesh; - struct MPoly; - struct MLoop; - } - - class BlenderBMeshConverter: public LogFunctions< BlenderBMeshConverter > - { - public: - BlenderBMeshConverter( const Blender::Mesh* mesh ); - ~BlenderBMeshConverter( ); - - bool ContainsBMesh( ) const; - - const Blender::Mesh* TriangulateBMesh( ); - - private: - void AssertValidMesh( ); - void AssertValidSizes( ); - void PrepareTriMesh( ); - void DestroyTriMesh( ); - void ConvertPolyToFaces( const Blender::MPoly& poly ); - void AddFace( int v1, int v2, int v3, int v4 = 0 ); - void AddTFace( const float* uv1, const float* uv2, const float *uv3, const float* uv4 = 0 ); - - const Blender::Mesh* BMesh; - Blender::Mesh* triMesh; - - friend class BlenderTessellatorGL; - friend class BlenderTessellatorP2T; - }; - -} // end of namespace Assimp - -#endif // INCLUDED_AI_BLEND_BMESH_H diff --git a/src/3rdparty/assimp/code/BlenderDNA.cpp b/src/3rdparty/assimp/code/BlenderDNA.cpp deleted file mode 100644 index 23ece913f..000000000 --- a/src/3rdparty/assimp/code/BlenderDNA.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file BlenderDNA.cpp - * @brief Implementation of the Blender `DNA`, that is its own - * serialized set of data structures. - */ - - -#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER -#include "BlenderDNA.h" -#include "StreamReader.h" -#include "fast_atof.h" -#include "TinyFormatter.h" - -using namespace Assimp; -using namespace Assimp::Blender; -using namespace Assimp::Formatter; - -static bool match4(StreamReaderAny& stream, const char* string) { - ai_assert( nullptr != string ); - char tmp[] = { - (const char)(stream).GetI1(), - (const char)(stream).GetI1(), - (const char)(stream).GetI1(), - (const char)(stream).GetI1() - }; - return (tmp[0]==string[0] && tmp[1]==string[1] && tmp[2]==string[2] && tmp[3]==string[3]); -} - -struct Type { - size_t size; - std::string name; -}; - -// ------------------------------------------------------------------------------------------------ -void DNAParser::Parse () -{ - StreamReaderAny& stream = *db.reader.get(); - DNA& dna = db.dna; - - if(!match4(stream,"SDNA")) { - throw DeadlyImportError("BlenderDNA: Expected SDNA chunk"); - } - - // name dictionary - if(!match4(stream,"NAME")) { - throw DeadlyImportError("BlenderDNA: Expected NAME field"); - } - - std::vector names (stream.GetI4()); - for(std::string& s : names) { - while (char c = stream.GetI1()) { - s += c; - } - } - - // type dictionary - for (;stream.GetCurrentPos() & 0x3; stream.GetI1()); - if(!match4(stream,"TYPE")) { - throw DeadlyImportError("BlenderDNA: Expected TYPE field"); - } - - std::vector types (stream.GetI4()); - for(Type& s : types) { - while (char c = stream.GetI1()) { - s.name += c; - } - } - - // type length dictionary - for (;stream.GetCurrentPos() & 0x3; stream.GetI1()); - if(!match4(stream,"TLEN")) { - throw DeadlyImportError("BlenderDNA: Expected TLEN field"); - } - - for(Type& s : types) { - s.size = stream.GetI2(); - } - - // structures dictionary - for (;stream.GetCurrentPos() & 0x3; stream.GetI1()); - if(!match4(stream,"STRC")) { - throw DeadlyImportError("BlenderDNA: Expected STRC field"); - } - - size_t end = stream.GetI4(), fields = 0; - - dna.structures.reserve(end); - for(size_t i = 0; i != end; ++i) { - - uint16_t n = stream.GetI2(); - if (n >= types.size()) { - throw DeadlyImportError((format(), - "BlenderDNA: Invalid type index in structure name" ,n, - " (there are only ", types.size(), " entries)" - )); - } - - // maintain separate indexes - dna.indices[types[n].name] = dna.structures.size(); - - dna.structures.push_back(Structure()); - Structure& s = dna.structures.back(); - s.name = types[n].name; - //s.index = dna.structures.size()-1; - - n = stream.GetI2(); - s.fields.reserve(n); - - size_t offset = 0; - for (size_t m = 0; m < n; ++m, ++fields) { - - uint16_t j = stream.GetI2(); - if (j >= types.size()) { - throw DeadlyImportError((format(), - "BlenderDNA: Invalid type index in structure field ", j, - " (there are only ", types.size(), " entries)" - )); - } - s.fields.push_back(Field()); - Field& f = s.fields.back(); - f.offset = offset; - - f.type = types[j].name; - f.size = types[j].size; - - j = stream.GetI2(); - if (j >= names.size()) { - throw DeadlyImportError((format(), - "BlenderDNA: Invalid name index in structure field ", j, - " (there are only ", names.size(), " entries)" - )); - } - - f.name = names[j]; - f.flags = 0u; - - // pointers always specify the size of the pointee instead of their own. - // The pointer asterisk remains a property of the lookup name. - if (f.name[0] == '*') { - f.size = db.i64bit ? 8 : 4; - f.flags |= FieldFlag_Pointer; - } - - // arrays, however, specify the size of a single element so we - // need to parse the (possibly multi-dimensional) array declaration - // in order to obtain the actual size of the array in the file. - // Also we need to alter the lookup name to include no array - // brackets anymore or size fixup won't work (if our size does - // not match the size read from the DNA). - if (*f.name.rbegin() == ']') { - const std::string::size_type rb = f.name.find('['); - if (rb == std::string::npos) { - throw DeadlyImportError((format(), - "BlenderDNA: Encountered invalid array declaration ", - f.name - )); - } - - f.flags |= FieldFlag_Array; - DNA::ExtractArraySize(f.name,f.array_sizes); - f.name = f.name.substr(0,rb); - - f.size *= f.array_sizes[0] * f.array_sizes[1]; - } - - // maintain separate indexes - s.indices[f.name] = s.fields.size()-1; - offset += f.size; - } - s.size = offset; - } - - DefaultLogger::get()->debug((format(),"BlenderDNA: Got ",dna.structures.size(), - " structures with totally ",fields," fields")); - -#ifdef ASSIMP_BUILD_BLENDER_DEBUG - dna.DumpToFile(); -#endif - - dna.AddPrimitiveStructures(); - dna.RegisterConverters(); -} - - -#ifdef ASSIMP_BUILD_BLENDER_DEBUG - -#include -// ------------------------------------------------------------------------------------------------ -void DNA :: DumpToFile() -{ - // we dont't bother using the VFS here for this is only for debugging. - // (and all your bases are belong to us). - - std::ofstream f("dna.txt"); - if (f.fail()) { - DefaultLogger::get()->error("Could not dump dna to dna.txt"); - return; - } - f << "Field format: type name offset size" << "\n"; - f << "Structure format: name size" << "\n"; - - for(const Structure& s : structures) { - f << s.name << " " << s.size << "\n\n"; - for(const Field& ff : s.fields) { - f << "\t" << ff.type << " " << ff.name << " " << ff.offset << " " << ff.size << "\n"; - } - f << "\n"; - } - f << std::flush; - - DefaultLogger::get()->info("BlenderDNA: Dumped dna to dna.txt"); -} -#endif - -// ------------------------------------------------------------------------------------------------ -/*static*/ void DNA :: ExtractArraySize( - const std::string& out, - size_t array_sizes[2] -) -{ - array_sizes[0] = array_sizes[1] = 1; - std::string::size_type pos = out.find('['); - if (pos++ == std::string::npos) { - return; - } - array_sizes[0] = strtoul10(&out[pos]); - - pos = out.find('[',pos); - if (pos++ == std::string::npos) { - return; - } - array_sizes[1] = strtoul10(&out[pos]); -} - -// ------------------------------------------------------------------------------------------------ -std::shared_ptr< ElemBase > DNA :: ConvertBlobToStructure( - const Structure& structure, - const FileDatabase& db -) const -{ - std::map::const_iterator it = converters.find(structure.name); - if (it == converters.end()) { - return std::shared_ptr< ElemBase >(); - } - - std::shared_ptr< ElemBase > ret = (structure.*((*it).second.first))(); - (structure.*((*it).second.second))(ret,db); - - return ret; -} - -// ------------------------------------------------------------------------------------------------ -DNA::FactoryPair DNA :: GetBlobToStructureConverter( - const Structure& structure, - const FileDatabase& /*db*/ -) const -{ - std::map::const_iterator it = converters.find(structure.name); - return it == converters.end() ? FactoryPair() : (*it).second; -} - -// basing on http://www.blender.org/development/architecture/notes-on-sdna/ -// ------------------------------------------------------------------------------------------------ -void DNA :: AddPrimitiveStructures() -{ - // NOTE: these are just dummies. Their presence enforces - // Structure::Convert to be called on these - // empty structures. These converters are special - // overloads which scan the name of the structure and - // perform the required data type conversion if one - // of these special names is found in the structure - // in question. - - indices["int"] = structures.size(); - structures.push_back( Structure() ); - structures.back().name = "int"; - structures.back().size = 4; - - indices["short"] = structures.size(); - structures.push_back( Structure() ); - structures.back().name = "short"; - structures.back().size = 2; - - - indices["char"] = structures.size(); - structures.push_back( Structure() ); - structures.back().name = "char"; - structures.back().size = 1; - - - indices["float"] = structures.size(); - structures.push_back( Structure() ); - structures.back().name = "float"; - structures.back().size = 4; - - - indices["double"] = structures.size(); - structures.push_back( Structure() ); - structures.back().name = "double"; - structures.back().size = 8; - - // no long, seemingly. -} - -// ------------------------------------------------------------------------------------------------ -void SectionParser :: Next() -{ - stream.SetCurrentPos(current.start + current.size); - - const char tmp[] = { - (const char)stream.GetI1(), - (const char)stream.GetI1(), - (const char)stream.GetI1(), - (const char)stream.GetI1() - }; - current.id = std::string(tmp,tmp[3]?4:tmp[2]?3:tmp[1]?2:1); - - current.size = stream.GetI4(); - current.address.val = ptr64 ? stream.GetU8() : stream.GetU4(); - - current.dna_index = stream.GetI4(); - current.num = stream.GetI4(); - - current.start = stream.GetCurrentPos(); - if (stream.GetRemainingSizeToLimit() < current.size) { - throw DeadlyImportError("BLEND: invalid size of file block"); - } - -#ifdef ASSIMP_BUILD_BLENDER_DEBUG - DefaultLogger::get()->debug(current.id); -#endif -} - - - -#endif diff --git a/src/3rdparty/assimp/code/BlenderDNA.h b/src/3rdparty/assimp/code/BlenderDNA.h deleted file mode 100644 index bac8d78bc..000000000 --- a/src/3rdparty/assimp/code/BlenderDNA.h +++ /dev/null @@ -1,810 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2017, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file BlenderDNA.h - * @brief Blender `DNA` (file format specification embedded in - * blend file itself) loader. - */ -#ifndef INCLUDED_AI_BLEND_DNA_H -#define INCLUDED_AI_BLEND_DNA_H - -#include "BaseImporter.h" -#include "StreamReader.h" -#include -#include -#include -#include - -// enable verbose log output. really verbose, so be careful. -#ifdef ASSIMP_BUILD_DEBUG -# define ASSIMP_BUILD_BLENDER_DEBUG -#endif - -// #define ASSIMP_BUILD_BLENDER_NO_STATS - -namespace Assimp { - -template class StreamReader; -typedef StreamReader StreamReaderAny; - -namespace Blender { - -class FileDatabase; -struct FileBlockHead; - -template