Merge branch 'master' into master
commit
cb623f8b74
|
@ -1,7 +1,7 @@
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
#Open Asset Import Library (assimp)
|
#Open Asset Import Library (assimp)
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Copyright (c) 2006-2017, assimp team
|
# Copyright (c) 2006-2020, assimp team
|
||||||
#
|
#
|
||||||
# License see LICENSE file
|
# License see LICENSE file
|
||||||
#
|
#
|
||||||
|
|
|
@ -30,6 +30,9 @@ env:
|
||||||
- secure: "lZ7pHQvl5dpZWzBQAaIMf0wqrvtcZ4wiZKeIZjf83TEsflW8+z0uTpIuN30ZV6Glth/Sq1OhLnTP5+N57fZU/1ebA5twHdvP4bS5CIUUg71/CXQZNl36xeaqvxsG/xRrdpKOsPdjAOsQ9KPTQulsX43XDLS7CasMiLvYOpqKcPc="
|
- secure: "lZ7pHQvl5dpZWzBQAaIMf0wqrvtcZ4wiZKeIZjf83TEsflW8+z0uTpIuN30ZV6Glth/Sq1OhLnTP5+N57fZU/1ebA5twHdvP4bS5CIUUg71/CXQZNl36xeaqvxsG/xRrdpKOsPdjAOsQ9KPTQulsX43XDLS7CasMiLvYOpqKcPc="
|
||||||
- PV=r8e PLATF=linux-x86_64 NDK_HOME=${TRAVIS_BUILD_DIR}/android-ndk-${PV} PATH=${PATH}:${NDK_HOME}
|
- PV=r8e PLATF=linux-x86_64 NDK_HOME=${TRAVIS_BUILD_DIR}/android-ndk-${PV} PATH=${PATH}:${NDK_HOME}
|
||||||
|
|
||||||
|
git:
|
||||||
|
depth: 1
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- os: linux
|
||||||
|
|
100
CMakeLists.txt
100
CMakeLists.txt
|
@ -1,6 +1,6 @@
|
||||||
# Open Asset Import Library (assimp)
|
# Open Asset Import Library (assimp)
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Copyright (c) 2006-2019, assimp team
|
# Copyright (c) 2006-2020, assimp team
|
||||||
#
|
#
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -51,7 +51,7 @@ IF(HUNTER_ENABLED)
|
||||||
add_definitions(-DASSIMP_USE_HUNTER)
|
add_definitions(-DASSIMP_USE_HUNTER)
|
||||||
ENDIF(HUNTER_ENABLED)
|
ENDIF(HUNTER_ENABLED)
|
||||||
|
|
||||||
PROJECT( Assimp VERSION 5.0.0 )
|
PROJECT( Assimp VERSION 5.0.1 )
|
||||||
|
|
||||||
# All supported options ###############################################
|
# All supported options ###############################################
|
||||||
|
|
||||||
|
@ -100,6 +100,10 @@ OPTION ( ASSIMP_COVERALLS
|
||||||
"Enable this to measure test coverage."
|
"Enable this to measure test coverage."
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
OPTION( ASSIMP_INSTALL
|
||||||
|
"DIsable this if you want to use assimp as a submodule."
|
||||||
|
ON
|
||||||
|
)
|
||||||
OPTION ( ASSIMP_ERROR_MAX
|
OPTION ( ASSIMP_ERROR_MAX
|
||||||
"Enable all warnings."
|
"Enable all warnings."
|
||||||
OFF
|
OFF
|
||||||
|
@ -601,55 +605,59 @@ ENDIF ( ASSIMP_BUILD_TESTS )
|
||||||
|
|
||||||
# Generate a pkg-config .pc for the Assimp library.
|
# Generate a pkg-config .pc for the Assimp library.
|
||||||
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY )
|
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY )
|
||||||
INSTALL( FILES "${PROJECT_BINARY_DIR}/assimp.pc" DESTINATION ${ASSIMP_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
IF ( ASSIMP_INSTALL )
|
||||||
|
INSTALL( FILES "${PROJECT_BINARY_DIR}/assimp.pc" DESTINATION ${ASSIMP_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||||
|
ENDIF( ASSIMP_INSTALL )
|
||||||
|
|
||||||
IF(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
IF ( ASSIMP_INSTALL )
|
||||||
# Packing information
|
IF(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
||||||
SET(CPACK_PACKAGE_NAME "assimp{ASSIMP_VERSION_MAJOR}.{ASSIMP_VERSION_MINOR}")
|
# Packing information
|
||||||
SET(CPACK_PACKAGE_CONTACT "" CACHE STRING "Package maintainer and PGP signer.")
|
SET(CPACK_PACKAGE_NAME "assimp{ASSIMP_VERSION_MAJOR}.{ASSIMP_VERSION_MINOR}")
|
||||||
SET(CPACK_PACKAGE_VENDOR "https://github.com/assimp")
|
SET(CPACK_PACKAGE_CONTACT "" CACHE STRING "Package maintainer and PGP signer.")
|
||||||
SET(CPACK_PACKAGE_DISPLAY_NAME "Assimp ${ASSIMP_VERSION}")
|
SET(CPACK_PACKAGE_VENDOR "https://github.com/assimp")
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY " - Open Asset Import Library ${ASSIMP_VERSION}")
|
SET(CPACK_PACKAGE_DISPLAY_NAME "Assimp ${ASSIMP_VERSION}")
|
||||||
SET(CPACK_PACKAGE_VERSION "${ASSIMP_VERSION}.${ASSIMP_PACKAGE_VERSION}" )
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY " - Open Asset Import Library ${ASSIMP_VERSION}")
|
||||||
SET(CPACK_PACKAGE_VERSION_MAJOR "${ASSIMP_VERSION_MAJOR}")
|
SET(CPACK_PACKAGE_VERSION "${ASSIMP_VERSION}.${ASSIMP_PACKAGE_VERSION}" )
|
||||||
SET(CPACK_PACKAGE_VERSION_MINOR "${ASSIMP_VERSION_MINOR}")
|
SET(CPACK_PACKAGE_VERSION_MAJOR "${ASSIMP_VERSION_MAJOR}")
|
||||||
SET(CPACK_PACKAGE_VERSION_PATCH "${ASSIMP_VERSION_PATCH}")
|
SET(CPACK_PACKAGE_VERSION_MINOR "${ASSIMP_VERSION_MINOR}")
|
||||||
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "assimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}")
|
SET(CPACK_PACKAGE_VERSION_PATCH "${ASSIMP_VERSION_PATCH}")
|
||||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "assimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}")
|
||||||
|
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||||
|
|
||||||
STRING(TOUPPER ${LIBASSIMP_COMPONENT} "LIBASSIMP_COMPONENT_UPPER")
|
STRING(TOUPPER ${LIBASSIMP_COMPONENT} "LIBASSIMP_COMPONENT_UPPER")
|
||||||
STRING(TOUPPER ${LIBASSIMP-DEV_COMPONENT} "LIBASSIMP-DEV_COMPONENT_UPPER")
|
STRING(TOUPPER ${LIBASSIMP-DEV_COMPONENT} "LIBASSIMP-DEV_COMPONENT_UPPER")
|
||||||
|
|
||||||
SET(CPACK_COMPONENT_ASSIMP-BIN_DISPLAY_NAME "tools")
|
SET(CPACK_COMPONENT_ASSIMP-BIN_DISPLAY_NAME "tools")
|
||||||
SET(CPACK_COMPONENT_ASSIMP-BIN_DEPENDS "${LIBASSIMP_COMPONENT}" )
|
SET(CPACK_COMPONENT_ASSIMP-BIN_DEPENDS "${LIBASSIMP_COMPONENT}" )
|
||||||
SET(CPACK_COMPONENT_${LIBASSIMP_COMPONENT_UPPER}_DISPLAY_NAME "libraries")
|
SET(CPACK_COMPONENT_${LIBASSIMP_COMPONENT_UPPER}_DISPLAY_NAME "libraries")
|
||||||
SET(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DISPLAY_NAME "common headers and installs")
|
SET(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DISPLAY_NAME "common headers and installs")
|
||||||
SET(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DEPENDS $ "{LIBASSIMP_COMPONENT}" )
|
SET(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DEPENDS $ "{LIBASSIMP_COMPONENT}" )
|
||||||
SET(CPACK_COMPONENT_ASSIMP-DEV_DISPLAY_NAME "${CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT}_DISPLAY_NAME}" )
|
SET(CPACK_COMPONENT_ASSIMP-DEV_DISPLAY_NAME "${CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT}_DISPLAY_NAME}" )
|
||||||
SET(CPACK_COMPONENT_ASSIMP-DEV_DEPENDS "${LIBASSIMP-DEV_COMPONENT}" )
|
SET(CPACK_COMPONENT_ASSIMP-DEV_DEPENDS "${LIBASSIMP-DEV_COMPONENT}" )
|
||||||
SET(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake zlib1g-dev pkg-config)
|
SET(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake zlib1g-dev pkg-config)
|
||||||
|
|
||||||
# debian
|
# debian
|
||||||
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||||
SET(CPACK_DEBIAN_CMAKE_OPTIONS "-DBUILD_ASSIMP_SAMPLES:BOOL=${ASSIMP_BUILD_SAMPLES}")
|
SET(CPACK_DEBIAN_CMAKE_OPTIONS "-DBUILD_ASSIMP_SAMPLES:BOOL=${ASSIMP_BUILD_SAMPLES}")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_SECTION "libs" )
|
SET(CPACK_DEBIAN_PACKAGE_SECTION "libs" )
|
||||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_COMPONENTS_ALL}")
|
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_COMPONENTS_ALL}")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_SUGGESTS)
|
SET(CPACK_DEBIAN_PACKAGE_SUGGESTS)
|
||||||
set(cPACK_DEBIAN_PACKAGE_NAME "assimp")
|
SET(cPACK_DEBIAN_PACKAGE_NAME "assimp")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES contrib/gtest contrib/zlib workspaces test doc obj samples packaging)
|
SET(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES contrib/gtest contrib/zlib workspaces test doc obj samples packaging)
|
||||||
SET(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force)
|
SET(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force)
|
||||||
SET(CPACK_DEBIAN_CHANGELOG)
|
SET(CPACK_DEBIAN_CHANGELOG)
|
||||||
execute_process(COMMAND lsb_release -is
|
execute_process(COMMAND lsb_release -is
|
||||||
OUTPUT_VARIABLE _lsb_distribution OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_VARIABLE _lsb_distribution OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
RESULT_VARIABLE _lsb_release_failed)
|
RESULT_VARIABLE _lsb_release_failed)
|
||||||
SET(CPACK_DEBIAN_DISTRIBUTION_NAME ${_lsb_distribution} CACHE STRING "Name of the distrubiton")
|
SET(CPACK_DEBIAN_DISTRIBUTION_NAME ${_lsb_distribution} CACHE STRING "Name of the distrubiton")
|
||||||
STRING(TOLOWER ${CPACK_DEBIAN_DISTRIBUTION_NAME} CPACK_DEBIAN_DISTRIBUTION_NAME)
|
STRING(TOLOWER ${CPACK_DEBIAN_DISTRIBUTION_NAME} CPACK_DEBIAN_DISTRIBUTION_NAME)
|
||||||
IF( ${CPACK_DEBIAN_DISTRIBUTION_NAME} STREQUAL "ubuntu" )
|
IF( ${CPACK_DEBIAN_DISTRIBUTION_NAME} STREQUAL "ubuntu" )
|
||||||
SET(CPACK_DEBIAN_DISTRIBUTION_RELEASES lucid maverick natty oneiric precise CACHE STRING "Release code-names of the distrubiton release")
|
SET(CPACK_DEBIAN_DISTRIBUTION_RELEASES lucid maverick natty oneiric precise CACHE STRING "Release code-names of the distrubiton release")
|
||||||
|
ENDIF()
|
||||||
|
SET(DPUT_HOST "" CACHE STRING "PPA repository to upload the debian sources")
|
||||||
|
INCLUDE(CPack)
|
||||||
|
INCLUDE(DebSourcePPA)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
SET(DPUT_HOST "" CACHE STRING "PPA repository to upload the debian sources")
|
|
||||||
INCLUDE(CPack)
|
|
||||||
INCLUDE(DebSourcePPA)
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2016, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -131,7 +131,7 @@ Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file.
|
||||||
### Ports ###
|
### Ports ###
|
||||||
* [Android](port/AndroidJNI/README.md)
|
* [Android](port/AndroidJNI/README.md)
|
||||||
* [Python](port/PyAssimp/README.md)
|
* [Python](port/PyAssimp/README.md)
|
||||||
* [.NET](https://github.com/kebby/assimp-net)
|
* [.NET](https://github.com/assimp/assimp-net)
|
||||||
* [Pascal](port/AssimpPascal/Readme.md)
|
* [Pascal](port/AssimpPascal/Readme.md)
|
||||||
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
|
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
|
||||||
* [Unity 3d Plugin](https://www.assetstore.unity3d.com/en/#!/content/91777)
|
* [Unity 3d Plugin](https://www.assetstore.unity3d.com/en/#!/content/91777)
|
||||||
|
|
14
appveyor.yml
14
appveyor.yml
|
@ -4,6 +4,8 @@
|
||||||
# clone directory
|
# clone directory
|
||||||
clone_folder: c:\projects\assimp
|
clone_folder: c:\projects\assimp
|
||||||
|
|
||||||
|
clone_depth: 1
|
||||||
|
|
||||||
# branches to build
|
# branches to build
|
||||||
branches:
|
branches:
|
||||||
# whitelist
|
# whitelist
|
||||||
|
@ -15,10 +17,10 @@ matrix:
|
||||||
|
|
||||||
image:
|
image:
|
||||||
- Visual Studio 2013
|
- Visual Studio 2013
|
||||||
- Visual Studio 2015
|
#- Visual Studio 2015
|
||||||
- Visual Studio 2017
|
#- Visual Studio 2017
|
||||||
- Visual Studio 2019
|
- Visual Studio 2019
|
||||||
- MinGW
|
#- MinGW
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
- Win32
|
- Win32
|
||||||
|
@ -52,11 +54,11 @@ cache:
|
||||||
- bin\.mtime_cache
|
- bin\.mtime_cache
|
||||||
|
|
||||||
before_build:
|
before_build:
|
||||||
|
- echo NUMBER_OF_PROCESSORS=%NUMBER_OF_PROCESSORS%
|
||||||
- ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json
|
- ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json
|
||||||
|
|
||||||
build:
|
build_script:
|
||||||
parallel: true
|
cmake --build . --config Release -- /maxcpucount:2
|
||||||
project: Assimp.sln
|
|
||||||
|
|
||||||
after_build:
|
after_build:
|
||||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (
|
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Open Asset Import Library (assimp)
|
# Open Asset Import Library (assimp)
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Copyright (c) 2006-2017, assimp team
|
# Copyright (c) 2006-2020, assimp team
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use of this software in source and binary forms,
|
# Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -46,799 +46,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||||
|
|
||||||
#include "Common/assbin_chunks.h"
|
#include "AssbinFileWriter.h"
|
||||||
#include "PostProcessing/ProcessHelper.h"
|
|
||||||
|
|
||||||
#include <assimp/version.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/IOStream.hpp>
|
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
#include <assimp/Exceptional.h>
|
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
|
||||||
# include <zlib.h>
|
|
||||||
#else
|
|
||||||
# include "../contrib/zlib/zlib.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
size_t Write(IOStream * stream, const T& v) {
|
|
||||||
return stream->Write( &v, sizeof(T), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize an aiString
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiString>(IOStream * stream, const aiString& s) {
|
|
||||||
const size_t s2 = (uint32_t)s.length;
|
|
||||||
stream->Write(&s,4,1);
|
|
||||||
stream->Write(s.data,s2,1);
|
|
||||||
|
|
||||||
return s2+4;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize an unsigned int as uint32_t
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<unsigned int>(IOStream * stream, const unsigned int& w) {
|
|
||||||
const uint32_t t = (uint32_t)w;
|
|
||||||
if (w > t) {
|
|
||||||
// this shouldn't happen, integers in Assimp data structures never exceed 2^32
|
|
||||||
throw DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion");
|
|
||||||
}
|
|
||||||
|
|
||||||
stream->Write(&t,4,1);
|
|
||||||
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize an unsigned int as uint16_t
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<uint16_t>(IOStream * stream, const uint16_t& w) {
|
|
||||||
static_assert(sizeof(uint16_t)==2, "sizeof(uint16_t)==2");
|
|
||||||
stream->Write(&w,2,1);
|
|
||||||
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize a float
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<float>(IOStream * stream, const float& f) {
|
|
||||||
static_assert(sizeof(float)==4, "sizeof(float)==4");
|
|
||||||
stream->Write(&f,4,1);
|
|
||||||
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize a double
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<double>(IOStream * stream, const double& f) {
|
|
||||||
static_assert(sizeof(double)==8, "sizeof(double)==8");
|
|
||||||
stream->Write(&f,8,1);
|
|
||||||
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize a vec3
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiVector3D>(IOStream * stream, const aiVector3D& v) {
|
|
||||||
size_t t = Write<float>(stream,v.x);
|
|
||||||
t += Write<float>(stream,v.y);
|
|
||||||
t += Write<float>(stream,v.z);
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize a color value
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiColor3D>(IOStream * stream, const aiColor3D& v) {
|
|
||||||
size_t t = Write<float>(stream,v.r);
|
|
||||||
t += Write<float>(stream,v.g);
|
|
||||||
t += Write<float>(stream,v.b);
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize a color value
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiColor4D>(IOStream * stream, const aiColor4D& v) {
|
|
||||||
size_t t = Write<float>(stream,v.r);
|
|
||||||
t += Write<float>(stream,v.g);
|
|
||||||
t += Write<float>(stream,v.b);
|
|
||||||
t += Write<float>(stream,v.a);
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize a quaternion
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiQuaternion>(IOStream * stream, const aiQuaternion& v) {
|
|
||||||
size_t t = Write<float>(stream,v.w);
|
|
||||||
t += Write<float>(stream,v.x);
|
|
||||||
t += Write<float>(stream,v.y);
|
|
||||||
t += Write<float>(stream,v.z);
|
|
||||||
ai_assert(t == 16);
|
|
||||||
|
|
||||||
return 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize a vertex weight
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiVertexWeight>(IOStream * stream, const aiVertexWeight& v) {
|
|
||||||
size_t t = Write<unsigned int>(stream,v.mVertexId);
|
|
||||||
|
|
||||||
return t+Write<float>(stream,v.mWeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize a mat4x4
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiMatrix4x4>(IOStream * stream, const aiMatrix4x4& m) {
|
|
||||||
for (unsigned int i = 0; i < 4;++i) {
|
|
||||||
for (unsigned int i2 = 0; i2 < 4;++i2) {
|
|
||||||
Write<float>(stream,m[i][i2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize an aiVectorKey
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiVectorKey>(IOStream * stream, const aiVectorKey& v) {
|
|
||||||
const size_t t = Write<double>(stream,v.mTime);
|
|
||||||
return t + Write<aiVector3D>(stream,v.mValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Serialize an aiQuatKey
|
|
||||||
template <>
|
|
||||||
inline
|
|
||||||
size_t Write<aiQuatKey>(IOStream * stream, const aiQuatKey& v) {
|
|
||||||
const size_t t = Write<double>(stream,v.mTime);
|
|
||||||
return t + Write<aiQuaternion>(stream,v.mValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline
|
|
||||||
size_t WriteBounds(IOStream * stream, const T* in, unsigned int size) {
|
|
||||||
T minc, maxc;
|
|
||||||
ArrayBounds(in,size,minc,maxc);
|
|
||||||
|
|
||||||
const size_t t = Write<T>(stream,minc);
|
|
||||||
return t + Write<T>(stream,maxc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use this to write out non-byte arrays so that we write using the specializations.
|
|
||||||
// This way we avoid writing out extra bytes that potentially come from struct alignment.
|
|
||||||
template <typename T>
|
|
||||||
inline
|
|
||||||
size_t WriteArray(IOStream * stream, const T* in, unsigned int size) {
|
|
||||||
size_t n = 0;
|
|
||||||
for (unsigned int i=0; i<size; i++) n += Write<T>(stream,in[i]);
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
|
||||||
/** @class AssbinChunkWriter
|
|
||||||
* @brief Chunk writer mechanism for the .assbin file structure
|
|
||||||
*
|
|
||||||
* This is a standard in-memory IOStream (most of the code is based on BlobIOStream),
|
|
||||||
* the difference being that this takes another IOStream as a "container" in the
|
|
||||||
* constructor, and when it is destroyed, it appends the magic number, the chunk size,
|
|
||||||
* and the chunk contents to the container stream. This allows relatively easy chunk
|
|
||||||
* chunk construction, even recursively.
|
|
||||||
*/
|
|
||||||
class AssbinChunkWriter : public IOStream
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
uint8_t* buffer;
|
|
||||||
uint32_t magic;
|
|
||||||
IOStream * container;
|
|
||||||
size_t cur_size, cursor, initial;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
void Grow(size_t need = 0)
|
|
||||||
{
|
|
||||||
size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) ));
|
|
||||||
|
|
||||||
const uint8_t* const old = buffer;
|
|
||||||
buffer = new uint8_t[new_size];
|
|
||||||
|
|
||||||
if (old) {
|
|
||||||
memcpy(buffer,old,cur_size);
|
|
||||||
delete[] old;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_size = new_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
AssbinChunkWriter( IOStream * container, uint32_t magic, size_t initial = 4096)
|
|
||||||
: buffer(NULL), magic(magic), container(container), cur_size(0), cursor(0), initial(initial)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~AssbinChunkWriter()
|
|
||||||
{
|
|
||||||
if (container) {
|
|
||||||
container->Write( &magic, sizeof(uint32_t), 1 );
|
|
||||||
container->Write( &cursor, sizeof(uint32_t), 1 );
|
|
||||||
container->Write( buffer, 1, cursor );
|
|
||||||
}
|
|
||||||
if (buffer) delete[] buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void * GetBufferPointer() { return buffer; }
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
virtual size_t Read(void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
virtual aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) {
|
|
||||||
return aiReturn_FAILURE;
|
|
||||||
}
|
|
||||||
virtual size_t Tell() const {
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
virtual void Flush() {
|
|
||||||
// not implemented
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual size_t FileSize() const {
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
virtual size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) {
|
|
||||||
pSize *= pCount;
|
|
||||||
if (cursor + pSize > cur_size) {
|
|
||||||
Grow(cursor + pSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(buffer+cursor, pvBuffer, pSize);
|
|
||||||
cursor += pSize;
|
|
||||||
|
|
||||||
return pCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
|
||||||
/** @class AssbinExport
|
|
||||||
* @brief Assbin exporter class
|
|
||||||
*
|
|
||||||
* This class performs the .assbin exporting, and is responsible for the file layout.
|
|
||||||
*/
|
|
||||||
class AssbinExport
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
bool shortened;
|
|
||||||
bool compressed;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryNode( IOStream * container, const aiNode* node)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODE );
|
|
||||||
|
|
||||||
unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
|
|
||||||
|
|
||||||
Write<aiString>(&chunk,node->mName);
|
|
||||||
Write<aiMatrix4x4>(&chunk,node->mTransformation);
|
|
||||||
Write<unsigned int>(&chunk,node->mNumChildren);
|
|
||||||
Write<unsigned int>(&chunk,node->mNumMeshes);
|
|
||||||
Write<unsigned int>(&chunk,nb_metadata);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < node->mNumMeshes;++i) {
|
|
||||||
Write<unsigned int>(&chunk,node->mMeshes[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < node->mNumChildren;++i) {
|
|
||||||
WriteBinaryNode( &chunk, node->mChildren[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nb_metadata; ++i) {
|
|
||||||
const aiString& key = node->mMetaData->mKeys[i];
|
|
||||||
aiMetadataType type = node->mMetaData->mValues[i].mType;
|
|
||||||
void* value = node->mMetaData->mValues[i].mData;
|
|
||||||
|
|
||||||
Write<aiString>(&chunk, key);
|
|
||||||
Write<uint16_t>(&chunk, type);
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case AI_BOOL:
|
|
||||||
Write<bool>(&chunk, *((bool*) value));
|
|
||||||
break;
|
|
||||||
case AI_INT32:
|
|
||||||
Write<int32_t>(&chunk, *((int32_t*) value));
|
|
||||||
break;
|
|
||||||
case AI_UINT64:
|
|
||||||
Write<uint64_t>(&chunk, *((uint64_t*) value));
|
|
||||||
break;
|
|
||||||
case AI_FLOAT:
|
|
||||||
Write<float>(&chunk, *((float*) value));
|
|
||||||
break;
|
|
||||||
case AI_DOUBLE:
|
|
||||||
Write<double>(&chunk, *((double*) value));
|
|
||||||
break;
|
|
||||||
case AI_AISTRING:
|
|
||||||
Write<aiString>(&chunk, *((aiString*) value));
|
|
||||||
break;
|
|
||||||
case AI_AIVECTOR3D:
|
|
||||||
Write<aiVector3D>(&chunk, *((aiVector3D*) value));
|
|
||||||
break;
|
|
||||||
#ifdef SWIG
|
|
||||||
case FORCE_32BIT:
|
|
||||||
#endif // SWIG
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryTexture(IOStream * container, const aiTexture* tex)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AITEXTURE );
|
|
||||||
|
|
||||||
Write<unsigned int>(&chunk,tex->mWidth);
|
|
||||||
Write<unsigned int>(&chunk,tex->mHeight);
|
|
||||||
chunk.Write( tex->achFormatHint, sizeof(char), 4 );
|
|
||||||
|
|
||||||
if(!shortened) {
|
|
||||||
if (!tex->mHeight) {
|
|
||||||
chunk.Write(tex->pcData,1,tex->mWidth);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
chunk.Write(tex->pcData,1,tex->mWidth*tex->mHeight*4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryBone(IOStream * container, const aiBone* b)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIBONE );
|
|
||||||
|
|
||||||
Write<aiString>(&chunk,b->mName);
|
|
||||||
Write<unsigned int>(&chunk,b->mNumWeights);
|
|
||||||
Write<aiMatrix4x4>(&chunk,b->mOffsetMatrix);
|
|
||||||
|
|
||||||
// for the moment we write dumb min/max values for the bones, too.
|
|
||||||
// maybe I'll add a better, hash-like solution later
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,b->mWeights,b->mNumWeights);
|
|
||||||
} // else write as usual
|
|
||||||
else WriteArray<aiVertexWeight>(&chunk,b->mWeights,b->mNumWeights);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryMesh(IOStream * container, const aiMesh* mesh)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMESH );
|
|
||||||
|
|
||||||
Write<unsigned int>(&chunk,mesh->mPrimitiveTypes);
|
|
||||||
Write<unsigned int>(&chunk,mesh->mNumVertices);
|
|
||||||
Write<unsigned int>(&chunk,mesh->mNumFaces);
|
|
||||||
Write<unsigned int>(&chunk,mesh->mNumBones);
|
|
||||||
Write<unsigned int>(&chunk,mesh->mMaterialIndex);
|
|
||||||
|
|
||||||
// first of all, write bits for all existent vertex components
|
|
||||||
unsigned int c = 0;
|
|
||||||
if (mesh->mVertices) {
|
|
||||||
c |= ASSBIN_MESH_HAS_POSITIONS;
|
|
||||||
}
|
|
||||||
if (mesh->mNormals) {
|
|
||||||
c |= ASSBIN_MESH_HAS_NORMALS;
|
|
||||||
}
|
|
||||||
if (mesh->mTangents && mesh->mBitangents) {
|
|
||||||
c |= ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS;
|
|
||||||
}
|
|
||||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
|
||||||
if (!mesh->mTextureCoords[n]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
c |= ASSBIN_MESH_HAS_TEXCOORD(n);
|
|
||||||
}
|
|
||||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
|
|
||||||
if (!mesh->mColors[n]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
c |= ASSBIN_MESH_HAS_COLOR(n);
|
|
||||||
}
|
|
||||||
Write<unsigned int>(&chunk,c);
|
|
||||||
|
|
||||||
aiVector3D minVec, maxVec;
|
|
||||||
if (mesh->mVertices) {
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,mesh->mVertices,mesh->mNumVertices);
|
|
||||||
} // else write as usual
|
|
||||||
else WriteArray<aiVector3D>(&chunk,mesh->mVertices,mesh->mNumVertices);
|
|
||||||
}
|
|
||||||
if (mesh->mNormals) {
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,mesh->mNormals,mesh->mNumVertices);
|
|
||||||
} // else write as usual
|
|
||||||
else WriteArray<aiVector3D>(&chunk,mesh->mNormals,mesh->mNumVertices);
|
|
||||||
}
|
|
||||||
if (mesh->mTangents && mesh->mBitangents) {
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,mesh->mTangents,mesh->mNumVertices);
|
|
||||||
WriteBounds(&chunk,mesh->mBitangents,mesh->mNumVertices);
|
|
||||||
} // else write as usual
|
|
||||||
else {
|
|
||||||
WriteArray<aiVector3D>(&chunk,mesh->mTangents,mesh->mNumVertices);
|
|
||||||
WriteArray<aiVector3D>(&chunk,mesh->mBitangents,mesh->mNumVertices);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
|
|
||||||
if (!mesh->mColors[n])
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,mesh->mColors[n],mesh->mNumVertices);
|
|
||||||
} // else write as usual
|
|
||||||
else WriteArray<aiColor4D>(&chunk,mesh->mColors[n],mesh->mNumVertices);
|
|
||||||
}
|
|
||||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
|
||||||
if (!mesh->mTextureCoords[n])
|
|
||||||
break;
|
|
||||||
|
|
||||||
// write number of UV components
|
|
||||||
Write<unsigned int>(&chunk,mesh->mNumUVComponents[n]);
|
|
||||||
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices);
|
|
||||||
} // else write as usual
|
|
||||||
else WriteArray<aiVector3D>(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write faces. There are no floating-point calculations involved
|
|
||||||
// in these, so we can write a simple hash over the face data
|
|
||||||
// to the dump file. We generate a single 32 Bit hash for 512 faces
|
|
||||||
// using Assimp's standard hashing function.
|
|
||||||
if (shortened) {
|
|
||||||
unsigned int processed = 0;
|
|
||||||
for (unsigned int job;(job = std::min(mesh->mNumFaces-processed,512u));processed += job) {
|
|
||||||
|
|
||||||
uint32_t hash = 0;
|
|
||||||
for (unsigned int a = 0; a < job;++a) {
|
|
||||||
|
|
||||||
const aiFace& f = mesh->mFaces[processed+a];
|
|
||||||
uint32_t tmp = f.mNumIndices;
|
|
||||||
hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
|
|
||||||
for (unsigned int i = 0; i < f.mNumIndices; ++i) {
|
|
||||||
static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff");
|
|
||||||
tmp = static_cast<uint32_t>( f.mIndices[i] );
|
|
||||||
hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Write<unsigned int>(&chunk,hash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // else write as usual
|
|
||||||
{
|
|
||||||
// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
|
|
||||||
for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
|
|
||||||
const aiFace& f = mesh->mFaces[i];
|
|
||||||
|
|
||||||
static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff");
|
|
||||||
Write<uint16_t>(&chunk,f.mNumIndices);
|
|
||||||
|
|
||||||
for (unsigned int a = 0; a < f.mNumIndices;++a) {
|
|
||||||
if (mesh->mNumVertices < (1u<<16)) {
|
|
||||||
Write<uint16_t>(&chunk,f.mIndices[a]);
|
|
||||||
}
|
|
||||||
else Write<unsigned int>(&chunk,f.mIndices[a]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// write bones
|
|
||||||
if (mesh->mNumBones) {
|
|
||||||
for (unsigned int a = 0; a < mesh->mNumBones;++a) {
|
|
||||||
const aiBone* b = mesh->mBones[a];
|
|
||||||
WriteBinaryBone(&chunk,b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryMaterialProperty(IOStream * container, const aiMaterialProperty* prop)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIALPROPERTY );
|
|
||||||
|
|
||||||
Write<aiString>(&chunk,prop->mKey);
|
|
||||||
Write<unsigned int>(&chunk,prop->mSemantic);
|
|
||||||
Write<unsigned int>(&chunk,prop->mIndex);
|
|
||||||
|
|
||||||
Write<unsigned int>(&chunk,prop->mDataLength);
|
|
||||||
Write<unsigned int>(&chunk,(unsigned int)prop->mType);
|
|
||||||
chunk.Write(prop->mData,1,prop->mDataLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryMaterial(IOStream * container, const aiMaterial* mat)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIAL);
|
|
||||||
|
|
||||||
Write<unsigned int>(&chunk,mat->mNumProperties);
|
|
||||||
for (unsigned int i = 0; i < mat->mNumProperties;++i) {
|
|
||||||
WriteBinaryMaterialProperty( &chunk, mat->mProperties[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryNodeAnim(IOStream * container, const aiNodeAnim* nd)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODEANIM );
|
|
||||||
|
|
||||||
Write<aiString>(&chunk,nd->mNodeName);
|
|
||||||
Write<unsigned int>(&chunk,nd->mNumPositionKeys);
|
|
||||||
Write<unsigned int>(&chunk,nd->mNumRotationKeys);
|
|
||||||
Write<unsigned int>(&chunk,nd->mNumScalingKeys);
|
|
||||||
Write<unsigned int>(&chunk,nd->mPreState);
|
|
||||||
Write<unsigned int>(&chunk,nd->mPostState);
|
|
||||||
|
|
||||||
if (nd->mPositionKeys) {
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,nd->mPositionKeys,nd->mNumPositionKeys);
|
|
||||||
|
|
||||||
} // else write as usual
|
|
||||||
else WriteArray<aiVectorKey>(&chunk,nd->mPositionKeys,nd->mNumPositionKeys);
|
|
||||||
}
|
|
||||||
if (nd->mRotationKeys) {
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,nd->mRotationKeys,nd->mNumRotationKeys);
|
|
||||||
|
|
||||||
} // else write as usual
|
|
||||||
else WriteArray<aiQuatKey>(&chunk,nd->mRotationKeys,nd->mNumRotationKeys);
|
|
||||||
}
|
|
||||||
if (nd->mScalingKeys) {
|
|
||||||
if (shortened) {
|
|
||||||
WriteBounds(&chunk,nd->mScalingKeys,nd->mNumScalingKeys);
|
|
||||||
|
|
||||||
} // else write as usual
|
|
||||||
else WriteArray<aiVectorKey>(&chunk,nd->mScalingKeys,nd->mNumScalingKeys);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryAnim( IOStream * container, const aiAnimation* anim )
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIANIMATION );
|
|
||||||
|
|
||||||
Write<aiString>(&chunk,anim->mName);
|
|
||||||
Write<double>(&chunk,anim->mDuration);
|
|
||||||
Write<double>(&chunk,anim->mTicksPerSecond);
|
|
||||||
Write<unsigned int>(&chunk,anim->mNumChannels);
|
|
||||||
|
|
||||||
for (unsigned int a = 0; a < anim->mNumChannels;++a) {
|
|
||||||
const aiNodeAnim* nd = anim->mChannels[a];
|
|
||||||
WriteBinaryNodeAnim(&chunk,nd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryLight( IOStream * container, const aiLight* l )
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AILIGHT );
|
|
||||||
|
|
||||||
Write<aiString>(&chunk,l->mName);
|
|
||||||
Write<unsigned int>(&chunk,l->mType);
|
|
||||||
|
|
||||||
if (l->mType != aiLightSource_DIRECTIONAL) {
|
|
||||||
Write<float>(&chunk,l->mAttenuationConstant);
|
|
||||||
Write<float>(&chunk,l->mAttenuationLinear);
|
|
||||||
Write<float>(&chunk,l->mAttenuationQuadratic);
|
|
||||||
}
|
|
||||||
|
|
||||||
Write<aiColor3D>(&chunk,l->mColorDiffuse);
|
|
||||||
Write<aiColor3D>(&chunk,l->mColorSpecular);
|
|
||||||
Write<aiColor3D>(&chunk,l->mColorAmbient);
|
|
||||||
|
|
||||||
if (l->mType == aiLightSource_SPOT) {
|
|
||||||
Write<float>(&chunk,l->mAngleInnerCone);
|
|
||||||
Write<float>(&chunk,l->mAngleOuterCone);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryCamera( IOStream * container, const aiCamera* cam )
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AICAMERA );
|
|
||||||
|
|
||||||
Write<aiString>(&chunk,cam->mName);
|
|
||||||
Write<aiVector3D>(&chunk,cam->mPosition);
|
|
||||||
Write<aiVector3D>(&chunk,cam->mLookAt);
|
|
||||||
Write<aiVector3D>(&chunk,cam->mUp);
|
|
||||||
Write<float>(&chunk,cam->mHorizontalFOV);
|
|
||||||
Write<float>(&chunk,cam->mClipPlaneNear);
|
|
||||||
Write<float>(&chunk,cam->mClipPlaneFar);
|
|
||||||
Write<float>(&chunk,cam->mAspect);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
void WriteBinaryScene( IOStream * container, const aiScene* scene)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AISCENE );
|
|
||||||
|
|
||||||
// basic scene information
|
|
||||||
Write<unsigned int>(&chunk,scene->mFlags);
|
|
||||||
Write<unsigned int>(&chunk,scene->mNumMeshes);
|
|
||||||
Write<unsigned int>(&chunk,scene->mNumMaterials);
|
|
||||||
Write<unsigned int>(&chunk,scene->mNumAnimations);
|
|
||||||
Write<unsigned int>(&chunk,scene->mNumTextures);
|
|
||||||
Write<unsigned int>(&chunk,scene->mNumLights);
|
|
||||||
Write<unsigned int>(&chunk,scene->mNumCameras);
|
|
||||||
|
|
||||||
// write node graph
|
|
||||||
WriteBinaryNode( &chunk, scene->mRootNode );
|
|
||||||
|
|
||||||
// write all meshes
|
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
|
||||||
const aiMesh* mesh = scene->mMeshes[i];
|
|
||||||
WriteBinaryMesh( &chunk,mesh);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write materials
|
|
||||||
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
|
||||||
const aiMaterial* mat = scene->mMaterials[i];
|
|
||||||
WriteBinaryMaterial(&chunk,mat);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write all animations
|
|
||||||
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
|
||||||
const aiAnimation* anim = scene->mAnimations[i];
|
|
||||||
WriteBinaryAnim(&chunk,anim);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// write all textures
|
|
||||||
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
|
||||||
const aiTexture* mesh = scene->mTextures[i];
|
|
||||||
WriteBinaryTexture(&chunk,mesh);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write lights
|
|
||||||
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
|
||||||
const aiLight* l = scene->mLights[i];
|
|
||||||
WriteBinaryLight(&chunk,l);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write cameras
|
|
||||||
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
|
||||||
const aiCamera* cam = scene->mCameras[i];
|
|
||||||
WriteBinaryCamera(&chunk,cam);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
AssbinExport()
|
|
||||||
: shortened(false), compressed(false) // temporary settings until properties are introduced for exporters
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
|
||||||
// Write a binary model dump
|
|
||||||
void WriteBinaryDump(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene)
|
|
||||||
{
|
|
||||||
IOStream * out = pIOSystem->Open( pFile, "wb" );
|
|
||||||
if (!out) return;
|
|
||||||
|
|
||||||
time_t tt = time(NULL);
|
|
||||||
#if _WIN32
|
|
||||||
tm* p = gmtime(&tt);
|
|
||||||
#else
|
|
||||||
struct tm now;
|
|
||||||
tm* p = gmtime_r(&tt, &now);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// header
|
|
||||||
char s[64];
|
|
||||||
memset( s, 0, 64 );
|
|
||||||
#if _MSC_VER >= 1400
|
|
||||||
sprintf_s(s,"ASSIMP.binary-dump.%s",asctime(p));
|
|
||||||
#else
|
|
||||||
ai_snprintf(s,64,"ASSIMP.binary-dump.%s",asctime(p));
|
|
||||||
#endif
|
|
||||||
out->Write( s, 44, 1 );
|
|
||||||
// == 44 bytes
|
|
||||||
|
|
||||||
Write<unsigned int>( out, ASSBIN_VERSION_MAJOR );
|
|
||||||
Write<unsigned int>( out, ASSBIN_VERSION_MINOR );
|
|
||||||
Write<unsigned int>( out, aiGetVersionRevision() );
|
|
||||||
Write<unsigned int>( out, aiGetCompileFlags() );
|
|
||||||
Write<uint16_t>( out, shortened );
|
|
||||||
Write<uint16_t>( out, compressed );
|
|
||||||
// == 20 bytes
|
|
||||||
|
|
||||||
char buff[256];
|
|
||||||
strncpy(buff,pFile,256);
|
|
||||||
out->Write(buff,sizeof(char),256);
|
|
||||||
|
|
||||||
char cmd[] = "\0";
|
|
||||||
strncpy(buff,cmd,128);
|
|
||||||
out->Write(buff,sizeof(char),128);
|
|
||||||
|
|
||||||
// leave 64 bytes free for future extensions
|
|
||||||
memset(buff,0xcd,64);
|
|
||||||
out->Write(buff,sizeof(char),64);
|
|
||||||
// == 435 bytes
|
|
||||||
|
|
||||||
// ==== total header size: 512 bytes
|
|
||||||
ai_assert( out->Tell() == ASSBIN_HEADER_LENGTH );
|
|
||||||
|
|
||||||
// Up to here the data is uncompressed. For compressed files, the rest
|
|
||||||
// is compressed using standard DEFLATE from zlib.
|
|
||||||
if (compressed)
|
|
||||||
{
|
|
||||||
AssbinChunkWriter uncompressedStream( NULL, 0 );
|
|
||||||
WriteBinaryScene( &uncompressedStream, pScene );
|
|
||||||
|
|
||||||
uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());
|
|
||||||
uLongf compressedSize = (uLongf)compressBound(uncompressedSize);
|
|
||||||
uint8_t* compressedBuffer = new uint8_t[ compressedSize ];
|
|
||||||
|
|
||||||
int res = compress2( compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9 );
|
|
||||||
if(res != Z_OK)
|
|
||||||
{
|
|
||||||
delete [] compressedBuffer;
|
|
||||||
pIOSystem->Close(out);
|
|
||||||
throw DeadlyExportError("Compression failed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
out->Write( &uncompressedSize, sizeof(uint32_t), 1 );
|
|
||||||
out->Write( compressedBuffer, sizeof(char), compressedSize );
|
|
||||||
|
|
||||||
delete[] compressedBuffer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WriteBinaryScene( out, pScene );
|
|
||||||
}
|
|
||||||
|
|
||||||
pIOSystem->Close( out );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) {
|
void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) {
|
||||||
AssbinExport exporter;
|
DumpSceneToAssbin(
|
||||||
exporter.WriteBinaryDump( pFile, pIOSystem, pScene );
|
pFile,
|
||||||
|
"\0", // no command(s).
|
||||||
|
pIOSystem,
|
||||||
|
pScene,
|
||||||
|
false, // shortened?
|
||||||
|
false); // compressed?
|
||||||
}
|
}
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -0,0 +1,858 @@
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, 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 AssbinFileWriter.cpp
|
||||||
|
* @brief Implementation of Assbin file writer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AssbinFileWriter.h"
|
||||||
|
|
||||||
|
#include "Common/assbin_chunks.h"
|
||||||
|
#include "PostProcessing/ProcessHelper.h"
|
||||||
|
|
||||||
|
#include <assimp/version.h>
|
||||||
|
#include <assimp/IOStream.hpp>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Exceptional.h>
|
||||||
|
|
||||||
|
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||||
|
# include <zlib.h>
|
||||||
|
#else
|
||||||
|
# include "../contrib/zlib/zlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
size_t Write(IOStream * stream, const T& v) {
|
||||||
|
return stream->Write( &v, sizeof(T), 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize an aiString
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiString>(IOStream * stream, const aiString& s) {
|
||||||
|
const size_t s2 = (uint32_t)s.length;
|
||||||
|
stream->Write(&s,4,1);
|
||||||
|
stream->Write(s.data,s2,1);
|
||||||
|
|
||||||
|
return s2+4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize an unsigned int as uint32_t
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<unsigned int>(IOStream * stream, const unsigned int& w) {
|
||||||
|
const uint32_t t = (uint32_t)w;
|
||||||
|
if (w > t) {
|
||||||
|
// this shouldn't happen, integers in Assimp data structures never exceed 2^32
|
||||||
|
throw DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion");
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->Write(&t,4,1);
|
||||||
|
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize an unsigned int as uint16_t
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<uint16_t>(IOStream * stream, const uint16_t& w) {
|
||||||
|
static_assert(sizeof(uint16_t)==2, "sizeof(uint16_t)==2");
|
||||||
|
stream->Write(&w,2,1);
|
||||||
|
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a float
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<float>(IOStream * stream, const float& f) {
|
||||||
|
static_assert(sizeof(float)==4, "sizeof(float)==4");
|
||||||
|
stream->Write(&f,4,1);
|
||||||
|
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a double
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<double>(IOStream * stream, const double& f) {
|
||||||
|
static_assert(sizeof(double)==8, "sizeof(double)==8");
|
||||||
|
stream->Write(&f,8,1);
|
||||||
|
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a vec3
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiVector3D>(IOStream * stream, const aiVector3D& v) {
|
||||||
|
size_t t = Write<float>(stream,v.x);
|
||||||
|
t += Write<float>(stream,v.y);
|
||||||
|
t += Write<float>(stream,v.z);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a color value
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiColor3D>(IOStream * stream, const aiColor3D& v) {
|
||||||
|
size_t t = Write<float>(stream,v.r);
|
||||||
|
t += Write<float>(stream,v.g);
|
||||||
|
t += Write<float>(stream,v.b);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a color value
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiColor4D>(IOStream * stream, const aiColor4D& v) {
|
||||||
|
size_t t = Write<float>(stream,v.r);
|
||||||
|
t += Write<float>(stream,v.g);
|
||||||
|
t += Write<float>(stream,v.b);
|
||||||
|
t += Write<float>(stream,v.a);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a quaternion
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiQuaternion>(IOStream * stream, const aiQuaternion& v) {
|
||||||
|
size_t t = Write<float>(stream,v.w);
|
||||||
|
t += Write<float>(stream,v.x);
|
||||||
|
t += Write<float>(stream,v.y);
|
||||||
|
t += Write<float>(stream,v.z);
|
||||||
|
ai_assert(t == 16);
|
||||||
|
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a vertex weight
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiVertexWeight>(IOStream * stream, const aiVertexWeight& v) {
|
||||||
|
size_t t = Write<unsigned int>(stream,v.mVertexId);
|
||||||
|
|
||||||
|
return t+Write<float>(stream,v.mWeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a mat4x4
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiMatrix4x4>(IOStream * stream, const aiMatrix4x4& m) {
|
||||||
|
for (unsigned int i = 0; i < 4;++i) {
|
||||||
|
for (unsigned int i2 = 0; i2 < 4;++i2) {
|
||||||
|
Write<float>(stream,m[i][i2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize an aiVectorKey
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiVectorKey>(IOStream * stream, const aiVectorKey& v) {
|
||||||
|
const size_t t = Write<double>(stream,v.mTime);
|
||||||
|
return t + Write<aiVector3D>(stream,v.mValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize an aiQuatKey
|
||||||
|
template <>
|
||||||
|
inline
|
||||||
|
size_t Write<aiQuatKey>(IOStream * stream, const aiQuatKey& v) {
|
||||||
|
const size_t t = Write<double>(stream,v.mTime);
|
||||||
|
return t + Write<aiQuaternion>(stream,v.mValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
size_t WriteBounds(IOStream * stream, const T* in, unsigned int size) {
|
||||||
|
T minc, maxc;
|
||||||
|
ArrayBounds(in,size,minc,maxc);
|
||||||
|
|
||||||
|
const size_t t = Write<T>(stream,minc);
|
||||||
|
return t + Write<T>(stream,maxc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We use this to write out non-byte arrays so that we write using the specializations.
|
||||||
|
// This way we avoid writing out extra bytes that potentially come from struct alignment.
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
size_t WriteArray(IOStream * stream, const T* in, unsigned int size) {
|
||||||
|
size_t n = 0;
|
||||||
|
for (unsigned int i=0; i<size; i++) n += Write<T>(stream,in[i]);
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
/** @class AssbinChunkWriter
|
||||||
|
* @brief Chunk writer mechanism for the .assbin file structure
|
||||||
|
*
|
||||||
|
* This is a standard in-memory IOStream (most of the code is based on BlobIOStream),
|
||||||
|
* the difference being that this takes another IOStream as a "container" in the
|
||||||
|
* constructor, and when it is destroyed, it appends the magic number, the chunk size,
|
||||||
|
* and the chunk contents to the container stream. This allows relatively easy chunk
|
||||||
|
* chunk construction, even recursively.
|
||||||
|
*/
|
||||||
|
class AssbinChunkWriter : public IOStream
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint8_t* buffer;
|
||||||
|
uint32_t magic;
|
||||||
|
IOStream * container;
|
||||||
|
size_t cur_size, cursor, initial;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
void Grow(size_t need = 0)
|
||||||
|
{
|
||||||
|
size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) ));
|
||||||
|
|
||||||
|
const uint8_t* const old = buffer;
|
||||||
|
buffer = new uint8_t[new_size];
|
||||||
|
|
||||||
|
if (old) {
|
||||||
|
memcpy(buffer,old,cur_size);
|
||||||
|
delete[] old;
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_size = new_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
AssbinChunkWriter( IOStream * container, uint32_t magic, size_t initial = 4096)
|
||||||
|
: buffer(NULL), magic(magic), container(container), cur_size(0), cursor(0), initial(initial)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~AssbinChunkWriter()
|
||||||
|
{
|
||||||
|
if (container) {
|
||||||
|
container->Write( &magic, sizeof(uint32_t), 1 );
|
||||||
|
container->Write( &cursor, sizeof(uint32_t), 1 );
|
||||||
|
container->Write( buffer, 1, cursor );
|
||||||
|
}
|
||||||
|
if (buffer) delete[] buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void * GetBufferPointer() { return buffer; }
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
virtual size_t Read(void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
virtual aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) {
|
||||||
|
return aiReturn_FAILURE;
|
||||||
|
}
|
||||||
|
virtual size_t Tell() const {
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
virtual void Flush() {
|
||||||
|
// not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual size_t FileSize() const {
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
virtual size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) {
|
||||||
|
pSize *= pCount;
|
||||||
|
if (cursor + pSize > cur_size) {
|
||||||
|
Grow(cursor + pSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(buffer+cursor, pvBuffer, pSize);
|
||||||
|
cursor += pSize;
|
||||||
|
|
||||||
|
return pCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
/** @class AssbinFileWriter
|
||||||
|
* @brief Assbin file writer class
|
||||||
|
*
|
||||||
|
* This class writes an .assbin file, and is responsible for the file layout.
|
||||||
|
*/
|
||||||
|
class AssbinFileWriter
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
bool shortened;
|
||||||
|
bool compressed;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryNode( IOStream * container, const aiNode* node)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODE );
|
||||||
|
|
||||||
|
unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
|
||||||
|
|
||||||
|
Write<aiString>(&chunk,node->mName);
|
||||||
|
Write<aiMatrix4x4>(&chunk,node->mTransformation);
|
||||||
|
Write<unsigned int>(&chunk,node->mNumChildren);
|
||||||
|
Write<unsigned int>(&chunk,node->mNumMeshes);
|
||||||
|
Write<unsigned int>(&chunk,nb_metadata);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < node->mNumMeshes;++i) {
|
||||||
|
Write<unsigned int>(&chunk,node->mMeshes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < node->mNumChildren;++i) {
|
||||||
|
WriteBinaryNode( &chunk, node->mChildren[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < nb_metadata; ++i) {
|
||||||
|
const aiString& key = node->mMetaData->mKeys[i];
|
||||||
|
aiMetadataType type = node->mMetaData->mValues[i].mType;
|
||||||
|
void* value = node->mMetaData->mValues[i].mData;
|
||||||
|
|
||||||
|
Write<aiString>(&chunk, key);
|
||||||
|
Write<uint16_t>(&chunk, type);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case AI_BOOL:
|
||||||
|
Write<bool>(&chunk, *((bool*) value));
|
||||||
|
break;
|
||||||
|
case AI_INT32:
|
||||||
|
Write<int32_t>(&chunk, *((int32_t*) value));
|
||||||
|
break;
|
||||||
|
case AI_UINT64:
|
||||||
|
Write<uint64_t>(&chunk, *((uint64_t*) value));
|
||||||
|
break;
|
||||||
|
case AI_FLOAT:
|
||||||
|
Write<float>(&chunk, *((float*) value));
|
||||||
|
break;
|
||||||
|
case AI_DOUBLE:
|
||||||
|
Write<double>(&chunk, *((double*) value));
|
||||||
|
break;
|
||||||
|
case AI_AISTRING:
|
||||||
|
Write<aiString>(&chunk, *((aiString*) value));
|
||||||
|
break;
|
||||||
|
case AI_AIVECTOR3D:
|
||||||
|
Write<aiVector3D>(&chunk, *((aiVector3D*) value));
|
||||||
|
break;
|
||||||
|
#ifdef SWIG
|
||||||
|
case FORCE_32BIT:
|
||||||
|
#endif // SWIG
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryTexture(IOStream * container, const aiTexture* tex)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AITEXTURE );
|
||||||
|
|
||||||
|
Write<unsigned int>(&chunk,tex->mWidth);
|
||||||
|
Write<unsigned int>(&chunk,tex->mHeight);
|
||||||
|
// Write the texture format, but don't include the null terminator.
|
||||||
|
chunk.Write( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 );
|
||||||
|
|
||||||
|
if(!shortened) {
|
||||||
|
if (!tex->mHeight) {
|
||||||
|
chunk.Write(tex->pcData,1,tex->mWidth);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
chunk.Write(tex->pcData,1,tex->mWidth*tex->mHeight*4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryBone(IOStream * container, const aiBone* b)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIBONE );
|
||||||
|
|
||||||
|
Write<aiString>(&chunk,b->mName);
|
||||||
|
Write<unsigned int>(&chunk,b->mNumWeights);
|
||||||
|
Write<aiMatrix4x4>(&chunk,b->mOffsetMatrix);
|
||||||
|
|
||||||
|
// for the moment we write dumb min/max values for the bones, too.
|
||||||
|
// maybe I'll add a better, hash-like solution later
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,b->mWeights,b->mNumWeights);
|
||||||
|
} // else write as usual
|
||||||
|
else WriteArray<aiVertexWeight>(&chunk,b->mWeights,b->mNumWeights);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryMesh(IOStream * container, const aiMesh* mesh)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMESH );
|
||||||
|
|
||||||
|
Write<unsigned int>(&chunk,mesh->mPrimitiveTypes);
|
||||||
|
Write<unsigned int>(&chunk,mesh->mNumVertices);
|
||||||
|
Write<unsigned int>(&chunk,mesh->mNumFaces);
|
||||||
|
Write<unsigned int>(&chunk,mesh->mNumBones);
|
||||||
|
Write<unsigned int>(&chunk,mesh->mMaterialIndex);
|
||||||
|
|
||||||
|
// first of all, write bits for all existent vertex components
|
||||||
|
unsigned int c = 0;
|
||||||
|
if (mesh->mVertices) {
|
||||||
|
c |= ASSBIN_MESH_HAS_POSITIONS;
|
||||||
|
}
|
||||||
|
if (mesh->mNormals) {
|
||||||
|
c |= ASSBIN_MESH_HAS_NORMALS;
|
||||||
|
}
|
||||||
|
if (mesh->mTangents && mesh->mBitangents) {
|
||||||
|
c |= ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS;
|
||||||
|
}
|
||||||
|
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
||||||
|
if (!mesh->mTextureCoords[n]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
c |= ASSBIN_MESH_HAS_TEXCOORD(n);
|
||||||
|
}
|
||||||
|
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
|
||||||
|
if (!mesh->mColors[n]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
c |= ASSBIN_MESH_HAS_COLOR(n);
|
||||||
|
}
|
||||||
|
Write<unsigned int>(&chunk,c);
|
||||||
|
|
||||||
|
aiVector3D minVec, maxVec;
|
||||||
|
if (mesh->mVertices) {
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,mesh->mVertices,mesh->mNumVertices);
|
||||||
|
} // else write as usual
|
||||||
|
else WriteArray<aiVector3D>(&chunk,mesh->mVertices,mesh->mNumVertices);
|
||||||
|
}
|
||||||
|
if (mesh->mNormals) {
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,mesh->mNormals,mesh->mNumVertices);
|
||||||
|
} // else write as usual
|
||||||
|
else WriteArray<aiVector3D>(&chunk,mesh->mNormals,mesh->mNumVertices);
|
||||||
|
}
|
||||||
|
if (mesh->mTangents && mesh->mBitangents) {
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,mesh->mTangents,mesh->mNumVertices);
|
||||||
|
WriteBounds(&chunk,mesh->mBitangents,mesh->mNumVertices);
|
||||||
|
} // else write as usual
|
||||||
|
else {
|
||||||
|
WriteArray<aiVector3D>(&chunk,mesh->mTangents,mesh->mNumVertices);
|
||||||
|
WriteArray<aiVector3D>(&chunk,mesh->mBitangents,mesh->mNumVertices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
|
||||||
|
if (!mesh->mColors[n])
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,mesh->mColors[n],mesh->mNumVertices);
|
||||||
|
} // else write as usual
|
||||||
|
else WriteArray<aiColor4D>(&chunk,mesh->mColors[n],mesh->mNumVertices);
|
||||||
|
}
|
||||||
|
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
||||||
|
if (!mesh->mTextureCoords[n])
|
||||||
|
break;
|
||||||
|
|
||||||
|
// write number of UV components
|
||||||
|
Write<unsigned int>(&chunk,mesh->mNumUVComponents[n]);
|
||||||
|
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices);
|
||||||
|
} // else write as usual
|
||||||
|
else WriteArray<aiVector3D>(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write faces. There are no floating-point calculations involved
|
||||||
|
// in these, so we can write a simple hash over the face data
|
||||||
|
// to the dump file. We generate a single 32 Bit hash for 512 faces
|
||||||
|
// using Assimp's standard hashing function.
|
||||||
|
if (shortened) {
|
||||||
|
unsigned int processed = 0;
|
||||||
|
for (unsigned int job;(job = std::min(mesh->mNumFaces-processed,512u));processed += job) {
|
||||||
|
|
||||||
|
uint32_t hash = 0;
|
||||||
|
for (unsigned int a = 0; a < job;++a) {
|
||||||
|
|
||||||
|
const aiFace& f = mesh->mFaces[processed+a];
|
||||||
|
uint32_t tmp = f.mNumIndices;
|
||||||
|
hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
|
||||||
|
for (unsigned int i = 0; i < f.mNumIndices; ++i) {
|
||||||
|
static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff");
|
||||||
|
tmp = static_cast<uint32_t>( f.mIndices[i] );
|
||||||
|
hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write<unsigned int>(&chunk,hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // else write as usual
|
||||||
|
{
|
||||||
|
// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
|
||||||
|
for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
|
||||||
|
const aiFace& f = mesh->mFaces[i];
|
||||||
|
|
||||||
|
static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff");
|
||||||
|
Write<uint16_t>(&chunk,f.mNumIndices);
|
||||||
|
|
||||||
|
for (unsigned int a = 0; a < f.mNumIndices;++a) {
|
||||||
|
if (mesh->mNumVertices < (1u<<16)) {
|
||||||
|
Write<uint16_t>(&chunk,f.mIndices[a]);
|
||||||
|
}
|
||||||
|
else Write<unsigned int>(&chunk,f.mIndices[a]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// write bones
|
||||||
|
if (mesh->mNumBones) {
|
||||||
|
for (unsigned int a = 0; a < mesh->mNumBones;++a) {
|
||||||
|
const aiBone* b = mesh->mBones[a];
|
||||||
|
WriteBinaryBone(&chunk,b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryMaterialProperty(IOStream * container, const aiMaterialProperty* prop)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIALPROPERTY );
|
||||||
|
|
||||||
|
Write<aiString>(&chunk,prop->mKey);
|
||||||
|
Write<unsigned int>(&chunk,prop->mSemantic);
|
||||||
|
Write<unsigned int>(&chunk,prop->mIndex);
|
||||||
|
|
||||||
|
Write<unsigned int>(&chunk,prop->mDataLength);
|
||||||
|
Write<unsigned int>(&chunk,(unsigned int)prop->mType);
|
||||||
|
chunk.Write(prop->mData,1,prop->mDataLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryMaterial(IOStream * container, const aiMaterial* mat)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIAL);
|
||||||
|
|
||||||
|
Write<unsigned int>(&chunk,mat->mNumProperties);
|
||||||
|
for (unsigned int i = 0; i < mat->mNumProperties;++i) {
|
||||||
|
WriteBinaryMaterialProperty( &chunk, mat->mProperties[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryNodeAnim(IOStream * container, const aiNodeAnim* nd)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODEANIM );
|
||||||
|
|
||||||
|
Write<aiString>(&chunk,nd->mNodeName);
|
||||||
|
Write<unsigned int>(&chunk,nd->mNumPositionKeys);
|
||||||
|
Write<unsigned int>(&chunk,nd->mNumRotationKeys);
|
||||||
|
Write<unsigned int>(&chunk,nd->mNumScalingKeys);
|
||||||
|
Write<unsigned int>(&chunk,nd->mPreState);
|
||||||
|
Write<unsigned int>(&chunk,nd->mPostState);
|
||||||
|
|
||||||
|
if (nd->mPositionKeys) {
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,nd->mPositionKeys,nd->mNumPositionKeys);
|
||||||
|
|
||||||
|
} // else write as usual
|
||||||
|
else WriteArray<aiVectorKey>(&chunk,nd->mPositionKeys,nd->mNumPositionKeys);
|
||||||
|
}
|
||||||
|
if (nd->mRotationKeys) {
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,nd->mRotationKeys,nd->mNumRotationKeys);
|
||||||
|
|
||||||
|
} // else write as usual
|
||||||
|
else WriteArray<aiQuatKey>(&chunk,nd->mRotationKeys,nd->mNumRotationKeys);
|
||||||
|
}
|
||||||
|
if (nd->mScalingKeys) {
|
||||||
|
if (shortened) {
|
||||||
|
WriteBounds(&chunk,nd->mScalingKeys,nd->mNumScalingKeys);
|
||||||
|
|
||||||
|
} // else write as usual
|
||||||
|
else WriteArray<aiVectorKey>(&chunk,nd->mScalingKeys,nd->mNumScalingKeys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryAnim( IOStream * container, const aiAnimation* anim )
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIANIMATION );
|
||||||
|
|
||||||
|
Write<aiString>(&chunk,anim->mName);
|
||||||
|
Write<double>(&chunk,anim->mDuration);
|
||||||
|
Write<double>(&chunk,anim->mTicksPerSecond);
|
||||||
|
Write<unsigned int>(&chunk,anim->mNumChannels);
|
||||||
|
|
||||||
|
for (unsigned int a = 0; a < anim->mNumChannels;++a) {
|
||||||
|
const aiNodeAnim* nd = anim->mChannels[a];
|
||||||
|
WriteBinaryNodeAnim(&chunk,nd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryLight( IOStream * container, const aiLight* l )
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AILIGHT );
|
||||||
|
|
||||||
|
Write<aiString>(&chunk,l->mName);
|
||||||
|
Write<unsigned int>(&chunk,l->mType);
|
||||||
|
|
||||||
|
if (l->mType != aiLightSource_DIRECTIONAL) {
|
||||||
|
Write<float>(&chunk,l->mAttenuationConstant);
|
||||||
|
Write<float>(&chunk,l->mAttenuationLinear);
|
||||||
|
Write<float>(&chunk,l->mAttenuationQuadratic);
|
||||||
|
}
|
||||||
|
|
||||||
|
Write<aiColor3D>(&chunk,l->mColorDiffuse);
|
||||||
|
Write<aiColor3D>(&chunk,l->mColorSpecular);
|
||||||
|
Write<aiColor3D>(&chunk,l->mColorAmbient);
|
||||||
|
|
||||||
|
if (l->mType == aiLightSource_SPOT) {
|
||||||
|
Write<float>(&chunk,l->mAngleInnerCone);
|
||||||
|
Write<float>(&chunk,l->mAngleOuterCone);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryCamera( IOStream * container, const aiCamera* cam )
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AICAMERA );
|
||||||
|
|
||||||
|
Write<aiString>(&chunk,cam->mName);
|
||||||
|
Write<aiVector3D>(&chunk,cam->mPosition);
|
||||||
|
Write<aiVector3D>(&chunk,cam->mLookAt);
|
||||||
|
Write<aiVector3D>(&chunk,cam->mUp);
|
||||||
|
Write<float>(&chunk,cam->mHorizontalFOV);
|
||||||
|
Write<float>(&chunk,cam->mClipPlaneNear);
|
||||||
|
Write<float>(&chunk,cam->mClipPlaneFar);
|
||||||
|
Write<float>(&chunk,cam->mAspect);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
void WriteBinaryScene( IOStream * container, const aiScene* scene)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AISCENE );
|
||||||
|
|
||||||
|
// basic scene information
|
||||||
|
Write<unsigned int>(&chunk,scene->mFlags);
|
||||||
|
Write<unsigned int>(&chunk,scene->mNumMeshes);
|
||||||
|
Write<unsigned int>(&chunk,scene->mNumMaterials);
|
||||||
|
Write<unsigned int>(&chunk,scene->mNumAnimations);
|
||||||
|
Write<unsigned int>(&chunk,scene->mNumTextures);
|
||||||
|
Write<unsigned int>(&chunk,scene->mNumLights);
|
||||||
|
Write<unsigned int>(&chunk,scene->mNumCameras);
|
||||||
|
|
||||||
|
// write node graph
|
||||||
|
WriteBinaryNode( &chunk, scene->mRootNode );
|
||||||
|
|
||||||
|
// write all meshes
|
||||||
|
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||||
|
const aiMesh* mesh = scene->mMeshes[i];
|
||||||
|
WriteBinaryMesh( &chunk,mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write materials
|
||||||
|
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
||||||
|
const aiMaterial* mat = scene->mMaterials[i];
|
||||||
|
WriteBinaryMaterial(&chunk,mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write all animations
|
||||||
|
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
||||||
|
const aiAnimation* anim = scene->mAnimations[i];
|
||||||
|
WriteBinaryAnim(&chunk,anim);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// write all textures
|
||||||
|
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
||||||
|
const aiTexture* mesh = scene->mTextures[i];
|
||||||
|
WriteBinaryTexture(&chunk,mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write lights
|
||||||
|
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
||||||
|
const aiLight* l = scene->mLights[i];
|
||||||
|
WriteBinaryLight(&chunk,l);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write cameras
|
||||||
|
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
||||||
|
const aiCamera* cam = scene->mCameras[i];
|
||||||
|
WriteBinaryCamera(&chunk,cam);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
AssbinFileWriter(bool shortened, bool compressed)
|
||||||
|
: shortened(shortened), compressed(compressed)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Write a binary model dump
|
||||||
|
void WriteBinaryDump(const char* pFile, const char* cmd, IOSystem* pIOSystem, const aiScene* pScene)
|
||||||
|
{
|
||||||
|
IOStream * out = pIOSystem->Open( pFile, "wb" );
|
||||||
|
if (!out)
|
||||||
|
throw std::runtime_error("Unable to open output file " + std::string(pFile) + '\n');
|
||||||
|
|
||||||
|
auto CloseIOStream = [&]() {
|
||||||
|
if (out) {
|
||||||
|
pIOSystem->Close(out);
|
||||||
|
out = nullptr; // Ensure this is only done once.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
time_t tt = time(NULL);
|
||||||
|
#if _WIN32
|
||||||
|
tm* p = gmtime(&tt);
|
||||||
|
#else
|
||||||
|
struct tm now;
|
||||||
|
tm* p = gmtime_r(&tt, &now);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// header
|
||||||
|
char s[64];
|
||||||
|
memset(s, 0, 64);
|
||||||
|
#if _MSC_VER >= 1400
|
||||||
|
sprintf_s(s, "ASSIMP.binary-dump.%s", asctime(p));
|
||||||
|
#else
|
||||||
|
ai_snprintf(s, 64, "ASSIMP.binary-dump.%s", asctime(p));
|
||||||
|
#endif
|
||||||
|
out->Write(s, 44, 1);
|
||||||
|
// == 44 bytes
|
||||||
|
|
||||||
|
Write<unsigned int>(out, ASSBIN_VERSION_MAJOR);
|
||||||
|
Write<unsigned int>(out, ASSBIN_VERSION_MINOR);
|
||||||
|
Write<unsigned int>(out, aiGetVersionRevision());
|
||||||
|
Write<unsigned int>(out, aiGetCompileFlags());
|
||||||
|
Write<uint16_t>(out, shortened);
|
||||||
|
Write<uint16_t>(out, compressed);
|
||||||
|
// == 20 bytes
|
||||||
|
|
||||||
|
char buff[256] = {0};
|
||||||
|
ai_snprintf(buff, 256, "%s", pFile);
|
||||||
|
out->Write(buff, sizeof(char), 256);
|
||||||
|
|
||||||
|
memset(buff, 0, sizeof(buff));
|
||||||
|
ai_snprintf(buff, 128, "%s", cmd);
|
||||||
|
out->Write(buff, sizeof(char), 128);
|
||||||
|
|
||||||
|
// leave 64 bytes free for future extensions
|
||||||
|
memset(buff, 0xcd, 64);
|
||||||
|
out->Write(buff, sizeof(char), 64);
|
||||||
|
// == 435 bytes
|
||||||
|
|
||||||
|
// ==== total header size: 512 bytes
|
||||||
|
ai_assert(out->Tell() == ASSBIN_HEADER_LENGTH);
|
||||||
|
|
||||||
|
// Up to here the data is uncompressed. For compressed files, the rest
|
||||||
|
// is compressed using standard DEFLATE from zlib.
|
||||||
|
if (compressed)
|
||||||
|
{
|
||||||
|
AssbinChunkWriter uncompressedStream(NULL, 0);
|
||||||
|
WriteBinaryScene(&uncompressedStream, pScene);
|
||||||
|
|
||||||
|
uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());
|
||||||
|
uLongf compressedSize = (uLongf)compressBound(uncompressedSize);
|
||||||
|
uint8_t* compressedBuffer = new uint8_t[compressedSize];
|
||||||
|
|
||||||
|
int res = compress2(compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9);
|
||||||
|
if (res != Z_OK)
|
||||||
|
{
|
||||||
|
delete[] compressedBuffer;
|
||||||
|
throw DeadlyExportError("Compression failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
out->Write(&uncompressedSize, sizeof(uint32_t), 1);
|
||||||
|
out->Write(compressedBuffer, sizeof(char), compressedSize);
|
||||||
|
|
||||||
|
delete[] compressedBuffer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteBinaryScene(out, pScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseIOStream();
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
CloseIOStream();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void DumpSceneToAssbin(
|
||||||
|
const char* pFile, const char* cmd, IOSystem* pIOSystem,
|
||||||
|
const aiScene* pScene, bool shortened, bool compressed) {
|
||||||
|
AssbinFileWriter fileWriter(shortened, compressed);
|
||||||
|
fileWriter.WriteBinaryDump(pFile, cmd, pIOSystem, pScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end of namespace Assimp
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, 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 AssbinFileWriter.h
|
||||||
|
* @brief Declaration of Assbin file writer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AI_ASSBINFILEWRITER_H_INC
|
||||||
|
#define AI_ASSBINFILEWRITER_H_INC
|
||||||
|
|
||||||
|
#include <assimp/defs.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/IOSystem.hpp>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
void ASSIMP_API DumpSceneToAssbin(
|
||||||
|
const char* pFile,
|
||||||
|
const char* cmd,
|
||||||
|
IOSystem* pIOSystem,
|
||||||
|
const aiScene* pScene,
|
||||||
|
bool shortened,
|
||||||
|
bool compressed);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // AI_ASSBINFILEWRITER_H_INC
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
|
||||||
|
|
||||||
tex->mWidth = Read<unsigned int>(stream);
|
tex->mWidth = Read<unsigned int>(stream);
|
||||||
tex->mHeight = Read<unsigned int>(stream);
|
tex->mHeight = Read<unsigned int>(stream);
|
||||||
stream->Read( tex->achFormatHint, sizeof(char), 4 );
|
stream->Read( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 );
|
||||||
|
|
||||||
if(!shortened) {
|
if(!shortened) {
|
||||||
if (!tex->mHeight) {
|
if (!tex->mHeight) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -42,7 +42,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
||||||
{
|
{
|
||||||
state_in->result = result;
|
state_in->result = result;
|
||||||
state_in->step = step_A;
|
state_in->step = step_A;
|
||||||
return codechar - code_out;
|
return (int)(codechar - code_out);
|
||||||
}
|
}
|
||||||
fragment = *plainchar++;
|
fragment = *plainchar++;
|
||||||
result = (fragment & 0x0fc) >> 2;
|
result = (fragment & 0x0fc) >> 2;
|
||||||
|
@ -53,7 +53,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
||||||
{
|
{
|
||||||
state_in->result = result;
|
state_in->result = result;
|
||||||
state_in->step = step_B;
|
state_in->step = step_B;
|
||||||
return codechar - code_out;
|
return (int)(codechar - code_out);
|
||||||
}
|
}
|
||||||
fragment = *plainchar++;
|
fragment = *plainchar++;
|
||||||
result |= (fragment & 0x0f0) >> 4;
|
result |= (fragment & 0x0f0) >> 4;
|
||||||
|
@ -64,7 +64,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
||||||
{
|
{
|
||||||
state_in->result = result;
|
state_in->result = result;
|
||||||
state_in->step = step_C;
|
state_in->step = step_C;
|
||||||
return codechar - code_out;
|
return (int)(codechar - code_out);
|
||||||
}
|
}
|
||||||
fragment = *plainchar++;
|
fragment = *plainchar++;
|
||||||
result |= (fragment & 0x0c0) >> 6;
|
result |= (fragment & 0x0c0) >> 6;
|
||||||
|
@ -81,7 +81,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* control should not reach here */
|
/* control should not reach here */
|
||||||
return codechar - code_out;
|
return (int)(codechar - code_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
||||||
|
@ -104,6 +104,6 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
||||||
}
|
}
|
||||||
*codechar++ = '\n';
|
*codechar++ = '\n';
|
||||||
|
|
||||||
return codechar - code_out;
|
return (int)(codechar - code_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2013, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2013, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (ASSIMP)
|
Open Asset Import Library (ASSIMP)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2016, ASSIMP Development Team
|
Copyright (c) 2006-2020, ASSIMP Development Team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (ASSIMP)
|
Open Asset Import Library (ASSIMP)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2016, ASSIMP Development Team
|
Copyright (c) 2006-2020, ASSIMP Development Team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Open Asset Import Library (assimp)
|
# Open Asset Import Library (assimp)
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006-2019, assimp team
|
# Copyright (c) 2006-2020, assimp team
|
||||||
#
|
#
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -66,6 +66,7 @@ SET( PUBLIC_HEADERS
|
||||||
${HEADER_PATH}/color4.h
|
${HEADER_PATH}/color4.h
|
||||||
${HEADER_PATH}/color4.inl
|
${HEADER_PATH}/color4.inl
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../include/assimp/config.h
|
${CMAKE_CURRENT_BINARY_DIR}/../include/assimp/config.h
|
||||||
|
${HEADER_PATH}/commonMetaData.h
|
||||||
${HEADER_PATH}/defs.h
|
${HEADER_PATH}/defs.h
|
||||||
${HEADER_PATH}/Defines.h
|
${HEADER_PATH}/Defines.h
|
||||||
${HEADER_PATH}/cfileio.h
|
${HEADER_PATH}/cfileio.h
|
||||||
|
@ -330,6 +331,8 @@ ADD_ASSIMP_IMPORTER( ASSBIN
|
||||||
ADD_ASSIMP_EXPORTER( ASSBIN
|
ADD_ASSIMP_EXPORTER( ASSBIN
|
||||||
Assbin/AssbinExporter.h
|
Assbin/AssbinExporter.h
|
||||||
Assbin/AssbinExporter.cpp
|
Assbin/AssbinExporter.cpp
|
||||||
|
Assbin/AssbinFileWriter.h
|
||||||
|
Assbin/AssbinFileWriter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_ASSIMP_EXPORTER( ASSXML
|
ADD_ASSIMP_EXPORTER( ASSXML
|
||||||
|
@ -348,6 +351,7 @@ ADD_ASSIMP_IMPORTER( BVH
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_ASSIMP_IMPORTER( COLLADA
|
ADD_ASSIMP_IMPORTER( COLLADA
|
||||||
|
Collada/ColladaHelper.cpp
|
||||||
Collada/ColladaHelper.h
|
Collada/ColladaHelper.h
|
||||||
Collada/ColladaLoader.cpp
|
Collada/ColladaLoader.cpp
|
||||||
Collada/ColladaLoader.h
|
Collada/ColladaLoader.h
|
||||||
|
@ -454,6 +458,16 @@ ADD_ASSIMP_IMPORTER( MDL
|
||||||
MDL/MDLLoader.cpp
|
MDL/MDLLoader.cpp
|
||||||
MDL/MDLLoader.h
|
MDL/MDLLoader.h
|
||||||
MDL/MDLMaterialLoader.cpp
|
MDL/MDLMaterialLoader.cpp
|
||||||
|
MDL/HalfLife/HalfLifeMDLBaseHeader.h
|
||||||
|
MDL/HalfLife/HL1FileData.h
|
||||||
|
MDL/HalfLife/HL1MDLLoader.cpp
|
||||||
|
MDL/HalfLife/HL1MDLLoader.h
|
||||||
|
MDL/HalfLife/HL1ImportDefinitions.h
|
||||||
|
MDL/HalfLife/HL1ImportSettings.h
|
||||||
|
MDL/HalfLife/HL1MeshTrivert.h
|
||||||
|
MDL/HalfLife/LogFunctions.h
|
||||||
|
MDL/HalfLife/UniqueNameGenerator.cpp
|
||||||
|
MDL/HalfLife/UniqueNameGenerator.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( MaterialSystem_SRCS
|
SET( MaterialSystem_SRCS
|
||||||
|
@ -1201,10 +1215,6 @@ SET_TARGET_PROPERTIES( assimp PROPERTIES
|
||||||
)
|
)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
|
||||||
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (BUILD_FRAMEWORK)
|
if (BUILD_FRAMEWORK)
|
||||||
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
||||||
FRAMEWORK TRUE
|
FRAMEWORK TRUE
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
||||||
*ot++ = *buffer++;
|
*ot++ = *buffer++;
|
||||||
|
|
||||||
*ot = '\0';
|
*ot = '\0';
|
||||||
nda->mNodeName.length = (size_t)(ot-nda->mNodeName.data);
|
nda->mNodeName.length = (ai_uint32)(ot-nda->mNodeName.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
|
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "ColladaExporter.h"
|
#include "ColladaExporter.h"
|
||||||
#include <assimp/Bitmap.h>
|
#include <assimp/Bitmap.h>
|
||||||
|
#include <assimp/commonMetaData.h>
|
||||||
#include <assimp/MathFunctions.h>
|
#include <assimp/MathFunctions.h>
|
||||||
#include <assimp/fast_atof.h>
|
#include <assimp/fast_atof.h>
|
||||||
#include <assimp/SceneCombiner.h>
|
#include <assimp/SceneCombiner.h>
|
||||||
|
@ -277,7 +278,7 @@ void ColladaExporter::WriteHeader() {
|
||||||
mOutput << startstr << "<author>" << XMLEscape(value.C_Str()) << "</author>" << endstr;
|
mOutput << startstr << "<author>" << XMLEscape(value.C_Str()) << "</author>" << endstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullptr == meta || !meta->Get("AuthoringTool", value)) {
|
if (nullptr == meta || !meta->Get(AI_METADATA_SOURCE_GENERATOR, value)) {
|
||||||
mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr;
|
mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr;
|
||||||
} else {
|
} else {
|
||||||
mOutput << startstr << "<authoring_tool>" << XMLEscape(value.C_Str()) << "</authoring_tool>" << endstr;
|
mOutput << startstr << "<authoring_tool>" << XMLEscape(value.C_Str()) << "</authoring_tool>" << endstr;
|
||||||
|
@ -287,7 +288,7 @@ void ColladaExporter::WriteHeader() {
|
||||||
if (meta->Get("Comments", value)) {
|
if (meta->Get("Comments", value)) {
|
||||||
mOutput << startstr << "<comments>" << XMLEscape(value.C_Str()) << "</comments>" << endstr;
|
mOutput << startstr << "<comments>" << XMLEscape(value.C_Str()) << "</comments>" << endstr;
|
||||||
}
|
}
|
||||||
if (meta->Get("Copyright", value)) {
|
if (meta->Get(AI_METADATA_SOURCE_COPYRIGHT, value)) {
|
||||||
mOutput << startstr << "<copyright>" << XMLEscape(value.C_Str()) << "</copyright>" << endstr;
|
mOutput << startstr << "<copyright>" << XMLEscape(value.C_Str()) << "</copyright>" << endstr;
|
||||||
}
|
}
|
||||||
if (meta->Get("SourceData", value)) {
|
if (meta->Get("SourceData", value)) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
/** Helper structures for the Collada loader */
|
||||||
|
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, 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.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ColladaHelper.h"
|
||||||
|
|
||||||
|
#include <assimp/commonMetaData.h>
|
||||||
|
#include <assimp/ParsingUtils.h>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
namespace Collada {
|
||||||
|
|
||||||
|
const MetaKeyPairVector MakeColladaAssimpMetaKeys() {
|
||||||
|
MetaKeyPairVector result;
|
||||||
|
result.emplace_back("authoring_tool", AI_METADATA_SOURCE_GENERATOR);
|
||||||
|
result.emplace_back("copyright", AI_METADATA_SOURCE_COPYRIGHT);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const MetaKeyPairVector &GetColladaAssimpMetaKeys() {
|
||||||
|
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MetaKeyPairVector MakeColladaAssimpMetaKeysCamelCase() {
|
||||||
|
MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
|
||||||
|
for (auto &val : result)
|
||||||
|
{
|
||||||
|
ToCamelCase(val.first);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase()
|
||||||
|
{
|
||||||
|
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeysCamelCase();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Convert underscore_separated to CamelCase: "authoring_tool" becomes "AuthoringTool"
|
||||||
|
void ToCamelCase(std::string &text)
|
||||||
|
{
|
||||||
|
if (text.empty())
|
||||||
|
return;
|
||||||
|
// Capitalise first character
|
||||||
|
auto it = text.begin();
|
||||||
|
(*it) = ToUpper(*it);
|
||||||
|
++it;
|
||||||
|
for (/*started above*/ ; it != text.end(); /*iterated below*/)
|
||||||
|
{
|
||||||
|
if ((*it) == '_')
|
||||||
|
{
|
||||||
|
it = text.erase(it);
|
||||||
|
if (it != text.end())
|
||||||
|
(*it) = ToUpper(*it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Make lower case
|
||||||
|
(*it) = ToLower(*it);
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Collada
|
||||||
|
} // namespace Assimp
|
|
@ -4,7 +4,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <assimp/light.h>
|
#include <assimp/light.h>
|
||||||
#include <assimp/mesh.h>
|
#include <assimp/mesh.h>
|
||||||
|
@ -104,6 +105,17 @@ enum MorphMethod
|
||||||
Relative
|
Relative
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Common metadata keys as <Collada, Assimp> */
|
||||||
|
typedef std::pair<std::string, std::string> MetaKeyPair;
|
||||||
|
typedef std::vector<MetaKeyPair> MetaKeyPairVector;
|
||||||
|
|
||||||
|
// Collada as lower_case (native)
|
||||||
|
const MetaKeyPairVector &GetColladaAssimpMetaKeys();
|
||||||
|
// Collada as CamelCase (used by Assimp for consistency)
|
||||||
|
const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase();
|
||||||
|
|
||||||
|
/** Convert underscore_separated to CamelCase "authoring_tool" becomes "AuthoringTool" */
|
||||||
|
void ToCamelCase(std::string &text);
|
||||||
|
|
||||||
/** Contains all data for one of the different transformation types */
|
/** Contains all data for one of the different transformation types */
|
||||||
struct Transform
|
struct Transform
|
||||||
|
@ -647,23 +659,37 @@ struct Animation
|
||||||
|
|
||||||
void CombineSingleChannelAnimationsRecursively(Animation *pParent)
|
void CombineSingleChannelAnimationsRecursively(Animation *pParent)
|
||||||
{
|
{
|
||||||
|
std::set<std::string> childrenTargets;
|
||||||
|
bool childrenAnimationsHaveDifferentChannels = true;
|
||||||
|
|
||||||
for (std::vector<Animation*>::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();)
|
for (std::vector<Animation*>::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();)
|
||||||
{
|
{
|
||||||
Animation *anim = *it;
|
Animation *anim = *it;
|
||||||
|
|
||||||
CombineSingleChannelAnimationsRecursively(anim);
|
CombineSingleChannelAnimationsRecursively(anim);
|
||||||
|
|
||||||
if (anim->mChannels.size() == 1)
|
if (childrenAnimationsHaveDifferentChannels && anim->mChannels.size() == 1 &&
|
||||||
|
childrenTargets.find(anim->mChannels[0].mTarget) == childrenTargets.end()) {
|
||||||
|
childrenTargets.insert(anim->mChannels[0].mTarget);
|
||||||
|
} else {
|
||||||
|
childrenAnimationsHaveDifferentChannels = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We only want to combine animations if they have different channels
|
||||||
|
if (childrenAnimationsHaveDifferentChannels)
|
||||||
|
{
|
||||||
|
for (std::vector<Animation*>::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();)
|
||||||
{
|
{
|
||||||
|
Animation *anim = *it;
|
||||||
|
|
||||||
pParent->mChannels.push_back(anim->mChannels[0]);
|
pParent->mChannels.push_back(anim->mChannels[0]);
|
||||||
|
|
||||||
it = pParent->mSubAnims.erase(it);
|
it = pParent->mSubAnims.erase(it);
|
||||||
|
|
||||||
delete anim;
|
delete anim;
|
||||||
}
|
continue;
|
||||||
else
|
|
||||||
{
|
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -963,18 +963,38 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
|
||||||
|
|
||||||
// catch special case: many animations with the same length, each affecting only a single node.
|
// catch special case: many animations with the same length, each affecting only a single node.
|
||||||
// we need to unite all those single-node-anims to a proper combined animation
|
// we need to unite all those single-node-anims to a proper combined animation
|
||||||
for( size_t a = 0; a < mAnims.size(); ++a) {
|
for(size_t a = 0; a < mAnims.size(); ++a) {
|
||||||
aiAnimation* templateAnim = mAnims[a];
|
aiAnimation* templateAnim = mAnims[a];
|
||||||
if( templateAnim->mNumChannels == 1) {
|
|
||||||
|
if (templateAnim->mNumChannels == 1) {
|
||||||
// search for other single-channel-anims with the same duration
|
// search for other single-channel-anims with the same duration
|
||||||
std::vector<size_t> collectedAnimIndices;
|
std::vector<size_t> collectedAnimIndices;
|
||||||
for( size_t b = a+1; b < mAnims.size(); ++b) {
|
for( size_t b = a+1; b < mAnims.size(); ++b) {
|
||||||
aiAnimation* other = mAnims[b];
|
aiAnimation* other = mAnims[b];
|
||||||
if (other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration &&
|
if (other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration &&
|
||||||
other->mTicksPerSecond == templateAnim->mTicksPerSecond)
|
other->mTicksPerSecond == templateAnim->mTicksPerSecond)
|
||||||
collectedAnimIndices.push_back(b);
|
collectedAnimIndices.push_back(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We only want to combine the animations if they have different channels
|
||||||
|
std::set<std::string> animTargets;
|
||||||
|
animTargets.insert(templateAnim->mChannels[0]->mNodeName.C_Str());
|
||||||
|
bool collectedAnimationsHaveDifferentChannels = true;
|
||||||
|
for (size_t b = 0; b < collectedAnimIndices.size(); ++b)
|
||||||
|
{
|
||||||
|
aiAnimation* srcAnimation = mAnims[collectedAnimIndices[b]];
|
||||||
|
std::string channelName = std::string(srcAnimation->mChannels[0]->mNodeName.C_Str());
|
||||||
|
if (animTargets.find(channelName) == animTargets.end()) {
|
||||||
|
animTargets.insert(channelName);
|
||||||
|
} else {
|
||||||
|
collectedAnimationsHaveDifferentChannels = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!collectedAnimationsHaveDifferentChannels)
|
||||||
|
continue;
|
||||||
|
|
||||||
// if there are other animations which fit the template anim, combine all channels into a single anim
|
// if there are other animations which fit the template anim, combine all channels into a single anim
|
||||||
if (!collectedAnimIndices.empty())
|
if (!collectedAnimIndices.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "ColladaParser.h"
|
#include "ColladaParser.h"
|
||||||
|
#include <assimp/commonMetaData.h>
|
||||||
#include <assimp/fast_atof.h>
|
#include <assimp/fast_atof.h>
|
||||||
#include <assimp/ParsingUtils.h>
|
#include <assimp/ParsingUtils.h>
|
||||||
#include <assimp/StringUtils.h>
|
#include <assimp/StringUtils.h>
|
||||||
|
@ -249,6 +250,9 @@ void ColladaParser::UriDecodePath(aiString& ss)
|
||||||
bool ColladaParser::ReadBoolFromTextContent()
|
bool ColladaParser::ReadBoolFromTextContent()
|
||||||
{
|
{
|
||||||
const char* cur = GetTextContent();
|
const char* cur = GetTextContent();
|
||||||
|
if ( nullptr == cur) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur);
|
return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +261,9 @@ bool ColladaParser::ReadBoolFromTextContent()
|
||||||
ai_real ColladaParser::ReadFloatFromTextContent()
|
ai_real ColladaParser::ReadFloatFromTextContent()
|
||||||
{
|
{
|
||||||
const char* cur = GetTextContent();
|
const char* cur = GetTextContent();
|
||||||
|
if ( nullptr == cur ) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
return fast_atof(cur);
|
return fast_atof(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,6 +283,11 @@ void ColladaParser::ReadContents()
|
||||||
if (attrib != -1) {
|
if (attrib != -1) {
|
||||||
const char* version = mReader->getAttributeValue(attrib);
|
const char* version = mReader->getAttributeValue(attrib);
|
||||||
|
|
||||||
|
// Store declared format version string
|
||||||
|
aiString v;
|
||||||
|
v.Set(version);
|
||||||
|
mAssetMetaData.emplace(AI_METADATA_SOURCE_FORMAT_VERSION, v );
|
||||||
|
|
||||||
if (!::strncmp(version, "1.5", 3)) {
|
if (!::strncmp(version, "1.5", 3)) {
|
||||||
mFormat = FV_1_5_n;
|
mFormat = FV_1_5_n;
|
||||||
ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n");
|
ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n");
|
||||||
|
@ -434,23 +446,39 @@ void ColladaParser::ReadContributorInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVector &key_renaming, size_t &found_index) {
|
||||||
|
for (size_t i = 0; i < key_renaming.size(); ++i) {
|
||||||
|
if (key_renaming[i].first == collada_key) {
|
||||||
|
found_index = i;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
found_index = std::numeric_limits<size_t>::max();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Reads a single string metadata item
|
// Reads a single string metadata item
|
||||||
void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
void ColladaParser::ReadMetaDataItem(StringMetaData &metadata) {
|
||||||
{
|
const Collada::MetaKeyPairVector &key_renaming = GetColladaAssimpMetaKeysCamelCase();
|
||||||
// Metadata such as created, keywords, subject etc
|
// Metadata such as created, keywords, subject etc
|
||||||
const char* key_char = mReader->getNodeName();
|
const char *key_char = mReader->getNodeName();
|
||||||
if (key_char != nullptr)
|
if (key_char != nullptr) {
|
||||||
{
|
|
||||||
const std::string key_str(key_char);
|
const std::string key_str(key_char);
|
||||||
const char* value_char = TestTextContent();
|
const char *value_char = TestTextContent();
|
||||||
if (value_char != nullptr)
|
if (value_char != nullptr) {
|
||||||
{
|
|
||||||
std::string camel_key_str = key_str;
|
|
||||||
ToCamelCase(camel_key_str);
|
|
||||||
aiString aistr;
|
aiString aistr;
|
||||||
aistr.Set(value_char);
|
aistr.Set(value_char);
|
||||||
metadata.emplace(camel_key_str, aistr);
|
|
||||||
|
std::string camel_key_str(key_str);
|
||||||
|
ToCamelCase(camel_key_str);
|
||||||
|
|
||||||
|
size_t found_index;
|
||||||
|
if (FindCommonKey(camel_key_str, key_renaming, found_index)) {
|
||||||
|
metadata.emplace(key_renaming[found_index].second, aistr);
|
||||||
|
} else {
|
||||||
|
metadata.emplace(camel_key_str, aistr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TestClosing(key_str.c_str());
|
TestClosing(key_str.c_str());
|
||||||
}
|
}
|
||||||
|
@ -458,27 +486,6 @@ void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
||||||
SkipElement();
|
SkipElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Convert underscore_seperated to CamelCase: "authoring_tool" becomes "AuthoringTool"
|
|
||||||
void ColladaParser::ToCamelCase(std::string &text)
|
|
||||||
{
|
|
||||||
if (text.empty())
|
|
||||||
return;
|
|
||||||
// Capitalise first character
|
|
||||||
text[0] = ToUpper(text[0]);
|
|
||||||
for (auto it = text.begin(); it != text.end(); /*iterated below*/)
|
|
||||||
{
|
|
||||||
if ((*it) == '_')
|
|
||||||
{
|
|
||||||
it = text.erase(it);
|
|
||||||
if (it != text.end())
|
|
||||||
(*it) = ToUpper(*it);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Reads the animation clips
|
// Reads the animation clips
|
||||||
void ColladaParser::ReadAnimationClipLibrary()
|
void ColladaParser::ReadAnimationClipLibrary()
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -94,12 +94,9 @@ namespace Assimp
|
||||||
/** Reads contributor information such as author and legal blah */
|
/** Reads contributor information such as author and legal blah */
|
||||||
void ReadContributorInfo();
|
void ReadContributorInfo();
|
||||||
|
|
||||||
/** Reads generic metadata into provided map */
|
/** Reads generic metadata into provided map and renames keys for Assimp */
|
||||||
void ReadMetaDataItem(StringMetaData &metadata);
|
void ReadMetaDataItem(StringMetaData &metadata);
|
||||||
|
|
||||||
/** Convert underscore_seperated to CamelCase "authoring_tool" becomes "AuthoringTool" */
|
|
||||||
static void ToCamelCase(std::string &text);
|
|
||||||
|
|
||||||
/** Reads the animation library */
|
/** Reads the animation library */
|
||||||
void ReadAnimationLibrary();
|
void ReadAnimationLibrary();
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (C) 2016 The Qt Company Ltd.
|
Copyright (C) 2016 The Qt Company Ltd.
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2008, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2019, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue