Merge branch 'master' of https://github.com/assimp/assimp
commit
1a2c69fda8
12
CHANGES
12
CHANGES
|
@ -1,6 +1,18 @@
|
|||
----------------------------------------------------------------------
|
||||
CHANGELOG
|
||||
----------------------------------------------------------------------
|
||||
4.0.1 (2017-07-28)
|
||||
- FIXES/HOUSEKEEPING:
|
||||
- fix version test.
|
||||
- Not compiling when using ASSIMP_DOUBLE_PRECISION
|
||||
- Added support for python3
|
||||
- Check if cmake is installed with brew
|
||||
- Low performance in OptimizeMeshesProcess::ProcessNode with huge numbers of meshes
|
||||
- Elapsed seconds not shown correctly
|
||||
- StreamReader: fix out-of-range exception
|
||||
- PPdPmdParser: fix compilation for clang
|
||||
|
||||
|
||||
4.0.0 (2017-07-18)
|
||||
|
||||
FEATURES:
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#----------------------------------------------------------------------
|
||||
SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
|
||||
cmake_minimum_required( VERSION 2.8 )
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
|
||||
PROJECT( Assimp )
|
||||
|
||||
# All supported options ###############################################
|
||||
|
@ -62,11 +62,11 @@ OPTION( ASSIMP_BUILD_ZLIB
|
|||
"Build your own zlib"
|
||||
OFF
|
||||
)
|
||||
option( ASSIMP_BUILD_ASSIMP_TOOLS
|
||||
OPTION( ASSIMP_BUILD_ASSIMP_TOOLS
|
||||
"If the supplementary tools for Assimp are built in addition to the library."
|
||||
ON
|
||||
)
|
||||
option ( ASSIMP_BUILD_SAMPLES
|
||||
OPTION ( ASSIMP_BUILD_SAMPLES
|
||||
"If the official samples are built as well (needs Glut)."
|
||||
OFF
|
||||
)
|
||||
|
@ -75,10 +75,10 @@ OPTION ( ASSIMP_BUILD_TESTS
|
|||
ON
|
||||
)
|
||||
OPTION ( ASSIMP_COVERALLS
|
||||
"Eańable this to measure test coverage."
|
||||
"Enable this to measure test coverage."
|
||||
OFF
|
||||
)
|
||||
option ( SYSTEM_IRRXML
|
||||
OPTION ( SYSTEM_IRRXML
|
||||
"Use system installed Irrlicht/IrrXML library."
|
||||
OFF
|
||||
)
|
||||
|
@ -88,11 +88,11 @@ OPTION ( BUILD_DOCS
|
|||
)
|
||||
|
||||
if (WIN32)
|
||||
add_definitions( -DWIN32_LEAN_AND_MEAN )
|
||||
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
|
||||
endif()
|
||||
|
||||
IF(MSVC)
|
||||
set (CMAKE_PREFIX_PATH "D:\\libs\\devil")
|
||||
SET (CMAKE_PREFIX_PATH "D:\\libs\\devil")
|
||||
OPTION( ASSIMP_INSTALL_PDB
|
||||
"Install MSVC debug files."
|
||||
ON
|
||||
|
@ -106,15 +106,15 @@ ENDIF(NOT BUILD_SHARED_LIBS)
|
|||
# Define here the needed parameters
|
||||
SET (ASSIMP_VERSION_MAJOR 4)
|
||||
SET (ASSIMP_VERSION_MINOR 0)
|
||||
SET (ASSIMP_VERSION_PATCH 0) # subversion revision?
|
||||
SET (ASSIMP_VERSION_PATCH 1)
|
||||
SET (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH})
|
||||
SET (ASSIMP_SOVERSION 4)
|
||||
SET (PROJECT_VERSION "${ASSIMP_VERSION}")
|
||||
|
||||
SET(ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources")
|
||||
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
|
||||
|
||||
# Needed for openddl_parser config, no use of c++11 at this moment
|
||||
add_definitions( -DOPENDDL_NO_USE_CPP11 )
|
||||
ADD_DEFINITIONS( -DOPENDDL_NO_USE_CPP11 )
|
||||
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
||||
|
||||
# Get the current working branch
|
||||
|
@ -146,22 +146,23 @@ ENDIF(ASSIMP_DOUBLE_PRECISION)
|
|||
# Check for OpenMP support
|
||||
find_package(OpenMP)
|
||||
if (OPENMP_FOUND)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_CURRENT_LIST_DIR}/revision.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/revision.h
|
||||
)
|
||||
|
||||
configure_file(
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/assimp/config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/assimp/config.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
INCLUDE_DIRECTORIES(
|
||||
./
|
||||
include
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
)
|
||||
|
@ -179,7 +180,7 @@ IF( UNIX )
|
|||
ENDIF()
|
||||
|
||||
# Use GNUInstallDirs for Unix predefined directories
|
||||
include(GNUInstallDirs)
|
||||
INCLUDE(GNUInstallDirs)
|
||||
ENDIF( UNIX )
|
||||
|
||||
|
||||
|
@ -193,20 +194,18 @@ ELSEIF(MSVC)
|
|||
# enable multi-core compilation with MSVC
|
||||
add_compile_options(/MP)
|
||||
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fvisibility=hidden -fPIC -Wall -Wno-long-long -pedantic -std=c++11" )
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fvisibility=hidden -fPIC -Wall -Wno-long-long -pedantic -std=c++11" )
|
||||
ELSEIF( CMAKE_COMPILER_IS_MINGW )
|
||||
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wno-long-long -pedantic -std=c++11" )
|
||||
add_definitions( -U__STRICT_ANSI__ )
|
||||
ADD_DEFINITIONS( -U__STRICT_ANSI__ )
|
||||
ENDIF()
|
||||
|
||||
if (ASSIMP_COVERALLS)
|
||||
include(Coveralls)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
INCLUDE(Coveralls)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
||||
INCLUDE_DIRECTORIES( include )
|
||||
|
||||
INCLUDE (FindPkgMacros)
|
||||
INCLUDE (PrecompiledHeader)
|
||||
|
||||
|
@ -237,13 +236,13 @@ ENDIF()
|
|||
# Only generate this target if no higher-level project already has
|
||||
IF (NOT TARGET uninstall)
|
||||
# add make uninstall capability
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
ENDIF()
|
||||
|
||||
# cmake configuration files
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||
|
||||
FIND_PACKAGE( DirectX )
|
||||
|
@ -265,9 +264,9 @@ ENDIF( NOT ASSIMP_BUILD_ZLIB )
|
|||
|
||||
IF( NOT ZLIB_FOUND )
|
||||
message(STATUS "compiling zlib from souces")
|
||||
include(CheckIncludeFile)
|
||||
include(CheckTypeSize)
|
||||
include(CheckFunctionExists)
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckTypeSize)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
# compile from sources
|
||||
add_subdirectory(contrib/zlib)
|
||||
SET(ZLIB_FOUND 1)
|
||||
|
@ -472,13 +471,25 @@ if(WIN32)
|
|||
|
||||
if(MSVC12 OR MSVC14)
|
||||
add_custom_target(UpdateAssimpLibsDebugSymbolsAndDLLs COMMENT "Copying Assimp Libraries ..." VERBATIM)
|
||||
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
IF(CMAKE_GENERATOR MATCHES "^Visual Studio")
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ELSE()
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ENDIF()
|
||||
ENDIF(MSVC12 OR MSVC14)
|
||||
ENDIF (WIN32)
|
||||
|
|
78
Readme.md
78
Readme.md
|
@ -1,5 +1,6 @@
|
|||
Open Asset Import Library (assimp)
|
||||
==================================
|
||||
A library to import and export various 3d-model-formats including scene-post-processing to generate missing render data.
|
||||
### Current build status ###
|
||||
[![Linux Build Status](https://travis-ci.org/assimp/assimp.svg)](https://travis-ci.org/assimp/assimp)
|
||||
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp)
|
||||
|
@ -29,46 +30,62 @@ Please check our Wiki as well: https://github.com/assimp/assimp/wiki
|
|||
|
||||
A full list [is here](http://assimp.org/main_features_formats.html).
|
||||
__Importers__:
|
||||
|
||||
- 3D
|
||||
- 3DS
|
||||
- BLEND (Blender)
|
||||
- DAE/Collada
|
||||
- FBX
|
||||
- IFC-STEP
|
||||
- 3MF
|
||||
- AC
|
||||
- AC3D
|
||||
- ACC
|
||||
- AMJ
|
||||
- ASE
|
||||
- ASK
|
||||
- B3D;
|
||||
- BLEND (Blender)
|
||||
- BVH
|
||||
- COB
|
||||
- CMS
|
||||
- DAE/Collada
|
||||
- DXF
|
||||
- HMP
|
||||
- ENFF
|
||||
- FBX
|
||||
- GLB/GLTF
|
||||
- HMB
|
||||
- IFC-STEP
|
||||
- IRR / IRRMESH
|
||||
- LWO
|
||||
- LWS
|
||||
- LXO
|
||||
- MD2
|
||||
- MD3
|
||||
- MD5
|
||||
- MDC
|
||||
- MDL
|
||||
- NFF
|
||||
- PLY
|
||||
- STL
|
||||
- X
|
||||
- OBJ
|
||||
- OpenGEX
|
||||
- SMD
|
||||
- LWO
|
||||
- LXO
|
||||
- LWS
|
||||
- TER
|
||||
- AC3D
|
||||
- MESH / MESH.XML
|
||||
- MOT
|
||||
- MS3D
|
||||
- COB
|
||||
- Q3BSP
|
||||
- XGL
|
||||
- CSM
|
||||
- BVH
|
||||
- B3D
|
||||
- NDO
|
||||
- Ogre Binary
|
||||
- Ogre XML
|
||||
- Q3D
|
||||
- ASSBIN (Assimp custom format)
|
||||
- glTF (partial)
|
||||
- 3MF
|
||||
- NFF
|
||||
- OBJ
|
||||
- OFF
|
||||
- OGEX
|
||||
- PLY
|
||||
- PMX
|
||||
- PRJ
|
||||
- Q3O
|
||||
- Q3S
|
||||
- RAW
|
||||
- SCN
|
||||
- SIB
|
||||
- SMD
|
||||
- STL
|
||||
- STP
|
||||
- TER
|
||||
- UC
|
||||
- VTA
|
||||
- X
|
||||
- X3D
|
||||
- XGL
|
||||
- ZGL
|
||||
|
||||
Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default):
|
||||
|
||||
|
@ -86,6 +103,7 @@ __Exporters__:
|
|||
- ASSBIN
|
||||
- STEP
|
||||
- glTF (partial)
|
||||
- glTF2.0
|
||||
|
||||
### Building ###
|
||||
Take a look into the `INSTALL` file. Our build system is CMake, if you used CMake before there is a good chance you know what to do.
|
||||
|
|
|
@ -661,6 +661,12 @@ ADD_ASSIMP_IMPORTER( GLTF
|
|||
glTFImporter.h
|
||||
glTFExporter.h
|
||||
glTFExporter.cpp
|
||||
glTF2Asset.h
|
||||
glTF2Asset.inl
|
||||
glTF2AssetWriter.h
|
||||
glTF2AssetWriter.inl
|
||||
glTF2Exporter.h
|
||||
glTF2Exporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( 3MF
|
||||
|
@ -934,6 +940,7 @@ if (ASSIMP_ANDROID_JNIIOSYSTEM)
|
|||
endif(ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
|
||||
if(MSVC AND ASSIMP_INSTALL_PDB)
|
||||
IF(CMAKE_GENERATOR MATCHES "^Visual Studio")
|
||||
install(FILES ${Assimp_BINARY_DIR}/code/Debug/assimp${LIBRARY_SUFFIX}${CMAKE_DEBUG_POSTFIX}.pdb
|
||||
DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
CONFIGURATIONS Debug
|
||||
|
@ -942,6 +949,16 @@ if(MSVC AND ASSIMP_INSTALL_PDB)
|
|||
DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
CONFIGURATIONS RelWithDebInfo
|
||||
)
|
||||
ELSE()
|
||||
install(FILES ${Assimp_BINARY_DIR}/code/assimp${LIBRARY_SUFFIX}${CMAKE_DEBUG_POSTFIX}.pdb
|
||||
DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
CONFIGURATIONS Debug
|
||||
)
|
||||
install(FILES ${Assimp_BINARY_DIR}/code/assimp${LIBRARY_SUFFIX}.pdb
|
||||
DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
CONFIGURATIONS RelWithDebInfo
|
||||
)
|
||||
ENDIF()
|
||||
endif ()
|
||||
|
||||
if (ASSIMP_COVERALLS)
|
||||
|
|
|
@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/ai_assert.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
|
|
@ -90,6 +90,7 @@ void ExportScenePlyBinary(const char*, IOSystem*, const aiScene*, const ExportPr
|
|||
void ExportScene3DS(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneGLTF(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneGLB(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneGLTF2(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneAssbin(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneAssxml(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneX3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
|
@ -144,6 +145,8 @@ Exporter::ExportFormatEntry gExporters[] =
|
|||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType),
|
||||
Exporter::ExportFormatEntry( "glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType),
|
||||
Exporter::ExportFormatEntry( "gltf2", "GL Transmission Format v. 2", "gltf", &ExportSceneGLTF2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||
|
|
|
@ -45,6 +45,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||
|
||||
// Workaround for issue #1361
|
||||
// https://github.com/assimp/assimp/issues/1361
|
||||
#ifdef __ANDROID__
|
||||
#define _GLIBCXX_USE_C99 1
|
||||
#endif
|
||||
|
||||
#include "FIReader.hpp"
|
||||
#include "Exceptional.h"
|
||||
#include <assimp/IOStream.hpp>
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace pmd
|
|||
sphere_filename.clear();
|
||||
}
|
||||
else {
|
||||
*pstar = (char)NULL;
|
||||
*pstar = 0;
|
||||
texture_filename = std::string(buffer);
|
||||
sphere_filename = std::string(pstar+1);
|
||||
}
|
||||
|
|
|
@ -299,8 +299,7 @@ void PLYImporter::InternReadFile(const std::string& pFile,
|
|||
}
|
||||
}
|
||||
|
||||
void PLYImporter::LoadVertex(const PLY::Element* pcElement, const PLY::ElementInstance* instElement, unsigned int pos)
|
||||
{
|
||||
void PLYImporter::LoadVertex(const PLY::Element* pcElement, const PLY::ElementInstance* instElement, unsigned int pos) {
|
||||
ai_assert(NULL != pcElement);
|
||||
ai_assert(NULL != instElement);
|
||||
|
||||
|
@ -316,113 +315,84 @@ void PLYImporter::LoadVertex(const PLY::Element* pcElement, const PLY::ElementIn
|
|||
unsigned int aiTexcoord[2] = { 0xFFFFFFFF, 0xFFFFFFFF };
|
||||
PLY::EDataType aiTexcoordTypes[2] = { EDT_Char, EDT_Char };
|
||||
|
||||
unsigned int cnt = 0;
|
||||
|
||||
// now check whether which normal components are available
|
||||
unsigned int _a = 0;
|
||||
for (std::vector<PLY::Property>::const_iterator a = pcElement->alProperties.begin();
|
||||
a != pcElement->alProperties.end(); ++a, ++_a)
|
||||
{
|
||||
if ((*a).bIsList)continue;
|
||||
unsigned int _a( 0 ), cnt( 0 );
|
||||
for ( std::vector<PLY::Property>::const_iterator a = pcElement->alProperties.begin();
|
||||
a != pcElement->alProperties.end(); ++a, ++_a) {
|
||||
if ((*a).bIsList) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Positions
|
||||
if (PLY::EST_XCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
if (PLY::EST_XCoord == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiPositions[0] = _a;
|
||||
aiTypes[0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_YCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
} else if (PLY::EST_YCoord == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiPositions[1] = _a;
|
||||
aiTypes[1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_ZCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
} else if (PLY::EST_ZCoord == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiPositions[2] = _a;
|
||||
aiTypes[2] = (*a).eType;
|
||||
}
|
||||
|
||||
} else if (PLY::EST_XNormal == (*a).Semantic) {
|
||||
// Normals
|
||||
else if (PLY::EST_XNormal == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
++cnt;
|
||||
aiNormal[0] = _a;
|
||||
aiNormalTypes[0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_YNormal == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
} else if (PLY::EST_YNormal == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiNormal[1] = _a;
|
||||
aiNormalTypes[1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_ZNormal == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
} else if (PLY::EST_ZNormal == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiNormal[2] = _a;
|
||||
aiNormalTypes[2] = (*a).eType;
|
||||
}
|
||||
} else if (PLY::EST_Red == (*a).Semantic) {
|
||||
// Colors
|
||||
else if (PLY::EST_Red == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
++cnt;
|
||||
aiColors[0] = _a;
|
||||
aiColorsTypes[0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_Green == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
} else if (PLY::EST_Green == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiColors[1] = _a;
|
||||
aiColorsTypes[1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_Blue == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
} else if (PLY::EST_Blue == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiColors[2] = _a;
|
||||
aiColorsTypes[2] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_Alpha == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
} else if (PLY::EST_Alpha == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiColors[3] = _a;
|
||||
aiColorsTypes[3] = (*a).eType;
|
||||
}
|
||||
} else if (PLY::EST_UTextureCoord == (*a).Semantic) {
|
||||
// Texture coordinates
|
||||
else if (PLY::EST_UTextureCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
++cnt;
|
||||
aiTexcoord[0] = _a;
|
||||
aiTexcoordTypes[0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_VTextureCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
} else if (PLY::EST_VTextureCoord == (*a).Semantic) {
|
||||
++cnt;
|
||||
aiTexcoord[1] = _a;
|
||||
aiTexcoordTypes[1] = (*a).eType;
|
||||
}
|
||||
}
|
||||
|
||||
// check whether we have a valid source for the vertex data
|
||||
if (0 != cnt)
|
||||
{
|
||||
if (0 != cnt) {
|
||||
// Position
|
||||
aiVector3D vOut;
|
||||
if (0xFFFFFFFF != aiPositions[0])
|
||||
{
|
||||
if (0xFFFFFFFF != aiPositions[0]) {
|
||||
vOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||
GetProperty(instElement->alProperties, aiPositions[0]).avList.front(), aiTypes[0]);
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiPositions[1])
|
||||
{
|
||||
if (0xFFFFFFFF != aiPositions[1]) {
|
||||
vOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||
GetProperty(instElement->alProperties, aiPositions[1]).avList.front(), aiTypes[1]);
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiPositions[2])
|
||||
{
|
||||
if (0xFFFFFFFF != aiPositions[2]) {
|
||||
vOut.z = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||
GetProperty(instElement->alProperties, aiPositions[2]).avList.front(), aiTypes[2]);
|
||||
}
|
||||
|
@ -430,22 +400,19 @@ void PLYImporter::LoadVertex(const PLY::Element* pcElement, const PLY::ElementIn
|
|||
// Normals
|
||||
aiVector3D nOut;
|
||||
bool haveNormal = false;
|
||||
if (0xFFFFFFFF != aiNormal[0])
|
||||
{
|
||||
if (0xFFFFFFFF != aiNormal[0]) {
|
||||
nOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||
GetProperty(instElement->alProperties, aiNormal[0]).avList.front(), aiNormalTypes[0]);
|
||||
haveNormal = true;
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiNormal[1])
|
||||
{
|
||||
if (0xFFFFFFFF != aiNormal[1]) {
|
||||
nOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||
GetProperty(instElement->alProperties, aiNormal[1]).avList.front(), aiNormalTypes[1]);
|
||||
haveNormal = true;
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiNormal[2])
|
||||
{
|
||||
if (0xFFFFFFFF != aiNormal[2]) {
|
||||
nOut.z = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||
GetProperty(instElement->alProperties, aiNormal[2]).avList.front(), aiNormalTypes[2]);
|
||||
haveNormal = true;
|
||||
|
@ -454,34 +421,28 @@ void PLYImporter::LoadVertex(const PLY::Element* pcElement, const PLY::ElementIn
|
|||
//Colors
|
||||
aiColor4D cOut;
|
||||
bool haveColor = false;
|
||||
if (0xFFFFFFFF != aiColors[0])
|
||||
{
|
||||
if (0xFFFFFFFF != aiColors[0]) {
|
||||
cOut.r = NormalizeColorValue(GetProperty(instElement->alProperties,
|
||||
aiColors[0]).avList.front(), aiColorsTypes[0]);
|
||||
haveColor = true;
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiColors[1])
|
||||
{
|
||||
if (0xFFFFFFFF != aiColors[1]) {
|
||||
cOut.g = NormalizeColorValue(GetProperty(instElement->alProperties,
|
||||
aiColors[1]).avList.front(), aiColorsTypes[1]);
|
||||
haveColor = true;
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiColors[2])
|
||||
{
|
||||
if (0xFFFFFFFF != aiColors[2]) {
|
||||
cOut.b = NormalizeColorValue(GetProperty(instElement->alProperties,
|
||||
aiColors[2]).avList.front(), aiColorsTypes[2]);
|
||||
haveColor = true;
|
||||
}
|
||||
|
||||
// assume 1.0 for the alpha channel ifit is not set
|
||||
if (0xFFFFFFFF == aiColors[3])
|
||||
{
|
||||
if (0xFFFFFFFF == aiColors[3]) {
|
||||
cOut.a = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cOut.a = NormalizeColorValue(GetProperty(instElement->alProperties,
|
||||
aiColors[3]).avList.front(), aiColorsTypes[3]);
|
||||
|
||||
|
@ -492,53 +453,45 @@ void PLYImporter::LoadVertex(const PLY::Element* pcElement, const PLY::ElementIn
|
|||
aiVector3D tOut;
|
||||
tOut.z = 0;
|
||||
bool haveTextureCoords = false;
|
||||
if (0xFFFFFFFF != aiTexcoord[0])
|
||||
{
|
||||
if (0xFFFFFFFF != aiTexcoord[0]) {
|
||||
tOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||
GetProperty(instElement->alProperties, aiTexcoord[0]).avList.front(), aiTexcoordTypes[0]);
|
||||
haveTextureCoords = true;
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiTexcoord[1])
|
||||
{
|
||||
if (0xFFFFFFFF != aiTexcoord[1]) {
|
||||
tOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||
GetProperty(instElement->alProperties, aiTexcoord[1]).avList.front(), aiTexcoordTypes[1]);
|
||||
haveTextureCoords = true;
|
||||
}
|
||||
|
||||
//create aiMesh if needed
|
||||
if (mGeneratedMesh == NULL)
|
||||
{
|
||||
if ( nullptr == mGeneratedMesh ) {
|
||||
mGeneratedMesh = new aiMesh();
|
||||
mGeneratedMesh->mMaterialIndex = 0;
|
||||
}
|
||||
|
||||
if (mGeneratedMesh->mVertices == NULL)
|
||||
{
|
||||
if (nullptr == mGeneratedMesh->mVertices) {
|
||||
mGeneratedMesh->mNumVertices = pcElement->NumOccur;
|
||||
mGeneratedMesh->mVertices = new aiVector3D[mGeneratedMesh->mNumVertices];
|
||||
}
|
||||
|
||||
mGeneratedMesh->mVertices[pos] = vOut;
|
||||
|
||||
if (haveNormal)
|
||||
{
|
||||
if (mGeneratedMesh->mNormals == NULL)
|
||||
if (haveNormal) {
|
||||
if (nullptr == mGeneratedMesh->mNormals)
|
||||
mGeneratedMesh->mNormals = new aiVector3D[mGeneratedMesh->mNumVertices];
|
||||
mGeneratedMesh->mNormals[pos] = nOut;
|
||||
}
|
||||
|
||||
if (haveColor)
|
||||
{
|
||||
if (mGeneratedMesh->mColors[0] == NULL)
|
||||
if (haveColor) {
|
||||
if (nullptr == mGeneratedMesh->mColors[0])
|
||||
mGeneratedMesh->mColors[0] = new aiColor4D[mGeneratedMesh->mNumVertices];
|
||||
mGeneratedMesh->mColors[0][pos] = cOut;
|
||||
}
|
||||
|
||||
if (haveTextureCoords)
|
||||
{
|
||||
if (mGeneratedMesh->mTextureCoords[0] == NULL)
|
||||
{
|
||||
if (haveTextureCoords) {
|
||||
if (nullptr == mGeneratedMesh->mTextureCoords[0]) {
|
||||
mGeneratedMesh->mNumUVComponents[0] = 2;
|
||||
mGeneratedMesh->mTextureCoords[0] = new aiVector3D[mGeneratedMesh->mNumVertices];
|
||||
}
|
||||
|
|
|
@ -409,12 +409,12 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh)
|
|||
// the MSB flag is temporarily used by the extra verbose
|
||||
// mode to tell us that the JoinVerticesProcess might have
|
||||
// been executed already.
|
||||
if ( !(this->mScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT ) && !(this->mScene->mFlags & AI_SCENE_FLAGS_ALLOW_SHARED) &&
|
||||
/*if ( !(this->mScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT ) && !(this->mScene->mFlags & AI_SCENE_FLAGS_ALLOW_SHARED) &&
|
||||
abRefList[face.mIndices[a]])
|
||||
{
|
||||
ReportError("aiMesh::mVertices[%i] is referenced twice - second "
|
||||
"time by aiMesh::mFaces[%i]::mIndices[%i]",face.mIndices[a],i,a);
|
||||
}
|
||||
}*/
|
||||
abRefList[face.mIndices[a]] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,8 +107,7 @@ ASSIMP_API unsigned int aiGetCompileFlags () {
|
|||
#include "revision.h"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API unsigned int aiGetVersionRevision ()
|
||||
{
|
||||
ASSIMP_API unsigned int aiGetVersionRevision() {
|
||||
return GitVersion;
|
||||
}
|
||||
|
||||
|
@ -133,8 +132,7 @@ ASSIMP_API aiScene::aiScene()
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API aiScene::~aiScene()
|
||||
{
|
||||
ASSIMP_API aiScene::~aiScene() {
|
||||
// delete all sub-objects recursively
|
||||
delete mRootNode;
|
||||
|
||||
|
@ -173,3 +171,4 @@ ASSIMP_API aiScene::~aiScene()
|
|||
|
||||
delete static_cast<Assimp::ScenePrivateData*>( mPrivate );
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file glTFWriter.h
|
||||
* Declares a class to write gltf/glb files
|
||||
*
|
||||
* glTF Extensions Support:
|
||||
* KHR_binary_glTF: full
|
||||
* KHR_materials_common: full
|
||||
*/
|
||||
#ifndef GLTF2ASSETWRITER_H_INC
|
||||
#define GLTF2ASSETWRITER_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
||||
#include "glTF2Asset.h"
|
||||
|
||||
namespace glTF2
|
||||
{
|
||||
|
||||
using rapidjson::MemoryPoolAllocator;
|
||||
|
||||
class AssetWriter
|
||||
{
|
||||
template<class T>
|
||||
friend void WriteLazyDict(LazyDict<T>& d, AssetWriter& w);
|
||||
|
||||
private:
|
||||
|
||||
void WriteBinaryData(IOStream* outfile, size_t sceneLength);
|
||||
|
||||
void WriteMetadata();
|
||||
void WriteExtensionsUsed();
|
||||
|
||||
template<class T>
|
||||
void WriteObjects(LazyDict<T>& d);
|
||||
|
||||
public:
|
||||
Document mDoc;
|
||||
Asset& mAsset;
|
||||
|
||||
MemoryPoolAllocator<>& mAl;
|
||||
|
||||
AssetWriter(Asset& asset);
|
||||
|
||||
void WriteFile(const char* path);
|
||||
void WriteGLBFile(const char* path);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Include the implementation of the methods
|
||||
#include "glTF2AssetWriter.inl"
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
||||
#endif // GLTF2ASSETWRITER_H_INC
|
|
@ -0,0 +1,677 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
#include <rapidjson/writer.h>
|
||||
#include <rapidjson/prettywriter.h>
|
||||
|
||||
namespace glTF2 {
|
||||
|
||||
using rapidjson::StringBuffer;
|
||||
using rapidjson::PrettyWriter;
|
||||
using rapidjson::Writer;
|
||||
using rapidjson::StringRef;
|
||||
using rapidjson::StringRef;
|
||||
|
||||
namespace {
|
||||
|
||||
template<size_t N>
|
||||
inline Value& MakeValue(Value& val, float(&r)[N], MemoryPoolAllocator<>& al) {
|
||||
val.SetArray();
|
||||
val.Reserve(N, al);
|
||||
for (decltype(N) i = 0; i < N; ++i) {
|
||||
val.PushBack(r[i], al);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
inline Value& MakeValue(Value& val, const std::vector<float> & r, MemoryPoolAllocator<>& al) {
|
||||
val.SetArray();
|
||||
val.Reserve(static_cast<rapidjson::SizeType>(r.size()), al);
|
||||
for (unsigned int i = 0; i < r.size(); ++i) {
|
||||
val.PushBack(r[i], al);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void AddRefsVector(Value& obj, const char* fieldId, std::vector< Ref<T> >& v, MemoryPoolAllocator<>& al) {
|
||||
if (v.empty()) return;
|
||||
Value lst;
|
||||
lst.SetArray();
|
||||
lst.Reserve(unsigned(v.size()), al);
|
||||
for (size_t i = 0; i < v.size(); ++i) {
|
||||
lst.PushBack(v[i]->index, al);
|
||||
}
|
||||
obj.AddMember(StringRef(fieldId), lst, al);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Accessor& a, AssetWriter& w)
|
||||
{
|
||||
obj.AddMember("bufferView", a.bufferView->index, w.mAl);
|
||||
obj.AddMember("byteOffset", a.byteOffset, w.mAl);
|
||||
obj.AddMember("byteStride", a.byteStride, w.mAl);
|
||||
obj.AddMember("componentType", int(a.componentType), w.mAl);
|
||||
obj.AddMember("count", a.count, w.mAl);
|
||||
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
|
||||
|
||||
Value vTmpMax, vTmpMin;
|
||||
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
|
||||
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Animation& a, AssetWriter& w)
|
||||
{
|
||||
/****************** Channels *******************/
|
||||
Value channels;
|
||||
channels.SetArray();
|
||||
channels.Reserve(unsigned(a.Channels.size()), w.mAl);
|
||||
|
||||
for (size_t i = 0; i < unsigned(a.Channels.size()); ++i) {
|
||||
Animation::AnimChannel& c = a.Channels[i];
|
||||
Value valChannel;
|
||||
valChannel.SetObject();
|
||||
{
|
||||
valChannel.AddMember("sampler", c.sampler, w.mAl);
|
||||
|
||||
Value valTarget;
|
||||
valTarget.SetObject();
|
||||
{
|
||||
valTarget.AddMember("node", c.target.node->index, w.mAl);
|
||||
valTarget.AddMember("path", c.target.path, w.mAl);
|
||||
}
|
||||
valChannel.AddMember("target", valTarget, w.mAl);
|
||||
}
|
||||
channels.PushBack(valChannel, w.mAl);
|
||||
}
|
||||
obj.AddMember("channels", channels, w.mAl);
|
||||
|
||||
/****************** Samplers *******************/
|
||||
Value valSamplers;
|
||||
valSamplers.SetArray();
|
||||
|
||||
for (size_t i = 0; i < unsigned(a.Samplers.size()); ++i) {
|
||||
Animation::AnimSampler& s = a.Samplers[i];
|
||||
Value valSampler;
|
||||
valSampler.SetObject();
|
||||
{
|
||||
Ref<Accessor> inputAccessor = a.GetAccessor(s.input);
|
||||
Ref<Accessor> outputAccessor = a.GetAccessor(s.output);
|
||||
valSampler.AddMember("input", inputAccessor->index, w.mAl);
|
||||
valSampler.AddMember("interpolation", s.interpolation, w.mAl);
|
||||
valSampler.AddMember("output", outputAccessor->index, w.mAl);
|
||||
}
|
||||
valSamplers.PushBack(valSampler, w.mAl);
|
||||
}
|
||||
obj.AddMember("samplers", valSamplers, w.mAl);
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Buffer& b, AssetWriter& w)
|
||||
{
|
||||
obj.AddMember("byteLength", static_cast<uint64_t>(b.byteLength), w.mAl);
|
||||
obj.AddMember("uri", Value(b.GetURI(), w.mAl).Move(), w.mAl);
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, BufferView& bv, AssetWriter& w)
|
||||
{
|
||||
obj.AddMember("buffer", bv.buffer->index, w.mAl);
|
||||
obj.AddMember("byteOffset", static_cast<uint64_t>(bv.byteOffset), w.mAl);
|
||||
obj.AddMember("byteLength", static_cast<uint64_t>(bv.byteLength), w.mAl);
|
||||
obj.AddMember("target", int(bv.target), w.mAl);
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Camera& c, AssetWriter& w)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Image& img, AssetWriter& w)
|
||||
{
|
||||
std::string uri;
|
||||
if (w.mAsset.extensionsUsed.KHR_binary_glTF && img.bufferView) {
|
||||
Value exts, ext;
|
||||
exts.SetObject();
|
||||
ext.SetObject();
|
||||
|
||||
ext.AddMember("bufferView", img.bufferView->index, w.mAl);
|
||||
|
||||
if (!img.mimeType.empty())
|
||||
ext.AddMember("mimeType", StringRef(img.mimeType), w.mAl);
|
||||
|
||||
exts.AddMember("KHR_binary_glTF", ext, w.mAl);
|
||||
obj.AddMember("extensions", exts, w.mAl);
|
||||
return;
|
||||
}
|
||||
else if (img.HasData()) {
|
||||
uri = "data:" + (img.mimeType.empty() ? "application/octet-stream" : img.mimeType);
|
||||
uri += ";base64,";
|
||||
Util::EncodeBase64(img.GetData(), img.GetDataLength(), uri);
|
||||
}
|
||||
else {
|
||||
uri = img.uri;
|
||||
}
|
||||
|
||||
obj.AddMember("uri", Value(uri, w.mAl).Move(), w.mAl);
|
||||
}
|
||||
|
||||
namespace {
|
||||
inline void WriteTex(Value& obj, Ref<Texture> texture, const char* propName, MemoryPoolAllocator<>& al)
|
||||
{
|
||||
if (texture) {
|
||||
Value tex;
|
||||
tex.SetObject();
|
||||
tex.AddMember("index", texture->index, al);
|
||||
obj.AddMember(StringRef(propName), tex, al);
|
||||
}
|
||||
}
|
||||
|
||||
inline void WriteColorOrTex(Value& obj, TexProperty& prop, const char* propName, MemoryPoolAllocator<>& al)
|
||||
{
|
||||
WriteTex(obj, prop.texture, propName, al);
|
||||
if (!prop.texture) {
|
||||
Value col;
|
||||
obj.AddMember(StringRef(propName), MakeValue(col, prop.color, al), al);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Material& m, AssetWriter& w)
|
||||
{
|
||||
if (m.transparent) {
|
||||
obj.AddMember("alphaMode", "BLEND", w.mAl);
|
||||
}
|
||||
|
||||
Value v;
|
||||
v.SetObject();
|
||||
{
|
||||
if (m.transparent && !m.diffuse.texture) {
|
||||
m.diffuse.color[3] = m.transparency;
|
||||
}
|
||||
WriteColorOrTex(v, m.ambient, m.ambient.texture ? "ambientTexture" : "ambientFactor", w.mAl);
|
||||
WriteColorOrTex(v, m.diffuse, m.diffuse.texture ? "diffuseTexture" : "diffuseFactor", w.mAl);
|
||||
WriteColorOrTex(v, m.specular, m.specular.texture ? "specularTexture" : "specularFactor", w.mAl);
|
||||
WriteColorOrTex(v, m.emission, m.emission.texture ? "emissionTexture" : "emissionFactor", w.mAl);
|
||||
v.AddMember("shininessFactor", m.shininess, w.mAl);
|
||||
}
|
||||
v.AddMember("type", "commonPhong", w.mAl);
|
||||
Value ext;
|
||||
ext.SetObject();
|
||||
ext.AddMember("KHR_materials_common", v, w.mAl);
|
||||
obj.AddMember("extensions", ext, w.mAl);
|
||||
|
||||
WriteTex(obj, m.normal, "normalTexture", w.mAl);
|
||||
}
|
||||
|
||||
namespace {
|
||||
inline void WriteAttrs(AssetWriter& w, Value& attrs, Mesh::AccessorList& lst,
|
||||
const char* semantic, bool forceNumber = false)
|
||||
{
|
||||
if (lst.empty()) return;
|
||||
if (lst.size() == 1 && !forceNumber) {
|
||||
attrs.AddMember(StringRef(semantic), lst[0]->index, w.mAl);
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < lst.size(); ++i) {
|
||||
char buffer[32];
|
||||
ai_snprintf(buffer, 32, "%s_%d", semantic, int(i));
|
||||
attrs.AddMember(Value(buffer, w.mAl).Move(), lst[i]->index, w.mAl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Mesh& m, AssetWriter& w)
|
||||
{
|
||||
/********************* Name **********************/
|
||||
obj.AddMember("name", m.name, w.mAl);
|
||||
|
||||
/**************** Mesh extensions ****************/
|
||||
if(m.Extension.size() > 0)
|
||||
{
|
||||
Value json_extensions;
|
||||
|
||||
json_extensions.SetObject();
|
||||
for(Mesh::SExtension* ptr_ext : m.Extension)
|
||||
{
|
||||
switch(ptr_ext->Type)
|
||||
{
|
||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
case Mesh::SExtension::EType::Compression_Open3DGC:
|
||||
{
|
||||
Value json_comp_data;
|
||||
Mesh::SCompression_Open3DGC* ptr_ext_comp = (Mesh::SCompression_Open3DGC*)ptr_ext;
|
||||
|
||||
// filling object "compressedData"
|
||||
json_comp_data.SetObject();
|
||||
json_comp_data.AddMember("buffer", ptr_ext_comp->Buffer, w.mAl);
|
||||
json_comp_data.AddMember("byteOffset", ptr_ext_comp->Offset, w.mAl);
|
||||
json_comp_data.AddMember("componentType", 5121, w.mAl);
|
||||
json_comp_data.AddMember("type", "SCALAR", w.mAl);
|
||||
json_comp_data.AddMember("count", ptr_ext_comp->Count, w.mAl);
|
||||
if(ptr_ext_comp->Binary)
|
||||
json_comp_data.AddMember("mode", "binary", w.mAl);
|
||||
else
|
||||
json_comp_data.AddMember("mode", "ascii", w.mAl);
|
||||
|
||||
json_comp_data.AddMember("indicesCount", ptr_ext_comp->IndicesCount, w.mAl);
|
||||
json_comp_data.AddMember("verticesCount", ptr_ext_comp->VerticesCount, w.mAl);
|
||||
// filling object "Open3DGC-compression"
|
||||
Value json_o3dgc;
|
||||
|
||||
json_o3dgc.SetObject();
|
||||
json_o3dgc.AddMember("compressedData", json_comp_data, w.mAl);
|
||||
// add member to object "extensions"
|
||||
json_extensions.AddMember("Open3DGC-compression", json_o3dgc, w.mAl);
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
throw DeadlyImportError("GLTF: Can not write mesh: unknown mesh extension, only Open3DGC is supported.");
|
||||
}// switch(ptr_ext->Type)
|
||||
}// for(Mesh::SExtension* ptr_ext : m.Extension)
|
||||
|
||||
// Add extensions to mesh
|
||||
obj.AddMember("extensions", json_extensions, w.mAl);
|
||||
}// if(m.Extension.size() > 0)
|
||||
|
||||
/****************** Primitives *******************/
|
||||
Value primitives;
|
||||
primitives.SetArray();
|
||||
primitives.Reserve(unsigned(m.primitives.size()), w.mAl);
|
||||
|
||||
for (size_t i = 0; i < m.primitives.size(); ++i) {
|
||||
Mesh::Primitive& p = m.primitives[i];
|
||||
Value prim;
|
||||
prim.SetObject();
|
||||
{
|
||||
prim.AddMember("mode", Value(int(p.mode)).Move(), w.mAl);
|
||||
|
||||
if (p.material)
|
||||
prim.AddMember("material", p.material->index, w.mAl);
|
||||
|
||||
if (p.indices)
|
||||
prim.AddMember("indices", p.indices->index, w.mAl);
|
||||
|
||||
Value attrs;
|
||||
attrs.SetObject();
|
||||
{
|
||||
WriteAttrs(w, attrs, p.attributes.position, "POSITION");
|
||||
WriteAttrs(w, attrs, p.attributes.normal, "NORMAL");
|
||||
WriteAttrs(w, attrs, p.attributes.texcoord, "TEXCOORD", true);
|
||||
WriteAttrs(w, attrs, p.attributes.color, "COLOR");
|
||||
WriteAttrs(w, attrs, p.attributes.joint, "JOINT");
|
||||
WriteAttrs(w, attrs, p.attributes.jointmatrix, "JOINTMATRIX");
|
||||
WriteAttrs(w, attrs, p.attributes.weight, "WEIGHT");
|
||||
}
|
||||
prim.AddMember("attributes", attrs, w.mAl);
|
||||
}
|
||||
primitives.PushBack(prim, w.mAl);
|
||||
}
|
||||
|
||||
obj.AddMember("primitives", primitives, w.mAl);
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Node& n, AssetWriter& w)
|
||||
{
|
||||
|
||||
if (n.matrix.isPresent) {
|
||||
Value val;
|
||||
obj.AddMember("matrix", MakeValue(val, n.matrix.value, w.mAl).Move(), w.mAl);
|
||||
}
|
||||
|
||||
if (n.translation.isPresent) {
|
||||
Value val;
|
||||
obj.AddMember("translation", MakeValue(val, n.translation.value, w.mAl).Move(), w.mAl);
|
||||
}
|
||||
|
||||
if (n.scale.isPresent) {
|
||||
Value val;
|
||||
obj.AddMember("scale", MakeValue(val, n.scale.value, w.mAl).Move(), w.mAl);
|
||||
}
|
||||
if (n.rotation.isPresent) {
|
||||
Value val;
|
||||
obj.AddMember("rotation", MakeValue(val, n.rotation.value, w.mAl).Move(), w.mAl);
|
||||
}
|
||||
|
||||
AddRefsVector(obj, "children", n.children, w.mAl);
|
||||
|
||||
AddRefsVector(obj, "meshes", n.meshes, w.mAl);
|
||||
|
||||
AddRefsVector(obj, "skeletons", n.skeletons, w.mAl);
|
||||
|
||||
if (n.skin) {
|
||||
obj.AddMember("skin", n.skin->index, w.mAl);
|
||||
}
|
||||
|
||||
if (!n.jointName.empty()) {
|
||||
obj.AddMember("jointName", n.jointName, w.mAl);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Program& b, AssetWriter& w)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Sampler& b, AssetWriter& w)
|
||||
{
|
||||
if (b.wrapS) {
|
||||
obj.AddMember("wrapS", b.wrapS, w.mAl);
|
||||
}
|
||||
if (b.wrapT) {
|
||||
obj.AddMember("wrapT", b.wrapT, w.mAl);
|
||||
}
|
||||
if (b.magFilter) {
|
||||
obj.AddMember("magFilter", b.magFilter, w.mAl);
|
||||
}
|
||||
if (b.minFilter) {
|
||||
obj.AddMember("minFilter", b.minFilter, w.mAl);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Write(Value& scene, Scene& s, AssetWriter& w)
|
||||
{
|
||||
AddRefsVector(scene, "nodes", s.nodes, w.mAl);
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Shader& b, AssetWriter& w)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Skin& b, AssetWriter& w)
|
||||
{
|
||||
/****************** jointNames *******************/
|
||||
Value vJointNames;
|
||||
vJointNames.SetArray();
|
||||
vJointNames.Reserve(unsigned(b.jointNames.size()), w.mAl);
|
||||
|
||||
for (size_t i = 0; i < unsigned(b.jointNames.size()); ++i) {
|
||||
vJointNames.PushBack(b.jointNames[i]->index, w.mAl);
|
||||
}
|
||||
obj.AddMember("joints", vJointNames, w.mAl);
|
||||
|
||||
if (b.bindShapeMatrix.isPresent) {
|
||||
Value val;
|
||||
obj.AddMember("bindShapeMatrix", MakeValue(val, b.bindShapeMatrix.value, w.mAl).Move(), w.mAl);
|
||||
}
|
||||
|
||||
if (b.inverseBindMatrices) {
|
||||
obj.AddMember("inverseBindMatrices", b.inverseBindMatrices->index, w.mAl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Technique& b, AssetWriter& w)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Texture& tex, AssetWriter& w)
|
||||
{
|
||||
if (tex.source) {
|
||||
obj.AddMember("source", tex.source->index, w.mAl);
|
||||
}
|
||||
if (tex.sampler) {
|
||||
obj.AddMember("sampler", tex.sampler->index, w.mAl);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Light& b, AssetWriter& w)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline AssetWriter::AssetWriter(Asset& a)
|
||||
: mDoc()
|
||||
, mAsset(a)
|
||||
, mAl(mDoc.GetAllocator())
|
||||
{
|
||||
mDoc.SetObject();
|
||||
|
||||
WriteMetadata();
|
||||
WriteExtensionsUsed();
|
||||
|
||||
// Dump the contents of the dictionaries
|
||||
for (size_t i = 0; i < a.mDicts.size(); ++i) {
|
||||
a.mDicts[i]->WriteObjects(*this);
|
||||
}
|
||||
|
||||
// Add the target scene field
|
||||
if (mAsset.scene) {
|
||||
mDoc.AddMember("scene", mAsset.scene->index, mAl);
|
||||
}
|
||||
}
|
||||
|
||||
inline void AssetWriter::WriteFile(const char* path)
|
||||
{
|
||||
std::unique_ptr<IOStream> jsonOutFile(mAsset.OpenFile(path, "wt", true));
|
||||
|
||||
if (jsonOutFile == 0) {
|
||||
throw DeadlyExportError("Could not open output file: " + std::string(path));
|
||||
}
|
||||
|
||||
StringBuffer docBuffer;
|
||||
|
||||
PrettyWriter<StringBuffer> writer(docBuffer);
|
||||
mDoc.Accept(writer);
|
||||
|
||||
if (jsonOutFile->Write(docBuffer.GetString(), docBuffer.GetSize(), 1) != 1) {
|
||||
throw DeadlyExportError("Failed to write scene data!");
|
||||
}
|
||||
|
||||
// Write buffer data to separate .bin files
|
||||
for (unsigned int i = 0; i < mAsset.buffers.Size(); ++i) {
|
||||
Ref<Buffer> b = mAsset.buffers.Get(i);
|
||||
|
||||
std::string binPath = b->GetURI();
|
||||
|
||||
std::unique_ptr<IOStream> binOutFile(mAsset.OpenFile(binPath, "wb", true));
|
||||
|
||||
if (binOutFile == 0) {
|
||||
throw DeadlyExportError("Could not open output file: " + binPath);
|
||||
}
|
||||
|
||||
if (b->byteLength > 0) {
|
||||
if (binOutFile->Write(b->GetPointer(), b->byteLength, 1) != 1) {
|
||||
throw DeadlyExportError("Failed to write binary file: " + binPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void AssetWriter::WriteGLBFile(const char* path)
|
||||
{
|
||||
std::unique_ptr<IOStream> outfile(mAsset.OpenFile(path, "wb", true));
|
||||
|
||||
if (outfile == 0) {
|
||||
throw DeadlyExportError("Could not open output file: " + std::string(path));
|
||||
}
|
||||
|
||||
// we will write the header later, skip its size
|
||||
outfile->Seek(sizeof(GLB_Header), aiOrigin_SET);
|
||||
|
||||
StringBuffer docBuffer;
|
||||
Writer<StringBuffer> writer(docBuffer);
|
||||
mDoc.Accept(writer);
|
||||
|
||||
if (outfile->Write(docBuffer.GetString(), docBuffer.GetSize(), 1) != 1) {
|
||||
throw DeadlyExportError("Failed to write scene data!");
|
||||
}
|
||||
|
||||
WriteBinaryData(outfile.get(), docBuffer.GetSize());
|
||||
}
|
||||
|
||||
inline void AssetWriter::WriteBinaryData(IOStream* outfile, size_t sceneLength)
|
||||
{
|
||||
//
|
||||
// write the body data
|
||||
//
|
||||
|
||||
size_t bodyLength = 0;
|
||||
if (Ref<Buffer> b = mAsset.GetBodyBuffer()) {
|
||||
bodyLength = b->byteLength;
|
||||
|
||||
if (bodyLength > 0) {
|
||||
size_t bodyOffset = sizeof(GLB_Header) + sceneLength;
|
||||
bodyOffset = (bodyOffset + 3) & ~3; // Round up to next multiple of 4
|
||||
|
||||
outfile->Seek(bodyOffset, aiOrigin_SET);
|
||||
|
||||
if (outfile->Write(b->GetPointer(), b->byteLength, 1) != 1) {
|
||||
throw DeadlyExportError("Failed to write body data!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// write the header
|
||||
//
|
||||
|
||||
GLB_Header header;
|
||||
memcpy(header.magic, AI_GLB_MAGIC_NUMBER, sizeof(header.magic));
|
||||
|
||||
header.version = 2;
|
||||
AI_SWAP4(header.version);
|
||||
|
||||
header.length = uint32_t(sizeof(header) + sceneLength + bodyLength);
|
||||
AI_SWAP4(header.length);
|
||||
|
||||
header.sceneLength = uint32_t(sceneLength);
|
||||
AI_SWAP4(header.sceneLength);
|
||||
|
||||
header.sceneFormat = SceneFormat_JSON;
|
||||
AI_SWAP4(header.sceneFormat);
|
||||
|
||||
outfile->Seek(0, aiOrigin_SET);
|
||||
|
||||
if (outfile->Write(&header, 1, sizeof(header)) != sizeof(header)) {
|
||||
throw DeadlyExportError("Failed to write the header!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void AssetWriter::WriteMetadata()
|
||||
{
|
||||
Value asset;
|
||||
asset.SetObject();
|
||||
{
|
||||
char versionChar[10];
|
||||
ai_snprintf(versionChar, sizeof(versionChar), "%d", mAsset.asset.version);
|
||||
asset.AddMember("version", Value(versionChar, mAl).Move(), mAl);
|
||||
|
||||
asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl);
|
||||
}
|
||||
mDoc.AddMember("asset", asset, mAl);
|
||||
}
|
||||
|
||||
inline void AssetWriter::WriteExtensionsUsed()
|
||||
{
|
||||
Value exts;
|
||||
exts.SetArray();
|
||||
{
|
||||
if (false)
|
||||
exts.PushBack(StringRef("KHR_binary_glTF"), mAl);
|
||||
|
||||
// This is used to export common materials with GLTF 2.
|
||||
exts.PushBack(StringRef("KHR_materials_common"), mAl);
|
||||
}
|
||||
|
||||
if (!exts.Empty())
|
||||
mDoc.AddMember("extensionsUsed", exts, mAl);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void AssetWriter::WriteObjects(LazyDict<T>& d)
|
||||
{
|
||||
if (d.mObjs.empty()) return;
|
||||
|
||||
Value* container = &mDoc;
|
||||
|
||||
if (d.mExtId) {
|
||||
Value* exts = FindObject(mDoc, "extensions");
|
||||
if (!exts) {
|
||||
mDoc.AddMember("extensions", Value().SetObject().Move(), mDoc.GetAllocator());
|
||||
exts = FindObject(mDoc, "extensions");
|
||||
}
|
||||
|
||||
if (!(container = FindObject(*exts, d.mExtId))) {
|
||||
exts->AddMember(StringRef(d.mExtId), Value().SetObject().Move(), mDoc.GetAllocator());
|
||||
container = FindObject(*exts, d.mExtId);
|
||||
}
|
||||
}
|
||||
|
||||
Value* dict;
|
||||
if (!(dict = FindArray(*container, d.mDictId))) {
|
||||
container->AddMember(StringRef(d.mDictId), Value().SetArray().Move(), mDoc.GetAllocator());
|
||||
dict = FindArray(*container, d.mDictId);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < d.mObjs.size(); ++i) {
|
||||
if (d.mObjs[i]->IsSpecial()) continue;
|
||||
|
||||
Value obj;
|
||||
obj.SetObject();
|
||||
|
||||
if (!d.mObjs[i]->name.empty()) {
|
||||
obj.AddMember("name", StringRef(d.mObjs[i]->name.c_str()), mAl);
|
||||
}
|
||||
|
||||
Write(obj, *d.mObjs[i], *this);
|
||||
|
||||
dict->PushBack(obj, mAl);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void WriteLazyDict(LazyDict<T>& d, AssetWriter& w)
|
||||
{
|
||||
w.WriteObjects(d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file GltfExporter.h
|
||||
* Declares the exporter class to write a scene to a gltf/glb file
|
||||
*/
|
||||
#ifndef AI_GLTF2EXPORTER_H_INC
|
||||
#define AI_GLTF2EXPORTER_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/material.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
struct aiScene;
|
||||
struct aiNode;
|
||||
struct aiMaterial;
|
||||
|
||||
namespace glTF2
|
||||
{
|
||||
template<class T>
|
||||
class Ref;
|
||||
|
||||
class Asset;
|
||||
struct TexProperty;
|
||||
struct Node;
|
||||
struct Texture;
|
||||
}
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
class IOSystem;
|
||||
class IOStream;
|
||||
class ExportProperties;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** Helper class to export a given scene to an glTF file. */
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class glTF2Exporter
|
||||
{
|
||||
public:
|
||||
/// Constructor for a specific scene to export
|
||||
glTF2Exporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene,
|
||||
const ExportProperties* pProperties, bool binary);
|
||||
|
||||
private:
|
||||
|
||||
const char* mFilename;
|
||||
IOSystem* mIOSystem;
|
||||
const aiScene* mScene;
|
||||
const ExportProperties* mProperties;
|
||||
|
||||
std::map<std::string, unsigned int> mTexturesByPath;
|
||||
|
||||
std::shared_ptr<glTF2::Asset> mAsset;
|
||||
|
||||
std::vector<unsigned char> mBodyData;
|
||||
|
||||
void WriteBinaryData(IOStream* outfile, std::size_t sceneLength);
|
||||
|
||||
void GetTexSampler(const aiMaterial* mat, glTF2::Ref<glTF2::Texture> texture);
|
||||
void GetMatTex(const aiMaterial* mat, glTF2::Ref<glTF2::Texture>& texture, aiTextureType tt);
|
||||
void GetMatColorOrTex(const aiMaterial* mat, glTF2::TexProperty& prop, const char* propName, int type, int idx, aiTextureType tt);
|
||||
void ExportMetadata();
|
||||
void ExportMaterials();
|
||||
void ExportMeshes();
|
||||
unsigned int ExportNodeHierarchy(const aiNode* n);
|
||||
unsigned int ExportNode(const aiNode* node, glTF2::Ref<glTF2::Node>& parent);
|
||||
void ExportScene();
|
||||
void ExportAnimations();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
||||
#endif // AI_GLTF2EXPORTER_H_INC
|
|
@ -105,3 +105,4 @@ ASSIMP_API unsigned int aiGetCompileFlags (void);
|
|||
#endif
|
||||
|
||||
#endif // !! #ifndef AI_VERSION_H_INC
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
/* Header for class jassimp_Jassimp */
|
||||
|
||||
#ifndef _Included_jassimp_Jassimp
|
||||
|
|
|
@ -140,17 +140,17 @@ public final class AiMesh {
|
|||
/**
|
||||
* Number of bytes per float value.
|
||||
*/
|
||||
private static final int SIZEOF_FLOAT = Jassimp.NATIVE_FLOAT_SIZE;
|
||||
private final int SIZEOF_FLOAT = Jassimp.NATIVE_FLOAT_SIZE;
|
||||
|
||||
/**
|
||||
* Number of bytes per int value.
|
||||
*/
|
||||
private static final int SIZEOF_INT = Jassimp.NATIVE_INT_SIZE;
|
||||
private final int SIZEOF_INT = Jassimp.NATIVE_INT_SIZE;
|
||||
|
||||
/**
|
||||
* Size of an AiVector3D in the native world.
|
||||
*/
|
||||
private static final int SIZEOF_V3D = Jassimp.NATIVE_AIVEKTOR3D_SIZE;
|
||||
private final int SIZEOF_V3D = Jassimp.NATIVE_AIVEKTOR3D_SIZE;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,17 +70,17 @@ public final class AiNodeAnim {
|
|||
/**
|
||||
* Size of one position key entry.
|
||||
*/
|
||||
private static final int POS_KEY_SIZE = Jassimp.NATIVE_AIVEKTORKEY_SIZE;
|
||||
private final int POS_KEY_SIZE = Jassimp.NATIVE_AIVEKTORKEY_SIZE;
|
||||
|
||||
/**
|
||||
* Size of one rotation key entry.
|
||||
*/
|
||||
private static final int ROT_KEY_SIZE = Jassimp.NATIVE_AIQUATKEY_SIZE;
|
||||
private final int ROT_KEY_SIZE = Jassimp.NATIVE_AIQUATKEY_SIZE;
|
||||
|
||||
/**
|
||||
* Size of one scaling key entry.
|
||||
*/
|
||||
private static final int SCALE_KEY_SIZE = Jassimp.NATIVE_AIVEKTORKEY_SIZE;
|
||||
private final int SCALE_KEY_SIZE = Jassimp.NATIVE_AIVEKTORKEY_SIZE;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,6 +91,8 @@ public final class Jassimp {
|
|||
public static AiScene importFile(String filename,
|
||||
Set<AiPostProcessSteps> postProcessing) throws IOException {
|
||||
|
||||
loadLibrary();
|
||||
|
||||
return aiImportFile(filename, AiPostProcessSteps.toRawValue(
|
||||
postProcessing));
|
||||
}
|
||||
|
@ -177,6 +179,11 @@ public final class Jassimp {
|
|||
}
|
||||
|
||||
|
||||
public static void setLibraryLoader(JassimpLibraryLoader libraryLoader) {
|
||||
s_libraryLoader = libraryLoader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method for wrapping a matrix.<p>
|
||||
*
|
||||
|
@ -264,6 +271,35 @@ public final class Jassimp {
|
|||
return s_wrapperProvider.wrapSceneNode(parent, matrix, meshRefs, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to load the library using the provided JassimpLibraryLoader.<p>
|
||||
*
|
||||
* Synchronized to avoid race conditions.
|
||||
*/
|
||||
private static void loadLibrary()
|
||||
{
|
||||
if(!s_libraryLoaded)
|
||||
{
|
||||
synchronized(s_libraryLoadingLock)
|
||||
{
|
||||
if(!s_libraryLoaded)
|
||||
{
|
||||
s_libraryLoader.loadLibrary();
|
||||
NATIVE_AIVEKTORKEY_SIZE = getVKeysize();
|
||||
NATIVE_AIQUATKEY_SIZE = getQKeysize();
|
||||
NATIVE_AIVEKTOR3D_SIZE = getV3Dsize();
|
||||
NATIVE_FLOAT_SIZE = getfloatsize();
|
||||
NATIVE_INT_SIZE = getintsize();
|
||||
NATIVE_UINT_SIZE = getuintsize();
|
||||
NATIVE_DOUBLE_SIZE = getdoublesize();
|
||||
NATIVE_LONG_SIZE = getlongsize();
|
||||
|
||||
s_libraryLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The native interface.
|
||||
|
@ -284,6 +320,25 @@ public final class Jassimp {
|
|||
new AiBuiltInWrapperProvider();
|
||||
|
||||
|
||||
/**
|
||||
* The library loader to load the native library.
|
||||
*/
|
||||
private static JassimpLibraryLoader s_libraryLoader =
|
||||
new JassimpLibraryLoader();
|
||||
|
||||
/**
|
||||
* Status flag if the library is loaded.
|
||||
*
|
||||
* Volatile to avoid problems with double checked locking.
|
||||
*
|
||||
*/
|
||||
private static volatile boolean s_libraryLoaded = false;
|
||||
|
||||
/**
|
||||
* Lock for library loading.
|
||||
*/
|
||||
private static final Object s_libraryLoadingLock = new Object();
|
||||
|
||||
/**
|
||||
* Pure static class, no accessible constructor.
|
||||
*/
|
||||
|
@ -291,24 +346,13 @@ public final class Jassimp {
|
|||
/* nothing to do */
|
||||
}
|
||||
|
||||
public static final int NATIVE_AIVEKTORKEY_SIZE;
|
||||
public static final int NATIVE_AIQUATKEY_SIZE;
|
||||
public static final int NATIVE_AIVEKTOR3D_SIZE;
|
||||
public static final int NATIVE_FLOAT_SIZE;
|
||||
public static final int NATIVE_INT_SIZE;
|
||||
public static final int NATIVE_UINT_SIZE;
|
||||
public static final int NATIVE_DOUBLE_SIZE;
|
||||
public static final int NATIVE_LONG_SIZE;
|
||||
public static int NATIVE_AIVEKTORKEY_SIZE;
|
||||
public static int NATIVE_AIQUATKEY_SIZE;
|
||||
public static int NATIVE_AIVEKTOR3D_SIZE;
|
||||
public static int NATIVE_FLOAT_SIZE;
|
||||
public static int NATIVE_INT_SIZE;
|
||||
public static int NATIVE_UINT_SIZE;
|
||||
public static int NATIVE_DOUBLE_SIZE;
|
||||
public static int NATIVE_LONG_SIZE;
|
||||
|
||||
static {
|
||||
System.loadLibrary("jassimp");
|
||||
NATIVE_AIVEKTORKEY_SIZE = getVKeysize();
|
||||
NATIVE_AIQUATKEY_SIZE = getQKeysize();
|
||||
NATIVE_AIVEKTOR3D_SIZE = getV3Dsize();
|
||||
NATIVE_FLOAT_SIZE = getfloatsize();
|
||||
NATIVE_INT_SIZE = getintsize();
|
||||
NATIVE_UINT_SIZE = getuintsize();
|
||||
NATIVE_DOUBLE_SIZE = getdoublesize();
|
||||
NATIVE_LONG_SIZE = getlongsize();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library - Java Binding (jassimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2012, 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
package jassimp;
|
||||
|
||||
/**
|
||||
* Library loader for the jassimp library.<p>
|
||||
*
|
||||
* The default implementation uses "System.loadLibrary" to
|
||||
* load the jassimp native library. <p>
|
||||
*
|
||||
* Custom implementations should override the loadLibrary()
|
||||
* function.
|
||||
*
|
||||
*/
|
||||
public class JassimpLibraryLoader
|
||||
{
|
||||
/**
|
||||
* Function to load the native jassimp library.
|
||||
*
|
||||
* Called the first time Jassimp.importFile() is
|
||||
* called.
|
||||
*/
|
||||
public void loadLibrary()
|
||||
{
|
||||
System.loadLibrary("jassimp");
|
||||
}
|
||||
}
|
|
@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include "AbstractImportExportBase.h"
|
||||
|
||||
using namespace ::Assimp;
|
||||
|
@ -51,7 +52,12 @@ public:
|
|||
virtual bool importerTest() {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", 0 );
|
||||
return nullptr != scene;
|
||||
EXPECT_EQ( 1u, scene->mNumMeshes );
|
||||
EXPECT_NE( nullptr, scene->mMeshes[0] );
|
||||
EXPECT_EQ( 8u, scene->mMeshes[0]->mNumVertices );
|
||||
EXPECT_EQ( 6u, scene->mMeshes[0]->mNumFaces );
|
||||
|
||||
return (nullptr != scene);
|
||||
}
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
|
|
|
@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
const char* AICMD_MSG_ABOUT =
|
||||
"------------------------------------------------------ \n"
|
||||
"Open Asset Import Library (\"Assimp\", http://assimp.sourceforge.net) \n"
|
||||
"Open Asset Import Library (\"Assimp\", https://github.com/assimp/assimp) \n"
|
||||
" -- Commandline toolchain --\n"
|
||||
"------------------------------------------------------ \n\n"
|
||||
|
||||
|
|
Loading…
Reference in New Issue