Compare commits

..

112 Commits

Author SHA1 Message Date
Kim Kulling
c2375a4ff0 Merge pull request #4272 from errissa/pbr-obj
Support PBR properties/maps in Obj importer
2021-12-31 10:38:50 +01:00
Kim Kulling
ab19cff328 Merge branch 'master' into pbr-obj 2021-12-31 08:33:30 +01:00
Kim Kulling
049a241855 Merge pull request #4314 from pseiderer/ps-devel-fix-namespace-001
RFC: BlenderScene: use explicit namespace instead of using namespace
2021-12-31 08:32:54 +01:00
Kim Kulling
a86ab45161 Merge branch 'master' into ps-devel-fix-namespace-001 2021-12-31 08:20:24 +01:00
Peter Seiderer
a099fe7cd3 BlenderScene: use explicit namespace instead of using namespace
Fixes (using g++ Sourcery CodeBench Lite 2014.05-29 - 4.8.3 20140320):

  .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.cpp:101:33: error: specialization of 'template<class T> void Assimp::Blender::Structure::Convert(T&, const Assimp::Blender::FileDatabase&) const' in different namespace [-fpermissive]
           const FileDatabase &db) const {
                                   ^
 In file included from .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.h:49:0,
                   from .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.cpp:47:
  .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderDNA.h:266:10: error:   from definition of 'template<class T> void Assimp::Blender::Structure::Convert(T&, const Assimp::Blender::FileDatabase&) const' [-fpermissive]
       void Convert(T &dest, const FileDatabase &db) const;
            ^
  .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.cpp:121:33: error: specialization of 'template<class T> void Assimp::Blender::Structure::Convert(T&, const Assimp::Blender::FileDatabase&) const' in different namespace [-fpermissive]
           const FileDatabase &db) const {
                                   ^
  In file included from .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.h:49:0,
                   from .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.cpp:47:
  .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderDNA.h:266:10: error:   from definition of 'template<class T> void Assimp::Blender::Structure::Convert(T&, const Assimp::Blender::FileDatabase&) const' [-fpermissive]
       void Convert(T &dest, const FileDatabase &db) const;
            ^

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2021-12-30 18:01:54 +01:00
Kim Kulling
85dd84cc78 Merge pull request #4259 from VyacheslavVanin/fix-fbx-metalness-import
fix fbx import metalness
2021-12-29 20:35:46 +01:00
Kim Kulling
0a5bd792de Merge branch 'master' into fix-fbx-metalness-import 2021-12-29 19:08:16 +01:00
Kim Kulling
c882731688 Merge pull request #4311 from SirLynix/fix-mingw
CMake: Replace CMAKE_COMPILER_IS_MINGW by MINGW
2021-12-29 17:31:12 +01:00
Jérôme Leclercq
81fc50f612 CMake: Replace CMAKE_COMPILER_IS_MINGW by MINGW
See https://discourse.cmake.org/t/cmake-compiler-is-mingw-removed/4539 and https://cmake.org/cmake/help/latest/variable/MINGW.html
2021-12-28 15:58:37 +01:00
Vyacheslav Vanin
2da06dd41a Merge branch 'master' into fix-fbx-metalness-import 2021-12-26 17:31:33 +03:00
Kim Kulling
54a8da1d55 Merge pull request #4293 from assimp/add_colsole_progresshandler_issue_963
Add console progresshandler
2021-12-26 11:38:24 +01:00
Kim Kulling
d44641398f Add console progresshandler 2021-12-26 11:16:02 +01:00
Kim Kulling
4d7e817bd8 Merge pull request #4284 from assimp/kimkulling-skip_empty_embedded_textures_issue4238
MDL: Do not try to copy empty embedded texture
2021-12-23 13:03:43 +01:00
Kim Kulling
db2500c393 MDL: Do not try to copy empty embedded texture
- When an embedded texture is empty, skip it instead of trying to copy it. This must fail.
- closes https://github.com/assimp/assimp/issues/4238
- Found from the Google fuzzer.
2021-12-23 12:28:43 +01:00
Kim Kulling
64af16c427 Merge pull request #4283 from assimp/kimkulling-avoid_invalid_string_access_issue4222
LWS-Import: Avoid access to empty string token
2021-12-22 21:28:42 +01:00
Kim Kulling
635153b3a4 LWS-Import: Avoid access to empty string token
- Fix invalid access to string pointer when string token is empty
- closes https://github.com/assimp/assimp/issues/4222
2021-12-22 21:08:28 +01:00
Kim Kulling
7ec52e9e02 Merge pull request #4282 from assimp/kimkulling-fix_heap_overflow_during_utf8_issue4230
Make sure no overflow can happen
2021-12-22 20:56:39 +01:00
Kim Kulling
2c66d4d3a2 Optimize the check 2021-12-22 20:43:44 +01:00
Kim Kulling
215f4e1f4d Fix typo 2021-12-22 20:02:29 +01:00
Kim Kulling
2eb86d75b8 Make sure no overflow can happen
- During UTF32 LE with BOM make sure that the byteswap operation will have enough space when iterating through the text buffer, which shall get encoded.
- closes https://github.com/assimp/assimp/issues/4230
2021-12-22 19:45:19 +01:00
Rene Sepulveda
19371af6e6 Support PBR properties/maps in Obj importer 2021-12-20 13:43:46 -05:00
Kim Kulling
80b0b897ed Merge pull request #4266 from assimp/kimkulling-patch-1
Update version to 5.1.4
2021-12-18 21:42:19 +01:00
Kim Kulling
572e31ddcb Update version to 5.1.4 2021-12-18 21:30:04 +01:00
Kim Kulling
9dfd401624 Merge pull request #4263 from RivIs-sssa01/fix_X3DImporter.cpp_closingBraces
Fix compile error when ASSIMP_BUILD_NO_X3D_IMPORTER is define.
2021-12-18 21:28:32 +01:00
Kim Kulling
5a46597e47 Merge branch 'master' into fix_X3DImporter.cpp_closingBraces 2021-12-18 21:17:23 +01:00
Kim Kulling
01f68dd916 Merge pull request #4264 from Garux/IMAGE1.bmp_jpg
fix test/models/3DS/IMAGE1.bmp: is jpg
2021-12-18 21:16:59 +01:00
Garux
7fc4603579 fix test/models/3DS/IMAGE1.bmp: is jpg 2021-12-18 14:32:46 +03:00
sssaoi
d7bf8d6e07 Fix compile error when ASSIMP_BUILD_NO_X3D_IMPORTER is define. 2021-12-18 14:50:22 +09:00
Vyacheslav Vanin
53968550e4 Merge branch 'master' into fix-fbx-metalness-import 2021-12-17 12:08:55 +03:00
Kim Kulling
6693e7e08c Merge pull request #4256 from rumgot/cmake_no_known_features_error_fix
Fixed cmake error: No known features for C compiler when using the assimp library from another project
2021-12-16 21:35:52 +01:00
Kim Kulling
3e97329fa1 Merge branch 'master' into cmake_no_known_features_error_fix 2021-12-16 20:27:58 +01:00
Kim Kulling
c72e3905c2 Merge pull request #4261 from assimp/kimkulling-enable_language_support_issue4257-2
Enable C++11 and C99
2021-12-16 20:27:17 +01:00
Kim Kulling
2ffa0c59eb Switch to C++11 until gtest gets an update. 2021-12-16 19:54:40 +01:00
Kim Kulling
af42d53c92 Enable C++17 and C99
- closes https://github.com/assimp/assimp/issues/4257
2021-12-16 19:41:15 +01:00
Kim Kulling
c4d858cf4d Merge pull request #4260 from assimp/kimkulling-patch-1
Fix a typo in the Visual-Studio Dll-Versions
2021-12-16 15:39:01 +01:00
Kim Kulling
7a29147095 Fix a typo 2021-12-16 14:55:23 +01:00
Kim Kulling
46b28a442b Merge pull request #4226 from umlaeute/bugfix/import-crashes
Bugfix/import crashes
2021-12-16 14:51:34 +01:00
Vyacheslav.Vanin
1afe7e6255 fix fbx import metalness
Can't import metalness textures in fbx importer
2021-12-16 12:09:06 +03:00
Kim Kulling
26dc168449 Merge branch 'master' into bugfix/import-crashes 2021-12-15 07:54:48 +01:00
rumgot
92aef9236f Fixed cmake error: No known features for C compiler when using the assimp library from another project. 2021-12-14 23:54:36 +03:00
Kim Kulling
8322e393c5 Merge pull request #4244 from kovacsv/copyscene_fix
Bug: Export crashes when any of the meshes contains texture coordinate names #4243
2021-12-14 00:14:42 +01:00
Kim Kulling
003942aafe Merge branch 'master' into copyscene_fix 2021-12-13 21:19:08 +01:00
Kim Kulling
0491eb3591 Merge pull request #4253 from assimp/kimkulling_fix_double_prec_build_issue4248
Use correct XmlParser-methods and add some missing casts
2021-12-13 21:17:15 +01:00
Viktor Kovacs
d619f7015a Merge branch 'master' into copyscene_fix 2021-12-13 20:08:45 +01:00
Kim Kulling
65bc801734 Some fixes for possible divisions by zero 2021-12-13 18:48:58 +01:00
Kim Kulling
e4f38810ca Add missing static casts 2021-12-13 18:12:19 +01:00
Kim Kulling
cb657e4c13 Use correct XmlParser-methods and add some missing casts 2021-12-13 18:06:23 +01:00
Kim Kulling
052594568a Merge pull request #4247 from inhosens/master
Revert "FBXConverter : Fix timescales of FBX animations"
2021-12-12 21:42:14 +01:00
Kim Kulling
54e60b031e Merge branch 'master' into master 2021-12-12 21:12:37 +01:00
Viktor Kovacs
4959924dab Merge branch 'master' into copyscene_fix 2021-12-10 20:10:25 +01:00
Kim Kulling
819d9f7257 Merge pull request #4250 from assimp/kimkulling-fix_division_by_zero_issue4235-1
Update HMPLoader.cpp
2021-12-10 15:03:01 +01:00
Kim Kulling
33c6762272 Update HMPLoader.cpp
- Fix possible division by zero
- closes https://github.com/assimp/assimp/issues/4235
2021-12-10 14:32:45 +01:00
Kim Kulling
6bb856335f Merge pull request #4249 from assimp/kimkulling-fix_nullptr_dereferencing_issue4237
Fix nullptr dereferencing from std::shared_ptr
2021-12-10 11:02:32 +01:00
Kim Kulling
68682d75b5 Fix nullptr dereferencing from std::shared_ptr
- Finding from fuzzer
- closes https://github.com/assimp/assimp/issues/4237
2021-12-10 08:39:21 +01:00
Inho Lee
c2297e9199 Revert "FBXConverter : Fix timescales of FBX animations"
The previous patch was made by misunderstanding about mTime.
It is not real time value, but time ticks.

This reverts commit b8bf1eac04.
2021-12-09 10:57:39 +01:00
Viktor Kovacs
d2c8cb755e Merge branch 'master' into copyscene_fix 2021-12-08 14:29:31 +01:00
Kim Kulling
ea2e442046 Merge pull request #4245 from assimp/kimkulling-fix-division-by-zero-issue4240
Fix division by zero in PointInTriangle2D
2021-12-07 21:37:50 +01:00
Kim Kulling
e51feac2c5 Update PolyTools.h 2021-12-07 21:19:01 +01:00
Kim Kulling
1e4861f86e Fix division by zero in PointInTriangle2D
- closes https://github.com/assimp/assimp/issues/4240
2021-12-07 20:45:21 +01:00
kovacsv
2be6bac4b0 Bug: Export crashes when any of the meshes contains texture coordinate names #4243 2021-12-07 20:42:43 +01:00
IOhannes m zmölnig
9a7ee0ac14 Throw a DeadlyImportError rather than an assertion if all materials are redundant and thus removed
Closes: https://github.com/assimp/assimp/issues/4224
Closes: https://github.com/assimp/assimp/issues/4225
2021-12-07 12:35:15 +01:00
IOhannes m zmölnig
6e090c88b8 fix index variable for surfaces
Closes: https://github.com/assimp/assimp/issues/4209
2021-12-07 12:13:31 +01:00
Kim Kulling
70f5cca9c3 Merge pull request #4219 from assimp/kimkulling-v5.1.3
Update CMakeLists.txt
2021-12-04 21:01:52 +01:00
Kim Kulling
983b20cda6 Update CMakeLists.txt
- tag v5.1.3
2021-12-04 20:26:29 +01:00
Kim Kulling
16149348ed Merge pull request #4217 from umlaeute/bugfix/x3d-extension-check
Fix file-extension check for X3D-files
2021-12-01 16:07:12 +01:00
IOhannes m zmölnig
0e2ac2a91c X3D: simplistic attempt to avoid crashes due to nullptr access
Related: https://github.com/assimp/assimp/issues/4201

while the crashes go away, i'm not sure whether this is the correct fix.
also, afaict the X3D importer produces wrong results anyhow
2021-12-01 12:21:29 +01:00
IOhannes m zmölnig
c8cdf3009e X3D: replace 'here' debugging printout by an assertion.
if mNodeElementCur is NULL, we get a crash anyhow...
2021-12-01 12:19:19 +01:00
IOhannes m zmölnig
23d7811276 X3D: consistent initialization with nullptr 2021-12-01 11:35:06 +01:00
IOhannes m zmölnig
836963428e Fix file-extension check for X3D-files
using the pre-existing and well-tested GetExtension() (which happens
to also normalize the extension), rather than attempting our own
buggy one...

Closes: https://github.com/assimp/assimp/issues/4177
2021-12-01 11:17:42 +01:00
Kim Kulling
8c9a148776 Merge pull request #4216 from inhosens/master
Interpolate euler rotations for quaternion animations
2021-12-01 00:24:15 +01:00
Kim Kulling
834ec20008 Merge branch 'master' into master 2021-11-30 23:44:42 +01:00
Kim Kulling
cc05b4c8f1 Merge pull request #4211 from ms-maxvollmer/ms-maxvollmer/crashfixes2
Added checks for out of bounds data access/writing
2021-11-30 23:44:00 +01:00
Kim Kulling
d6f3f292f2 Merge branch 'master' into ms-maxvollmer/crashfixes2 2021-11-30 23:17:59 +01:00
Inho Lee
4a37aa2ef8 Interpolate euler rotations for quaternion animations
FBX uses euler rotation but assimp library's base type is
quaternion. When assimp convert FBX some animation information
can be lost.
This patch interpolates euler-angle rotations and insert
additional keyframes for the FBX format.
2021-11-30 12:49:59 +01:00
Kim Kulling
745f5e7e65 Merge pull request #4193 from PencilAmazing/BlenderCollections
Update blender importer to work with Blender 2.8+ files
2021-11-28 23:51:06 +01:00
Pencil Amazing
095bd67e10 Fix memory leaks in CollectionObject by making ob a weak pointer and removing prev pointer.
Something was cyclic in CollectionObject and we don't traverse backwards anyways
2021-11-26 22:09:06 -04:00
Pencil Amazing
e831ecf3c2 Add a separate test case for Blender 276 and update Box.blend to be 293 2021-11-26 22:09:06 -04:00
Pencil Amazing
44fa1ec6a7 Make Blender importer aware of collections, and use them when available. Also add the default startup file for Blender 2.93 2021-11-26 22:09:06 -04:00
Kim Kulling
70c1aec7c7 Merge pull request #4212 from assimp/kimkulling-remove_deprecated_data
Delete test/models/3DS/UVTransformTest directory
2021-11-26 19:34:02 +01:00
Kim Kulling
34daf87428 Delete test/models/3DS/UVTransformTest directory
- Remove deprecated data
2021-11-26 19:17:42 +01:00
Max Vollmer (Microsoft Havok)
5e1188c44e Check that positions exist before accessing them 2021-11-26 13:01:38 +00:00
Max Vollmer (Microsoft Havok)
0015823bef Reject files with an invalid byteLength value 2021-11-26 13:01:15 +00:00
Max Vollmer (Microsoft Havok)
38382715f7 Ensure we don't access the vector with an out of bounds index 2021-11-26 13:01:00 +00:00
Kim Kulling
da8772c57b Merge pull request #4207 from jakrams/msft-jakras-fix-corrupted-accessor
Prevent out-of-range memory writes by sparse accessors
2021-11-26 09:02:17 +01:00
Jan Krassnigg
1a5d66714f Prevent out-of-range memory writes by sparse accessors
This turned up during fuzz testing. Corrupted data would make assimp write to random memory locations, leading to subsequent crashes.
2021-11-25 11:20:26 +01:00
Kim Kulling
889e559696 Merge pull request #4195 from ruyo/fix-gltf2-sparse-indicesType
Fixed an incorrect indeiciesType in the glTF2 sparse accessor.
2021-11-22 22:43:43 +01:00
Kim Kulling
b22098c234 Merge branch 'master' into fix-gltf2-sparse-indicesType 2021-11-22 22:02:05 +01:00
Kim Kulling
85ea57dcdb Merge pull request #4196 from Rodousse/fix_mingw_compile_flags
Use adviced c++ flag to supress warning on mingw
2021-11-22 22:01:05 +01:00
Robin Dousse
6819b84b8b Use adviced c++ flag to supress warning on mingw 2021-11-22 09:27:14 +01:00
ruyo
60bfde78eb Fixed an incorrect indeiciesType in the glTF2 sparse accessor. 2021-11-21 23:23:22 +09:00
Kim Kulling
aeba7a43a0 Merge pull request #4185 from rhabacker/win_dll_so_version
On Windows/mingw in shared build mode append '-SOVERSION' to DLL base file name
2021-11-20 16:53:21 +01:00
Kim Kulling
9ebd74bd26 Merge branch 'master' into win_dll_so_version 2021-11-20 14:16:32 +01:00
Kim Kulling
9267f4c5b8 Merge pull request #4184 from RichardTea/deprecated_gltfpbr_macros
Redefine deprecated glTF-specific PBR material macros
2021-11-20 14:01:57 +01:00
Kim Kulling
0d857bcf9f Merge branch 'master' into deprecated_gltfpbr_macros 2021-11-20 12:35:56 +01:00
Ralf Habacker
2ceb18746b Append '-SOVERSION' to DLL base file name for mingw builds to match common style 2021-11-18 08:17:31 +01:00
Kim Kulling
3db1592f7e Merge pull request #4187 from RichardTea/collada_value_not_attrib_4179
Collada: Read value, not attribute
2021-11-17 19:16:10 +01:00
RichardTea
74b3be194d Read the Value, not the Attribute
Correct some mistakes made when moving to pugixml from IrrXML
Fixes #4179
2021-11-17 17:10:10 +00:00
RichardTea
bab8b8dbab apply clangformat 2021-11-17 17:08:19 +00:00
RichardTea
33845cd019 Only issue compile warning on gcc and msvc
I'm not sure on the proper syntax for clang and mingw
2021-11-17 15:44:16 +00:00
Kim Kulling
b1c83f437f Merge pull request #4173 from jdumas/jdumas/ziplib
Do not build ziplib when 3MF exporter is disabled.
2021-11-17 14:09:07 +01:00
Kim Kulling
ce3101ea4e Merge branch 'master' into jdumas/ziplib 2021-11-17 13:46:16 +01:00
RichardTea
c24f99cd0e Redefine deprecated glTF-specific PBR material macros
Intended to support Qt5 QtQuick3D until it is ported to generic PBR
macros.
2021-11-16 11:42:59 +00:00
Kim Kulling
c174575cf8 Merge pull request #4181 from assimp/kimkulling-prepare_installer
Update script_x64.iss
2021-11-15 11:05:34 +01:00
Kim Kulling
1ee8c1b51f Update script_x86.iss
- Update version for 5.1.0 in x86 installer script
2021-11-15 08:41:23 +01:00
Kim Kulling
595799b1bc Update script_x64.iss
- Update to 5.1.0
2021-11-15 08:39:31 +01:00
Kim Kulling
a5a091c138 Merge pull request #4180 from assimp/kimkulling-remove_irrxml_notes
Delete irrXML_note.txt
2021-11-15 08:37:49 +01:00
Kim Kulling
e8732341f4 Delete irrXML_note.txt
- Remove deprecated notes from irrxml
2021-11-15 08:23:56 +01:00
Jérémie Dumas
b0d564467e Merge branch 'master' into jdumas/ziplib 2021-11-14 08:25:59 -08:00
Jérémie Dumas
78d72bff59 Fix 3MF presence test. 2021-11-14 08:24:27 -08:00
Kim Kulling
c3ac5569c5 Merge branch 'master' into jdumas/ziplib 2021-11-13 08:46:46 +01:00
Jérémie Dumas
57d22e4dbf Merge branch 'master' into jdumas/ziplib 2021-11-12 10:13:21 -08:00
Jeremie Dumas
cedf1819c3 Do not build ziplib when 3MF exporter is disabled. 2021-11-04 01:14:24 -07:00
76 changed files with 867 additions and 386 deletions

View File

@@ -56,7 +56,7 @@ IF(ASSIMP_HUNTER_ENABLED)
add_definitions(-DASSIMP_USE_HUNTER)
ENDIF()
PROJECT(Assimp VERSION 5.1.0)
PROJECT(Assimp VERSION 5.1.4)
# All supported options ###############################################
@@ -183,7 +183,9 @@ SET (ASSIMP_SOVERSION 5)
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
if(NOT ASSIMP_HUNTER_ENABLED)
# Enable C++11 support globally
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 99)
endif()
IF(NOT ASSIMP_IGNORE_GIT_HASH)
@@ -244,7 +246,7 @@ IF( UNIX )
ENDIF()
# Grouped compiler settings ########################################
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW)
IF(NOT ASSIMP_HUNTER_ENABLED)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -281,19 +283,18 @@ ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
ENDIF()
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
ELSEIF( CMAKE_COMPILER_IS_MINGW )
ELSEIF( MINGW )
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
message(FATAL_ERROR "MinGW is too old to be supported. Please update MinGW and try again.")
ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
message(WARNING "MinGW is old, if you experience errors, update MinGW.")
ENDIF()
IF(NOT ASSIMP_HUNTER_ENABLED)
SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
ENDIF()
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -O3 ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
ADD_DEFINITIONS( -U__STRICT_ANSI__ )
ENDIF()
IF ( IOS AND NOT ASSIMP_HUNTER_ENABLED)
@@ -763,7 +764,7 @@ if(WIN32)
IF(MSVC_TOOLSET_VERSION)
SET(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
SET(ASSIMP_MSVC_VERSION ${MCVS_PREFIX})
SET(ASSIMP_MSVC_VERSION ${MSVC_PREFIX})
ELSE()
IF(MSVC12)
SET(ASSIMP_MSVC_VERSION "vc120")

View File

@@ -318,42 +318,81 @@ void BlenderImporter::ExtractScene(Scene &out, const FileDatabase &file) {
#endif
}
// ------------------------------------------------------------------------------------------------
void BlenderImporter::ParseSubCollection(const Blender::Scene &in, aiNode *root, std::shared_ptr<Collection> collection, ConversionData &conv_data) {
std::deque<Object *> root_objects;
// Count number of objects
for (std::shared_ptr<CollectionObject> cur = std::static_pointer_cast<CollectionObject>(collection->gobject.first); cur; cur = cur->next) {
if (cur->ob) {
root_objects.push_back(cur->ob);
}
}
std::deque<Collection *> root_children;
// Count number of child nodes
for (std::shared_ptr<CollectionChild> cur = std::static_pointer_cast<CollectionChild>(collection->children.first); cur; cur = cur->next) {
if (cur->collection) {
root_children.push_back(cur->collection.get());
}
}
root->mNumChildren = static_cast<unsigned int>(root_objects.size() + root_children.size());
root->mChildren = new aiNode *[root->mNumChildren]();
for (unsigned int i = 0; i < static_cast<unsigned int>(root_objects.size()); ++i) {
root->mChildren[i] = ConvertNode(in, root_objects[i], conv_data, aiMatrix4x4());
root->mChildren[i]->mParent = root;
}
// For each subcollection create a new node to represent it
unsigned int iterator = static_cast<unsigned int>(root_objects.size());
for (std::shared_ptr<CollectionChild> cur = std::static_pointer_cast<CollectionChild>(collection->children.first); cur; cur = cur->next) {
if (cur->collection) {
root->mChildren[iterator] = new aiNode(cur->collection->id.name + 2); // skip over the name prefix 'OB'
root->mChildren[iterator]->mParent = root;
ParseSubCollection(in, root->mChildren[iterator], cur->collection, conv_data);
}
iterator += 1;
}
}
// ------------------------------------------------------------------------------------------------
void BlenderImporter::ConvertBlendFile(aiScene *out, const Scene &in, const FileDatabase &file) {
ConversionData conv(file);
// FIXME it must be possible to take the hierarchy directly from
// the file. This is terrible. Here, we're first looking for
// all objects which don't have parent objects at all -
std::deque<const Object *> no_parents;
for (std::shared_ptr<Base> cur = std::static_pointer_cast<Base>(in.base.first); cur; cur = cur->next) {
if (cur->object) {
if (!cur->object->parent) {
no_parents.push_back(cur->object.get());
} else {
conv.objects.insert(cur->object.get());
}
}
}
for (std::shared_ptr<Base> cur = in.basact; cur; cur = cur->next) {
if (cur->object) {
if (cur->object->parent) {
conv.objects.insert(cur->object.get());
}
}
}
if (no_parents.empty()) {
ThrowException("Expected at least one object with no parent");
}
aiNode *root = out->mRootNode = new aiNode("<BlenderRoot>");
// Iterate over all objects directly under master_collection,
// If in.master_collection == null, then we're parsing something older.
if (in.master_collection) {
ParseSubCollection(in, root, in.master_collection, conv);
} else {
std::deque<const Object *> no_parents;
for (std::shared_ptr<Base> cur = std::static_pointer_cast<Base>(in.base.first); cur; cur = cur->next) {
if (cur->object) {
if (!cur->object->parent) {
no_parents.push_back(cur->object.get());
} else {
conv.objects.insert(cur->object.get());
}
}
}
for (std::shared_ptr<Base> cur = in.basact; cur; cur = cur->next) {
if (cur->object) {
if (cur->object->parent) {
conv.objects.insert(cur->object.get());
}
}
}
root->mNumChildren = static_cast<unsigned int>(no_parents.size());
root->mChildren = new aiNode *[root->mNumChildren]();
for (unsigned int i = 0; i < root->mNumChildren; ++i) {
root->mChildren[i] = ConvertNode(in, no_parents[i], conv, aiMatrix4x4());
root->mChildren[i]->mParent = root;
if (no_parents.empty()) {
ThrowException("Expected at least one object with no parent");
}
root->mNumChildren = static_cast<unsigned int>(no_parents.size());
root->mChildren = new aiNode *[root->mNumChildren]();
for (unsigned int i = 0; i < root->mNumChildren; ++i) {
root->mChildren[i] = ConvertNode(in, no_parents[i], conv, aiMatrix4x4());
root->mChildren[i]->mParent = root;
}
}
BuildMaterials(conv);

View File

@@ -78,6 +78,7 @@ struct ElemBase;
namespace Blender {
struct Scene;
struct Object;
struct Collection;
struct Mesh;
struct Camera;
struct Lamp;
@@ -116,6 +117,7 @@ protected:
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
void ParseBlendFile(Blender::FileDatabase &out, std::shared_ptr<IOStream> stream);
void ExtractScene(Blender::Scene &out, const Blender::FileDatabase &file);
void ParseSubCollection(const Blender::Scene &in, aiNode *root, std::shared_ptr<Blender::Collection> collection, Blender::ConversionData &conv_data);
void ConvertBlendFile(aiScene *out, const Blender::Scene &in, const Blender::FileDatabase &file);
private:

View File

@@ -49,8 +49,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BlenderDNA.h"
#include "BlenderSceneGen.h"
using namespace Assimp;
using namespace Assimp::Blender;
namespace Assimp {
namespace Blender {
//--------------------------------------------------------------------------------
template <>
@@ -94,6 +94,52 @@ void Structure ::Convert<Group>(
db.reader->IncPtr(size);
}
//--------------------------------------------------------------------------------
template <>
void Structure::Convert<CollectionObject>(
CollectionObject &dest,
const FileDatabase &db) const {
ReadFieldPtr<ErrorPolicy_Fail>(dest.next, "*next", db);
{
//std::shared_ptr<CollectionObject> prev;
//ReadFieldPtr<ErrorPolicy_Fail>(prev, "*prev", db);
//dest.prev = prev.get();
std::shared_ptr<Object> ob;
ReadFieldPtr<ErrorPolicy_Igno>(ob, "*ob", db);
dest.ob = ob.get();
}
db.reader->IncPtr(size);
}
//--------------------------------------------------------------------------------
template <>
void Structure::Convert<CollectionChild>(
CollectionChild &dest,
const FileDatabase &db) const {
ReadFieldPtr<ErrorPolicy_Fail>(dest.prev, "*prev", db);
ReadFieldPtr<ErrorPolicy_Fail>(dest.next, "*next", db);
ReadFieldPtr<ErrorPolicy_Igno>(dest.collection, "*collection", db);
db.reader->IncPtr(size);
}
//--------------------------------------------------------------------------------
template <>
void Structure::Convert<Collection>(
Collection &dest,
const FileDatabase &db) const {
ReadField<ErrorPolicy_Fail>(dest.id, "id", db);
ReadField<ErrorPolicy_Fail>(dest.gobject, "gobject", db);
ReadField<ErrorPolicy_Fail>(dest.children, "children", db);
db.reader->IncPtr(size);
}
//--------------------------------------------------------------------------------
template <>
void Structure ::Convert<MTex>(
@@ -660,6 +706,7 @@ void Structure ::Convert<Scene>(
ReadFieldPtr<ErrorPolicy_Warn>(dest.camera, "*camera", db);
ReadFieldPtr<ErrorPolicy_Warn>(dest.world, "*world", db);
ReadFieldPtr<ErrorPolicy_Warn>(dest.basact, "*basact", db);
ReadFieldPtr<ErrorPolicy_Warn>(dest.master_collection, "*master_collection", db);
ReadField<ErrorPolicy_Igno>(dest.base, "base", db);
db.reader->IncPtr(size);
@@ -833,6 +880,12 @@ void DNA::RegisterConverters() {
converters["Image"] = DNA::FactoryPair(&Structure::Allocate<Image>, &Structure::Convert<Image>);
converters["CustomData"] = DNA::FactoryPair(&Structure::Allocate<CustomData>, &Structure::Convert<CustomData>);
converters["CustomDataLayer"] = DNA::FactoryPair(&Structure::Allocate<CustomDataLayer>, &Structure::Convert<CustomDataLayer>);
converters["Collection"] = DNA::FactoryPair(&Structure::Allocate<Collection>, &Structure::Convert<Collection>);
converters["CollectionChild"] = DNA::FactoryPair(&Structure::Allocate<CollectionChild>, &Structure::Convert<CollectionChild>);
converters["CollectionObject"] = DNA::FactoryPair(&Structure::Allocate<CollectionObject>, &Structure::Convert<CollectionObject>);
}
} // namespace Blender
} //namespace Assimp
#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER

View File

@@ -107,6 +107,7 @@ namespace Blender {
struct Object;
struct MTex;
struct Image;
struct Collection;
#include <memory>
@@ -147,6 +148,26 @@ struct Group : ElemBase {
std::shared_ptr<GroupObject> gobject;
};
// -------------------------------------------------------------------------------
struct CollectionObject : ElemBase {
//CollectionObject* prev;
std::shared_ptr<CollectionObject> next;
Object *ob;
};
// -------------------------------------------------------------------------------
struct CollectionChild : ElemBase {
std::shared_ptr<CollectionChild> next, prev;
std::shared_ptr<Collection> collection;
};
// -------------------------------------------------------------------------------
struct Collection : ElemBase {
ID id FAIL;
ListBase gobject; // CollectionObject
ListBase children; // CollectionChild
};
// -------------------------------------------------------------------------------
struct World : ElemBase {
ID id FAIL;
@@ -729,11 +750,12 @@ struct Scene : ElemBase {
std::shared_ptr<Object> camera WARN;
std::shared_ptr<World> world WARN;
std::shared_ptr<Base> basact WARN;
std::shared_ptr<Collection> master_collection WARN;
ListBase base;
Scene() :
ElemBase(), camera(), world(), basact() {
ElemBase(), camera(), world(), basact(), master_collection() {
// empty
}
};

View File

@@ -62,6 +62,12 @@ template <> void Structure :: Convert<Group> (
) const
;
template <> void Structure::Convert<Collection>(
Collection& dest,
const FileDatabase& db
) const
;
template <> void Structure :: Convert<MTex> (
MTex& dest,
const FileDatabase& db

View File

@@ -924,6 +924,8 @@ void ColladaParser::ReadMaterial(XmlNode &node, Collada::Material &pMaterial) {
void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
// TODO: Check the current technique and skip over unsupported extra techniques
while (xmlIt.getNext(currentNode)) {
const std::string &currentName = currentNode.name();
if (currentName == "spot") {
@@ -949,33 +951,34 @@ void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
content = fast_atoreal_move<ai_real>(content, (ai_real &)pLight.mColor.b);
SkipSpacesAndLineEnd(&content);
} else if (currentName == "constant_attenuation") {
XmlParser::getRealAttribute(currentNode, "constant_attenuation", pLight.mAttConstant);
XmlParser::getValueAsFloat(currentNode, pLight.mAttConstant);
} else if (currentName == "linear_attenuation") {
XmlParser::getRealAttribute(currentNode, "linear_attenuation", pLight.mAttLinear);
XmlParser::getValueAsFloat(currentNode, pLight.mAttLinear);
} else if (currentName == "quadratic_attenuation") {
XmlParser::getRealAttribute(currentNode, "quadratic_attenuation", pLight.mAttQuadratic);
XmlParser::getValueAsFloat(currentNode, pLight.mAttQuadratic);
} else if (currentName == "falloff_angle") {
XmlParser::getRealAttribute(currentNode, "falloff_angle", pLight.mFalloffAngle);
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffAngle);
} else if (currentName == "falloff_exponent") {
XmlParser::getRealAttribute(currentNode, "falloff_exponent", pLight.mFalloffExponent);
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffExponent);
}
// FCOLLADA extensions
// -------------------------------------------------------
else if (currentName == "outer_cone") {
XmlParser::getRealAttribute(currentNode, "outer_cone", pLight.mOuterAngle);
} else if (currentName == "penumbra_angle") { // ... and this one is even deprecated
XmlParser::getRealAttribute(currentNode, "penumbra_angle", pLight.mPenumbraAngle);
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
} else if (currentName == "penumbra_angle") { // this one is deprecated, now calculated using outer_cone
XmlParser::getValueAsFloat(currentNode, pLight.mPenumbraAngle);
} else if (currentName == "intensity") {
XmlParser::getRealAttribute(currentNode, "intensity", pLight.mIntensity);
} else if (currentName == "falloff") {
XmlParser::getRealAttribute(currentNode, "falloff", pLight.mOuterAngle);
XmlParser::getValueAsFloat(currentNode, pLight.mIntensity);
}
else if (currentName == "falloff") {
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
} else if (currentName == "hotspot_beam") {
XmlParser::getRealAttribute(currentNode, "hotspot_beam", pLight.mFalloffAngle);
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffAngle);
}
// OpenCOLLADA extensions
// -------------------------------------------------------
else if (currentName == "decay_falloff") {
XmlParser::getRealAttribute(currentNode, "decay_falloff", pLight.mOuterAngle);
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
}
}
}
@@ -1109,7 +1112,7 @@ void ColladaParser::ReadEffectProfileCommon(XmlNode &node, Collada::Effect &pEff
// GOOGLEEARTH/OKINO extensions
// -------------------------------------------------------
else if (currentName == "double_sided")
XmlParser::getBoolAttribute(currentNode, currentName.c_str(), pEffect.mDoubleSided);
XmlParser::getValueAsBool(currentNode, pEffect.mDoubleSided);
// FCOLLADA extensions
// -------------------------------------------------------
@@ -1121,9 +1124,9 @@ void ColladaParser::ReadEffectProfileCommon(XmlNode &node, Collada::Effect &pEff
// MAX3D extensions
// -------------------------------------------------------
else if (currentName == "wireframe") {
XmlParser::getBoolAttribute(currentNode, currentName.c_str(), pEffect.mWireframe);
XmlParser::getValueAsBool(currentNode, pEffect.mWireframe);
} else if (currentName == "faceted") {
XmlParser::getBoolAttribute(currentNode, currentName.c_str(), pEffect.mFaceted);
XmlParser::getValueAsBool(currentNode, pEffect.mFaceted);
}
}
}
@@ -1142,23 +1145,23 @@ void ColladaParser::ReadSamplerProperties(XmlNode &node, Sampler &out) {
// MAYA extensions
// -------------------------------------------------------
if (currentName == "wrapU") {
XmlParser::getBoolAttribute(currentNode, currentName.c_str(), out.mWrapU);
XmlParser::getValueAsBool(currentNode, out.mWrapU);
} else if (currentName == "wrapV") {
XmlParser::getBoolAttribute(currentNode, currentName.c_str(), out.mWrapV);
XmlParser::getValueAsBool(currentNode, out.mWrapV);
} else if (currentName == "mirrorU") {
XmlParser::getBoolAttribute(currentNode, currentName.c_str(), out.mMirrorU);
XmlParser::getValueAsBool(currentNode, out.mMirrorU);
} else if (currentName == "mirrorV") {
XmlParser::getBoolAttribute(currentNode, currentName.c_str(), out.mMirrorV);
XmlParser::getValueAsBool(currentNode, out.mMirrorV);
} else if (currentName == "repeatU") {
XmlParser::getRealAttribute(currentNode, currentName.c_str(), out.mTransform.mScaling.x);
XmlParser::getValueAsFloat(currentNode, out.mTransform.mScaling.x);
} else if (currentName == "repeatV") {
XmlParser::getRealAttribute(currentNode, currentName.c_str(), out.mTransform.mScaling.y);
XmlParser::getValueAsFloat(currentNode, out.mTransform.mScaling.y);
} else if (currentName == "offsetU") {
XmlParser::getRealAttribute(currentNode, currentName.c_str(), out.mTransform.mTranslation.x);
XmlParser::getValueAsFloat(currentNode, out.mTransform.mTranslation.x);
} else if (currentName == "offsetV") {
XmlParser::getRealAttribute(currentNode, currentName.c_str(), out.mTransform.mTranslation.y);
XmlParser::getValueAsFloat(currentNode, out.mTransform.mTranslation.y);
} else if (currentName == "rotateUV") {
XmlParser::getRealAttribute(currentNode, currentName.c_str(), out.mTransform.mRotation);
XmlParser::getValueAsFloat(currentNode, out.mTransform.mRotation);
} else if (currentName == "blend_mode") {
std::string v;
XmlParser::getValueAsString(currentNode, v);
@@ -1178,14 +1181,14 @@ void ColladaParser::ReadSamplerProperties(XmlNode &node, Sampler &out) {
// OKINO extensions
// -------------------------------------------------------
else if (currentName == "weighting") {
XmlParser::getRealAttribute(currentNode, currentName.c_str(), out.mWeighting);
XmlParser::getValueAsFloat(currentNode, out.mWeighting);
} else if (currentName == "mix_with_previous_layer") {
XmlParser::getRealAttribute(currentNode, currentName.c_str(), out.mMixWithPrevious);
XmlParser::getValueAsFloat(currentNode, out.mMixWithPrevious);
}
// MAX3D extensions
// -------------------------------------------------------
else if (currentName == "amount") {
XmlParser::getRealAttribute(currentNode, currentName.c_str(), out.mWeighting);
XmlParser::getValueAsFloat(currentNode, out.mWeighting);
}
}
}
@@ -2204,7 +2207,7 @@ void ColladaParser::ReadMaterialVertexInputBinding(XmlNode &node, Collada::Seman
void ColladaParser::ReadEmbeddedTextures(ZipArchiveIOSystem &zip_archive) {
// Attempt to load any undefined Collada::Image in ImageLibrary
for (auto & it : mImageLibrary) {
for (auto &it : mImageLibrary) {
Collada::Image &image = it.second;
if (image.mImageData.empty()) {

View File

@@ -378,6 +378,11 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
const DXF::Block& bl_src = *(*it).second;
for (std::shared_ptr<const DXF::PolyLine> pl_in : bl_src.lines) {
if (!pl_in) {
ASSIMP_LOG_ERROR("DXF: PolyLine instance is nullptr, skipping.");
continue;
}
std::shared_ptr<DXF::PolyLine> pl_out = std::shared_ptr<DXF::PolyLine>(new DXF::PolyLine(*pl_in));
if (bl_src.base.Length() || insert.scale.x!=1.f || insert.scale.y!=1.f || insert.scale.z!=1.f || insert.angle || insert.pos.Length()) {

View File

@@ -79,7 +79,7 @@ using namespace Util;
#define MAGIC_NODE_TAG "_$AssimpFbx$"
#define CONVERT_FBX_TIME(time) (static_cast<double>(time) * 1000.0 / 46186158000LL)
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL
FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) :
defaultMaterialIndex(),
@@ -2070,6 +2070,7 @@ void FBXConverter::SetTextureProperties(aiMaterial *out_mat, const LayeredTextur
TrySetTextureProperties(out_mat, layeredTextures, "ShininessExponent", aiTextureType_SHININESS, mesh);
TrySetTextureProperties(out_mat, layeredTextures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh);
TrySetTextureProperties(out_mat, layeredTextures, "TransparencyFactor", aiTextureType_OPACITY, mesh);
TrySetTextureProperties(out_mat, layeredTextures, "ReflectionFactor", aiTextureType_METALNESS, mesh);
}
aiColor3D FBXConverter::GetColorPropertyFactored(const PropertyTable &props, const std::string &colorName,
@@ -2618,7 +2619,7 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
meshMorphAnim->mKeys[j].mNumValuesAndWeights = numValuesAndWeights;
meshMorphAnim->mKeys[j].mValues = new unsigned int[numValuesAndWeights];
meshMorphAnim->mKeys[j].mWeights = new double[numValuesAndWeights];
meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first);
meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first) * anim_fps;
for (unsigned int k = 0; k < numValuesAndWeights; k++) {
meshMorphAnim->mKeys[j].mValues[k] = keyData->values.at(k);
meshMorphAnim->mKeys[j].mWeights[k] = keyData->weights.at(k);
@@ -2636,8 +2637,8 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
return;
}
double start_time_fps = has_local_startstop ? CONVERT_FBX_TIME(start_time) : min_time;
double stop_time_fps = has_local_startstop ? CONVERT_FBX_TIME(stop_time) : max_time;
double start_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(start_time) * anim_fps) : min_time;
double stop_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(stop_time) * anim_fps) : max_time;
// adjust relative timing for animation
for (unsigned int c = 0; c < anim->mNumChannels; c++) {
@@ -3127,7 +3128,12 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
if (chain[i] == iterEnd)
continue;
keyframeLists[i] = GetKeyframeList((*chain[i]).second, start, stop);
if (i == TransformationComp_Rotation || i == TransformationComp_PreRotation
|| i == TransformationComp_PostRotation || i == TransformationComp_GeometricRotation) {
keyframeLists[i] = GetRotationKeyframeList((*chain[i]).second, start, stop);
} else {
keyframeLists[i] = GetKeyframeList((*chain[i]).second, start, stop);
}
for (KeyFrameListList::const_iterator it = keyframeLists[i].begin(); it != keyframeLists[i].end(); ++it) {
const KeyTimeList& times = *std::get<0>(*it);
@@ -3157,7 +3163,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
InterpolateKeys(outTranslations, keytimes, keyframeLists[TransformationComp_Translation], defTranslate, maxTime, minTime);
} else {
for (size_t i = 0; i < keyCount; ++i) {
outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outTranslations[i].mValue = defTranslate;
}
}
@@ -3166,7 +3172,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder);
} else {
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outRotations[i].mValue = defQuat;
}
}
@@ -3175,7 +3181,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
InterpolateKeys(outScales, keytimes, keyframeLists[TransformationComp_Scaling], defScale, maxTime, minTime);
} else {
for (size_t i = 0; i < keyCount; ++i) {
outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outScales[i].mValue = defScale;
}
}
@@ -3274,6 +3280,79 @@ FBXConverter::KeyFrameListList FBXConverter::GetKeyframeList(const std::vector<c
return inputs; // pray for NRVO :-)
}
FBXConverter::KeyFrameListList FBXConverter::GetRotationKeyframeList(const std::vector<const AnimationCurveNode *> &nodes,
int64_t start, int64_t stop) {
KeyFrameListList inputs;
inputs.reserve(nodes.size() * 3);
//give some breathing room for rounding errors
const int64_t adj_start = start - 10000;
const int64_t adj_stop = stop + 10000;
for (const AnimationCurveNode *node : nodes) {
ai_assert(node);
const AnimationCurveMap &curves = node->Curves();
for (const AnimationCurveMap::value_type &kv : curves) {
unsigned int mapto;
if (kv.first == "d|X") {
mapto = 0;
} else if (kv.first == "d|Y") {
mapto = 1;
} else if (kv.first == "d|Z") {
mapto = 2;
} else {
FBXImporter::LogWarn("ignoring scale animation curve, did not recognize target component");
continue;
}
const AnimationCurve *const curve = kv.second;
ai_assert(curve->GetKeys().size() == curve->GetValues().size());
ai_assert(curve->GetKeys().size());
//get values within the start/stop time window
std::shared_ptr<KeyTimeList> Keys(new KeyTimeList());
std::shared_ptr<KeyValueList> Values(new KeyValueList());
const size_t count = curve->GetKeys().size();
int64_t tp = curve->GetKeys().at(0);
float vp = curve->GetValues().at(0);
Keys->push_back(tp);
Values->push_back(vp);
if (count > 1) {
int64_t tc = curve->GetKeys().at(1);
float vc = curve->GetValues().at(1);
for (size_t n = 1; n < count; n++) {
while (std::abs(vc - vp) >= 180.0f) {
float step = std::floor(float(tc - tp) / (vc - vp) * 179.0f);
int64_t tnew = tp + int64_t(step);
float vnew = vp + (vc - vp) * step / float(tc - tp);
if (tnew >= adj_start && tnew <= adj_stop) {
Keys->push_back(tnew);
Values->push_back(vnew);
}
tp = tnew;
vp = vnew;
}
if (tc >= adj_start && tc <= adj_stop) {
Keys->push_back(tc);
Values->push_back(vc);
}
if (n + 1 < count) {
tp = tc;
vp = vc;
tc = curve->GetKeys().at(n + 1);
vc = curve->GetValues().at(n + 1);
}
}
}
inputs.push_back(std::make_tuple(Keys, Values, mapto));
}
}
return inputs;
}
KeyTimeList FBXConverter::GetKeyTimeList(const KeyFrameListList &inputs) {
ai_assert(!inputs.empty());
@@ -3364,7 +3443,7 @@ void FBXConverter::InterpolateKeys(aiVectorKey *valOut, const KeyTimeList &keys,
}
// magic value to convert fbx times to seconds
valOut->mTime = CONVERT_FBX_TIME(time);
valOut->mTime = CONVERT_FBX_TIME(time) * anim_fps;
min_time = std::min(min_time, valOut->mTime);
max_time = std::max(max_time, valOut->mTime);
@@ -3464,7 +3543,7 @@ void FBXConverter::ConvertRotationKeys(aiNodeAnim *na, const std::vector<const A
ai_assert(nodes.size());
// XXX see notes in ConvertScaleKeys()
const std::vector<KeyFrameList> &inputs = GetKeyframeList(nodes, start, stop);
const std::vector<KeyFrameList> &inputs = GetRotationKeyframeList(nodes, start, stop);
const KeyTimeList &keys = GetKeyTimeList(inputs);
na->mNumRotationKeys = static_cast<unsigned int>(keys.size());

View File

@@ -361,6 +361,7 @@ private:
// ------------------------------------------------------------------------------------------------
KeyFrameListList GetKeyframeList(const std::vector<const AnimationCurveNode*>& nodes, int64_t start, int64_t stop);
KeyFrameListList GetRotationKeyframeList(const std::vector<const AnimationCurveNode*>& nodes, int64_t start, int64_t stop);
// ------------------------------------------------------------------------------------------------
KeyTimeList GetKeyTimeList(const KeyFrameListList& inputs);

View File

@@ -473,16 +473,22 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char *szC
// ------------------------------------------------------------------------------------------------
// Generate proepr texture coords
void HMPImporter::GenerateTextureCoords(
const unsigned int width, const unsigned int height) {
void HMPImporter::GenerateTextureCoords(const unsigned int width, const unsigned int height) {
ai_assert(nullptr != pScene->mMeshes);
ai_assert(nullptr != pScene->mMeshes[0]);
ai_assert(nullptr != pScene->mMeshes[0]->mTextureCoords[0]);
aiVector3D *uv = pScene->mMeshes[0]->mTextureCoords[0];
const float fY = (1.0f / height) + (1.0f / height) / (height - 1);
const float fX = (1.0f / width) + (1.0f / width) / (width - 1);
if (uv == nullptr) {
return;
}
if (height == 0.0f || width == 0.0) {
return;
}
const float fY = (1.0f / height) + (1.0f / height) / height;
const float fX = (1.0f / width) + (1.0f / width) / width;
for (unsigned int y = 0; y < height; ++y) {
for (unsigned int x = 0; x < width; ++x, ++uv) {

View File

@@ -393,7 +393,7 @@ void LWOImporter::InternReadFile(const std::string &pFile,
// If a RGB color map is explicitly requested delete the
// alpha channel - it could theoretically be != 1.
if (_mSurfaces[i].mVCMapType == AI_LWO_RGB)
if (_mSurfaces[j].mVCMapType == AI_LWO_RGB)
pvVC[w]->a = 1.f;
pvVC[w]++;

View File

@@ -537,6 +537,11 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// get file format version and print to log
++it;
if ((*it).tokens[0].empty()) {
ASSIMP_LOG_ERROR("Invalid LWS file detectedm abort import.");
return;
}
unsigned int version = strtoul10((*it).tokens[0].c_str());
ASSIMP_LOG_INFO("LWS file format version is ", (*it).tokens[0]);
first = 0.;

View File

@@ -463,8 +463,12 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
ASSIMP_LOG_WARN("Found a reference to an embedded DDS texture, "
"but texture height is not equal to 1, which is not supported by MED");
}
pcNew.reset(new aiTexture());
if (iWidth == 0) {
ASSIMP_LOG_ERROR("Found a reference to an embedded DDS texture, but texture width is zero, aborting import.");
return;
}
pcNew.reset(new aiTexture);
pcNew->mHeight = 0;
pcNew->mWidth = iWidth;

View File

@@ -133,6 +133,10 @@ struct Material {
aiString textureSpecularity;
aiString textureOpacity;
aiString textureDisp;
aiString textureRoughness;
aiString textureMetallic;
aiString textureSheen;
aiString textureRMA;
enum TextureType {
TextureDiffuseType = 0,
@@ -151,6 +155,10 @@ struct Material {
TextureSpecularityType,
TextureOpacityType,
TextureDispType,
TextureRoughnessType,
TextureMetallicType,
TextureSheenType,
TextureRMAType,
TextureTypeCount
};
bool clamp[TextureTypeCount];
@@ -174,6 +182,19 @@ struct Material {
//! Transparency color
aiColor3D transparent;
//! PBR Roughness
ai_real roughness;
//! PBR Metallic
ai_real metallic;
//! PBR Metallic
aiColor3D sheen;
//! PBR Clearcoat Thickness
ai_real clearcoat_thickness;
//! PBR Clearcoat Rougness
ai_real clearcoat_roughness;
//! PBR Anisotropy
ai_real anisotropy;
//! Constructor
Material() :
diffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)),
@@ -181,7 +202,13 @@ struct Material {
shineness(ai_real(0.0)),
illumination_model(1),
ior(ai_real(1.0)),
transparent(ai_real(1.0), ai_real(1.0), ai_real(1.0)) {
transparent(ai_real(1.0), ai_real(1.0), ai_real(1.0)),
roughness(ai_real(1.0)),
metallic(ai_real(0.0)),
sheen(ai_real(1.0), ai_real(1.0), ai_real(1.0)),
clearcoat_thickness(ai_real(0.0)),
clearcoat_roughness(ai_real(0.0)),
anisotropy(ai_real(0.0)) {
std::fill_n(clamp, static_cast<unsigned int>(TextureTypeCount), false);
}

View File

@@ -618,6 +618,12 @@ void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pSc
mat->AddProperty(&pCurrentMaterial->shineness, 1, AI_MATKEY_SHININESS);
mat->AddProperty(&pCurrentMaterial->alpha, 1, AI_MATKEY_OPACITY);
mat->AddProperty(&pCurrentMaterial->transparent, 1, AI_MATKEY_COLOR_TRANSPARENT);
mat->AddProperty(&pCurrentMaterial->roughness, 1, AI_MATKEY_ROUGHNESS_FACTOR);
mat->AddProperty(&pCurrentMaterial->metallic, 1, AI_MATKEY_METALLIC_FACTOR);
mat->AddProperty(&pCurrentMaterial->sheen, 1, AI_MATKEY_SHEEN_COLOR_FACTOR);
mat->AddProperty(&pCurrentMaterial->clearcoat_thickness, 1, AI_MATKEY_CLEARCOAT_FACTOR);
mat->AddProperty(&pCurrentMaterial->clearcoat_roughness, 1, AI_MATKEY_CLEARCOAT_ROUGHNESS_FACTOR);
mat->AddProperty(&pCurrentMaterial->anisotropy, 1, AI_MATKEY_ANISOTROPY_FACTOR);
// Adding refraction index
mat->AddProperty(&pCurrentMaterial->ior, 1, AI_MATKEY_REFRACTI);
@@ -709,6 +715,39 @@ void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pSc
}
}
if (0 != pCurrentMaterial->textureRoughness.length) {
mat->AddProperty(&pCurrentMaterial->textureRoughness, _AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE_ROUGHNESS, 0);
mat->AddProperty(&uvwIndex, 1, _AI_MATKEY_UVWSRC_BASE, aiTextureType_DIFFUSE_ROUGHNESS, 0 );
if (pCurrentMaterial->clamp[ObjFile::Material::TextureRoughnessType]) {
addTextureMappingModeProperty(mat, aiTextureType_DIFFUSE_ROUGHNESS);
}
}
if (0 != pCurrentMaterial->textureMetallic.length) {
mat->AddProperty(&pCurrentMaterial->textureMetallic, _AI_MATKEY_TEXTURE_BASE, aiTextureType_METALNESS, 0);
mat->AddProperty(&uvwIndex, 1, _AI_MATKEY_UVWSRC_BASE, aiTextureType_METALNESS, 0 );
if (pCurrentMaterial->clamp[ObjFile::Material::TextureMetallicType]) {
addTextureMappingModeProperty(mat, aiTextureType_METALNESS);
}
}
if (0 != pCurrentMaterial->textureSheen.length) {
mat->AddProperty(&pCurrentMaterial->textureSheen, _AI_MATKEY_TEXTURE_BASE, aiTextureType_SHEEN, 0);
mat->AddProperty(&uvwIndex, 1, _AI_MATKEY_UVWSRC_BASE, aiTextureType_SHEEN, 0 );
if (pCurrentMaterial->clamp[ObjFile::Material::TextureSheenType]) {
addTextureMappingModeProperty(mat, aiTextureType_SHEEN);
}
}
if (0 != pCurrentMaterial->textureRMA.length) {
// NOTE: glTF importer places Rough/Metal/AO texture in Unknown so doing the same here for consistency.
mat->AddProperty(&pCurrentMaterial->textureRMA, _AI_MATKEY_TEXTURE_BASE, aiTextureType_UNKNOWN, 0);
mat->AddProperty(&uvwIndex, 1, _AI_MATKEY_UVWSRC_BASE, aiTextureType_UNKNOWN, 0 );
if (pCurrentMaterial->clamp[ObjFile::Material::TextureRMAType]) {
addTextureMappingModeProperty(mat, aiTextureType_UNKNOWN);
}
}
// Store material property info in material array in scene
pScene->mMaterials[pScene->mNumMaterials] = mat;
pScene->mNumMaterials++;

View File

@@ -67,6 +67,10 @@ static const std::string ReflectionTexture = "refl";
static const std::string DisplacementTexture1 = "map_disp";
static const std::string DisplacementTexture2 = "disp";
static const std::string SpecularityTexture = "map_ns";
static const std::string RoughnessTexture = "map_Pr";
static const std::string MetallicTexture = "map_Pm";
static const std::string SheenTexture = "map_Ps";
static const std::string RMATexture = "map_Ps";
// texture option specific token
static const std::string BlendUOption = "-blendu";
@@ -178,10 +182,45 @@ void ObjFileMtlImporter::load() {
case 'e': // New material
createMaterial();
break;
case 'o': // Norm texture
--m_DataIt;
getTexture();
break;
}
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break;
case 'P':
{
++m_DataIt;
switch(*m_DataIt)
{
case 'r':
++m_DataIt;
getFloatValue(m_pModel->m_pCurrentMaterial->roughness);
break;
case 'm':
++m_DataIt;
getFloatValue(m_pModel->m_pCurrentMaterial->metallic);
break;
case 's':
++m_DataIt;
getColorRGBA(&m_pModel->m_pCurrentMaterial->sheen);
break;
case 'c':
++m_DataIt;
if (*m_DataIt == 'r') {
++m_DataIt;
getFloatValue(m_pModel->m_pCurrentMaterial->clearcoat_roughness);
} else {
getFloatValue(m_pModel->m_pCurrentMaterial->clearcoat_thickness);
}
break;
}
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
}
break;
case 'm': // Texture
case 'b': // quick'n'dirty - for 'bump' sections
case 'r': // quick'n'dirty - for 'refl' sections
@@ -197,6 +236,12 @@ void ObjFileMtlImporter::load() {
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break;
case 'a': // Anisotropy
{
getFloatValue(m_pModel->m_pCurrentMaterial->anisotropy);
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break;
default: {
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break;
@@ -334,6 +379,22 @@ void ObjFileMtlImporter::getTexture() {
// Specularity scaling (glossiness)
out = &m_pModel->m_pCurrentMaterial->textureSpecularity;
clampIndex = ObjFile::Material::TextureSpecularityType;
} else if ( !ASSIMP_strincmp( pPtr, RoughnessTexture.c_str(), static_cast<unsigned int>(RoughnessTexture.size()))) {
// PBR Roughness texture
out = & m_pModel->m_pCurrentMaterial->textureRoughness;
clampIndex = ObjFile::Material::TextureRoughnessType;
} else if ( !ASSIMP_strincmp( pPtr, MetallicTexture.c_str(), static_cast<unsigned int>(MetallicTexture.size()))) {
// PBR Metallic texture
out = & m_pModel->m_pCurrentMaterial->textureMetallic;
clampIndex = ObjFile::Material::TextureMetallicType;
} else if (!ASSIMP_strincmp( pPtr, SheenTexture.c_str(), static_cast<unsigned int>(SheenTexture.size()))) {
// PBR Sheen (reflectance) texture
out = & m_pModel->m_pCurrentMaterial->textureSheen;
clampIndex = ObjFile::Material::TextureSheenType;
} else if (!ASSIMP_strincmp( pPtr, RMATexture.c_str(), static_cast<unsigned int>(RMATexture.size()))) {
// PBR Rough/Metal/AO texture
out = & m_pModel->m_pCurrentMaterial->textureRMA;
clampIndex = ObjFile::Material::TextureRMAType;
} else {
ASSIMP_LOG_ERROR("OBJ/MTL: Encountered unknown texture type");
return;

View File

@@ -235,10 +235,8 @@ void X3DImporter::ParseFile(const std::string &file, IOSystem *pIOHandler) {
bool X3DImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool checkSig) const {
if (checkSig) {
std::string::size_type pos = pFile.find_last_of(".x3d");
if (pos != std::string::npos) {
if (GetExtension(pFile) == "x3d")
return true;
}
}
return false;
@@ -482,6 +480,6 @@ void X3DImporter::ParseHelper_Node_Exit() {
}
}
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
} // namespace Assimp
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER

View File

@@ -879,7 +879,7 @@ void X3DImporter::readSphere(XmlNode &node) {
X3DNodeElementBase *ne(nullptr);
MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
XmlParser::getFloatAttribute(node, "radius", radius);
XmlParser::getRealAttribute(node, "radius", radius);
XmlParser::getBoolAttribute(node, "solid", solid);
// if "USE" defined then find already defined element.

View File

@@ -72,7 +72,7 @@ void X3DImporter::startReadGroup(XmlNode &node) {
// if "USE" defined then find already defined element.
if (!use.empty()) {
X3DNodeElementBase *ne = nullptr;
X3DNodeElementBase *ne(nullptr);
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
} else {
ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children.
@@ -110,7 +110,7 @@ void X3DImporter::startReadStaticGroup(XmlNode &node) {
// if "USE" defined then find already defined element.
if (!use.empty()) {
X3DNodeElementBase *ne = nullptr;
X3DNodeElementBase *ne(nullptr);
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
} else {
@@ -153,7 +153,7 @@ void X3DImporter::startReadSwitch(XmlNode &node) {
// if "USE" defined then find already defined element.
if (!use.empty()) {
X3DNodeElementBase *ne=nullptr;
X3DNodeElementBase *ne(nullptr);
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
} else {
@@ -226,8 +226,13 @@ void X3DImporter::startReadTransform(XmlNode &node) {
// if "USE" defined then find already defined element.
if (!use.empty()) {
X3DNodeElementBase *ne(nullptr);
bool newgroup = (nullptr == mNodeElementCur);
if(newgroup)
ParseHelper_Group_Begin();
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
if (newgroup && isNodeEmpty(node)) {
ParseHelper_Node_Exit();
}
} else {
ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children.
// at this place new group mode created and made current, so we can name it.

View File

@@ -60,14 +60,12 @@ namespace Assimp {
/// \param [in] pType - type of element to find.
/// \param [out] pNE - pointer to found node element.
inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, std::string pDEF, std::string pUSE, X3DElemType pType, X3DNodeElementBase *pNE) {
if (nullptr == mNodeElementCur) {
printf("here\n");
}
checkNodeMustBeEmpty(node);
if (!pDEF.empty())
Assimp::Throw_DEF_And_USE(node.name());
if (!FindNodeElement(pUSE, pType, &pNE))
Assimp::Throw_USE_NotFound(node.name(), pUSE);
ai_assert(nullptr != mNodeElementCur);
mNodeElementCur->Children.push_back(pNE); /* add found object as child to current element */
return pNE;

View File

@@ -300,7 +300,7 @@ public:
inline unsigned int GetIndex() const { return index; }
operator bool() const { return vector != 0; }
operator bool() const { return vector != nullptr && index < vector->size(); }
T *operator->() { return (*vector)[index]; }

View File

@@ -113,6 +113,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// clang-format on
#include <assimp/StringUtils.h>
#include <assimp/material.h>
#include <assimp/GltfMaterial.h>
#include "AssetLib/glTF/glTFCommon.h"
@@ -140,7 +142,6 @@ using glTFCommon::vec4;
//! Magic number for GLB files
#define AI_GLB_MAGIC_NUMBER "glTF"
#include <assimp/pbrmaterial.h>
#ifdef ASSIMP_API
#include <assimp/Compiler/pushpack1.h>

View File

@@ -600,6 +600,10 @@ inline void Buffer::Read(Value &obj, Asset &r) {
inline bool Buffer::LoadFromStream(IOStream &stream, size_t length, size_t baseOffset) {
byteLength = length ? length : stream.FileSize();
if (byteLength > stream.FileSize()) {
throw DeadlyImportError("GLTF: Invalid byteLength exceeds size of actual data.");
}
if (baseOffset) {
stream.Seek(baseOffset, aiOrigin_SET);
}
@@ -809,6 +813,11 @@ inline void Accessor::Sparse::PatchData(unsigned int elementSize) {
}
offset *= elementSize;
if (offset + elementSize > data.size()) {
throw DeadlyImportError("Invalid sparse accessor. Byte offset for patching points outside allocated memory.");
}
std::memcpy(data.data() + offset, pValues, elementSize);
pValues += elementSize;
@@ -863,6 +872,9 @@ inline void Accessor::Read(Value &obj, Asset &r) {
//indices componentType
sparse->indicesType = MemberOrDefault(*indicesValue, "componentType", ComponentType_BYTE);
//sparse->indices->Read(*indicesValue, r);
} else {
// indicesType
sparse->indicesType = MemberOrDefault(*sparseValue, "componentType", ComponentType_UNSIGNED_SHORT);
}
// value
@@ -875,8 +887,6 @@ inline void Accessor::Read(Value &obj, Asset &r) {
//sparse->values->Read(*valuesValue, r);
}
// indicesType
sparse->indicesType = MemberOrDefault(*sparseValue, "componentType", ComponentType_UNSIGNED_SHORT);
const unsigned int elementSize = GetElementSize();
const size_t dataSize = count * elementSize;

View File

@@ -1410,7 +1410,7 @@ void glTF2Exporter::ExportMetadata() {
}
}
inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<float> &times) {
inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<ai_real> &times) {
return ExportData(asset, animId, buffer, (unsigned int)times.size(), &times[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
}

View File

@@ -66,7 +66,9 @@ class Ref;
}
namespace glTF2 {
class Asset;
struct TexProperty;
struct TextureInfo;
struct NormalTextureInfo;
@@ -84,6 +86,7 @@ struct MaterialIOR;
typedef float(vec2)[2];
typedef float(vec3)[3];
typedef float(vec4)[4];
} // namespace glTF2
namespace Assimp {

View File

@@ -299,6 +299,7 @@ static aiMaterial *ImportMaterial(std::vector<int> &embeddedTexIdxs, Asset &r, M
// glTFv2 is either PBR or Unlit
aiShadingMode shadingMode = aiShadingMode_PBR_BRDF;
if (mat.unlit) {
aimat->AddProperty(&mat.unlit, 1, "$mat.gltf.unlit", 0, 0); // TODO: Remove this property, it is kept for backwards compatibility with assimp 5.0.1
shadingMode = aiShadingMode_Unlit;
}

View File

@@ -79,6 +79,7 @@ SET( PUBLIC_HEADERS
${HEADER_PATH}/matrix4x4.inl
${HEADER_PATH}/mesh.h
${HEADER_PATH}/pbrmaterial.h
${HEADER_PATH}/GltfMaterial.h
${HEADER_PATH}/postprocess.h
${HEADER_PATH}/quaternion.h
${HEADER_PATH}/quaternion.inl
@@ -556,7 +557,7 @@ ADD_ASSIMP_IMPORTER( IFC
if (ASSIMP_BUILD_IFC_IMPORTER)
if (MSVC)
set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "/bigobj")
elseif(CMAKE_COMPILER_IS_MINGW)
elseif(MINGW)
set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "-O2 -Wa,-mbig-obj")
endif()
endif ()
@@ -861,7 +862,7 @@ ADD_ASSIMP_IMPORTER( MMD
# optimizations that take up extra space. Given that the issue is a string table overflowing, -Os seemed appropriate
# Also, I'm not positive if both link & compile flags are needed, but this hopefully ensures that the issue should not
# recur for edge cases such as static builds.
if ((CMAKE_COMPILER_IS_MINGW) AND (CMAKE_BUILD_TYPE MATCHES Debug))
if ((MINGW) AND (CMAKE_BUILD_TYPE MATCHES Debug))
message("-- Applying MinGW StepFileGen1.cpp Debug Workaround")
SET_SOURCE_FILES_PROPERTIES(Importer/StepFile/StepFileGen1.cpp PROPERTIES COMPILE_FLAGS -Os )
SET_SOURCE_FILES_PROPERTIES(Importer/StepFile/StepFileGen1.cpp PROPERTIES LINK_FLAGS -Os )
@@ -953,24 +954,27 @@ ELSE()
ENDIF()
# zip (https://github.com/kuba--/zip)
IF(ASSIMP_HUNTER_ENABLED)
hunter_add_package(zip)
find_package(zip CONFIG REQUIRED)
ELSE()
SET( ziplib_SRCS
../contrib/zip/src/miniz.h
../contrib/zip/src/zip.c
../contrib/zip/src/zip.h
)
separate_arguments(ASSIMP_EXPORTERS_LIST UNIX_COMMAND ${ASSIMP_EXPORTERS_ENABLED})
IF(3MF IN_LIST ASSIMP_EXPORTERS_LIST)
IF(ASSIMP_HUNTER_ENABLED)
hunter_add_package(zip)
find_package(zip CONFIG REQUIRED)
ELSE()
SET( ziplib_SRCS
../contrib/zip/src/miniz.h
../contrib/zip/src/zip.c
../contrib/zip/src/zip.h
)
# TODO if cmake required version has been updated to >3.12.0, collapse this to the second case only
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
add_definitions(-DMINIZ_USE_UNALIGNED_LOADS_AND_STORES=0)
else()
add_compile_definitions(MINIZ_USE_UNALIGNED_LOADS_AND_STORES=0)
endif()
# TODO if cmake required version has been updated to >3.12.0, collapse this to the second case only
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
add_definitions(-DMINIZ_USE_UNALIGNED_LOADS_AND_STORES=0)
else()
add_compile_definitions(MINIZ_USE_UNALIGNED_LOADS_AND_STORES=0)
endif()
SOURCE_GROUP( ziplib FILES ${ziplib_SRCS} )
SOURCE_GROUP( ziplib FILES ${ziplib_SRCS} )
ENDIF()
ENDIF()
# openddlparser
@@ -1168,7 +1172,7 @@ ELSE()
ENDIF()
# adds C_FLAGS required to compile zip.c on old GCC 4.x compiler
TARGET_COMPILE_FEATURES(assimp PUBLIC c_std_99)
TARGET_COMPILE_FEATURES(assimp PRIVATE c_std_99)
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
@@ -1186,10 +1190,12 @@ IF(ASSIMP_HUNTER_ENABLED)
ZLIB::zlib
RapidJSON::rapidjson
utf8cpp
zip::zip
pugixml
stb::stb
)
if(TARGET zip::zip)
target_link_libraries(assimp PUBLIC zip::zip)
endif()
if (ASSIMP_BUILD_DRACO)
target_link_libraries(assimp PUBLIC ${draco_LIBRARIES})
@@ -1256,6 +1262,12 @@ SET_TARGET_PROPERTIES( assimp PROPERTIES
OUTPUT_NAME assimp${LIBRARY_SUFFIX}
)
if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND BUILD_SHARED_LIBS)
set_target_properties(assimp PROPERTIES
SUFFIX "-${ASSIMP_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}"
)
endif()
if (APPLE)
if (ASSIMP_BUILD_FRAMEWORK)
SET_TARGET_PROPERTIES( assimp PROPERTIES

View File

@@ -65,6 +65,7 @@ using namespace Assimp;
// Constructor to be privately used by Importer
BaseImporter::BaseImporter() AI_NO_EXCEPT
: m_progress() {
// empty
}
// ------------------------------------------------------------------------------------------------
@@ -372,7 +373,10 @@ void BaseImporter::ConvertToUTF8(std::vector<char> &data) {
// UTF 16 BE with BOM
if (*((uint16_t *)&data.front()) == 0xFFFE) {
// Check to ensure no overflow can happen
if(data.size() % 2 != 0) {
return;
}
// swap the endianness ..
for (uint16_t *p = (uint16_t *)&data.front(), *end = (uint16_t *)&data.back(); p <= end; ++p) {
ByteSwap::Swap2(p);

View File

@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -48,18 +47,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/ProgressHandler.hpp>
namespace Assimp {
namespace Assimp {
// ------------------------------------------------------------------------------------
/** @brief Internal default implementation of the #ProgressHandler interface. */
/**
* @brief Internal default implementation of the #ProgressHandler interface.
*/
class DefaultProgressHandler : public ProgressHandler {
virtual bool Update(float /*percentage*/) {
public:
/// @brief Ignores the update callback.
bool Update(float) override {
return false;
}
};
}; // !class DefaultProgressHandler
} // Namespace Assimp
#endif
#endif // INCLUDED_AI_DEFAULTPROGRESSHANDLER_H

View File

@@ -329,7 +329,7 @@ bool Importer::IsDefaultIOHandler() const {
// ------------------------------------------------------------------------------------------------
// Supplies a custom progress handler to get regular callbacks during importing
void Importer::SetProgressHandler ( ProgressHandler* pHandler ) {
void Importer::SetProgressHandler(ProgressHandler* pHandler) {
ai_assert(nullptr != pimpl);
ASSIMP_BEGIN_EXCEPTION_REGION();

View File

@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -42,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @file PolyTools.h, various utilities for our dealings with arbitrary polygons */
#pragma once
#ifndef AI_POLYTOOLS_H_INCLUDED
#define AI_POLYTOOLS_H_INCLUDED
@@ -55,8 +55,7 @@ namespace Assimp {
* The function accepts an unconstrained template parameter for use with
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
template <typename T>
inline double GetArea2D(const T& v1, const T& v2, const T& v3)
{
inline double GetArea2D(const T& v1, const T& v2, const T& v3) {
return 0.5 * (v1.x * ((double)v3.y - v2.y) + v2.x * ((double)v1.y - v3.y) + v3.x * ((double)v2.y - v1.y));
}
@@ -65,8 +64,7 @@ inline double GetArea2D(const T& v1, const T& v2, const T& v3)
* The function accepts an unconstrained template parameter for use with
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
template <typename T>
inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2)
{
inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2) {
return GetArea2D(p0,p2,p1) > 0;
}
@@ -75,20 +73,23 @@ inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2)
* The function accepts an unconstrained template parameter for use with
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
template <typename T>
inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp)
{
inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp) {
// Point in triangle test using baryzentric coordinates
const aiVector2D v0 = p1 - p0;
const aiVector2D v1 = p2 - p0;
const aiVector2D v2 = pp - p0;
double dot00 = v0 * v0;
double dot01 = v0 * v1;
double dot02 = v0 * v2;
double dot11 = v1 * v1;
double dot12 = v1 * v2;
const double invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
const double dot01 = v0 * v1;
const double dot02 = v0 * v2;
const double dot12 = v1 * v2;
const double denom = dot00 * dot11 - dot01 * dot01;
if (denom == 0.0) {
return false;
}
const double invDenom = 1.0 / denom;
dot11 = (dot11 * dot02 - dot01 * dot12) * invDenom;
dot00 = (dot00 * dot12 - dot01 * dot02) * invDenom;
@@ -133,8 +134,7 @@ inline bool IsCCW(T* in, size_t npoints) {
// in[i+2].x, in[i+2].y)) {
convex_turn = AI_MATH_PI_F - theta;
convex_sum += convex_turn;
}
else {
} else {
convex_sum -= AI_MATH_PI_F - theta;
}
}
@@ -161,15 +161,13 @@ inline bool IsCCW(T* in, size_t npoints) {
if (OnLeftSideOfLine2D(in[npoints-2],in[1],in[0])) {
convex_turn = AI_MATH_PI_F - theta;
convex_sum += convex_turn;
}
else {
} else {
convex_sum -= AI_MATH_PI_F - theta;
}
return convex_sum >= (2 * AI_MATH_PI_F);
}
// -------------------------------------------------------------------------------
/** Compute the normal of an arbitrary polygon in R3.
*
@@ -186,8 +184,7 @@ inline bool IsCCW(T* in, size_t npoints) {
* this method is much faster than the 'other' NewellNormal()
*/
template <int ofs_x, int ofs_y, int ofs_z, typename TReal>
inline void NewellNormal (aiVector3t<TReal>& out, int num, TReal* x, TReal* y, TReal* z)
{
inline void NewellNormal (aiVector3t<TReal>& out, int num, TReal* x, TReal* y, TReal* z) {
// Duplicate the first two vertices at the end
x[(num+0)*ofs_x] = x[0];
x[(num+1)*ofs_x] = x[ofs_x];
@@ -224,6 +221,6 @@ inline void NewellNormal (aiVector3t<TReal>& out, int num, TReal* x, TReal* y, T
out = aiVector3t<TReal>(sum_yz,sum_zx,sum_xy);
}
} // ! Assimp
} // ! namespace Assimp
#endif
#endif // AI_POLYTOOLS_H_INCLUDED

View File

@@ -1101,6 +1101,14 @@ void SceneCombiner::Copy(aiMesh **_dest, const aiMesh *src) {
// make a deep copy of all blend shapes
CopyPtrArray(dest->mAnimMeshes, dest->mAnimMeshes, dest->mNumAnimMeshes);
// make a deep copy of all texture coordinate names
if (src->mTextureCoordsNames != nullptr) {
dest->mTextureCoordsNames = new aiString *[AI_MAX_NUMBER_OF_TEXTURECOORDS] {};
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
Copy(&dest->mTextureCoordsNames[i], src->mTextureCoordsNames[i]);
}
}
}
// ------------------------------------------------------------------------------------------------
@@ -1348,6 +1356,18 @@ void SceneCombiner::Copy(aiMetadata **_dest, const aiMetadata *src) {
}
}
// ------------------------------------------------------------------------------------------------
void SceneCombiner::Copy(aiString **_dest, const aiString *src) {
if (nullptr == _dest || nullptr == src) {
return;
}
aiString *dest = *_dest = new aiString();
// get a flat copy
*dest = *src;
}
#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0)
#pragma GCC diagnostic pop
#endif

View File

@@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/ParsingUtils.h>
#include "ProcessHelper.h"
#include "Material/MaterialSystem.h"
#include <assimp/Exceptional.h>
#include <stdio.h>
using namespace Assimp;
@@ -171,6 +172,8 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
}
// If the new material count differs from the original,
// we need to rebuild the material list and remap mesh material indexes.
if(iNewNum < 1)
throw DeadlyImportError("No materials remaining");
if (iNewNum != pScene->mNumMaterials) {
ai_assert(iNewNum > 0);
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];

View File

@@ -1616,6 +1616,7 @@ endif()
if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 )
# it is a bad hack after all
# CMake generates Ninja makefiles with UNIX paths only if it thinks that we are going to build with MinGW
set( MINGW TRUE ) # tell CMake that we are MinGW
set( CMAKE_COMPILER_IS_MINGW TRUE ) # tell CMake that we are MinGW
set( CMAKE_CROSSCOMPILING TRUE ) # stop recursion
enable_language( C )

View File

@@ -1,6 +0,0 @@
IrrXML
Downloaded September 2008
- fixed a minor compiler warning (vs 2005, shift too large)
- fixed an issue regarding wchar_t/unsigned short

View File

@@ -0,0 +1,74 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2021, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file GltfMaterial.h
* @brief glTF-specific material macros
* These will be made generic at some future date
*/
#ifndef AI_GLTFMATERIAL_H_INC
#define AI_GLTFMATERIAL_H_INC
#ifdef __GNUC__
# pragma GCC system_header
#endif
#include <assimp/material.h>
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 0
#define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0
#define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0
#define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname"
#define _AI_MATKEY_GLTF_MAPPINGID_BASE "$tex.mappingid"
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE "$tex.mappingfiltermag"
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE "$tex.mappingfiltermin"
#define _AI_MATKEY_GLTF_SCALE_BASE "$tex.scale"
#define _AI_MATKEY_GLTF_STRENGTH_BASE "$tex.strength"
#define AI_MATKEY_GLTF_MAPPINGNAME(type, N) _AI_MATKEY_GLTF_MAPPINGNAME_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGID(type, N) _AI_MATKEY_GLTF_MAPPINGID_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGFILTER_MAG(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGFILTER_MIN(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE, type, N
#define AI_MATKEY_GLTF_TEXTURE_SCALE(type, N) _AI_MATKEY_GLTF_SCALE_BASE, type, N
#define AI_MATKEY_GLTF_TEXTURE_STRENGTH(type, N) _AI_MATKEY_GLTF_STRENGTH_BASE, type, N
#endif

View File

@@ -74,6 +74,7 @@ protected:
public:
/// @brief Virtual destructor.
virtual ~ProgressHandler () {
// empty
}
// -------------------------------------------------------------------

View File

@@ -361,6 +361,7 @@ public:
static void Copy(aiNodeAnim **dest, const aiNodeAnim *src);
static void Copy(aiMeshMorphAnim **dest, const aiMeshMorphAnim *src);
static void Copy(aiMetadata **dest, const aiMetadata *src);
static void Copy(aiString **dest, const aiString *src);
// recursive, of course
static void Copy(aiNode **dest, const aiNode *src);

View File

@@ -6,7 +6,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -102,7 +101,7 @@ protected:
/** Creates a dummy material and returns it. */
aiMaterial *CreateMaterial();
protected:
private:
/** space to assemble the mesh data: points */
std::vector<aiVector3D> mVertices;

View File

@@ -135,7 +135,9 @@ public:
/** Extract a particular vertex from a anim mesh and interleave all components */
explicit Vertex(const aiAnimMesh* msh, unsigned int idx) {
ai_assert(idx < msh->mNumVertices);
position = msh->mVertices[idx];
if (msh->HasPositions()) {
position = msh->mVertices[idx];
}
if (msh->HasNormals()) {
normal = msh->mNormals[idx];

View File

@@ -42,8 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef INCLUDED_AI_IRRXML_WRAPPER
#define INCLUDED_AI_IRRXML_WRAPPER
#include <assimp/DefaultLogger.hpp>
#include <assimp/ai_assert.h>
#include <assimp/DefaultLogger.hpp>
#include "BaseImporter.h"
#include "IOStream.hpp"
@@ -112,7 +112,7 @@ public:
/// @brief Will clear the parsed xml-file.
void clear() {
if(mData.empty()) {
if (mData.empty()) {
mDoc = nullptr;
return;
}
@@ -243,7 +243,7 @@ public:
/// @param name [in] The attribute name to look for.
/// @param val [out] The int value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is an int.
static inline bool getIntAttribute(XmlNode &xmlNode, const char *name, int &val ) {
static inline bool getIntAttribute(XmlNode &xmlNode, const char *name, int &val) {
pugi::xml_attribute attr = xmlNode.attribute(name);
if (attr.empty()) {
return false;
@@ -258,7 +258,7 @@ public:
/// @param name [in] The attribute name to look for.
/// @param val [out] The real value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is a real.
static inline bool getRealAttribute( XmlNode &xmlNode, const char *name, ai_real &val ) {
static inline bool getRealAttribute(XmlNode &xmlNode, const char *name, ai_real &val) {
pugi::xml_attribute attr = xmlNode.attribute(name);
if (attr.empty()) {
return false;
@@ -284,7 +284,6 @@ public:
val = attr.as_float();
return true;
}
/// @brief Will try to get a double attribute value.
@@ -322,7 +321,7 @@ public:
/// @param name [in] The attribute name to look for.
/// @param val [out] The bool value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is a bool.
static inline bool getBoolAttribute( XmlNode &xmlNode, const char *name, bool &val ) {
static inline bool getBoolAttribute(XmlNode &xmlNode, const char *name, bool &val) {
pugi::xml_attribute attr = xmlNode.attribute(name);
if (attr.empty()) {
return false;
@@ -330,14 +329,13 @@ public:
val = attr.as_bool();
return true;
}
/// @brief Will try to get the value of the node as a string.
/// @param node [in] The node to search in.
/// @param text [out] The value as a text.
/// @return true, if the value can be read out.
static inline bool getValueAsString( XmlNode &node, std::string &text ) {
static inline bool getValueAsString(XmlNode &node, std::string &text) {
text = std::string();
if (node.empty()) {
return false;
@@ -352,7 +350,7 @@ public:
/// @param node [in] The node to search in.
/// @param text [out] The value as a float.
/// @return true, if the value can be read out.
static inline bool getValueAsFloat( XmlNode &node, ai_real &v ) {
static inline bool getValueAsFloat(XmlNode &node, ai_real &v) {
if (node.empty()) {
return false;
}
@@ -360,10 +358,38 @@ public:
v = node.text().as_float();
return true;
}
private:
/// @brief Will try to get the value of the node as an integer.
/// @param node [in] The node to search in.
/// @param text [out] The value as a int.
/// @return true, if the value can be read out.
static inline bool getValueAsInt(XmlNode &node, int &v) {
if (node.empty()) {
return false;
}
v = node.text().as_int();
return true;
}
/// @brief Will try to get the value of the node as an bool.
/// @param node [in] The node to search in.
/// @param text [out] The value as a bool.
/// @return true, if the value can be read out.
static inline bool getValueAsBool(XmlNode& node, bool& v)
{
if (node.empty()) {
return false;
}
v = node.text().as_bool();
return true;
}
private:
pugi::xml_document *mDoc;
TNodeType mCurrent;
std::vector<char> mData;
@@ -376,8 +402,8 @@ class XmlNodeIterator {
public:
/// @brief The iteration mode.
enum IterationMode {
PreOrderMode, ///< Pre-ordering, get the values, continue the iteration.
PostOrderMode ///< Post-ordering, continue the iteration, get the values.
PreOrderMode, ///< Pre-ordering, get the values, continue the iteration.
PostOrderMode ///< Post-ordering, continue the iteration, get the values.
};
/// @brief The class constructor
/// @param parent [in] The xml parent to to iterate through.
@@ -400,7 +426,7 @@ public:
/// @brief Will iterate through all children in pre-order iteration.
/// @param node [in] The nod to iterate through.
void collectChildrenPreOrder( XmlNode &node ) {
void collectChildrenPreOrder(XmlNode &node) {
if (node != mParent && node.type() == pugi::node_element) {
mNodes.push_back(node);
}

View File

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,

View File

@@ -255,5 +255,4 @@ struct aiLight {
}
#endif
#endif // !! AI_LIGHT_H_INC

View File

@@ -989,6 +989,9 @@ extern "C" {
// Roughness factor. 0.0 = Perfectly Smooth, 1.0 = Completely Rough
#define AI_MATKEY_ROUGHNESS_FACTOR "$mat.roughnessFactor", 0, 0
#define AI_MATKEY_ROUGHNESS_TEXTURE aiTextureType_DIFFUSE_ROUGHNESS, 0
// Anisotropy factor. 0.0 = isotropic, 1.0 = anisotropy along tangent direction,
// -1.0 = anisotropy along bitangent direction
#define AI_MATKEY_ANISOTROPY_FACTOR "$mat.anisotropyFactor", 0, 0
// Specular/Glossiness Workflow
// ---------------------------

View File

@@ -44,21 +44,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#ifndef AI_MATERIAL_INL_INC
#define AI_MATERIAL_INL_INC
#ifdef __GNUC__
# pragma GCC system_header
#endif
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiPropertyTypeInfo ai_real_to_property_type_info(float) {
AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(float) {
return aiPTI_Float;
}
AI_FORCE_INLINE
aiPropertyTypeInfo ai_real_to_property_type_info(double) {
AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(double) {
return aiPTI_Double;
}
// ---------------------------------------------------------------------------
@@ -66,8 +62,7 @@ aiPropertyTypeInfo ai_real_to_property_type_info(double) {
//! @cond never
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::GetTexture( aiTextureType type,
AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
unsigned int index,
C_STRUCT aiString* path,
aiTextureMapping* mapping /*= NULL*/,
@@ -79,15 +74,13 @@ aiReturn aiMaterial::GetTexture( aiTextureType type,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
AI_FORCE_INLINE unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
return ::aiGetMaterialTextureCount(this,type);
}
// ---------------------------------------------------------------------------
template <typename Type>
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx, Type* pOut,
unsigned int* pMax) const {
unsigned int iNum = pMax ? *pMax : 1;
@@ -105,7 +98,7 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
return AI_FAILURE;
}
iNum = std::min((size_t)iNum,prop->mDataLength / sizeof(Type));
iNum = static_cast<unsigned int>(std::min(static_cast<size_t>(iNum),prop->mDataLength / sizeof(Type)));
::memcpy(pOut,prop->mData,iNum * sizeof(Type));
if (pMax) {
*pMax = iNum;
@@ -116,8 +109,7 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
// ---------------------------------------------------------------------------
template <typename Type>
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,Type& pOut) const {
const aiMaterialProperty* prop;
const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx,
@@ -138,34 +130,29 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,ai_real* pOut,
unsigned int* pMax) const {
return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax);
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,int* pOut,
unsigned int* pMax) const {
return ::aiGetMaterialIntegerArray(this,pKey,type,idx,pOut,pMax);
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,ai_real& pOut) const {
return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,int& pOut) const {
return aiGetMaterialInteger(this,pKey,type,idx,&pOut);
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,aiColor4D& pOut) const {
return aiGetMaterialColor(this,pKey,type,idx,&pOut);
}
@@ -190,14 +177,10 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
// ---------------------------------------------------------------------------
template<class TYPE>
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
unsigned int index)
{
return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(TYPE),
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
const unsigned int pNumValues, const char* pKey, unsigned int type,
unsigned int index) {
return AddBinaryProperty((const void*)pInput, pNumValues * sizeof(TYPE),
pKey,type,index,aiPTI_Buffer);
}
@@ -213,8 +196,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const float* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const double* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const double* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -225,8 +207,7 @@ aiReturn aiMaterial::AddProperty(const double* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -237,8 +218,7 @@ aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -249,8 +229,7 @@ aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -261,8 +240,7 @@ aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -273,8 +251,7 @@ aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const int* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -293,8 +270,7 @@ aiReturn aiMaterial::AddProperty(const int* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<float>(const float* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<float>(const float* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -306,8 +282,7 @@ aiReturn aiMaterial::AddProperty<float>(const float* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<double>(const double* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<double>(const double* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -319,8 +294,7 @@ aiReturn aiMaterial::AddProperty<double>(const double* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -332,8 +306,7 @@ aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -345,8 +318,7 @@ aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -358,8 +330,7 @@ aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -371,8 +342,7 @@ aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<int>(const int* pInput,
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<int>(const int* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -383,5 +353,3 @@ aiReturn aiMaterial::AddProperty<int>(const int* pInput,
}
//! @endcond
#endif //! AI_MATERIAL_INL_INC

View File

@@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** @file pbrmaterial.h
* @brief Defines the material system of the library
* @brief Deprecated GLTF_PBR macros
*/
#pragma once
#ifndef AI_PBRMATERIAL_H_INC
@@ -48,47 +48,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef __GNUC__
# pragma GCC system_header
# warning pbrmaterial.h is deprecated. Please update to PBR materials in materials.h and glTF-specific items in GltfMaterial.h
#else if defined(_MSC_VER)
# pragma message("pbrmaterial.h is deprecated. Please update to PBR materials in materials.h and glTF-specific items in GltfMaterial.h")
#endif
//#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR "$mat.gltf.pbrMetallicRoughness.baseColorFactor", 0, 0
//#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR "$mat.gltf.pbrMetallicRoughness.metallicFactor", 0, 0
//#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR "$mat.gltf.pbrMetallicRoughness.roughnessFactor", 0, 0
//#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE aiTextureType_DIFFUSE, 1
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 0
#define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0
#define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0
#include <assimp/material.h>
#include <assimp/GltfMaterial.h>
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR AI_MATKEY_BASE_COLOR
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE AI_MATKEY_BASE_COLOR_TEXTURE
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR AI_MATKEY_METALLIC_FACTOR
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR AI_MATKEY_ROUGHNESS_FACTOR
//#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0
//#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0
//#define AI_MATKEY_GLTF_UNLIT "$mat.gltf.unlit", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_SHEEN "$mat.gltf.materialSheen", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_FACTOR "$mat.gltf.materialSheen.sheenColorFactor", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_FACTOR "$mat.gltf.materialSheen.sheenRoughnessFactor", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_TEXTURE aiTextureType_UNKNOWN, 1
//#define AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 2
//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT "$mat.gltf.materialClearcoat", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_FACTOR "$mat.gltf.materialClearcoat.clearcoatFactor", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_FACTOR "$mat.gltf.materialClearcoat.clearcoatRoughnessFactor", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_TEXTURE aiTextureType_UNKNOWN, 3
//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 4
//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE aiTextureType_NORMALS, 1
//#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION "$mat.gltf.materialTransmission", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_FACTOR "$mat.gltf.materialTransmission.transmissionFactor", 0, 0
//#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_TEXTURE aiTextureType_UNKNOWN, 5
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR AI_MATKEY_GLOSSINESS_FACTOR
//#define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord"
#define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname"
#define _AI_MATKEY_GLTF_MAPPINGID_BASE "$tex.mappingid"
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE "$tex.mappingfiltermag"
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE "$tex.mappingfiltermin"
#define _AI_MATKEY_GLTF_SCALE_BASE "$tex.scale"
#define _AI_MATKEY_GLTF_STRENGTH_BASE "$tex.strength"
// Use AI_MATKEY_SHADING_MODEL == aiShadingMode_Unlit instead
#define AI_MATKEY_GLTF_UNLIT "$mat.gltf.unlit", 0, 0
//#define AI_MATKEY_GLTF_TEXTURE_TEXCOORD(type, N) _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGNAME(type, N) _AI_MATKEY_GLTF_MAPPINGNAME_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGID(type, N) _AI_MATKEY_GLTF_MAPPINGID_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGFILTER_MAG(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGFILTER_MIN(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE, type, N
#define AI_MATKEY_GLTF_TEXTURE_SCALE(type, N) _AI_MATKEY_GLTF_SCALE_BASE, type, N
#define AI_MATKEY_GLTF_TEXTURE_STRENGTH(type, N) _AI_MATKEY_GLTF_STRENGTH_BASE, type, N
//AI_MATKEY_GLTF_MATERIAL_SHEEN
#define AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_FACTOR AI_MATKEY_SHEEN_COLOR_FACTOR
#define AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_FACTOR AI_MATKEY_SHEEN_ROUGHNESS_FACTOR
#define AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_TEXTURE AI_MATKEY_SHEEN_COLOR_TEXTURE
#define AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_TEXTURE AI_MATKEY_SHEEN_ROUGHNESS_TEXTURE
//AI_MATKEY_GLTF_MATERIAL_CLEARCOAT
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_FACTOR AI_MATKEY_CLEARCOAT_FACTOR
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_FACTOR AI_MATKEY_CLEARCOAT_ROUGHNESS_FACTOR
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_TEXTURE AI_MATKEY_CLEARCOAT_TEXTURE
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE AI_MATKEY_CLEARCOAT_ROUGHNESS_TEXTURE
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE AI_MATKEY_CLEARCOAT_NORMAL_TEXTURE
//AI_MATKEY_GLTF_MATERIAL_TRANSMISSION
#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_FACTOR AI_MATKEY_TRANSMISSION_FACTOR
#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_TEXTURE AI_MATKEY_TRANSMISSION_TEXTURE
#define AI_MATKEY_GLTF_TEXTURE_TEXCOORD(type, N) AI_MATKEY_UVWSRC(type, N)
#endif //!!AI_PBRMATERIAL_H_INC

View File

@@ -92,22 +92,19 @@ struct aiTexel {
#ifdef __cplusplus
//! Comparison operator
bool operator== (const aiTexel& other) const
{
bool operator== (const aiTexel& other) const {
return b == other.b && r == other.r &&
g == other.g && a == other.a;
}
//! Inverse comparison operator
bool operator!= (const aiTexel& other) const
{
bool operator!= (const aiTexel& other) const {
return b != other.b || r != other.r ||
g != other.g || a != other.a;
}
//! Conversion to a floating-point 4d color
operator aiColor4D() const
{
operator aiColor4D() const {
return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f);
}
#endif // __cplusplus
@@ -202,11 +199,11 @@ struct aiTexture {
}
// Construction
aiTexture() AI_NO_EXCEPT
: mWidth(0)
, mHeight(0)
, pcData(nullptr)
, mFilename() {
aiTexture() AI_NO_EXCEPT :
mWidth(0),
mHeight(0),
pcData(nullptr),
mFilename() {
memset(achFormatHint, 0, sizeof(achFormatHint));
}

View File

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,

View File

@@ -54,8 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ------------------------------------------------------------------------------------------------
/** Transformation of a vector by a 3x3 matrix */
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
aiVector3t<TReal> res;
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z;
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z;
@@ -66,8 +65,7 @@ aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector
// ------------------------------------------------------------------------------------------------
/** Transformation of a vector by a 4x4 matrix */
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
aiVector3t<TReal> res;
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4;
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4;
@@ -82,36 +80,35 @@ aiVector3t<TReal>::operator aiVector3t<TOther> () const {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
AI_FORCE_INLINE void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
x = pX;
y = pY;
z = pZ;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
TReal aiVector3t<TReal>::SquareLength() const {
AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const {
return x*x + y*y + z*z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
TReal aiVector3t<TReal>::Length() const {
AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const {
return std::sqrt( SquareLength());
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
const TReal l = Length();
if (l == 0) {
return *this;
}
*this /= Length();
return *this;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
TReal len = Length();
if ( len > static_cast< TReal >( 0 ) ) {
*this /= len;
@@ -120,8 +117,7 @@ aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
x += o.x;
y += o.y;
z += o.z;
@@ -130,8 +126,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
x -= o.x;
y -= o.y;
z -= o.z;
@@ -140,8 +135,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
x *= f;
y *= f;
z *= f;
@@ -150,8 +144,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
if ( f == static_cast<TReal>(0.0)) {
return *this;
}
@@ -164,20 +157,17 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
return (*this = mat * (*this));
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
return (*this = mat * (*this));
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
TReal aiVector3t<TReal>::operator[](unsigned int i) const {
AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const {
switch (i) {
case 0:
return x;
@@ -192,9 +182,7 @@ TReal aiVector3t<TReal>::operator[](unsigned int i) const {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
TReal& aiVector3t<TReal>::operator[](unsigned int i) {
// return *(&x + i);
AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) {
switch (i) {
case 0:
return x;
@@ -209,20 +197,17 @@ TReal& aiVector3t<TReal>::operator[](unsigned int i) {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
AI_FORCE_INLINE bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
return x == other.x && y == other.y && z == other.z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
AI_FORCE_INLINE bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
return x != other.x || y != other.y || z != other.z;
}
// ---------------------------------------------------------------------------
template<typename TReal>
AI_FORCE_INLINE
bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
return
std::abs(x - other.x) <= epsilon &&
std::abs(y - other.y) <= epsilon &&
@@ -230,77 +215,66 @@ bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) con
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
AI_FORCE_INLINE bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
}
// ------------------------------------------------------------------------------------------------
// symmetric addition
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}
// ------------------------------------------------------------------------------------------------
// symmetric subtraction
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}
// ------------------------------------------------------------------------------------------------
// scalar product
template <typename TReal>
AI_FORCE_INLINE
TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
// ------------------------------------------------------------------------------------------------
// scalar multiplication
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
AI_FORCE_INLINE aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
}
// ------------------------------------------------------------------------------------------------
// and the other way around
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
AI_FORCE_INLINE aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
}
// ------------------------------------------------------------------------------------------------
// scalar division
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
return v * (1/f);
}
// ------------------------------------------------------------------------------------------------
// vector division
template <typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>(v.x / v2.x,v.y / v2.y,v.z / v2.z);
}
// ------------------------------------------------------------------------------------------------
// cross product
template<typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x);
}
// ------------------------------------------------------------------------------------------------
// vector negation
template<typename TReal>
AI_FORCE_INLINE
aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
AI_FORCE_INLINE aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
return aiVector3t<TReal>( -v.x, -v.y, -v.z);
}

View File

@@ -2,7 +2,7 @@
[Setup]
AppName=Open Asset Import Library - SDK
AppVerName=Open Asset Import Library - SDK (v5.0.1)
AppVerName=Open Asset Import Library - SDK (v5.1.0)
DefaultDirName={pf}\Assimp
DefaultGroupName=Assimp
UninstallDisplayIcon={app}\bin\x64\assimp.exe
@@ -12,9 +12,9 @@ SetupIconFile=..\..\tools\shared\assimp_tools_icon.ico
WizardImageFile=compiler:WizModernImage-IS.BMP
WizardSmallImageFile=compiler:WizModernSmallImage-IS.BMP
LicenseFile=License.rtf
OutputBaseFileName=assimp-sdk-5.0.1-setup
VersionInfoVersion=5.0.1.0
VersionInfoTextVersion=5.0.1
OutputBaseFileName=assimp-sdk-5.1.0-setup
VersionInfoVersion=5.1.0.0
VersionInfoTextVersion=5.1.0
VersionInfoCompany=Assimp Development Team
ArchitecturesInstallIn64BitMode=x64

View File

@@ -2,7 +2,7 @@
[Setup]
AppName=Open Asset Import Library - SDK
AppVerName=Open Asset Import Library - SDK (v5.0.1)
AppVerName=Open Asset Import Library - SDK (v5.1.0)
DefaultDirName={pf}\Assimp
DefaultGroupName=Assimp
UninstallDisplayIcon={app}\bin\x86\assimp.exe
@@ -12,9 +12,9 @@ SetupIconFile=..\..\tools\shared\assimp_tools_icon.ico
WizardImageFile=compiler:WizModernImage-IS.BMP
WizardSmallImageFile=compiler:WizModernSmallImage-IS.BMP
LicenseFile=License.rtf
OutputBaseFileName=assimp-sdk-5.0.1-setup
VersionInfoVersion=5.0.1.0
VersionInfoTextVersion=5.0.1
OutputBaseFileName=assimp-sdk-5.1.0-setup
VersionInfoVersion=5.1.0.0
VersionInfoTextVersion=5.1.0
VersionInfoCompany=Assimp Development Team
;ArchitecturesInstallIn64BitMode=x64
@@ -49,11 +49,11 @@ Source: "WEB"; DestDir: "{app}"
Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs
; x86 binaries
Source: "..\..\bin\release\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x86"
Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools
Source: "..\..\bin\release\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x86"
Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools
Source: "C:\Windows\SysWOW64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools
Source: "C:\Windows\SysWOW64\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools
Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools
Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools
; Import libraries

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -1,11 +0,0 @@
All 'mirror' files are not absolutely correct. That's mainly
because it's difficult convert Max' handling of mirroring to
our's.
In other words: TO DO, but only if someone REALLY needs it.
-------------------------------------------------------------
To see how it should look like - test/ReferenceImages
Note that the viewer has no 'decal' texture mapping mode, so
the usual clamping is used.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "UnitTestPCH.h"
#include <assimp/scene.h>
#include <assimp/SceneCombiner.h>
using namespace Assimp;
@@ -88,5 +89,21 @@ TEST_F(utScene, getShortFilenameTest) {
EXPECT_NE(nullptr, name2);
}
TEST_F(utScene, deepCopyTest) {
scene->mRootNode = new aiNode();
scene->mNumMeshes = 1;
scene->mMeshes = new aiMesh *[scene->mNumMeshes] ();
scene->mMeshes[0] = new aiMesh ();
scene->mMeshes[0]->SetTextureCoordsName (0, aiString ("test"));
{
aiScene* copied = nullptr;
SceneCombiner::CopyScene(&copied,scene);
delete copied;
}
}
TEST_F(utScene, getEmbeddedTextureTest) {
}

View File

@@ -114,6 +114,12 @@ TEST(utBlenderImporter, importBlenderDefault271) {
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importBlenderDefault293) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_276.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importCubeHierarchy_248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure);

View File

@@ -125,13 +125,21 @@ TEST_F(utColladaExport, testExportLight) {
ASSERT_TRUE(pTest->HasLights());
const unsigned int origNumLights(pTest->mNumLights);
std::unique_ptr<aiLight[]> origLights(new aiLight[origNumLights]);
std::vector<std::string> origNames;
// There are FIVE!!! LIGHTS!!!
EXPECT_EQ(5, origNumLights) << "lights.dae should contain five lights";
std::vector<aiLight> origLights(5);
for (size_t i = 0; i < origNumLights; i++) {
origNames.push_back(pTest->mLights[i]->mName.C_Str());
origLights[i] = *(pTest->mLights[i]);
}
// Check loaded first light properly
EXPECT_STREQ("Lamp", origLights[0].mName.C_Str());
EXPECT_EQ(aiLightSource_POINT, origLights[0].mType);
EXPECT_FLOAT_EQ(1.0f, origLights[0].mAttenuationConstant);
EXPECT_FLOAT_EQ(0.0f, origLights[0].mAttenuationLinear);
EXPECT_FLOAT_EQ(0.00111109f, origLights[0].mAttenuationQuadratic);
// Common metadata
// Confirm was loaded by the Collada importer
aiString origImporter;
@@ -191,7 +199,7 @@ TEST_F(utColladaExport, testExportLight) {
for (size_t i = 0; i < origNumLights; i++) {
const aiLight *orig = &origLights[i];
const aiLight *read = imported->mLights[i];
EXPECT_EQ(0, strncmp(origNames[i].c_str(), read->mName.C_Str(), origNames[i].size()));
EXPECT_EQ(0, strcmp(orig->mName.C_Str(), read->mName.C_Str()));
EXPECT_EQ(orig->mType, read->mType);
EXPECT_FLOAT_EQ(orig->mAttenuationConstant, read->mAttenuationConstant);
EXPECT_FLOAT_EQ(orig->mAttenuationLinear, read->mAttenuationLinear);

View File

@@ -73,7 +73,7 @@ TEST_F(MaterialSystemTest, testFloatArrayProperty) {
pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2", 0, 0, pf, &pMax));
EXPECT_EQ(sizeof(pf) / sizeof(float), pMax);
EXPECT_EQ(sizeof(pf) / sizeof(float), static_cast<size_t>(pMax));
EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3]);
}

View File

@@ -53,7 +53,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <array>
#include <assimp/pbrmaterial.h>
#include <assimp/material.h>
#include <assimp/GltfMaterial.h>
using namespace Assimp;
class utglTF2ImportExport : public AbstractImportExportBase {

View File

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -47,6 +45,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Main.h"
#include <assimp/ProgressHandler.hpp>
#include <iostream>
class ConsoleProgressHandler : public ProgressHandler {
public:
ConsoleProgressHandler() :
ProgressHandler() {
// empty
}
~ConsoleProgressHandler() override {
// empty
}
bool Update(float percentage) override {
std::cout << percentage * 100.0f << " %\n";
return true;
}
};
const char* AICMD_MSG_ABOUT =
"------------------------------------------------------ \n"
"Open Asset Import Library (\"Assimp\", https://github.com/assimp/assimp) \n"
@@ -73,10 +90,10 @@ const char* AICMD_MSG_HELP =
"\n Use \'assimp <verb> --help\' for detailed help on a command.\n"
;
/*extern*/ Assimp::Importer* globalImporter = NULL;
/*extern*/ Assimp::Importer* globalImporter = nullptr;
#ifndef ASSIMP_BUILD_NO_EXPORT
/*extern*/ Assimp::Exporter* globalExporter = NULL;
/*extern*/ Assimp::Exporter* globalExporter = nullptr;
#endif
// ------------------------------------------------------------------------------
@@ -286,6 +303,9 @@ const aiScene* ImportModel(
// do the actual import, measure time
const clock_t first = clock();
ConsoleProgressHandler *ph = new ConsoleProgressHandler;
globalImporter->SetProgressHandler(ph);
const aiScene* scene = globalImporter->ReadFile(path,imp.ppFlags);
if (imp.showLog) {
@@ -305,6 +325,9 @@ const aiScene* ImportModel(
if (imp.log) {
FreeLogStreams();
}
globalImporter->SetProgressHandler(nullptr);
delete ph;
return scene;
}