diff --git a/.travis.yml b/.travis.yml
index e768c530c..8b00b4cc7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,16 +27,11 @@ compiler:
env:
global:
- # COVERITY_SCAN_TOKEN
- secure: "lZ7pHQvl5dpZWzBQAaIMf0wqrvtcZ4wiZKeIZjf83TEsflW8+z0uTpIuN30ZV6Glth/Sq1OhLnTP5+N57fZU/1ebA5twHdvP4bS5CIUUg71/CXQZNl36xeaqvxsG/xRrdpKOsPdjAOsQ9KPTQulsX43XDLS7CasMiLvYOpqKcPc="
- PV=r8e PLATF=linux-x86_64 NDK_HOME=${TRAVIS_BUILD_DIR}/android-ndk-${PV} PATH=${PATH}:${NDK_HOME}
matrix:
include:
- # disabled until clang 5.0 analyzer issues are fixed
- # - os: linux
- # compiler: clang
- # env: ANALYZE=ON
- os: linux
compiler: clang
env: ASAN=ON
@@ -51,7 +46,6 @@ matrix:
env: ANALYZE=ON
- os: linux
compiler: gcc
-# env: DISABLE_EXPORTERS=YES ENABLE_COVERALLS=ON
env: ENABLE_COVERALLS=ON
- os: linux
compiler: gcc
@@ -61,8 +55,7 @@ install:
- if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi
before_script:
- # init coverage to 0 (optional)
- - if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ${TRAVIS_BUILD_DIR} && lcov --directory . --zerocounters ; fi
+ cmake . -DASSIMP_ENABLE_BOOST_WORKAROUND=YES
script:
- export COVERALLS_SERVICE_NAME=travis-ci
@@ -77,6 +70,6 @@ addons:
project:
name: "assimp/assimp"
notification_email: kim.kulling@googlemail.com
- build_command_prepend: "cmake"
- build_command: "make"
+ build_command_prepend: "cmake . -DASSIMP_ENABLE_BOOST_WORKAROUND=YES"
+ build_command: "make -j4"
branch_pattern: coverity_scan
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 645d92689..14c65c188 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
# Open Asset Import Library (assimp)
# ----------------------------------------------------------------------
-# Copyright (c) 2006-2018, assimp team
+# Copyright (c) 2006-2019, assimp team
# All rights reserved.
#
@@ -119,6 +119,7 @@ IF (IOS)
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release")
ENDIF (NOT CMAKE_BUILD_TYPE)
+ ADD_DEFINITIONS(-DENABLE_BITCODE)
ENDIF (IOS)
# Use subset of Windows.h
@@ -126,6 +127,7 @@ if (WIN32)
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
endif()
+
IF(MSVC)
OPTION( ASSIMP_INSTALL_PDB
"Install MSVC debug files."
diff --git a/Readme.md b/Readme.md
index 1ba026d5a..7f42fb75c 100644
--- a/Readme.md
+++ b/Readme.md
@@ -10,6 +10,8 @@ A library to import and export various 3d-model-formats including scene-post-pro
[![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)
+[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
+[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5be56faac64f46fc941ac890fb4febef)](https://www.codacy.com/app/kimkulling/assimp?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
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.
diff --git a/assimp.pc.in b/assimp.pc.in
index 02cf59dc4..c659e19f2 100644
--- a/assimp.pc.in
+++ b/assimp.pc.in
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@/
libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@
-includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@
+includedir=@CMAKE_INSTALL_PREFIX@/../include/@ASSIMP_INCLUDE_INSTALL_DIR@
Name: @CMAKE_PROJECT_NAME@
Description: Import various well-known 3D model formats in an uniform manner.
diff --git a/code/3DSConverter.cpp b/code/3DSConverter.cpp
index 7ec79ba64..e6865a809 100644
--- a/code/3DSConverter.cpp
+++ b/code/3DSConverter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/3DSExporter.cpp b/code/3DSExporter.cpp
index 53976b16f..2501d4049 100644
--- a/code/3DSExporter.cpp
+++ b/code/3DSExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/3DSExporter.h b/code/3DSExporter.h
index 5db58a4cb..035b562cf 100644
--- a/code/3DSExporter.h
+++ b/code/3DSExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/3DSHelper.h b/code/3DSHelper.h
index d67a7c14c..8eb4cd97c 100644
--- a/code/3DSHelper.h
+++ b/code/3DSHelper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp
index 34066e44b..24626d936 100644
--- a/code/3DSLoader.cpp
+++ b/code/3DSLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/3DSLoader.h b/code/3DSLoader.h
index eb311a81b..f57e6a8e3 100644
--- a/code/3DSLoader.h
+++ b/code/3DSLoader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/3MFXmlTags.h b/code/3MFXmlTags.h
index e869c33c1..ea6aeede0 100644
--- a/code/3MFXmlTags.h
+++ b/code/3MFXmlTags.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ACLoader.cpp b/code/ACLoader.cpp
index 7b8afbe9b..2eb839553 100644
--- a/code/ACLoader.cpp
+++ b/code/ACLoader.cpp
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/ACLoader.h b/code/ACLoader.h
index 86af9afb6..cab2c3ae5 100644
--- a/code/ACLoader.h
+++ b/code/ACLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/AMFImporter.cpp b/code/AMFImporter.cpp
index e5b41b3ad..d173bd0f5 100644
--- a/code/AMFImporter.cpp
+++ b/code/AMFImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AMFImporter.hpp b/code/AMFImporter.hpp
index b7e58362c..2b8086a06 100644
--- a/code/AMFImporter.hpp
+++ b/code/AMFImporter.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AMFImporter_Geometry.cpp b/code/AMFImporter_Geometry.cpp
index d4d648fbd..f1538e3fb 100644
--- a/code/AMFImporter_Geometry.cpp
+++ b/code/AMFImporter_Geometry.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AMFImporter_Macro.hpp b/code/AMFImporter_Macro.hpp
index ea8c17850..f60c5fbbb 100644
--- a/code/AMFImporter_Macro.hpp
+++ b/code/AMFImporter_Macro.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AMFImporter_Material.cpp b/code/AMFImporter_Material.cpp
index c9190bb92..2f36df061 100644
--- a/code/AMFImporter_Material.cpp
+++ b/code/AMFImporter_Material.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AMFImporter_Node.hpp b/code/AMFImporter_Node.hpp
index 22b8f58cb..a1bf9f008 100644
--- a/code/AMFImporter_Node.hpp
+++ b/code/AMFImporter_Node.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AMFImporter_Postprocess.cpp b/code/AMFImporter_Postprocess.cpp
index a6ee8fa2f..2bfe3f78c 100644
--- a/code/AMFImporter_Postprocess.cpp
+++ b/code/AMFImporter_Postprocess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/ASELoader.cpp b/code/ASELoader.cpp
index 1808f25e2..321e8548a 100644
--- a/code/ASELoader.cpp
+++ b/code/ASELoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/ASELoader.h b/code/ASELoader.h
index 7f71bf49d..33406e3e5 100644
--- a/code/ASELoader.h
+++ b/code/ASELoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp
index 298c6fe61..e8d6febc2 100644
--- a/code/ASEParser.cpp
+++ b/code/ASEParser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/ASEParser.h b/code/ASEParser.h
index 305a3f3d6..b8c820632 100644
--- a/code/ASEParser.h
+++ b/code/ASEParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/AssbinExporter.cpp b/code/AssbinExporter.cpp
index f49389f78..77c8d1118 100644
--- a/code/AssbinExporter.cpp
+++ b/code/AssbinExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/AssbinExporter.h b/code/AssbinExporter.h
index ee70d78b6..3e13639bb 100644
--- a/code/AssbinExporter.h
+++ b/code/AssbinExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/AssbinLoader.cpp b/code/AssbinLoader.cpp
index 321a0cfec..7adb8db6f 100644
--- a/code/AssbinLoader.cpp
+++ b/code/AssbinLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AssbinLoader.h b/code/AssbinLoader.h
index 37799a2c8..9f2dde125 100644
--- a/code/AssbinLoader.h
+++ b/code/AssbinLoader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/Assimp.cpp b/code/Assimp.cpp
index 87f436602..41e1a4800 100644
--- a/code/Assimp.cpp
+++ b/code/Assimp.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AssimpCExport.cpp b/code/AssimpCExport.cpp
index caf51a08c..5121ce39c 100644
--- a/code/AssimpCExport.cpp
+++ b/code/AssimpCExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/AssxmlExporter.cpp b/code/AssxmlExporter.cpp
index c9e125d0d..fafee0e80 100644
--- a/code/AssxmlExporter.cpp
+++ b/code/AssxmlExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/AssxmlExporter.h b/code/AssxmlExporter.h
index 3db496db2..8ca887eea 100644
--- a/code/AssxmlExporter.h
+++ b/code/AssxmlExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/B3DImporter.cpp b/code/B3DImporter.cpp
index ce8bd5159..e48646de9 100644
--- a/code/B3DImporter.cpp
+++ b/code/B3DImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/B3DImporter.h b/code/B3DImporter.h
index 3cb66e5c7..d52dac34a 100644
--- a/code/B3DImporter.h
+++ b/code/B3DImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BVHLoader.cpp b/code/BVHLoader.cpp
index cba58d056..cd9ab0843 100644
--- a/code/BVHLoader.cpp
+++ b/code/BVHLoader.cpp
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/BVHLoader.h b/code/BVHLoader.h
index a18ad81d9..33b4e2453 100644
--- a/code/BVHLoader.h
+++ b/code/BVHLoader.h
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BaseImporter.cpp b/code/BaseImporter.cpp
index f03db189f..4803c6d6f 100644
--- a/code/BaseImporter.cpp
+++ b/code/BaseImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/BaseProcess.cpp b/code/BaseProcess.cpp
index 154b586d2..18872c369 100644
--- a/code/BaseProcess.cpp
+++ b/code/BaseProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/BaseProcess.h b/code/BaseProcess.h
index b09fc732e..4d5c7a76b 100644
--- a/code/BaseProcess.h
+++ b/code/BaseProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/Bitmap.cpp b/code/Bitmap.cpp
index 903a13fb1..b22b71ea9 100644
--- a/code/Bitmap.cpp
+++ b/code/Bitmap.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/BlenderCustomData.cpp b/code/BlenderCustomData.cpp
index 682186618..6561eaf22 100644
--- a/code/BlenderCustomData.cpp
+++ b/code/BlenderCustomData.cpp
@@ -28,7 +28,11 @@ namespace Assimp {
#define IMPL_STRUCT_READ(ty) \
bool read##ty(ElemBase *v, const size_t cnt, const FileDatabase &db) { \
- return read(db.dna[#ty], dynamic_cast(v), cnt, db); \
+ ty *ptr = dynamic_cast(v); \
+ if (nullptr == ptr) { \
+ return false; \
+ } \
+ return read(db.dna[#ty], ptr, cnt, db); \
}
#define IMPL_STRUCT_CREATE(ty) \
diff --git a/code/BlenderDNA.cpp b/code/BlenderDNA.cpp
index f84c45601..f274e02f9 100644
--- a/code/BlenderDNA.cpp
+++ b/code/BlenderDNA.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderDNA.h b/code/BlenderDNA.h
index ecf606a3b..5d3a4f6ea 100644
--- a/code/BlenderDNA.h
+++ b/code/BlenderDNA.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderDNA.inl b/code/BlenderDNA.inl
index 89c94e7bf..65bc1374c 100644
--- a/code/BlenderDNA.inl
+++ b/code/BlenderDNA.inl
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderIntermediate.h b/code/BlenderIntermediate.h
index f3d34d1b2..95fdf0f03 100644
--- a/code/BlenderIntermediate.h
+++ b/code/BlenderIntermediate.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderLoader.cpp b/code/BlenderLoader.cpp
index b0d273a5f..90065ceee 100644
--- a/code/BlenderLoader.cpp
+++ b/code/BlenderLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderLoader.h b/code/BlenderLoader.h
index 9f452a0aa..d85a82842 100644
--- a/code/BlenderLoader.h
+++ b/code/BlenderLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderModifier.cpp b/code/BlenderModifier.cpp
index 1f32ee410..cc7acc929 100644
--- a/code/BlenderModifier.cpp
+++ b/code/BlenderModifier.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderModifier.h b/code/BlenderModifier.h
index b8797691b..c260ba1f6 100644
--- a/code/BlenderModifier.h
+++ b/code/BlenderModifier.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderScene.h b/code/BlenderScene.h
index b74d7b198..8e4223eb1 100644
--- a/code/BlenderScene.h
+++ b/code/BlenderScene.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderTessellator.cpp b/code/BlenderTessellator.cpp
index afedbfb53..d98c2e865 100644
--- a/code/BlenderTessellator.cpp
+++ b/code/BlenderTessellator.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/BlenderTessellator.h b/code/BlenderTessellator.h
index dab3ba8aa..8675b4e57 100644
--- a/code/BlenderTessellator.h
+++ b/code/BlenderTessellator.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/CInterfaceIOWrapper.cpp b/code/CInterfaceIOWrapper.cpp
index 41dbba772..5a3a49565 100644
--- a/code/CInterfaceIOWrapper.cpp
+++ b/code/CInterfaceIOWrapper.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/CInterfaceIOWrapper.h b/code/CInterfaceIOWrapper.h
index 6f0eb7957..216232030 100644
--- a/code/CInterfaceIOWrapper.h
+++ b/code/CInterfaceIOWrapper.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt
index f34aac5c9..1726fda72 100644
--- a/code/CMakeLists.txt
+++ b/code/CMakeLists.txt
@@ -1,7 +1,7 @@
# Open Asset Import Library (assimp)
# ----------------------------------------------------------------------
#
-# Copyright (c) 2006-2018, assimp team
+# Copyright (c) 2006-2019, assimp team
# All rights reserved.
@@ -727,7 +727,7 @@ ADD_ASSIMP_IMPORTER( MMD
MMDVmdParser.h
)
-SET( Step_SRCS
+ADD_ASSIMP_IMPORTER( STEP
STEPFile.h
Importer/StepFile/StepFileImporter.h
Importer/StepFile/StepFileImporter.cpp
@@ -738,7 +738,6 @@ SET( Step_SRCS
StepExporter.h
StepExporter.cpp
)
-SOURCE_GROUP( Step FILES ${Step_SRCS})
SET( Exporter_SRCS
Exporter.cpp
@@ -891,7 +890,7 @@ SET( assimp_src
${PostProcessing_SRCS}
${MaterialSystem_SRCS}
${STEPParser_SRCS}
- ${Step_SRCS}
+# ${Step_SRCS} check if we need a different approach
# Model Support
${ASSIMP_LOADER_SRCS}
@@ -923,7 +922,7 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
ADD_LIBRARY( assimp ${assimp_src} )
-ADD_LIBRARY(assimp::asimp ALIAS assimp)
+ADD_LIBRARY(assimp::assimp ALIAS assimp)
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
$
@@ -967,6 +966,9 @@ if( MSVC )
set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library")
endif()
+if (${CMAKE_SYSTEM_NAME} MATCHES "WindowsStore")
+ set(WindowsStore TRUE)
+endif()
SET_TARGET_PROPERTIES( assimp PROPERTIES
VERSION ${ASSIMP_VERSION}
SOVERSION ${ASSIMP_SOVERSION} # use full version
diff --git a/code/COBLoader.cpp b/code/COBLoader.cpp
index a8e41dbbc..efb22e08b 100644
--- a/code/COBLoader.cpp
+++ b/code/COBLoader.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/COBLoader.h b/code/COBLoader.h
index 156c8d911..40fed324b 100644
--- a/code/COBLoader.h
+++ b/code/COBLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/COBScene.h b/code/COBScene.h
index 2473c42a5..90349be70 100644
--- a/code/COBScene.h
+++ b/code/COBScene.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/CSMLoader.cpp b/code/CSMLoader.cpp
index 777b6cf1b..9dbb38467 100644
--- a/code/CSMLoader.cpp
+++ b/code/CSMLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/CSMLoader.h b/code/CSMLoader.h
index ea82bb87a..31a814b52 100644
--- a/code/CSMLoader.h
+++ b/code/CSMLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/CalcTangentsProcess.cpp b/code/CalcTangentsProcess.cpp
index 54e55fc5a..b30f39c27 100644
--- a/code/CalcTangentsProcess.cpp
+++ b/code/CalcTangentsProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/CalcTangentsProcess.h b/code/CalcTangentsProcess.h
index 4cac2ed9f..18775abcc 100644
--- a/code/CalcTangentsProcess.h
+++ b/code/CalcTangentsProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp
index 96421a532..37a6ba4e0 100644
--- a/code/ColladaExporter.cpp
+++ b/code/ColladaExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
@@ -1500,24 +1500,18 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
// otherwise it is a normal node (NODE)
const char * node_type;
bool is_joint, is_skeleton_root = false;
- if (NULL == findBone(pScene, pNode->mName.C_Str())) {
+ if (nullptr == findBone(pScene, pNode->mName.C_Str())) {
node_type = "NODE";
is_joint = false;
} else {
node_type = "JOINT";
is_joint = true;
- if(!pNode->mParent || NULL == findBone(pScene, pNode->mParent->mName.C_Str()))
+ if (!pNode->mParent || nullptr == findBone(pScene, pNode->mParent->mName.C_Str())) {
is_skeleton_root = true;
+ }
}
const std::string node_name_escaped = XMLEscape(pNode->mName.data);
- /* // customized, Note! the id field is crucial for inter-xml look up, it cannot be replaced with sid ?!
- mOutput << startstr
- << "mTransformation;
+ aiMatrix4x4 mat = pNode->mTransformation;
+
+ // If this node is a Camera node, the camera coordinate system needs to be multiplied in.
+ // When importing from Collada, the mLookAt is set to 0, 0, -1, and the node transform is unchanged.
+ // When importing from a different format, mLookAt is set to 0, 0, 1. Therefore, the local camera
+ // coordinate system must be changed to matche the Collada specification.
+ for (size_t i = 0; imNumCameras; i++){
+ if (mScene->mCameras[i]->mName == pNode->mName){
+ aiMatrix4x4 sourceView;
+ mScene->mCameras[i]->GetCameraMatrix(sourceView);
+
+ aiMatrix4x4 colladaView;
+ colladaView.a1 = colladaView.c3 = -1; // move into -z space.
+ mat *= (sourceView * colladaView);
+ break;
+ }
+ }
// customized, sid should be 'matrix' to match with loader code.
//mOutput << startstr << "";
diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h
index d1a307532..8244b61aa 100644
--- a/code/ColladaExporter.h
+++ b/code/ColladaExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ColladaHelper.h b/code/ColladaHelper.h
index fe6674b93..ffab6226d 100644
--- a/code/ColladaHelper.h
+++ b/code/ColladaHelper.h
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp
index d86985a29..0c87330a9 100644
--- a/code/ColladaLoader.cpp
+++ b/code/ColladaLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
@@ -85,24 +85,27 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
ColladaLoader::ColladaLoader()
- : mFileName()
- , mMeshIndexByID()
- , mMaterialIndexByName()
- , mMeshes()
- , newMats()
- , mCameras()
- , mLights()
- , mTextures()
- , mAnims()
- , noSkeletonMesh( false )
- , ignoreUpDirection(false)
- , mNodeNameCounter( 0 )
-{}
+: mFileName()
+, mMeshIndexByID()
+, mMaterialIndexByName()
+, mMeshes()
+, newMats()
+, mCameras()
+, mLights()
+, mTextures()
+, mAnims()
+, noSkeletonMesh( false )
+, ignoreUpDirection(false)
+, useColladaName( false )
+, mNodeNameCounter( 0 ) {
+ // empty
+}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
-ColladaLoader::~ColladaLoader()
-{}
+ColladaLoader::~ColladaLoader() {
+ // empty
+}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
@@ -725,8 +728,11 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
std::vector animMeshes;
for (unsigned int i = 0; i < targetMeshes.size(); i++)
{
- aiAnimMesh *animMesh = aiCreateAnimMesh(targetMeshes.at(i));
- animMesh->mWeight = targetWeights[i];
+ aiMesh* targetMesh = targetMeshes.at(i);
+ aiAnimMesh *animMesh = aiCreateAnimMesh(targetMesh);
+ float weight = targetWeights[i];
+ animMesh->mWeight = weight == 0 ? 1.0f : weight;
+ animMesh->mName = targetMesh->mName;
animMeshes.push_back(animMesh);
}
dstMesh->mMethod = (method == Collada::Relative)
diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h
index d61845b24..72c2dd8e7 100644
--- a/code/ColladaLoader.h
+++ b/code/ColladaLoader.h
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp
index 052cd51c4..4d599a0c7 100644
--- a/code/ColladaParser.cpp
+++ b/code/ColladaParser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/ColladaParser.h b/code/ColladaParser.h
index 21f741551..232d85654 100644
--- a/code/ColladaParser.h
+++ b/code/ColladaParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
- Copyright (c) 2006-2018, assimp team
+ Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ComputeUVMappingProcess.cpp b/code/ComputeUVMappingProcess.cpp
index 3b0577b2d..bb571a551 100644
--- a/code/ComputeUVMappingProcess.cpp
+++ b/code/ComputeUVMappingProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ComputeUVMappingProcess.h b/code/ComputeUVMappingProcess.h
index 41e25f99f..24f6bb721 100644
--- a/code/ComputeUVMappingProcess.h
+++ b/code/ComputeUVMappingProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/ConvertToLHProcess.cpp b/code/ConvertToLHProcess.cpp
index 9cb45cc69..b7cd4f0bc 100644
--- a/code/ConvertToLHProcess.cpp
+++ b/code/ConvertToLHProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
@@ -166,8 +166,9 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) {
for( size_t a = 0; a < pMesh->mNumVertices; ++a)
{
pMesh->mVertices[a].z *= -1.0f;
- if( pMesh->HasNormals())
+ if (pMesh->HasNormals()) {
pMesh->mNormals[a].z *= -1.0f;
+ }
if( pMesh->HasTangentsAndBitangents())
{
pMesh->mTangents[a].z *= -1.0f;
@@ -175,6 +176,23 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) {
}
}
+ // mirror anim meshes positions, normals and stuff along the Z axis
+ for (size_t m = 0; m < pMesh->mNumAnimMeshes; ++m)
+ {
+ for (size_t a = 0; a < pMesh->mAnimMeshes[m]->mNumVertices; ++a)
+ {
+ pMesh->mAnimMeshes[m]->mVertices[a].z *= -1.0f;
+ if (pMesh->mAnimMeshes[m]->HasNormals()) {
+ pMesh->mAnimMeshes[m]->mNormals[a].z *= -1.0f;
+ }
+ if (pMesh->mAnimMeshes[m]->HasTangentsAndBitangents())
+ {
+ pMesh->mAnimMeshes[m]->mTangents[a].z *= -1.0f;
+ pMesh->mAnimMeshes[m]->mBitangents[a].z *= -1.0f;
+ }
+ }
+ }
+
// mirror offset matrices of all bones
for( size_t a = 0; a < pMesh->mNumBones; ++a)
{
@@ -346,8 +364,50 @@ void FlipWindingOrderProcess::ProcessMesh( aiMesh* pMesh)
for( unsigned int a = 0; a < pMesh->mNumFaces; a++)
{
aiFace& face = pMesh->mFaces[a];
- for( unsigned int b = 0; b < face.mNumIndices / 2; b++)
- std::swap( face.mIndices[b], face.mIndices[ face.mNumIndices - 1 - b]);
+ for (unsigned int b = 0; b < face.mNumIndices / 2; b++) {
+ std::swap(face.mIndices[b], face.mIndices[face.mNumIndices - 1 - b]);
+ }
+ }
+
+ // invert the order of all components in this mesh anim meshes
+ for (unsigned int m = 0; m < pMesh->mNumAnimMeshes; m++) {
+ aiAnimMesh* animMesh = pMesh->mAnimMeshes[m];
+ unsigned int numVertices = animMesh->mNumVertices;
+ if (animMesh->HasPositions()) {
+ for (unsigned int a = 0; a < numVertices; a++)
+ {
+ std::swap(animMesh->mVertices[a], animMesh->mVertices[numVertices - 1 - a]);
+ }
+ }
+ if (animMesh->HasNormals()) {
+ for (unsigned int a = 0; a < numVertices; a++)
+ {
+ std::swap(animMesh->mNormals[a], animMesh->mNormals[numVertices - 1 - a]);
+ }
+ }
+ for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++) {
+ if (animMesh->HasTextureCoords(i)) {
+ for (unsigned int a = 0; a < numVertices; a++)
+ {
+ std::swap(animMesh->mTextureCoords[i][a], animMesh->mTextureCoords[i][numVertices - 1 - a]);
+ }
+ }
+ }
+ if (animMesh->HasTangentsAndBitangents()) {
+ for (unsigned int a = 0; a < numVertices; a++)
+ {
+ std::swap(animMesh->mTangents[a], animMesh->mTangents[numVertices - 1 - a]);
+ std::swap(animMesh->mBitangents[a], animMesh->mBitangents[numVertices - 1 - a]);
+ }
+ }
+ for (unsigned int v = 0; v < AI_MAX_NUMBER_OF_COLOR_SETS; v++) {
+ if (animMesh->HasVertexColors(v)) {
+ for (unsigned int a = 0; a < numVertices; a++)
+ {
+ std::swap(animMesh->mColors[v][a], animMesh->mColors[v][numVertices - 1 - a]);
+ }
+ }
+ }
}
}
diff --git a/code/ConvertToLHProcess.h b/code/ConvertToLHProcess.h
index f219d6ca2..63351568d 100644
--- a/code/ConvertToLHProcess.h
+++ b/code/ConvertToLHProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/D3MFExporter.cpp b/code/D3MFExporter.cpp
index 99e2ff3f5..e8da91ba9 100644
--- a/code/D3MFExporter.cpp
+++ b/code/D3MFExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/D3MFExporter.h b/code/D3MFExporter.h
index 110862b99..e82120247 100644
--- a/code/D3MFExporter.h
+++ b/code/D3MFExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/D3MFImporter.cpp b/code/D3MFImporter.cpp
index de5708149..c218f4005 100644
--- a/code/D3MFImporter.cpp
+++ b/code/D3MFImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/D3MFImporter.h b/code/D3MFImporter.h
index 701d056e2..3dbdf07bf 100644
--- a/code/D3MFImporter.h
+++ b/code/D3MFImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/D3MFOpcPackage.cpp b/code/D3MFOpcPackage.cpp
index 8161a31e4..2545a2750 100644
--- a/code/D3MFOpcPackage.cpp
+++ b/code/D3MFOpcPackage.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/D3MFOpcPackage.h b/code/D3MFOpcPackage.h
index 6d7b3d478..47c67f45f 100644
--- a/code/D3MFOpcPackage.h
+++ b/code/D3MFOpcPackage.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/DXFHelper.h b/code/DXFHelper.h
index daf2f97e2..0ec8e130b 100644
--- a/code/DXFHelper.h
+++ b/code/DXFHelper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp
index 6710597df..ab86f89ae 100644
--- a/code/DXFLoader.cpp
+++ b/code/DXFLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/DXFLoader.h b/code/DXFLoader.h
index e7f534e98..044cf6bcb 100644
--- a/code/DXFLoader.h
+++ b/code/DXFLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/DeboneProcess.cpp b/code/DeboneProcess.cpp
index bc6afa36e..83b8336bc 100644
--- a/code/DeboneProcess.cpp
+++ b/code/DeboneProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/DeboneProcess.h b/code/DeboneProcess.h
index 3da861362..ba77aba70 100644
--- a/code/DeboneProcess.h
+++ b/code/DeboneProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/DefaultIOStream.cpp b/code/DefaultIOStream.cpp
index 3b0a672a7..1c100b618 100644
--- a/code/DefaultIOStream.cpp
+++ b/code/DefaultIOStream.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/DefaultIOSystem.cpp b/code/DefaultIOSystem.cpp
index 58afe475c..d40b67de3 100644
--- a/code/DefaultIOSystem.cpp
+++ b/code/DefaultIOSystem.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
@@ -76,6 +76,7 @@ bool DefaultIOSystem::Exists( const char* pFile) const
#ifdef _WIN32
wchar_t fileName16[PATHLIMIT];
+#ifndef WindowsStore
bool isUnicode = IsTextUnicode(pFile, static_cast(strlen(pFile)), NULL) != 0;
if (isUnicode) {
@@ -85,12 +86,15 @@ bool DefaultIOSystem::Exists( const char* pFile) const
return false;
}
} else {
+#endif
FILE* file = ::fopen(pFile, "rb");
if (!file)
return false;
::fclose(file);
+#ifndef WindowsStore
}
+#endif
#else
FILE* file = ::fopen( pFile, "rb");
if( !file)
@@ -110,14 +114,18 @@ IOStream* DefaultIOSystem::Open( const char* strFile, const char* strMode)
FILE* file;
#ifdef _WIN32
wchar_t fileName16[PATHLIMIT];
+#ifndef WindowsStore
bool isUnicode = IsTextUnicode(strFile, static_cast(strlen(strFile)), NULL) != 0;
if (isUnicode) {
MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, strFile, -1, fileName16, PATHLIMIT);
std::string mode8(strMode);
file = ::_wfopen(fileName16, std::wstring(mode8.begin(), mode8.end()).c_str());
} else {
+#endif
file = ::fopen(strFile, strMode);
+#ifndef WindowsStore
}
+#endif
#else
file = ::fopen(strFile, strMode);
#endif
@@ -158,6 +166,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out)
{
ai_assert(in && _out);
#if defined( _MSC_VER ) || defined( __MINGW32__ )
+#ifndef WindowsStore
bool isUnicode = IsTextUnicode(in, static_cast(strlen(in)), NULL) != 0;
if (isUnicode) {
wchar_t out16[PATHLIMIT];
@@ -175,6 +184,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out)
}
} else {
+#endif
char* ret = :: _fullpath(_out, in, PATHLIMIT);
if (!ret) {
// preserve the input path, maybe someone else is able to fix
@@ -182,7 +192,9 @@ inline static void MakeAbsolutePath (const char* in, char* _out)
ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in));
strcpy(_out, in);
}
+#ifndef WindowsStore
}
+#endif
#else
// use realpath
char* ret = realpath(in, _out);
diff --git a/code/DefaultLogger.cpp b/code/DefaultLogger.cpp
index 2871a4131..de3528d2b 100644
--- a/code/DefaultLogger.cpp
+++ b/code/DefaultLogger.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/DefaultProgressHandler.h b/code/DefaultProgressHandler.h
index 851c17be6..bd2cce00b 100644
--- a/code/DefaultProgressHandler.h
+++ b/code/DefaultProgressHandler.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/DropFaceNormalsProcess.cpp b/code/DropFaceNormalsProcess.cpp
index 57e8b972b..b11615bb8 100644
--- a/code/DropFaceNormalsProcess.cpp
+++ b/code/DropFaceNormalsProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/DropFaceNormalsProcess.h b/code/DropFaceNormalsProcess.h
index 6dbfe0397..0d116663b 100644
--- a/code/DropFaceNormalsProcess.h
+++ b/code/DropFaceNormalsProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/EmbedTexturesProcess.cpp b/code/EmbedTexturesProcess.cpp
index ebe7a0897..739382a05 100644
--- a/code/EmbedTexturesProcess.cpp
+++ b/code/EmbedTexturesProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
@@ -124,22 +124,28 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
file.read(reinterpret_cast(imageContent), imageSize);
// Enlarging the textures table
- auto textureId = pScene->mNumTextures++;
+ unsigned int textureId = pScene->mNumTextures++;
auto oldTextures = pScene->mTextures;
pScene->mTextures = new aiTexture*[pScene->mNumTextures];
- memmove(pScene->mTextures, oldTextures, sizeof(aiTexture*) * (pScene->mNumTextures - 1u));
+ ::memmove(pScene->mTextures, oldTextures, sizeof(aiTexture*) * (pScene->mNumTextures - 1u));
// Add the new texture
- auto pTexture = new aiTexture();
+ auto pTexture = new aiTexture;
pTexture->mHeight = 0; // Means that this is still compressed
pTexture->mWidth = static_cast(imageSize);
pTexture->pcData = imageContent;
auto extension = path.substr(path.find_last_of('.') + 1u);
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
- if (extension == "jpeg") extension = "jpg";
- strcpy(pTexture->achFormatHint, extension.c_str());
+ if (extension == "jpeg") {
+ extension = "jpg";
+ }
+ size_t len = extension.size();
+ if (len > HINTMAXTEXTURELEN -1 ) {
+ len = HINTMAXTEXTURELEN - 1;
+ }
+ ::strncpy(pTexture->achFormatHint, extension.c_str(), len);
pScene->mTextures[textureId] = pTexture;
return true;
diff --git a/code/EmbedTexturesProcess.h b/code/EmbedTexturesProcess.h
index ce9821652..cdf40bef7 100644
--- a/code/EmbedTexturesProcess.h
+++ b/code/EmbedTexturesProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/Exporter.cpp b/code/Exporter.cpp
index 0acde75bf..8848e87f5 100644
--- a/code/Exporter.cpp
+++ b/code/Exporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
diff --git a/code/FBXAnimation.cpp b/code/FBXAnimation.cpp
index 24ab9b14b..874914431 100644
--- a/code/FBXAnimation.cpp
+++ b/code/FBXAnimation.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
@@ -105,8 +105,8 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
const Scope& sc = GetRequiredScope(element);
// find target node
- const char* whitelist[] = {"Model","NodeAttribute"};
- const std::vector& conns = doc.GetConnectionsBySourceSequenced(ID(),whitelist,2);
+ const char* whitelist[] = {"Model","NodeAttribute","Deformer"};
+ const std::vector& conns = doc.GetConnectionsBySourceSequenced(ID(),whitelist,3);
for(const Connection* con : conns) {
diff --git a/code/FBXBinaryTokenizer.cpp b/code/FBXBinaryTokenizer.cpp
index b81a9f945..f12a5c5b2 100644
--- a/code/FBXBinaryTokenizer.cpp
+++ b/code/FBXBinaryTokenizer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/FBXCommon.h b/code/FBXCommon.h
index 60b040552..fcb20a5ca 100644
--- a/code/FBXCommon.h
+++ b/code/FBXCommon.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/FBXCompileConfig.h b/code/FBXCompileConfig.h
index 2e7336e85..3a3841fa5 100644
--- a/code/FBXCompileConfig.h
+++ b/code/FBXCompileConfig.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp
index 0cbe04d8f..d88a3cacd 100644
--- a/code/FBXConverter.cpp
+++ b/code/FBXConverter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2018, assimp team
+Copyright (c) 2006-2019, assimp team
All rights reserved.
@@ -53,10 +53,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXUtil.h"
#include "FBXProperties.h"
#include "FBXImporter.h"
+
#include
#include
+#include
+
#include
#include
#include
@@ -65,3028 +68,3440 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
namespace Assimp {
-namespace FBX {
+ namespace FBX {
-using namespace Util;
+ using namespace Util;
#define MAGIC_NODE_TAG "_$AssimpFbx$"
#define CONVERT_FBX_TIME(time) static_cast(time) / 46186158000L
-FBXConverter::FBXConverter( aiScene* out, const Document& doc )
-: defaultMaterialIndex()
-, out( out )
-, doc( doc ) {
- // animations need to be converted first since this will
- // populate the node_anim_chain_bits map, which is needed
- // to determine which nodes need to be generated.
- ConvertAnimations();
- ConvertRootNode();
+ FBXConverter::FBXConverter(aiScene* out, const Document& doc)
+ : defaultMaterialIndex()
+ , out(out)
+ , doc(doc) {
+ // animations need to be converted first since this will
+ // populate the node_anim_chain_bits map, which is needed
+ // to determine which nodes need to be generated.
+ ConvertAnimations();
+ ConvertRootNode();
- if ( doc.Settings().readAllMaterials ) {
- // unfortunately this means we have to evaluate all objects
- for( const ObjectMap::value_type& v : doc.Objects() ) {
+ if (doc.Settings().readAllMaterials) {
+ // unfortunately this means we have to evaluate all objects
+ for (const ObjectMap::value_type& v : doc.Objects()) {
- const Object* ob = v.second->Get();
- if ( !ob ) {
- continue;
+ const Object* ob = v.second->Get();
+ if (!ob) {
+ continue;
+ }
+
+ const Material* mat = dynamic_cast(ob);
+ if (mat) {
+
+ if (materials_converted.find(mat) == materials_converted.end()) {
+ ConvertMaterial(*mat, 0);
+ }
+ }
+ }
}
- const Material* mat = dynamic_cast( ob );
- if ( mat ) {
+ ConvertGlobalSettings();
+ TransferDataToScene();
- if ( materials_converted.find( mat ) == materials_converted.end() ) {
- ConvertMaterial( *mat, 0 );
- }
+ // if we didn't read any meshes set the AI_SCENE_FLAGS_INCOMPLETE
+ // to make sure the scene passes assimp's validation. FBX files
+ // need not contain geometry (i.e. camera animations, raw armatures).
+ if (out->mNumMeshes == 0) {
+ out->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
}
}
- }
-
- ConvertGlobalSettings();
- TransferDataToScene();
-
- // if we didn't read any meshes set the AI_SCENE_FLAGS_INCOMPLETE
- // to make sure the scene passes assimp's validation. FBX files
- // need not contain geometry (i.e. camera animations, raw armatures).
- if ( out->mNumMeshes == 0 ) {
- out->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
- }
-}
-FBXConverter::~FBXConverter() {
- std::for_each( meshes.begin(), meshes.end(), Util::delete_fun() );
- std::for_each( materials.begin(), materials.end(), Util::delete_fun() );
- std::for_each( animations.begin(), animations.end(), Util::delete_fun() );
- std::for_each( lights.begin(), lights.end(), Util::delete_fun() );
- std::for_each( cameras.begin(), cameras.end(), Util::delete_fun() );
- std::for_each( textures.begin(), textures.end(), Util::delete_fun() );
-}
+ FBXConverter::~FBXConverter() {
+ std::for_each(meshes.begin(), meshes.end(), Util::delete_fun());
+ std::for_each(materials.begin(), materials.end(), Util::delete_fun());
+ std::for_each(animations.begin(), animations.end(), Util::delete_fun());
+ std::for_each(lights.begin(), lights.end(), Util::delete_fun());
+ std::for_each(cameras.begin(), cameras.end(), Util::delete_fun());
+ std::for_each(textures.begin(), textures.end(), Util::delete_fun());
+ }
-void FBXConverter::ConvertRootNode() {
- out->mRootNode = new aiNode();
- out->mRootNode->mName.Set( "RootNode" );
+ void FBXConverter::ConvertRootNode() {
+ out->mRootNode = new aiNode();
+ out->mRootNode->mName.Set("RootNode");
- // root has ID 0
- ConvertNodes( 0L, *out->mRootNode );
-}
+ // root has ID 0
+ ConvertNodes(0L, *out->mRootNode);
+ }
-void FBXConverter::ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform ) {
- const std::vector& conns = doc.GetConnectionsByDestinationSequenced( id, "Model" );
+ void FBXConverter::ConvertNodes(uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform) {
+ const std::vector& conns = doc.GetConnectionsByDestinationSequenced(id, "Model");
- std::vector nodes;
- nodes.reserve( conns.size() );
+ std::vector nodes;
+ nodes.reserve(conns.size());
- std::vector nodes_chain;
- std::vector post_nodes_chain;
+ std::vector nodes_chain;
+ std::vector post_nodes_chain;
- try {
- for( const Connection* con : conns ) {
+ try {
+ for (const Connection* con : conns) {
- // ignore object-property links
- if ( con->PropertyName().length() ) {
- continue;
- }
-
- const Object* const object = con->SourceObject();
- if ( nullptr == object ) {
- FBXImporter::LogWarn( "failed to convert source object for Model link" );
- continue;
- }
-
- const Model* const model = dynamic_cast( object );
-
- if ( nullptr != model ) {
- nodes_chain.clear();
- post_nodes_chain.clear();
-
- aiMatrix4x4 new_abs_transform = parent_transform;
-
- // even though there is only a single input node, the design of
- // assimp (or rather: the complicated transformation chain that
- // is employed by fbx) means that we may need multiple aiNode's
- // to represent a fbx node's transformation.
- GenerateTransformationNodeChain( *model, nodes_chain, post_nodes_chain );
-
- ai_assert( nodes_chain.size() );
-
- std::string original_name = FixNodeName( model->Name() );
-
- // check if any of the nodes in the chain has the name the fbx node
- // is supposed to have. If there is none, add another node to
- // preserve the name - people might have scripts etc. that rely
- // on specific node names.
- aiNode* name_carrier = NULL;
- for( aiNode* prenode : nodes_chain ) {
- if ( !strcmp( prenode->mName.C_Str(), original_name.c_str() ) ) {
- name_carrier = prenode;
- break;
- }
- }
-
- if ( !name_carrier ) {
- std::string old_original_name = original_name;
- GetUniqueName(old_original_name, original_name);
- nodes_chain.push_back( new aiNode( original_name ) );
- } else {
- original_name = nodes_chain.back()->mName.C_Str();
- }
-
- //setup metadata on newest node
- SetupNodeMetadata( *model, *nodes_chain.back() );
-
- // link all nodes in a row
- aiNode* last_parent = &parent;
- for( aiNode* prenode : nodes_chain ) {
- ai_assert( prenode );
-
- if ( last_parent != &parent ) {
- last_parent->mNumChildren = 1;
- last_parent->mChildren = new aiNode*[ 1 ];
- last_parent->mChildren[ 0 ] = prenode;
+ // ignore object-property links
+ if (con->PropertyName().length()) {
+ continue;
}
- prenode->mParent = last_parent;
- last_parent = prenode;
+ const Object* const object = con->SourceObject();
+ if (nullptr == object) {
+ FBXImporter::LogWarn("failed to convert source object for Model link");
+ continue;
+ }
- new_abs_transform *= prenode->mTransformation;
- }
+ const Model* const model = dynamic_cast(object);
- // attach geometry
- ConvertModel( *model, *nodes_chain.back(), new_abs_transform );
+ if (nullptr != model) {
+ nodes_chain.clear();
+ post_nodes_chain.clear();
- // check if there will be any child nodes
- const std::vector& child_conns
- = doc.GetConnectionsByDestinationSequenced( model->ID(), "Model" );
+ aiMatrix4x4 new_abs_transform = parent_transform;
- // if so, link the geometric transform inverse nodes
- // before we attach any child nodes
- if (child_conns.size()) {
- for( aiNode* postnode : post_nodes_chain ) {
- ai_assert( postnode );
+ // even though there is only a single input node, the design of
+ // assimp (or rather: the complicated transformation chain that
+ // is employed by fbx) means that we may need multiple aiNode's
+ // to represent a fbx node's transformation.
+ GenerateTransformationNodeChain(*model, nodes_chain, post_nodes_chain);
- if ( last_parent != &parent ) {
- last_parent->mNumChildren = 1;
- last_parent->mChildren = new aiNode*[ 1 ];
- last_parent->mChildren[ 0 ] = postnode;
+ ai_assert(nodes_chain.size());
+
+ std::string original_name = FixNodeName(model->Name());
+
+ // check if any of the nodes in the chain has the name the fbx node
+ // is supposed to have. If there is none, add another node to
+ // preserve the name - people might have scripts etc. that rely
+ // on specific node names.
+ aiNode* name_carrier = NULL;
+ for (aiNode* prenode : nodes_chain) {
+ if (!strcmp(prenode->mName.C_Str(), original_name.c_str())) {
+ name_carrier = prenode;
+ break;
+ }
}
- postnode->mParent = last_parent;
- last_parent = postnode;
-
- new_abs_transform *= postnode->mTransformation;
- }
- } else {
- // free the nodes we allocated as we don't need them
- Util::delete_fun deleter;
- std::for_each(
- post_nodes_chain.begin(),
- post_nodes_chain.end(),
- deleter
- );
- }
-
- // attach sub-nodes (if any)
- ConvertNodes( model->ID(), *last_parent, new_abs_transform );
-
- if ( doc.Settings().readLights ) {
- ConvertLights( *model, original_name );
- }
-
- if ( doc.Settings().readCameras ) {
- ConvertCameras( *model, original_name );
- }
-
- nodes.push_back( nodes_chain.front() );
- nodes_chain.clear();
- }
- }
-
- if ( nodes.size() ) {
- parent.mChildren = new aiNode*[ nodes.size() ]();
- parent.mNumChildren = static_cast( nodes.size() );
-
- std::swap_ranges( nodes.begin(), nodes.end(), parent.mChildren );
- }
- }
- catch ( std::exception& ) {
- Util::delete_fun deleter;
- std::for_each( nodes.begin(), nodes.end(), deleter );
- std::for_each( nodes_chain.begin(), nodes_chain.end(), deleter );
- std::for_each( post_nodes_chain.begin(), post_nodes_chain.end(), deleter );
- }
-}
-
-
-void FBXConverter::ConvertLights( const Model& model, const std::string &orig_name ) {
- const std::vector& node_attrs = model.GetAttributes();
- for( const NodeAttribute* attr : node_attrs ) {
- const Light* const light = dynamic_cast( attr );
- if ( light ) {
- ConvertLight( *light, orig_name );
- }
- }
-}
-
-void FBXConverter::ConvertCameras( const Model& model, const std::string &orig_name ) {
- const std::vector& node_attrs = model.GetAttributes();
- for( const NodeAttribute* attr : node_attrs ) {
- const Camera* const cam = dynamic_cast( attr );
- if ( cam ) {
- ConvertCamera( *cam, orig_name );
- }
- }
-}
-
-void FBXConverter::ConvertLight( const Light& light, const std::string &orig_name ) {
- lights.push_back( new aiLight() );
- aiLight* const out_light = lights.back();
-
- out_light->mName.Set( orig_name );
-
- const float intensity = light.Intensity() / 100.0f;
- const aiVector3D& col = light.Color();
-
- out_light->mColorDiffuse = aiColor3D( col.x, col.y, col.z );
- out_light->mColorDiffuse.r *= intensity;
- out_light->mColorDiffuse.g *= intensity;
- out_light->mColorDiffuse.b *= intensity;
-
- out_light->mColorSpecular = out_light->mColorDiffuse;
-
- //lights are defined along negative y direction
- out_light->mPosition = aiVector3D(0.0f);
- out_light->mDirection = aiVector3D(0.0f, -1.0f, 0.0f);
- out_light->mUp = aiVector3D(0.0f, 0.0f, -1.0f);
-
- switch ( light.LightType() )
- {
- case Light::Type_Point:
- out_light->mType = aiLightSource_POINT;
- break;
-
- case Light::Type_Directional:
- out_light->mType = aiLightSource_DIRECTIONAL;
- break;
-
- case Light::Type_Spot:
- out_light->mType = aiLightSource_SPOT;
- out_light->mAngleOuterCone = AI_DEG_TO_RAD( light.OuterAngle() );
- out_light->mAngleInnerCone = AI_DEG_TO_RAD( light.InnerAngle() );
- break;
-
- case Light::Type_Area:
- FBXImporter::LogWarn( "cannot represent area light, set to UNDEFINED" );
- out_light->mType = aiLightSource_UNDEFINED;
- break;
-
- case Light::Type_Volume:
- FBXImporter::LogWarn( "cannot represent volume light, set to UNDEFINED" );
- out_light->mType = aiLightSource_UNDEFINED;
- break;
- default:
- ai_assert( false );
- }
-
- float decay = light.DecayStart();
- switch ( light.DecayType() )
- {
- case Light::Decay_None:
- out_light->mAttenuationConstant = decay;
- out_light->mAttenuationLinear = 0.0f;
- out_light->mAttenuationQuadratic = 0.0f;
- break;
- case Light::Decay_Linear:
- out_light->mAttenuationConstant = 0.0f;
- out_light->mAttenuationLinear = 2.0f / decay;
- out_light->mAttenuationQuadratic = 0.0f;
- break;
- case Light::Decay_Quadratic:
- out_light->mAttenuationConstant = 0.0f;
- out_light->mAttenuationLinear = 0.0f;
- out_light->mAttenuationQuadratic = 2.0f / (decay * decay);
- break;
- case Light::Decay_Cubic:
- FBXImporter::LogWarn( "cannot represent cubic attenuation, set to Quadratic" );
- out_light->mAttenuationQuadratic = 1.0f;
- break;
- default:
- ai_assert( false );
- }
-}
-
-void FBXConverter::ConvertCamera( const Camera& cam, const std::string &orig_name )
-{
- cameras.push_back( new aiCamera() );
- aiCamera* const out_camera = cameras.back();
-
- out_camera->mName.Set( orig_name );
-
- out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
-
- //cameras are defined along positive x direction
- out_camera->mPosition = cam.Position();
- out_camera->mLookAt = ( cam.InterestPosition() - out_camera->mPosition ).Normalize();
- out_camera->mUp = cam.UpVector();
-
- out_camera->mHorizontalFOV = AI_DEG_TO_RAD( cam.FieldOfView() );
- out_camera->mClipPlaneNear = cam.NearPlane();
- out_camera->mClipPlaneFar = cam.FarPlane();
-}
-
-void FBXConverter::GetUniqueName( const std::string &name, std::string &uniqueName )
-{
- int i = 0;
- uniqueName = name;
- while (mNodeNames.find(uniqueName) != mNodeNames.end())
- {
- ++i;
- std::stringstream ext;
- ext << name << std::setfill('0') << std::setw(3) << i;
- uniqueName = ext.str();
- }
- mNodeNames.insert(uniqueName);
-}
-
-
-const char* FBXConverter::NameTransformationComp( TransformationComp comp ) {
- switch ( comp ) {
- case TransformationComp_Translation:
- return "Translation";
- case TransformationComp_RotationOffset:
- return "RotationOffset";
- case TransformationComp_RotationPivot:
- return "RotationPivot";
- case TransformationComp_PreRotation:
- return "PreRotation";
- case TransformationComp_Rotation:
- return "Rotation";
- case TransformationComp_PostRotation:
- return "PostRotation";
- case TransformationComp_RotationPivotInverse:
- return "RotationPivotInverse";
- case TransformationComp_ScalingOffset:
- return "ScalingOffset";
- case TransformationComp_ScalingPivot:
- return "ScalingPivot";
- case TransformationComp_Scaling:
- return "Scaling";
- case TransformationComp_ScalingPivotInverse:
- return "ScalingPivotInverse";
- case TransformationComp_GeometricScaling:
- return "GeometricScaling";
- case TransformationComp_GeometricRotation:
- return "GeometricRotation";
- case TransformationComp_GeometricTranslation:
- return "GeometricTranslation";
- case TransformationComp_GeometricScalingInverse:
- return "GeometricScalingInverse";
- case TransformationComp_GeometricRotationInverse:
- return "GeometricRotationInverse";
- case TransformationComp_GeometricTranslationInverse:
- return "GeometricTranslationInverse";
- case TransformationComp_MAXIMUM: // this is to silence compiler warnings
- default:
- break;
- }
-
- ai_assert( false );
-
- return nullptr;
-}
-
-const char* FBXConverter::NameTransformationCompProperty( TransformationComp comp ) {
- switch ( comp ) {
- case TransformationComp_Translation:
- return "Lcl Translation";
- case TransformationComp_RotationOffset:
- return "RotationOffset";
- case TransformationComp_RotationPivot:
- return "RotationPivot";
- case TransformationComp_PreRotation:
- return "PreRotation";
- case TransformationComp_Rotation:
- return "Lcl Rotation";
- case TransformationComp_PostRotation:
- return "PostRotation";
- case TransformationComp_RotationPivotInverse:
- return "RotationPivotInverse";
- case TransformationComp_ScalingOffset:
- return "ScalingOffset";
- case TransformationComp_ScalingPivot:
- return "ScalingPivot";
- case TransformationComp_Scaling:
- return "Lcl Scaling";
- case TransformationComp_ScalingPivotInverse:
- return "ScalingPivotInverse";
- case TransformationComp_GeometricScaling:
- return "GeometricScaling";
- case TransformationComp_GeometricRotation:
- return "GeometricRotation";
- case TransformationComp_GeometricTranslation:
- return "GeometricTranslation";
- case TransformationComp_GeometricScalingInverse:
- return "GeometricScalingInverse";
- case TransformationComp_GeometricRotationInverse:
- return "GeometricRotationInverse";
- case TransformationComp_GeometricTranslationInverse:
- return "GeometricTranslationInverse";
- case TransformationComp_MAXIMUM: // this is to silence compiler warnings
- break;
- }
-
- ai_assert( false );
-
- return nullptr;
-}
-
-aiVector3D FBXConverter::TransformationCompDefaultValue( TransformationComp comp )
-{
- // XXX a neat way to solve the never-ending special cases for scaling
- // would be to do everything in log space!
- return comp == TransformationComp_Scaling ? aiVector3D( 1.f, 1.f, 1.f ) : aiVector3D();
-}
-
-void FBXConverter::GetRotationMatrix( Model::RotOrder mode, const aiVector3D& rotation, aiMatrix4x4& out )
-{
- if ( mode == Model::RotOrder_SphericXYZ ) {
- FBXImporter::LogError( "Unsupported RotationMode: SphericXYZ" );
- out = aiMatrix4x4();
- return;
- }
-
- const float angle_epsilon = 1e-6f;
-
- out = aiMatrix4x4();
-
- bool is_id[ 3 ] = { true, true, true };
-
- aiMatrix4x4 temp[ 3 ];
- if ( std::fabs( rotation.z ) > angle_epsilon ) {
- aiMatrix4x4::RotationZ( AI_DEG_TO_RAD( rotation.z ), temp[ 2 ] );
- is_id[ 2 ] = false;
- }
- if ( std::fabs( rotation.y ) > angle_epsilon ) {
- aiMatrix4x4::RotationY( AI_DEG_TO_RAD( rotation.y ), temp[ 1 ] );
- is_id[ 1 ] = false;
- }
- if ( std::fabs( rotation.x ) > angle_epsilon ) {
- aiMatrix4x4::RotationX( AI_DEG_TO_RAD( rotation.x ), temp[ 0 ] );
- is_id[ 0 ] = false;
- }
-
- int order[ 3 ] = { -1, -1, -1 };
-
- // note: rotation order is inverted since we're left multiplying as is usual in assimp
- switch ( mode )
- {
- case Model::RotOrder_EulerXYZ:
- order[ 0 ] = 2;
- order[ 1 ] = 1;
- order[ 2 ] = 0;
- break;
-
- case Model::RotOrder_EulerXZY:
- order[ 0 ] = 1;
- order[ 1 ] = 2;
- order[ 2 ] = 0;
- break;
-
- case Model::RotOrder_EulerYZX:
- order[ 0 ] = 0;
- order[ 1 ] = 2;
- order[ 2 ] = 1;
- break;
-
- case Model::RotOrder_EulerYXZ:
- order[ 0 ] = 2;
- order[ 1 ] = 0;
- order[ 2 ] = 1;
- break;
-
- case Model::RotOrder_EulerZXY:
- order[ 0 ] = 1;
- order[ 1 ] = 0;
- order[ 2 ] = 2;
- break;
-
- case Model::RotOrder_EulerZYX:
- order[ 0 ] = 0;
- order[ 1 ] = 1;
- order[ 2 ] = 2;
- break;
-
- default:
- ai_assert( false );
- break;
- }
-
- ai_assert( order[ 0 ] >= 0 );
- ai_assert( order[ 0 ] <= 2 );
- ai_assert( order[ 1 ] >= 0 );
- ai_assert( order[ 1 ] <= 2 );
- ai_assert( order[ 2 ] >= 0 );
- ai_assert( order[ 2 ] <= 2 );
-
- if ( !is_id[ order[ 0 ] ] ) {
- out = temp[ order[ 0 ] ];
- }
-
- if ( !is_id[ order[ 1 ] ] ) {
- out = out * temp[ order[ 1 ] ];
- }
-
- if ( !is_id[ order[ 2 ] ] ) {
- out = out * temp[ order[ 2 ] ];
- }
-}
-
-bool FBXConverter::NeedsComplexTransformationChain( const Model& model )
-{
- const PropertyTable& props = model.Props();
- bool ok;
-
- const float zero_epsilon = 1e-6f;
- const aiVector3D all_ones(1.0f, 1.0f, 1.0f);
- for ( size_t i = 0; i < TransformationComp_MAXIMUM; ++i ) {
- const TransformationComp comp = static_cast< TransformationComp >( i );
-
- if ( comp == TransformationComp_Rotation || comp == TransformationComp_Scaling || comp == TransformationComp_Translation ) {
- continue;
- }
-
- bool scale_compare = ( comp == TransformationComp_GeometricScaling || comp == TransformationComp_Scaling );
-
- const aiVector3D& v = PropertyGet( props, NameTransformationCompProperty( comp ), ok );
- if ( ok && scale_compare ) {
- if ( (v - all_ones).SquareLength() > zero_epsilon ) {
- return true;
- }
- } else if ( ok ) {
- if ( v.SquareLength() > zero_epsilon ) {
- return true;
- }
- }
- }
-
- return false;
-}
-
-std::string FBXConverter::NameTransformationChainNode( const std::string& name, TransformationComp comp )
-{
- return name + std::string( MAGIC_NODE_TAG ) + "_" + NameTransformationComp( comp );
-}
-
-void FBXConverter::GenerateTransformationNodeChain( const Model& model, std::vector& output_nodes,
- std::vector& post_output_nodes ) {
- const PropertyTable& props = model.Props();
- const Model::RotOrder rot = model.RotationOrder();
-
- bool ok;
-
- aiMatrix4x4 chain[ TransformationComp_MAXIMUM ];
- std::fill_n( chain, static_cast( TransformationComp_MAXIMUM ), aiMatrix4x4() );
-
- // generate transformation matrices for all the different transformation components
- const float zero_epsilon = 1e-6f;
- const aiVector3D all_ones(1.0f, 1.0f, 1.0f);
- bool is_complex = false;
-
- const aiVector3D& PreRotation = PropertyGet( props, "PreRotation", ok );
- if ( ok && PreRotation.SquareLength() > zero_epsilon ) {
- is_complex = true;
-
- GetRotationMatrix( Model::RotOrder::RotOrder_EulerXYZ, PreRotation, chain[ TransformationComp_PreRotation ] );
- }
-
- const aiVector3D& PostRotation = PropertyGet( props, "PostRotation", ok );
- if ( ok && PostRotation.SquareLength() > zero_epsilon ) {
- is_complex = true;
-
- GetRotationMatrix( Model::RotOrder::RotOrder_EulerXYZ, PostRotation, chain[ TransformationComp_PostRotation ] );
- }
-
- const aiVector3D& RotationPivot = PropertyGet( props, "RotationPivot", ok );
- if ( ok && RotationPivot.SquareLength() > zero_epsilon ) {
- is_complex = true;
-
- aiMatrix4x4::Translation( RotationPivot, chain[ TransformationComp_RotationPivot ] );
- aiMatrix4x4::Translation( -RotationPivot, chain[ TransformationComp_RotationPivotInverse ] );
- }
-
- const aiVector3D& RotationOffset = PropertyGet( props, "RotationOffset", ok );
- if ( ok && RotationOffset.SquareLength() > zero_epsilon ) {
- is_complex = true;
-
- aiMatrix4x4::Translation( RotationOffset, chain[ TransformationComp_RotationOffset ] );
- }
-
- const aiVector3D& ScalingOffset = PropertyGet( props, "ScalingOffset", ok );
- if ( ok && ScalingOffset.SquareLength() > zero_epsilon ) {
- is_complex = true;
-
- aiMatrix4x4::Translation( ScalingOffset, chain[ TransformationComp_ScalingOffset ] );
- }
-
- const aiVector3D& ScalingPivot = PropertyGet( props, "ScalingPivot", ok );
- if ( ok && ScalingPivot.SquareLength() > zero_epsilon ) {
- is_complex = true;
-
- aiMatrix4x4::Translation( ScalingPivot, chain[ TransformationComp_ScalingPivot ] );
- aiMatrix4x4::Translation( -ScalingPivot, chain[ TransformationComp_ScalingPivotInverse ] );
- }
-
- const aiVector3D& Translation = PropertyGet( props, "Lcl Translation", ok );
- if ( ok && Translation.SquareLength() > zero_epsilon ) {
- aiMatrix4x4::Translation( Translation, chain[ TransformationComp_Translation ] );
- }
-
- const aiVector3D& Scaling = PropertyGet( props, "Lcl Scaling", ok );
- if ( ok && (Scaling - all_ones).SquareLength() > zero_epsilon ) {
- aiMatrix4x4::Scaling( Scaling, chain[ TransformationComp_Scaling ] );
- }
-
- const aiVector3D& Rotation = PropertyGet( props, "Lcl Rotation", ok );
- if ( ok && Rotation.SquareLength() > zero_epsilon ) {
- GetRotationMatrix( rot, Rotation, chain[ TransformationComp_Rotation ] );
- }
-
- const aiVector3D& GeometricScaling = PropertyGet( props, "GeometricScaling", ok );
- if ( ok && (GeometricScaling - all_ones).SquareLength() > zero_epsilon ) {
- is_complex = true;
- aiMatrix4x4::Scaling( GeometricScaling, chain[ TransformationComp_GeometricScaling ] );
- aiVector3D GeometricScalingInverse = GeometricScaling;
- bool canscale = true;
- for (unsigned int i = 0; i < 3; ++i) {
- if ( std::fabs( GeometricScalingInverse[i] ) > zero_epsilon ) {
- GeometricScalingInverse[i] = 1.0f / GeometricScaling[i];
- } else {
- FBXImporter::LogError( "cannot invert geometric scaling matrix with a 0.0 scale component" );
- canscale = false;
- break;
- }
- }
- if (canscale) {
- aiMatrix4x4::Scaling( GeometricScalingInverse, chain[ TransformationComp_GeometricScalingInverse ] );
- }
- }
-
- const aiVector3D& GeometricRotation = PropertyGet( props, "GeometricRotation", ok );
- if ( ok && GeometricRotation.SquareLength() > zero_epsilon ) {
- is_complex = true;
- GetRotationMatrix( rot, GeometricRotation, chain[ TransformationComp_GeometricRotation ] );
- GetRotationMatrix( rot, GeometricRotation, chain[ TransformationComp_GeometricRotationInverse ] );
- chain[ TransformationComp_GeometricRotationInverse ].Inverse();
- }
-
- const aiVector3D& GeometricTranslation = PropertyGet( props, "GeometricTranslation", ok );
- if ( ok && GeometricTranslation.SquareLength() > zero_epsilon ) {
- is_complex = true;
- aiMatrix4x4::Translation( GeometricTranslation, chain[ TransformationComp_GeometricTranslation ] );
- aiMatrix4x4::Translation( -GeometricTranslation, chain[ TransformationComp_GeometricTranslationInverse ] );
- }
-
- // is_complex needs to be consistent with NeedsComplexTransformationChain()
- // or the interplay between this code and the animation converter would
- // not be guaranteed.
- ai_assert( NeedsComplexTransformationChain( model ) == is_complex );
-
- std::string name = FixNodeName( model.Name() );
-
- // now, if we have more than just Translation, Scaling and Rotation,
- // we need to generate a full node chain to accommodate for assimp's
- // lack to express pivots and offsets.
- if ( is_complex && doc.Settings().preservePivots ) {
- FBXImporter::LogInfo( "generating full transformation chain for node: " + name );
-
- // query the anim_chain_bits dictionary to find out which chain elements
- // have associated node animation channels. These can not be dropped
- // even if they have identity transform in bind pose.
- NodeAnimBitMap::const_iterator it = node_anim_chain_bits.find( name );
- const unsigned int anim_chain_bitmask = ( it == node_anim_chain_bits.end() ? 0 : ( *it ).second );
-
- unsigned int bit = 0x1;
- for ( size_t i = 0; i < TransformationComp_MAXIMUM; ++i, bit <<= 1 ) {
- const TransformationComp comp = static_cast( i );
-
- if ( chain[ i ].IsIdentity() && ( anim_chain_bitmask & bit ) == 0 ) {
- continue;
- }
-
- if ( comp == TransformationComp_PostRotation ) {
- chain[ i ] = chain[ i ].Inverse();
- }
-
- aiNode* nd = new aiNode();
- nd->mName.Set( NameTransformationChainNode( name, comp ) );
- nd->mTransformation = chain[ i ];
-
- // geometric inverses go in a post-node chain
- if ( comp == TransformationComp_GeometricScalingInverse ||
- comp == TransformationComp_GeometricRotationInverse ||
- comp == TransformationComp_GeometricTranslationInverse
- ) {
- post_output_nodes.push_back( nd );
- } else {
- output_nodes.push_back( nd );
- }
- }
-
- ai_assert( output_nodes.size() );
- return;
- }
-
- // else, we can just multiply the matrices together
- aiNode* nd = new aiNode();
- output_nodes.push_back( nd );
- std::string uniqueName;
- GetUniqueName( name, uniqueName );
-
- nd->mName.Set( uniqueName );
-
- for (const auto &transform : chain) {
- nd->mTransformation = nd->mTransformation * transform;
- }
-}
-
-void FBXConverter::SetupNodeMetadata( const Model& model, aiNode& nd )
-{
- const PropertyTable& props = model.Props();
- DirectPropertyMap unparsedProperties = props.GetUnparsedProperties();
-
- // create metadata on node
- const std::size_t numStaticMetaData = 2;
- aiMetadata* data = aiMetadata::Alloc( static_cast(unparsedProperties.size() + numStaticMetaData) );
- nd.mMetaData = data;
- int index = 0;
-
- // find user defined properties (3ds Max)
- data->Set( index++, "UserProperties", aiString( PropertyGet( props, "UDP3DSMAX", "" ) ) );
- // preserve the info that a node was marked as Null node in the original file.
- data->Set( index++, "IsNull", model.IsNull() ? true : false );
-
- // add unparsed properties to the node's metadata
- for( const DirectPropertyMap::value_type& prop : unparsedProperties ) {
- // Interpret the property as a concrete type
- if ( const TypedProperty* interpreted = prop.second->As >() ) {
- data->Set( index++, prop.first, interpreted->Value() );
- } else if ( const TypedProperty* interpreted = prop.second->As >() ) {
- data->Set( index++, prop.first, interpreted->Value() );
- } else if ( const TypedProperty* interpreted = prop.second->As >() ) {
- data->Set( index++, prop.first, interpreted->Value() );
- } else if ( const TypedProperty* interpreted = prop.second->As >() ) {
- data->Set( index++, prop.first, interpreted->Value() );
- } else if ( const TypedProperty* interpreted = prop.second->As >() ) {
- data->Set( index++, prop.first, aiString( interpreted->Value() ) );
- } else if ( const TypedProperty* interpreted = prop.second->As >() ) {
- data->Set( index++, prop.first, interpreted->Value() );
- } else {
- ai_assert( false );
- }
- }
-}
-
-void FBXConverter::ConvertModel( const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform )
-{
- const std::vector& geos = model.GetGeometry();
-
- std::vector meshes;
- meshes.reserve( geos.size() );
-
- for( const Geometry* geo : geos ) {
-
- const MeshGeometry* const mesh = dynamic_cast< const MeshGeometry* >( geo );
- if ( mesh ) {
- const std::vector& indices = ConvertMesh( *mesh, model, node_global_transform, nd);
- std::copy( indices.begin(), indices.end(), std::back_inserter( meshes ) );
- }
- else {
- FBXImporter::LogWarn( "ignoring unrecognized geometry: " + geo->Name() );
- }
- }
-
- if ( meshes.size() ) {
- nd.mMeshes = new unsigned int[ meshes.size() ]();
- nd.mNumMeshes = static_cast< unsigned int >( meshes.size() );
-
- std::swap_ranges( meshes.begin(), meshes.end(), nd.mMeshes );
- }
-}
-
-std::vector FBXConverter::ConvertMesh( const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd)
-{
- std::vector temp;
-
- MeshMap::const_iterator it = meshes_converted.find( &mesh );
- if ( it != meshes_converted.end() ) {
- std::copy( ( *it ).second.begin(), ( *it ).second.end(), std::back_inserter( temp ) );
- return temp;
- }
-
- const std::vector& vertices = mesh.GetVertices();
- const std::vector& faces = mesh.GetFaceIndexCounts();
- if ( vertices.empty() || faces.empty() ) {
- FBXImporter::LogWarn( "ignoring empty geometry: " + mesh.Name() );
- return temp;
- }
-
- // one material per mesh maps easily to aiMesh. Multiple material
- // meshes need to be split.
- const MatIndexArray& mindices = mesh.GetMaterialIndices();
- if ( doc.Settings().readMaterials && !mindices.empty() ) {
- const MatIndexArray::value_type base = mindices[ 0 ];
- for( MatIndexArray::value_type index : mindices ) {
- if ( index != base ) {
- return ConvertMeshMultiMaterial( mesh, model, node_global_transform, nd);
- }
- }
- }
-
- // faster code-path, just copy the data
- temp.push_back( ConvertMeshSingleMaterial( mesh, model, node_global_transform, nd) );
- return temp;
-}
-
-aiMesh* FBXConverter::SetupEmptyMesh( const MeshGeometry& mesh, aiNode& nd)
-{
- aiMesh* const out_mesh = new aiMesh();
- meshes.push_back( out_mesh );
- meshes_converted[ &mesh ].push_back( static_cast( meshes.size() - 1 ) );
-
- // set name
- std::string name = mesh.Name();
- if ( name.substr( 0, 10 ) == "Geometry::" ) {
- name = name.substr( 10 );
- }
-
- if ( name.length() ) {
- out_mesh->mName.Set( name );
- }
- else
- {
- out_mesh->mName = nd.mName;
- }
-
- return out_mesh;
-}
-
-unsigned int FBXConverter::ConvertMeshSingleMaterial( const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd)
-{
- const MatIndexArray& mindices = mesh.GetMaterialIndices();
- aiMesh* const out_mesh = SetupEmptyMesh(mesh, nd);
-
- const std::vector& vertices = mesh.GetVertices();
- const std::vector& faces = mesh.GetFaceIndexCounts();
-
- // copy vertices
- out_mesh->mNumVertices = static_cast( vertices.size() );
- out_mesh->mVertices = new aiVector3D[ vertices.size() ];
- std::copy( vertices.begin(), vertices.end(), out_mesh->mVertices );
-
- // generate dummy faces
- out_mesh->mNumFaces = static_cast( faces.size() );
- aiFace* fac = out_mesh->mFaces = new aiFace[ faces.size() ]();
-
- unsigned int cursor = 0;
- for( unsigned int pcount : faces ) {
- aiFace& f = *fac++;
- f.mNumIndices = pcount;
- f.mIndices = new unsigned int[ pcount ];
- switch ( pcount )
- {
- case 1:
- out_mesh->mPrimitiveTypes |= aiPrimitiveType_POINT;
- break;
- case 2:
- out_mesh->mPrimitiveTypes |= aiPrimitiveType_LINE;
- break;
- case 3:
- out_mesh->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE;
- break;
- default:
- out_mesh->mPrimitiveTypes |= aiPrimitiveType_POLYGON;
- break;
- }
- for ( unsigned int i = 0; i < pcount; ++i ) {
- f.mIndices[ i ] = cursor++;
- }
- }
-
- // copy normals
- const std::vector& normals = mesh.GetNormals();
- if ( normals.size() ) {
- ai_assert( normals.size() == vertices.size() );
-
- out_mesh->mNormals = new aiVector3D[ vertices.size() ];
- std::copy( normals.begin(), normals.end(), out_mesh->mNormals );
- }
-
- // copy tangents - assimp requires both tangents and bitangents (binormals)
- // to be present, or neither of them. Compute binormals from normals
- // and tangents if needed.
- const std::vector& tangents = mesh.GetTangents();
- const std::vector* binormals = &mesh.GetBinormals();
-
- if ( tangents.size() ) {
- std::vector tempBinormals;
- if ( !binormals->size() ) {
- if ( normals.size() ) {
- tempBinormals.resize( normals.size() );
- for ( unsigned int i = 0; i < tangents.size(); ++i ) {
- tempBinormals[ i ] = normals[ i ] ^ tangents[ i ];
- }
-
- binormals = &tempBinormals;
- }
- else {
- binormals = NULL;
- }
- }
-
- if ( binormals ) {
- ai_assert( tangents.size() == vertices.size() );
- ai_assert( binormals->size() == vertices.size() );
-
- out_mesh->mTangents = new aiVector3D[ vertices.size() ];
- std::copy( tangents.begin(), tangents.end(), out_mesh->mTangents );
-
- out_mesh->mBitangents = new aiVector3D[ vertices.size() ];
- std::copy( binormals->begin(), binormals->end(), out_mesh->mBitangents );
- }
- }
-
- // copy texture coords
- for ( unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i ) {
- const std::vector& uvs = mesh.GetTextureCoords( i );
- if ( uvs.empty() ) {
- break;
- }
-
- aiVector3D* out_uv = out_mesh->mTextureCoords[ i ] = new aiVector3D[ vertices.size() ];
- for( const aiVector2D& v : uvs ) {
- *out_uv++ = aiVector3D( v.x, v.y, 0.0f );
- }
-
- out_mesh->mNumUVComponents[ i ] = 2;
- }
-
- // copy vertex colors
- for ( unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i ) {
- const std::vector& colors = mesh.GetVertexColors( i );
- if ( colors.empty() ) {
- break;
- }
-
- out_mesh->mColors[ i ] = new aiColor4D[ vertices.size() ];
- std::copy( colors.begin(), colors.end(), out_mesh->mColors[ i ] );
- }
-
- if ( !doc.Settings().readMaterials || mindices.empty() ) {
- FBXImporter::LogError( "no material assigned to mesh, setting default material" );
- out_mesh->mMaterialIndex = GetDefaultMaterial();
- }
- else {
- ConvertMaterialForMesh( out_mesh, model, mesh, mindices[ 0 ] );
- }
-
- if ( doc.Settings().readWeights && mesh.DeformerSkin() != NULL ) {
- ConvertWeights( out_mesh, model, mesh, node_global_transform, NO_MATERIAL_SEPARATION );
- }
-
- return static_cast( meshes.size() - 1 );
-}
-
-std::vector FBXConverter::ConvertMeshMultiMaterial( const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd)
-{
- const MatIndexArray& mindices = mesh.GetMaterialIndices();
- ai_assert( mindices.size() );
-
- std::set had;
- std::vector indices;
-
- for( MatIndexArray::value_type index : mindices ) {
- if ( had.find( index ) == had.end() ) {
-
- indices.push_back( ConvertMeshMultiMaterial( mesh, model, index, node_global_transform, nd) );
- had.insert( index );
- }
- }
-
- return indices;
-}
-
-unsigned int FBXConverter::ConvertMeshMultiMaterial( const MeshGeometry& mesh, const Model& model,
- MatIndexArray::value_type index,
- const aiMatrix4x4& node_global_transform,
- aiNode& nd)
-{
- aiMesh* const out_mesh = SetupEmptyMesh(mesh, nd);
-
- const MatIndexArray& mindices = mesh.GetMaterialIndices();
- const std::vector& vertices = mesh.GetVertices();
- const std::vector& faces = mesh.GetFaceIndexCounts();
-
- const bool process_weights = doc.Settings().readWeights && mesh.DeformerSkin() != NULL;
-
- unsigned int count_faces = 0;
- unsigned int count_vertices = 0;
-
- // count faces
- std::vector::const_iterator itf = faces.begin();
- for ( MatIndexArray::const_iterator it = mindices.begin(),
- end = mindices.end(); it != end; ++it, ++itf )
- {
- if ( ( *it ) != index ) {
- continue;
- }
- ++count_faces;
- count_vertices += *itf;
- }
-
- ai_assert( count_faces );
- ai_assert( count_vertices );
-
- // mapping from output indices to DOM indexing, needed to resolve weights
- std::vector reverseMapping;
-
- if ( process_weights ) {
- reverseMapping.resize( count_vertices );
- }
-
- // allocate output data arrays, but don't fill them yet
- out_mesh->mNumVertices = count_vertices;
- out_mesh->mVertices = new aiVector3D[ count_vertices ];
-
- out_mesh->mNumFaces = count_faces;
- aiFace* fac = out_mesh->mFaces = new aiFace[ count_faces ]();
-
-
- // allocate normals
- const std::vector& normals = mesh.GetNormals();
- if ( normals.size() ) {
- ai_assert( normals.size() == vertices.size() );
- out_mesh->mNormals = new aiVector3D[ vertices.size() ];
- }
-
- // allocate tangents, binormals.
- const std::vector& tangents = mesh.GetTangents();
- const std::vector* binormals = &mesh.GetBinormals();
- std::vector tempBinormals;
-
- if ( tangents.size() ) {
- if ( !binormals->size() ) {
- if ( normals.size() ) {
- // XXX this computes the binormals for the entire mesh, not only
- // the part for which we need them.
- tempBinormals.resize( normals.size() );
- for ( unsigned int i = 0; i < tangents.size(); ++i ) {
- tempBinormals[ i ] = normals[ i ] ^ tangents[ i ];
- }
-
- binormals = &tempBinormals;
- }
- else {
- binormals = NULL;
- }
- }
-
- if ( binormals ) {
- ai_assert( tangents.size() == vertices.size() && binormals->size() == vertices.size() );
-
- out_mesh->mTangents = new aiVector3D[ vertices.size() ];
- out_mesh->mBitangents = new aiVector3D[ vertices.size() ];
- }
- }
-
- // allocate texture coords
- unsigned int num_uvs = 0;
- for ( unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i, ++num_uvs ) {
- const std::vector& uvs = mesh.GetTextureCoords( i );
- if ( uvs.empty() ) {
- break;
- }
-
- out_mesh->mTextureCoords[ i ] = new aiVector3D[ vertices.size() ];
- out_mesh->mNumUVComponents[ i ] = 2;
- }
-
- // allocate vertex colors
- unsigned int num_vcs = 0;
- for ( unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i, ++num_vcs ) {
- const std::vector& colors = mesh.GetVertexColors( i );
- if ( colors.empty() ) {
- break;
- }
-
- out_mesh->mColors[ i ] = new aiColor4D[ vertices.size() ];
- }
-
- unsigned int cursor = 0, in_cursor = 0;
-
- itf = faces.begin();
- for ( MatIndexArray::const_iterator it = mindices.begin(),
- end = mindices.end(); it != end; ++it, ++itf )
- {
- const unsigned int pcount = *itf;
- if ( ( *it ) != index ) {
- in_cursor += pcount;
- continue;
- }
-
- aiFace& f = *fac++;
-
- f.mNumIndices = pcount;
- f.mIndices = new unsigned int[ pcount ];
- switch ( pcount )
- {
- case 1:
- out_mesh->mPrimitiveTypes |= aiPrimitiveType_POINT;
- break;
- case 2:
- out_mesh->mPrimitiveTypes |= aiPrimitiveType_LINE;
- break;
- case 3:
- out_mesh->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE;
- break;
- default:
- out_mesh->mPrimitiveTypes |= aiPrimitiveType_POLYGON;
- break;
- }
- for ( unsigned int i = 0; i < pcount; ++i, ++cursor, ++in_cursor ) {
- f.mIndices[ i ] = cursor;
-
- if ( reverseMapping.size() ) {
- reverseMapping[ cursor ] = in_cursor;
- }
-
- out_mesh->mVertices[ cursor ] = vertices[ in_cursor ];
-
- if ( out_mesh->mNormals ) {
- out_mesh->mNormals[ cursor ] = normals[ in_cursor ];
- }
-
- if ( out_mesh->mTangents ) {
- out_mesh->mTangents[ cursor ] = tangents[ in_cursor ];
- out_mesh->mBitangents[ cursor ] = ( *binormals )[ in_cursor ];
- }
-
- for ( unsigned int j = 0; j < num_uvs; ++j ) {
- const std::vector& uvs = mesh.GetTextureCoords( j );
- out_mesh->mTextureCoords[ j ][ cursor ] = aiVector3D( uvs[ in_cursor ].x, uvs[ in_cursor ].y, 0.0f );
- }
-
- for ( unsigned int j = 0; j < num_vcs; ++j ) {
- const std::vector& cols = mesh.GetVertexColors( j );
- out_mesh->mColors[ j ][ cursor ] = cols[ in_cursor ];
- }
- }
- }
-
- ConvertMaterialForMesh( out_mesh, model, mesh, index );
-
- if ( process_weights ) {
- ConvertWeights( out_mesh, model, mesh, node_global_transform, index, &reverseMapping );
- }
-
- return static_cast( meshes.size() - 1 );
-}
-
-void FBXConverter::ConvertWeights( aiMesh* out, const Model& model, const MeshGeometry& geo,
- const aiMatrix4x4& node_global_transform ,
- unsigned int materialIndex,
- std::vector* outputVertStartIndices )
-{
- ai_assert( geo.DeformerSkin() );
-
- std::vector out_indices;
- std::vector index_out_indices;
- std::vector count_out_indices;
-
- const Skin& sk = *geo.DeformerSkin();
-
- std::vector bones;
- bones.reserve( sk.Clusters().size() );
-
- const bool no_mat_check = materialIndex == NO_MATERIAL_SEPARATION;
- ai_assert( no_mat_check || outputVertStartIndices );
-
- try {
-
- for( const Cluster* cluster : sk.Clusters() ) {
- ai_assert( cluster );
-
- const WeightIndexArray& indices = cluster->GetIndices();
-
- if ( indices.empty() ) {
- continue;
- }
-
- const MatIndexArray& mats = geo.GetMaterialIndices();
-
- bool ok = false;
-
- const size_t no_index_sentinel = std::numeric_limits::max();
-
- count_out_indices.clear();
- index_out_indices.clear();
- out_indices.clear();
-
- // now check if *any* of these weights is contained in the output mesh,
- // taking notes so we don't need to do it twice.
- for( WeightIndexArray::value_type index : indices ) {
-
- unsigned int count = 0;
- const unsigned int* const out_idx = geo.ToOutputVertexIndex( index, count );
- // ToOutputVertexIndex only returns NULL if index is out of bounds
- // which should never happen
- ai_assert( out_idx != NULL );
-
- index_out_indices.push_back( no_index_sentinel );
- count_out_indices.push_back( 0 );
-
- for ( unsigned int i = 0; i < count; ++i ) {
- if ( no_mat_check || static_cast( mats[ geo.FaceForVertexIndex( out_idx[ i ] ) ] ) == materialIndex ) {
-
- if ( index_out_indices.back() == no_index_sentinel ) {
- index_out_indices.back() = out_indices.size();
-
- }
-
- if ( no_mat_check ) {
- out_indices.push_back( out_idx[ i ] );
+ if (!name_carrier) {
+ std::string old_original_name = original_name;
+ GetUniqueName(old_original_name, original_name);
+ nodes_chain.push_back(new aiNode(original_name));
}
else {
- // this extra lookup is in O(logn), so the entire algorithm becomes O(nlogn)
- const std::vector::iterator it = std::lower_bound(
- outputVertStartIndices->begin(),
- outputVertStartIndices->end(),
- out_idx[ i ]
- );
-
- out_indices.push_back( std::distance( outputVertStartIndices->begin(), it ) );
+ original_name = nodes_chain.back()->mName.C_Str();
}
- ++count_out_indices.back();
- ok = true;
- }
- }
- }
+ //setup metadata on newest node
+ SetupNodeMetadata(*model, *nodes_chain.back());
- // if we found at least one, generate the output bones
- // XXX this could be heavily simplified by collecting the bone
- // data in a single step.
- if ( ok ) {
- ConvertCluster( bones, model, *cluster, out_indices, index_out_indices,
- count_out_indices, node_global_transform );
- }
- }
- }
- catch ( std::exception& ) {
- std::for_each( bones.begin(), bones.end(), Util::delete_fun() );
- throw;
- }
+ // link all nodes in a row
+ aiNode* last_parent = &parent;
+ for (aiNode* prenode : nodes_chain) {
+ ai_assert(prenode);
- if ( bones.empty() ) {
- return;
- }
-
- out->mBones = new aiBone*[ bones.size() ]();
- out->mNumBones = static_cast( bones.size() );
-
- std::swap_ranges( bones.begin(), bones.end(), out->mBones );
-}
-
-void FBXConverter::ConvertCluster( std::vector& bones, const Model& /*model*/, const Cluster& cl,
- std::vector& out_indices,
- std::vector& index_out_indices,
- std::vector& count_out_indices,
- const aiMatrix4x4& node_global_transform )
-{
-
- aiBone* const bone = new aiBone();
- bones.push_back( bone );
-
- bone->mName = FixNodeName( cl.TargetNode()->Name() );
-
- bone->mOffsetMatrix = cl.TransformLink();
- bone->mOffsetMatrix.Inverse();
-
- bone->mOffsetMatrix = bone->mOffsetMatrix * node_global_transform;
-
- bone->mNumWeights = static_cast( out_indices.size() );
- aiVertexWeight* cursor = bone->mWeights = new aiVertexWeight[ out_indices.size() ];
-
- const size_t no_index_sentinel = std::numeric_limits::max();
- const WeightArray& weights = cl.GetWeights();
-
- const size_t c = index_out_indices.size();
- for ( size_t i = 0; i < c; ++i ) {
- const size_t index_index = index_out_indices[ i ];
-
- if ( index_index == no_index_sentinel ) {
- continue;
- }
-
- const size_t cc = count_out_indices[ i ];
- for ( size_t j = 0; j < cc; ++j ) {
- aiVertexWeight& out_weight = *cursor++;
-
- out_weight.mVertexId = static_cast( out_indices[ index_index + j ] );
- out_weight.mWeight = weights[ i ];
- }
- }
-}
-
-void FBXConverter::ConvertMaterialForMesh( aiMesh* out, const Model& model, const MeshGeometry& geo,
- MatIndexArray::value_type materialIndex )
-{
- // locate source materials for this mesh
- const std::vector& mats = model.GetMaterials();
- if ( static_cast( materialIndex ) >= mats.size() || materialIndex < 0 ) {
- FBXImporter::LogError( "material index out of bounds, setting default material" );
- out->mMaterialIndex = GetDefaultMaterial();
- return;
- }
-
- const Material* const mat = mats[ materialIndex ];
- MaterialMap::const_iterator it = materials_converted.find( mat );
- if ( it != materials_converted.end() ) {
- out->mMaterialIndex = ( *it ).second;
- return;
- }
-
- out->mMaterialIndex = ConvertMaterial( *mat, &geo );
- materials_converted[ mat ] = out->mMaterialIndex;
-}
-
-unsigned int FBXConverter::GetDefaultMaterial()
-{
- if ( defaultMaterialIndex ) {
- return defaultMaterialIndex - 1;
- }
-
- aiMaterial* out_mat = new aiMaterial();
- materials.push_back( out_mat );
-
- const aiColor3D diffuse = aiColor3D( 0.8f, 0.8f, 0.8f );
- out_mat->AddProperty( &diffuse, 1, AI_MATKEY_COLOR_DIFFUSE );
-
- aiString s;
- s.Set( AI_DEFAULT_MATERIAL_NAME );
-
- out_mat->AddProperty( &s, AI_MATKEY_NAME );
-
- defaultMaterialIndex = static_cast< unsigned int >( materials.size() );
- return defaultMaterialIndex - 1;
-}
-
-
-unsigned int FBXConverter::ConvertMaterial( const Material& material, const MeshGeometry* const mesh )
-{
- const PropertyTable& props = material.Props();
-
- // generate empty output material
- aiMaterial* out_mat = new aiMaterial();
- materials_converted[ &material ] = static_cast( materials.size() );
-
- materials.push_back( out_mat );
-
- aiString str;
-
- // strip Material:: prefix
- std::string name = material.Name();
- if ( name.substr( 0, 10 ) == "Material::" ) {
- name = name.substr( 10 );
- }
-
- // set material name if not empty - this could happen
- // and there should be no key for it in this case.
- if ( name.length() ) {
- str.Set( name );
- out_mat->AddProperty( &str, AI_MATKEY_NAME );
- }
-
- // shading stuff and colors
- SetShadingPropertiesCommon( out_mat, props );
-
- // texture assignments
- SetTextureProperties( out_mat, material.Textures(), mesh );
- SetTextureProperties( out_mat, material.LayeredTextures(), mesh );
-
- return static_cast( materials.size() - 1 );
-}
-
-unsigned int FBXConverter::ConvertVideo( const Video& video )
-{
- // generate empty output texture
- aiTexture* out_tex = new aiTexture();
- textures.push_back( out_tex );
-
- // assuming the texture is compressed
- out_tex->mWidth = static_cast( video.ContentLength() ); // total data size
- out_tex->mHeight = 0; // fixed to 0
-
- // steal the data from the Video to avoid an additional copy
- out_tex->pcData = reinterpret_cast( const_cast