fixed the bug of export gltf2, the JOINTS_0 componentType is Incorrect
commit
f6af6ded1f
|
@ -60,6 +60,7 @@ test/gtest/src/gtest-stamp/Debug/gtest-build
|
|||
*.lib
|
||||
test/gtest/src/gtest-stamp/Debug/
|
||||
tools/assimp_view/assimp_viewer.vcxproj.user
|
||||
*.pyc
|
||||
|
||||
# Unix editor backups
|
||||
*~
|
||||
|
|
|
@ -33,9 +33,10 @@ env:
|
|||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: ANALYZE=ON
|
||||
# disabled until clang 5.0 analyzer issues are fixed
|
||||
# - os: linux
|
||||
# compiler: clang
|
||||
# env: ANALYZE=ON
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: ASAN=ON
|
||||
|
|
126
CMakeLists.txt
126
CMakeLists.txt
|
@ -1,6 +1,7 @@
|
|||
# Open Asset Import Library (assimp)
|
||||
# ----------------------------------------------------------------------
|
||||
# Copyright (c) 2006-2017, assimp team
|
||||
# Copyright (c) 2006-2018, assimp team
|
||||
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this software in source and binary forms,
|
||||
|
@ -103,12 +104,12 @@ OPTION ( BUILD_DOCS
|
|||
OFF
|
||||
)
|
||||
|
||||
# Use subset of Windows.h
|
||||
if (WIN32)
|
||||
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
|
||||
endif()
|
||||
|
||||
IF(MSVC)
|
||||
SET (CMAKE_PREFIX_PATH "D:\\libs\\devil")
|
||||
OPTION( ASSIMP_INSTALL_PDB
|
||||
"Install MSVC debug files."
|
||||
ON
|
||||
|
@ -137,8 +138,7 @@ SET (PROJECT_VERSION "${ASSIMP_VERSION}")
|
|||
|
||||
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 )
|
||||
# Enable C++1 globally
|
||||
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
||||
|
||||
# Get the current working branch
|
||||
|
@ -160,7 +160,7 @@ EXECUTE_PROCESS(
|
|||
)
|
||||
|
||||
IF(NOT GIT_COMMIT_HASH)
|
||||
SET(GIT_COMMIT_HASH 0)
|
||||
SET(GIT_COMMIT_HASH 0)
|
||||
ENDIF(NOT GIT_COMMIT_HASH)
|
||||
|
||||
IF(ASSIMP_DOUBLE_PRECISION)
|
||||
|
@ -178,10 +178,10 @@ CONFIGURE_FILE(
|
|||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
./
|
||||
include
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
./
|
||||
include
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
)
|
||||
|
||||
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules" )
|
||||
|
@ -191,19 +191,10 @@ SET(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPO
|
|||
SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
|
||||
|
||||
IF( UNIX )
|
||||
# Ensure that we do not run into issues like http://www.tcm.phy.cam.ac.uk/sw/inodes64.html on 32 bit linux
|
||||
IF( ${OPERATING_SYSTEM} MATCHES "Android")
|
||||
ELSE()
|
||||
IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux
|
||||
#ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 )
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Use GNUInstallDirs for Unix predefined directories
|
||||
INCLUDE(GNUInstallDirs)
|
||||
ENDIF( UNIX )
|
||||
|
||||
|
||||
# Grouped compiler settings
|
||||
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
||||
# hide all not-exported symbols
|
||||
|
@ -212,11 +203,13 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
|||
SET(LIBSTDC++_LIBRARIES -lstdc++)
|
||||
ELSEIF(MSVC)
|
||||
# enable multi-core compilation with MSVC
|
||||
add_compile_options(/MP)
|
||||
|
||||
ADD_COMPILE_OPTIONS(/MP)
|
||||
IF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
|
||||
ADD_COMPILE_OPTIONS( /bigobj )
|
||||
ENDIF()
|
||||
# disable "elements of array '' will be default initialized" warning on MSVC2013
|
||||
IF(MSVC12)
|
||||
add_compile_options(/wd4351)
|
||||
ADD_COMPILE_OPTIONS(/wd4351)
|
||||
ENDIF()
|
||||
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fvisibility=hidden -fPIC -Wall -Wno-long-long -std=c++11" )
|
||||
|
@ -227,34 +220,39 @@ ELSEIF( CMAKE_COMPILER_IS_MINGW )
|
|||
ADD_DEFINITIONS( -U__STRICT_ANSI__ )
|
||||
ENDIF()
|
||||
|
||||
if (ASSIMP_COVERALLS)
|
||||
MESSAGE(STATUS "Coveralls enabled")
|
||||
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()
|
||||
IF (IOS)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -O3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -O3")
|
||||
ENDIF()
|
||||
|
||||
if (ASSIMP_WERROR)
|
||||
IF (ASSIMP_COVERALLS)
|
||||
MESSAGE(STATUS "Coveralls enabled")
|
||||
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()
|
||||
|
||||
IF (ASSIMP_WERROR)
|
||||
MESSAGE(STATUS "Treating warnings as errors")
|
||||
IF (MSVC)
|
||||
add_compile_options(/WX)
|
||||
ADD_COMPILE_OPTIONS(/WX)
|
||||
ELSE()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
||||
ENDIF()
|
||||
endif()
|
||||
ENDIF()
|
||||
|
||||
if (ASSIMP_ASAN)
|
||||
MESSAGE(STATUS "AddressSanitizer enabled")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
|
||||
endif()
|
||||
IF (ASSIMP_ASAN)
|
||||
MESSAGE(STATUS "AddressSanitizer enabled")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
|
||||
ENDIF()
|
||||
|
||||
if (ASSIMP_UBSAN)
|
||||
MESSAGE(STATUS "Undefined Behavior sanitizer enabled")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
|
||||
endif()
|
||||
IF (ASSIMP_UBSAN)
|
||||
MESSAGE(STATUS "Undefined Behavior sanitizer enabled")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
|
||||
ENDIF()
|
||||
|
||||
INCLUDE (FindPkgMacros)
|
||||
INCLUDE (PrecompiledHeader)
|
||||
|
@ -287,42 +285,42 @@ ENDIF()
|
|||
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)
|
||||
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
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)
|
||||
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})
|
||||
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 )
|
||||
|
||||
IF( BUILD_DOCS )
|
||||
add_subdirectory(doc)
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
ENDIF( BUILD_DOCS )
|
||||
|
||||
# Look for system installed irrXML
|
||||
IF ( SYSTEM_IRRXML )
|
||||
find_package( IrrXML REQUIRED )
|
||||
FIND_PACKAGE( IrrXML REQUIRED )
|
||||
ENDIF( SYSTEM_IRRXML )
|
||||
|
||||
# Search for external dependencies, and build them from source if not found
|
||||
# Search for zlib
|
||||
IF ( NOT ASSIMP_BUILD_ZLIB )
|
||||
find_package(ZLIB)
|
||||
FIND_PACKAGE(ZLIB)
|
||||
ENDIF( NOT ASSIMP_BUILD_ZLIB )
|
||||
|
||||
IF( NOT ZLIB_FOUND )
|
||||
message(STATUS "compiling zlib from souces")
|
||||
MESSAGE(STATUS "compiling zlib from sources")
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckTypeSize)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
# compile from sources
|
||||
add_subdirectory(contrib/zlib)
|
||||
ADD_SUBDIRECTORY(contrib/zlib)
|
||||
SET(ZLIB_FOUND 1)
|
||||
SET(ZLIB_LIBRARIES zlibstatic)
|
||||
SET(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zlib ${CMAKE_CURRENT_BINARY_DIR}/contrib/zlib)
|
||||
else(NOT ZLIB_FOUND)
|
||||
ELSE(NOT ZLIB_FOUND)
|
||||
ADD_DEFINITIONS(-DASSIMP_BUILD_NO_OWN_ZLIB)
|
||||
SET(ZLIB_LIBRARIES_LINKED -lz)
|
||||
ENDIF(NOT ZLIB_FOUND)
|
||||
|
@ -364,7 +362,9 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
|||
SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/includes")
|
||||
|
||||
# pick the correct prebuilt library
|
||||
IF(MSVC14)
|
||||
IF(MSVC15)
|
||||
SET(C4D_LIB_POSTFIX "_2017")
|
||||
ELSEIF(MSVC14)
|
||||
SET(C4D_LIB_POSTFIX "_2015")
|
||||
ELSEIF(MSVC12)
|
||||
SET(C4D_LIB_POSTFIX "_2013")
|
||||
|
@ -405,7 +405,7 @@ ADD_SUBDIRECTORY(contrib)
|
|||
ADD_SUBDIRECTORY( code/ )
|
||||
IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
|
||||
IF ( WIN32 AND DirectX_D3DX9_LIBRARY )
|
||||
option ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} )
|
||||
OPTION ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} )
|
||||
IF ( ASSIMP_BUILD_ASSIMP_VIEW )
|
||||
ADD_SUBDIRECTORY( tools/assimp_view/ )
|
||||
ENDIF ( ASSIMP_BUILD_ASSIMP_VIEW )
|
||||
|
@ -457,7 +457,7 @@ INSTALL( FILES "${PROJECT_BINARY_DIR}/assimp.pc" DESTINATION ${ASSIMP_LIB_INSTAL
|
|||
|
||||
IF(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
||||
# Packing information
|
||||
SET(CPACK_PACKAGE_NAME "assimp{ASSIMP_VERSION_MAJOR}")
|
||||
SET(CPACK_PACKAGE_NAME "assimp{ASSIMP_VERSION_MAJOR}.{ASSIMP_VERSION_MINOR}")
|
||||
SET(CPACK_PACKAGE_CONTACT "" CACHE STRING "Package maintainer and PGP signer.")
|
||||
SET(CPACK_PACKAGE_VENDOR "https://github.com/assimp")
|
||||
SET(CPACK_PACKAGE_DISPLAY_NAME "Assimp ${ASSIMP_VERSION}")
|
||||
|
@ -469,8 +469,8 @@ IF(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
|||
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-DEV_COMPONENT} "LIBASSIMP-DEV_COMPONENT_UPPER")
|
||||
STRING(TOUPPER ${LIBASSIMP_COMPONENT} "LIBASSIMP_COMPONENT_UPPER")
|
||||
STRING(TOUPPER ${LIBASSIMP-DEV_COMPONENT} "LIBASSIMP-DEV_COMPONENT_UPPER")
|
||||
|
||||
SET(CPACK_COMPONENT_ASSIMP-BIN_DISPLAY_NAME "tools")
|
||||
SET(CPACK_COMPONENT_ASSIMP-BIN_DEPENDS "${LIBASSIMP_COMPONENT}" )
|
||||
|
@ -487,8 +487,8 @@ IF(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
|||
SET(CPACK_DEBIAN_PACKAGE_SECTION "libs" )
|
||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_COMPONENTS_ALL}")
|
||||
SET(CPACK_DEBIAN_PACKAGE_SUGGESTS)
|
||||
SET(CPACK_DEBIAN_PACKAGE_NAME "assimp")
|
||||
SET(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES contrib/cppunit-1.12.1 contrib/cppunit_note.txt contrib/zlib workspaces test doc obj samples packaging)
|
||||
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_SOURCE_COPY svn export --force)
|
||||
SET(CPACK_DEBIAN_CHANGELOG)
|
||||
execute_process(COMMAND lsb_release -is
|
||||
|
@ -500,8 +500,8 @@ IF(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
|||
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)
|
||||
INCLUDE(CPack)
|
||||
INCLUDE(DebSourcePPA)
|
||||
ENDIF()
|
||||
|
||||
if(WIN32)
|
||||
|
@ -513,14 +513,16 @@ if(WIN32)
|
|||
SET(LIB_DIR "${PROJECT_SOURCE_DIR}/lib32/")
|
||||
ENDIF()
|
||||
|
||||
if(MSVC12)
|
||||
IF(MSVC12)
|
||||
SET(ASSIMP_MSVC_VERSION "vc120")
|
||||
elseif(MSVC14)
|
||||
ELSEIF(MSVC14)
|
||||
SET(ASSIMP_MSVC_VERSION "vc140")
|
||||
ELSEIF(MSVC15)
|
||||
SET(ASSIMP_MSVC_VERSION "vc141")
|
||||
ENDIF(MSVC12)
|
||||
|
||||
if(MSVC12 OR MSVC14)
|
||||
add_custom_target(UpdateAssimpLibsDebugSymbolsAndDLLs COMMENT "Copying Assimp Libraries ..." VERBATIM)
|
||||
IF(MSVC12 OR MSVC14 OR MSVC15 )
|
||||
ADD_CUSTOM_TARGET(UpdateAssimpLibsDebugSymbolsAndDLLs COMMENT "Copying Assimp Libraries ..." 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)
|
||||
|
@ -541,5 +543,5 @@ if(WIN32)
|
|||
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(MSVC12 OR MSVC14 OR MSVC15 )
|
||||
ENDIF (WIN32)
|
||||
|
|
17
CREDITS
17
CREDITS
|
@ -157,12 +157,27 @@ Contributed ExportProperties interface
|
|||
Contributed X File exporter
|
||||
Contributed Step (stp) exporter
|
||||
|
||||
- Thomas Iorns (mesilliac)
|
||||
Initial FBX Export support
|
||||
|
||||
For a more detailed list just check: https://github.com/assimp/assimp/network/members
|
||||
|
||||
Patreons:
|
||||
|
||||
========
|
||||
Patreons
|
||||
========
|
||||
|
||||
Huge thanks to our Patreons!
|
||||
|
||||
- migenius
|
||||
- Marcus
|
||||
- Cort
|
||||
- elect
|
||||
- Steffen
|
||||
|
||||
|
||||
===================
|
||||
Commercial Sponsors
|
||||
===================
|
||||
|
||||
- MyDidimo (mydidimo.com): Sponsored development of FBX Export support
|
||||
|
|
48
Readme.md
48
Readme.md
|
@ -32,32 +32,32 @@ Please check our Wiki as well: https://github.com/assimp/assimp/wiki
|
|||
|
||||
#### Supported file formats ####
|
||||
|
||||
A full list [is here](http://assimp.org/main_features_formats.html).
|
||||
__Importers__:
|
||||
|
||||
- 3D
|
||||
- 3DS
|
||||
- 3MF
|
||||
- [3DS](https://en.wikipedia.org/wiki/.3ds)
|
||||
- [3MF](https://en.wikipedia.org/wiki/3D_Manufacturing_Format)
|
||||
- AC
|
||||
- AC3D
|
||||
- [AC3D](https://en.wikipedia.org/wiki/AC3D)
|
||||
- ACC
|
||||
- AMJ
|
||||
- ASE
|
||||
- ASK
|
||||
- B3D;
|
||||
- BLEND (Blender)
|
||||
- BVH
|
||||
- COB
|
||||
- B3D
|
||||
- [BLEND](https://en.wikipedia.org/wiki/.blend_(file_format))
|
||||
- [BVH](https://en.wikipedia.org/wiki/Biovision_Hierarchy)
|
||||
- CMS
|
||||
- DAE/Collada
|
||||
- DXF
|
||||
- COB
|
||||
- [DAE/Collada](https://en.wikipedia.org/wiki/COLLADA)
|
||||
- [DXF](https://en.wikipedia.org/wiki/AutoCAD_DXF)
|
||||
- ENFF
|
||||
- FBX
|
||||
- glTF 1.0 + GLB
|
||||
- glTF 2.0
|
||||
- [FBX](https://en.wikipedia.org/wiki/FBX)
|
||||
- [glTF 1.0](https://en.wikipedia.org/wiki/GlTF#glTF_1.0) + GLB
|
||||
- [glTF 2.0](https://en.wikipedia.org/wiki/GlTF#glTF_2.0)
|
||||
- HMB
|
||||
- IFC-STEP
|
||||
- IRR / IRRMESH
|
||||
- LWO
|
||||
- [LWO](https://en.wikipedia.org/wiki/LightWave_3D)
|
||||
- LWS
|
||||
- LXO
|
||||
- MD2
|
||||
|
@ -70,10 +70,10 @@ __Importers__:
|
|||
- MS3D
|
||||
- NDO
|
||||
- NFF
|
||||
- OBJ
|
||||
- OFF
|
||||
- OGEX
|
||||
- PLY
|
||||
- [OBJ](https://en.wikipedia.org/wiki/Wavefront_.obj_file)
|
||||
- [OFF](https://en.wikipedia.org/wiki/OFF_(file_format))
|
||||
- [OGEX](https://en.wikipedia.org/wiki/Open_Game_Engine_Exchange)
|
||||
- [PLY](https://en.wikipedia.org/wiki/PLY_(file_format))
|
||||
- PMX
|
||||
- PRJ
|
||||
- Q3O
|
||||
|
@ -82,19 +82,19 @@ __Importers__:
|
|||
- SCN
|
||||
- SIB
|
||||
- SMD
|
||||
- STL
|
||||
- STP
|
||||
- [STP](https://en.wikipedia.org/wiki/ISO_10303-21)
|
||||
- [STL](https://en.wikipedia.org/wiki/STL_(file_format))
|
||||
- TER
|
||||
- UC
|
||||
- VTA
|
||||
- X
|
||||
- X3D
|
||||
- [X3D](https://en.wikipedia.org/wiki/X3D)
|
||||
- XGL
|
||||
- ZGL
|
||||
|
||||
Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default):
|
||||
|
||||
- C4D (https://github.com/assimp/assimp/wiki/Cinema4D-&-Melange)
|
||||
- [C4D](https://en.wikipedia.org/wiki/Cinema_4D) (https://github.com/assimp/assimp/wiki/Cinema4D-&-Melange)
|
||||
|
||||
__Exporters__:
|
||||
|
||||
|
@ -109,6 +109,8 @@ __Exporters__:
|
|||
- STEP
|
||||
- glTF 1.0 (partial)
|
||||
- glTF 2.0 (partial)
|
||||
- 3MF ( experimental )
|
||||
- FBX ( experimental )
|
||||
|
||||
### 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.
|
||||
|
@ -120,7 +122,7 @@ Take a look into the `INSTALL` file. Our build system is CMake, if you used CMak
|
|||
* [Pascal](port/AssimpPascal/Readme.md)
|
||||
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
|
||||
* [Unity 3d Plugin](https://www.assetstore.unity3d.com/en/#!/content/91777)
|
||||
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (currently supported obj, ply, stl, collada, md2)
|
||||
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status))
|
||||
|
||||
### Other tools ###
|
||||
[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.
|
||||
|
|
|
@ -10,10 +10,7 @@
|
|||
# ASSIMP_LIBRARY_DIRS - link directories
|
||||
# ASSIMP_LIBRARIES - libraries to link plugins with
|
||||
# ASSIMP_Boost_VERSION - the boost version assimp was compiled with
|
||||
get_filename_component(_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_PREFIX "${_PREFIX}" PATH)
|
||||
get_filename_component(_PREFIX "${_PREFIX}" PATH)
|
||||
get_filename_component(ASSIMP_ROOT_DIR "${_PREFIX}" PATH)
|
||||
get_filename_component(ASSIMP_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" REALPATH)
|
||||
|
||||
if( MSVC )
|
||||
# in order to prevent DLL hell, each of the DLLs have to be suffixed with the major version and msvc prefix
|
||||
|
@ -34,36 +31,18 @@ if( MSVC )
|
|||
else()
|
||||
set(MSVC_PREFIX "vc150")
|
||||
endif()
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" FORCE)
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" )
|
||||
else()
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" FORCE)
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" )
|
||||
endif()
|
||||
|
||||
set( ASSIMP_CXX_FLAGS ) # dynamically linked library
|
||||
if( WIN32 )
|
||||
# for visual studio linking, most of the time boost dlls will be used
|
||||
set( ASSIMP_CXX_FLAGS " -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB")
|
||||
endif()
|
||||
set( ASSIMP_LINK_FLAGS "" )
|
||||
set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@")
|
||||
set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@")
|
||||
set( ASSIMP_LIBRARIES assimp${ASSIMP_LIBRARY_SUFFIX})
|
||||
set( ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES}@CMAKE_DEBUG_POSTFIX@)
|
||||
|
||||
# search for the boost version assimp was compiled with
|
||||
#set(Boost_USE_MULTITHREAD ON)
|
||||
#set(Boost_USE_STATIC_LIBS OFF)
|
||||
#set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
#find_package(Boost ${ASSIMP_Boost_VERSION} EXACT COMPONENTS thread date_time)
|
||||
#if(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
|
||||
# set( ASSIMP_INCLUDE_DIRS "${ASSIMP_INCLUDE_DIRS}" ${Boost_INCLUDE_DIRS})
|
||||
#else(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
|
||||
# message(WARNING "Failed to find Boost ${ASSIMP_Boost_VERSION} necessary for assimp")
|
||||
#endif(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
|
||||
|
||||
# the boost version assimp was compiled with
|
||||
set( ASSIMP_Boost_VERSION "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@")
|
||||
|
||||
# for compatibility with pkg-config
|
||||
set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}")
|
||||
set(ASSIMP_LDFLAGS_OTHER "${ASSIMP_LINK_FLAGS}")
|
||||
|
@ -74,7 +53,6 @@ MARK_AS_ADVANCED(
|
|||
ASSIMP_LINK_FLAGS
|
||||
ASSIMP_INCLUDE_DIRS
|
||||
ASSIMP_LIBRARIES
|
||||
ASSIMP_Boost_VERSION
|
||||
ASSIMP_CFLAGS_OTHER
|
||||
ASSIMP_LDFLAGS_OTHER
|
||||
ASSIMP_LIBRARY_SUFFIX
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -50,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "TargetAnimation.h"
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include "StringComparison.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <memory>
|
||||
#include <cctype>
|
||||
|
||||
|
@ -71,7 +72,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial()
|
|||
unsigned int idx( NotSet );
|
||||
for (unsigned int i = 0; i < mScene->mMaterials.size();++i)
|
||||
{
|
||||
std::string s = mScene->mMaterials[i].mName;
|
||||
std::string &s = mScene->mMaterials[i].mName;
|
||||
for ( std::string::iterator it = s.begin(); it != s.end(); ++it ) {
|
||||
*it = static_cast< char >( ::tolower( *it ) );
|
||||
}
|
||||
|
@ -127,9 +128,8 @@ void Discreet3DSImporter::ReplaceDefaultMaterial()
|
|||
if (cnt && idx == mScene->mMaterials.size())
|
||||
{
|
||||
// We need to create our own default material
|
||||
D3DS::Material sMat;
|
||||
D3DS::Material sMat("%%%DEFAULT");
|
||||
sMat.mDiffuse = aiColor3D(0.3f,0.3f,0.3f);
|
||||
sMat.mName = "%%%DEFAULT";
|
||||
mScene->mMaterials.push_back(sMat);
|
||||
|
||||
DefaultLogger::get()->info("3DS: Generating default material");
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -47,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "3DSHelper.h"
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include "SplitLargeMeshes.h"
|
||||
#include "StringComparison.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
|
@ -183,7 +184,7 @@ void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScen
|
|||
} // end of namespace Assimp
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Discreet3DSExporter:: Discreet3DSExporter(std::shared_ptr<IOStream> outfile, const aiScene* scene)
|
||||
Discreet3DSExporter:: Discreet3DSExporter(std::shared_ptr<IOStream> &outfile, const aiScene* scene)
|
||||
: scene(scene)
|
||||
, writer(outfile)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -48,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "StreamWriter.h"
|
||||
#include <assimp/StreamWriter.h>
|
||||
#include <assimp/material.h>
|
||||
|
||||
struct aiScene;
|
||||
|
@ -66,7 +67,7 @@ namespace Assimp
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
class Discreet3DSExporter {
|
||||
public:
|
||||
Discreet3DSExporter(std::shared_ptr<IOStream> outfile, const aiScene* pScene);
|
||||
Discreet3DSExporter(std::shared_ptr<IOStream> &outfile, const aiScene* pScene);
|
||||
~Discreet3DSExporter();
|
||||
|
||||
private:
|
||||
|
|
127
code/3DSHelper.h
127
code/3DSHelper.h
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -44,10 +45,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_3DSFILEHELPER_H_INC
|
||||
#define AI_3DSFILEHELPER_H_INC
|
||||
|
||||
#include "SpatialSort.h"
|
||||
#include "SmoothingGroups.h"
|
||||
#include "StringUtils.h"
|
||||
#include "qnan.h"
|
||||
#include <assimp/SpatialSort.h>
|
||||
#include <assimp/SmoothingGroups.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/qnan.h>
|
||||
#include <assimp/material.h>
|
||||
#include <assimp/camera.h>
|
||||
#include <assimp/light.h>
|
||||
|
@ -370,9 +371,14 @@ struct Texture
|
|||
/** Helper structure representing a 3ds material */
|
||||
struct Material
|
||||
{
|
||||
//! Default constructor. Builds a default name for the material
|
||||
Material()
|
||||
: mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black
|
||||
//! Default constructor has been deleted
|
||||
Material() = delete;
|
||||
|
||||
|
||||
//! Constructor with explicit name
|
||||
explicit Material(const std::string &name)
|
||||
: mName(name)
|
||||
, mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black
|
||||
, mSpecularExponent ( ai_real( 0.0 ) )
|
||||
, mShininessStrength ( ai_real( 1.0 ) )
|
||||
, mShading(Discreet3DS::Gouraud)
|
||||
|
@ -380,13 +386,70 @@ struct Material
|
|||
, mBumpHeight ( ai_real( 1.0 ) )
|
||||
, mTwoSided (false)
|
||||
{
|
||||
static int iCnt = 0;
|
||||
|
||||
char szTemp[128];
|
||||
ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
||||
mName = szTemp;
|
||||
}
|
||||
|
||||
|
||||
Material(const Material &other) = default;
|
||||
Material &operator=(const Material &other) = default;
|
||||
|
||||
|
||||
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||
Material(Material &&other)
|
||||
: mName(std::move(other.mName))
|
||||
, mDiffuse(std::move(other.mDiffuse))
|
||||
, mSpecularExponent(std::move(other.mSpecularExponent))
|
||||
, mShininessStrength(std::move(other.mShininessStrength))
|
||||
, mSpecular(std::move(other.mSpecular))
|
||||
, mAmbient(std::move(other.mAmbient))
|
||||
, mShading(std::move(other.mShading))
|
||||
, mTransparency(std::move(other.mTransparency))
|
||||
, sTexDiffuse(std::move(other.sTexDiffuse))
|
||||
, sTexOpacity(std::move(other.sTexOpacity))
|
||||
, sTexSpecular(std::move(other.sTexSpecular))
|
||||
, sTexReflective(std::move(other.sTexReflective))
|
||||
, sTexBump(std::move(other.sTexBump))
|
||||
, sTexEmissive(std::move(other.sTexEmissive))
|
||||
, sTexShininess(std::move(other.sTexShininess))
|
||||
, mBumpHeight(std::move(other.mBumpHeight))
|
||||
, mEmissive(std::move(other.mEmissive))
|
||||
, sTexAmbient(std::move(other.sTexAmbient))
|
||||
, mTwoSided(std::move(other.mTwoSided))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Material &operator=(Material &&other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
mName = std::move(other.mName);
|
||||
mDiffuse = std::move(other.mDiffuse);
|
||||
mSpecularExponent = std::move(other.mSpecularExponent);
|
||||
mShininessStrength = std::move(other.mShininessStrength),
|
||||
mSpecular = std::move(other.mSpecular);
|
||||
mAmbient = std::move(other.mAmbient);
|
||||
mShading = std::move(other.mShading);
|
||||
mTransparency = std::move(other.mTransparency);
|
||||
sTexDiffuse = std::move(other.sTexDiffuse);
|
||||
sTexOpacity = std::move(other.sTexOpacity);
|
||||
sTexSpecular = std::move(other.sTexSpecular);
|
||||
sTexReflective = std::move(other.sTexReflective);
|
||||
sTexBump = std::move(other.sTexBump);
|
||||
sTexEmissive = std::move(other.sTexEmissive);
|
||||
sTexShininess = std::move(other.sTexShininess);
|
||||
mBumpHeight = std::move(other.mBumpHeight);
|
||||
mEmissive = std::move(other.mEmissive);
|
||||
sTexAmbient = std::move(other.sTexAmbient);
|
||||
mTwoSided = std::move(other.mTwoSided);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
~Material() {}
|
||||
|
||||
|
||||
//! Name of the material
|
||||
std::string mName;
|
||||
//! Diffuse color of the material
|
||||
|
@ -432,17 +495,16 @@ struct Material
|
|||
/** Helper structure to represent a 3ds file mesh */
|
||||
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
|
||||
{
|
||||
//! Default constructor
|
||||
Mesh()
|
||||
{
|
||||
static int iCnt = 0;
|
||||
//! Default constructor has been deleted
|
||||
Mesh() = delete;
|
||||
|
||||
// Generate a default name for the mesh
|
||||
char szTemp[128];
|
||||
ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
||||
mName = szTemp;
|
||||
//! Constructor with explicit name
|
||||
explicit Mesh(const std::string &name)
|
||||
: mName(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! Name of the mesh
|
||||
std::string mName;
|
||||
|
||||
|
@ -488,25 +550,22 @@ struct aiFloatKey
|
|||
/** Helper structure to represent a 3ds file node */
|
||||
struct Node
|
||||
{
|
||||
Node():
|
||||
mParent(NULL)
|
||||
, mInstanceNumber(0)
|
||||
, mHierarchyPos (0)
|
||||
, mHierarchyIndex (0)
|
||||
, mInstanceCount (1)
|
||||
Node() = delete;
|
||||
|
||||
explicit Node(const std::string &name)
|
||||
: mParent(NULL)
|
||||
, mName(name)
|
||||
, mInstanceNumber(0)
|
||||
, mHierarchyPos (0)
|
||||
, mHierarchyIndex (0)
|
||||
, mInstanceCount (1)
|
||||
{
|
||||
static int iCnt = 0;
|
||||
|
||||
// Generate a default name for the node
|
||||
char szTemp[128];
|
||||
::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
||||
mName = szTemp;
|
||||
|
||||
aRotationKeys.reserve (20);
|
||||
aPositionKeys.reserve (20);
|
||||
aScalingKeys.reserve (20);
|
||||
}
|
||||
|
||||
|
||||
~Node()
|
||||
{
|
||||
for (unsigned int i = 0; i < mChildren.size();++i)
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -51,12 +52,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
// internal headers
|
||||
#include "3DSLoader.h"
|
||||
#include "Macros.h"
|
||||
#include <assimp/Macros.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include "StringComparison.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -70,7 +71,7 @@ static const aiImporterDesc desc = {
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
"3ds prj"
|
||||
"3ds prj 3DS PRJ"
|
||||
};
|
||||
|
||||
|
||||
|
@ -105,29 +106,31 @@ static const aiImporterDesc desc = {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
Discreet3DSImporter::Discreet3DSImporter()
|
||||
: stream(),
|
||||
mLastNodeIndex(),
|
||||
mCurrentNode(),
|
||||
mRootNode(),
|
||||
mScene(),
|
||||
mMasterScale(),
|
||||
bHasBG(),
|
||||
bIsPrj()
|
||||
{}
|
||||
: stream()
|
||||
, mLastNodeIndex()
|
||||
, mCurrentNode()
|
||||
, mRootNode()
|
||||
, mScene()
|
||||
, mMasterScale()
|
||||
, bHasBG()
|
||||
, bIsPrj() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
Discreet3DSImporter::~Discreet3DSImporter()
|
||||
{}
|
||||
Discreet3DSImporter::~Discreet3DSImporter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
||||
{
|
||||
bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||
std::string extension = GetExtension(pFile);
|
||||
if(extension == "3ds" || extension == "prj" ) {
|
||||
if(extension == "3ds" || extension == "3DS" || extension == "prj"|| extension == "PRJ" ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!extension.length() || checkSig) {
|
||||
uint16_t token[3];
|
||||
token[0] = 0x4d4d;
|
||||
|
@ -170,7 +173,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// Initialize members
|
||||
mLastNodeIndex = -1;
|
||||
mCurrentNode = new D3DS::Node();
|
||||
mCurrentNode = new D3DS::Node("UNNAMED");
|
||||
mRootNode = mCurrentNode;
|
||||
mRootNode->mHierarchyPos = -1;
|
||||
mRootNode->mHierarchyIndex = -1;
|
||||
|
@ -209,7 +212,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
|||
ConvertScene(pScene);
|
||||
|
||||
// Generate the node graph for the scene. This is a little bit
|
||||
// tricky since we'll need to split some meshes into submeshes
|
||||
// tricky since we'll need to split some meshes into sub-meshes
|
||||
GenerateNodeGraph(pScene);
|
||||
|
||||
// Now apply the master scaling factor to the scene
|
||||
|
@ -346,7 +349,7 @@ void Discreet3DSImporter::ParseObjectChunk()
|
|||
case Discreet3DS::CHUNK_MAT_MATERIAL:
|
||||
|
||||
// Add a new material to the list
|
||||
mScene->mMaterials.push_back(D3DS::Material());
|
||||
mScene->mMaterials.push_back(D3DS::Material(std::string("UNNAMED_" + to_string(mScene->mMaterials.size()))));
|
||||
ParseMaterialChunk();
|
||||
break;
|
||||
|
||||
|
@ -402,11 +405,7 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num)
|
|||
case Discreet3DS::CHUNK_TRIMESH:
|
||||
{
|
||||
// this starts a new triangle mesh
|
||||
mScene->mMeshes.push_back(D3DS::Mesh());
|
||||
D3DS::Mesh& m = mScene->mMeshes.back();
|
||||
|
||||
// Setup the name of the mesh
|
||||
m.mName = std::string(name, num);
|
||||
mScene->mMeshes.push_back(D3DS::Mesh(std::string(name, num)));
|
||||
|
||||
// Read mesh chunks
|
||||
ParseMeshChunk();
|
||||
|
@ -690,8 +689,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
|
|||
pcNode->mInstanceCount++;
|
||||
instanceNumber = pcNode->mInstanceCount;
|
||||
}
|
||||
pcNode = new D3DS::Node();
|
||||
pcNode->mName = name;
|
||||
pcNode = new D3DS::Node(name);
|
||||
pcNode->mInstanceNumber = instanceNumber;
|
||||
|
||||
// There are two unknown values which we can safely ignore
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -46,13 +47,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_3DSIMPORTER_H_INC
|
||||
#define AI_3DSIMPORTER_H_INC
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||
|
||||
#include "3DSHelper.h"
|
||||
#include "StreamReader.h"
|
||||
#include <assimp/StreamReader.h>
|
||||
|
||||
struct aiNode;
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -44,6 +45,11 @@ namespace Assimp {
|
|||
namespace D3MF {
|
||||
|
||||
namespace XmlTag {
|
||||
// Meta-data
|
||||
static const std::string meta = "metadata";
|
||||
static const std::string meta_name = "name";
|
||||
|
||||
// Model-data specific tags
|
||||
static const std::string model = "model";
|
||||
static const std::string model_unit = "unit";
|
||||
static const std::string metadata = "metadata";
|
||||
|
@ -61,6 +67,8 @@ namespace XmlTag {
|
|||
static const std::string v2 = "v2";
|
||||
static const std::string v3 = "v3";
|
||||
static const std::string id = "id";
|
||||
static const std::string pid = "pid";
|
||||
static const std::string p1 = "p1";
|
||||
static const std::string name = "name";
|
||||
static const std::string type = "type";
|
||||
static const std::string build = "build";
|
||||
|
@ -68,6 +76,14 @@ namespace XmlTag {
|
|||
static const std::string objectid = "objectid";
|
||||
static const std::string transform = "transform";
|
||||
|
||||
// Material definitions
|
||||
static const std::string basematerials = "basematerials";
|
||||
static const std::string basematerials_id = "id";
|
||||
static const std::string basematerials_base = "base";
|
||||
static const std::string basematerials_name = "name";
|
||||
static const std::string basematerials_displaycolor = "displaycolor";
|
||||
|
||||
// Meta info tags
|
||||
static const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml";
|
||||
static const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels";
|
||||
static const std::string SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
|
||||
|
@ -82,7 +98,6 @@ namespace XmlTag {
|
|||
static const std::string PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture";
|
||||
static const std::string PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
||||
static const std::string PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
|
||||
|
||||
}
|
||||
|
||||
} // Namespace D3MF
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -49,11 +50,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
// internal headers
|
||||
#include "ACLoader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
#include "Subdivision.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/Subdivision.h>
|
||||
#include "Importer.h"
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/light.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -47,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
struct aiNode;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -51,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "AMFImporter.hpp"
|
||||
#include "AMFImporter_Macro.hpp"
|
||||
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
|
||||
// Header files, stdlib.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -56,8 +57,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include "assimp/types.h"
|
||||
#include "BaseImporter.h"
|
||||
#include "irrXMLWrapper.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/irrXMLWrapper.h>
|
||||
|
||||
// Header files, stdlib.
|
||||
#include <set>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -51,8 +52,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
// Header files, Assimp.
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include "StandardShapes.h"
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/StandardShapes.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
// Header files, stdlib.
|
||||
#include <iterator>
|
||||
|
@ -155,10 +156,11 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string&
|
|||
TextureConverted_Index = 0;
|
||||
for(const SPP_Texture& tex_convd: mTexture_Converted)
|
||||
{
|
||||
if(tex_convd.ID == TextureConverted_ID)
|
||||
return TextureConverted_Index;
|
||||
else
|
||||
TextureConverted_Index++;
|
||||
if ( tex_convd.ID == TextureConverted_ID ) {
|
||||
return TextureConverted_Index;
|
||||
} else {
|
||||
++TextureConverted_Index;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -50,8 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
// internal headers
|
||||
#include "ASELoader.h"
|
||||
#include "StringComparison.h"
|
||||
#include "SkeletonMeshBuilder.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/SkeletonMeshBuilder.h>
|
||||
#include "TargetAnimation.h"
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
@ -62,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <memory>
|
||||
|
||||
// utilities
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::ASE;
|
||||
|
@ -83,11 +84,11 @@ static const aiImporterDesc desc = {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
ASEImporter::ASEImporter()
|
||||
: mParser(),
|
||||
mBuffer(),
|
||||
pcScene(),
|
||||
configRecomputeNormals(),
|
||||
noSkeletonMesh()
|
||||
: mParser()
|
||||
, mBuffer()
|
||||
, pcScene()
|
||||
, configRecomputeNormals()
|
||||
, noSkeletonMesh()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -276,14 +277,13 @@ void ASEImporter::GenerateDefaultMaterial()
|
|||
}
|
||||
if (bHas || mParser->m_vMaterials.empty()) {
|
||||
// add a simple material without submaterials to the parser's list
|
||||
mParser->m_vMaterials.push_back ( ASE::Material() );
|
||||
mParser->m_vMaterials.push_back ( ASE::Material(AI_DEFAULT_MATERIAL_NAME) );
|
||||
ASE::Material& mat = mParser->m_vMaterials.back();
|
||||
|
||||
mat.mDiffuse = aiColor3D(0.6f,0.6f,0.6f);
|
||||
mat.mSpecular = aiColor3D(1.0f,1.0f,1.0f);
|
||||
mat.mAmbient = aiColor3D(0.05f,0.05f,0.05f);
|
||||
mat.mShading = Discreet3DS::Gouraud;
|
||||
mat.mName = AI_DEFAULT_MATERIAL_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -583,7 +583,7 @@ void ASEImporter::AddNodes (const std::vector<BaseNode*>& nodes,
|
|||
node->mTransformation = mParentAdjust*snode->mTransform;
|
||||
|
||||
// Add sub nodes - prevent stack overflow due to recursive parenting
|
||||
if (node->mName != node->mParent->mName) {
|
||||
if (node->mName != node->mParent->mName && node->mName != node->mParent->mParent->mName ) {
|
||||
AddNodes(nodes,node,node->mName.data,snode->mTransform);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -45,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_ASELOADER_H_INCLUDED
|
||||
#define AI_ASELOADER_H_INCLUDED
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/types.h>
|
||||
#include "ASEParser.h"
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -51,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
// internal headers
|
||||
#include "TextureTransform.h"
|
||||
#include "ASELoader.h"
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
@ -266,7 +267,9 @@ void Parser::Parse()
|
|||
// at the file extension (ASE, ASK, ASC)
|
||||
// *************************************************************
|
||||
|
||||
if (fmt)iFileFormat = fmt;
|
||||
if ( fmt ) {
|
||||
iFileFormat = fmt;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// main scene information
|
||||
|
@ -292,7 +295,7 @@ void Parser::Parse()
|
|||
if (TokenMatch(filePtr,"GEOMOBJECT",10))
|
||||
|
||||
{
|
||||
m_vMeshes.push_back(Mesh());
|
||||
m_vMeshes.push_back(Mesh("UNNAMED"));
|
||||
ParseLV1ObjectBlock(m_vMeshes.back());
|
||||
continue;
|
||||
}
|
||||
|
@ -308,14 +311,14 @@ void Parser::Parse()
|
|||
if (TokenMatch(filePtr,"LIGHTOBJECT",11))
|
||||
|
||||
{
|
||||
m_vLights.push_back(Light());
|
||||
m_vLights.push_back(Light("UNNAMED"));
|
||||
ParseLV1ObjectBlock(m_vLights.back());
|
||||
continue;
|
||||
}
|
||||
// camera object
|
||||
if (TokenMatch(filePtr,"CAMERAOBJECT",12))
|
||||
{
|
||||
m_vCameras.push_back(Camera());
|
||||
m_vCameras.push_back(Camera("UNNAMED"));
|
||||
ParseLV1ObjectBlock(m_vCameras.back());
|
||||
continue;
|
||||
}
|
||||
|
@ -426,28 +429,25 @@ void Parser::ParseLV1SoftSkinBlock()
|
|||
// Reserve enough storage
|
||||
vert.mBoneWeights.reserve(numWeights);
|
||||
|
||||
for (unsigned int w = 0; w < numWeights;++w)
|
||||
{
|
||||
std::string bone;
|
||||
std::string bone;
|
||||
for (unsigned int w = 0; w < numWeights;++w) {
|
||||
bone.clear();
|
||||
ParseString(bone,"*MESH_SOFTSKINVERTS.Bone");
|
||||
|
||||
// Find the bone in the mesh's list
|
||||
std::pair<int,ai_real> me;
|
||||
me.first = -1;
|
||||
|
||||
for (unsigned int n = 0; n < curMesh->mBones.size();++n)
|
||||
{
|
||||
if (curMesh->mBones[n].mName == bone)
|
||||
{
|
||||
for (unsigned int n = 0; n < curMesh->mBones.size();++n) {
|
||||
if (curMesh->mBones[n].mName == bone) {
|
||||
me.first = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (-1 == me.first)
|
||||
{
|
||||
if (-1 == me.first) {
|
||||
// We don't have this bone yet, so add it to the list
|
||||
me.first = (int)curMesh->mBones.size();
|
||||
curMesh->mBones.push_back(ASE::Bone(bone));
|
||||
me.first = static_cast<int>( curMesh->mBones.size() );
|
||||
curMesh->mBones.push_back( ASE::Bone( bone ) );
|
||||
}
|
||||
ParseLV4MeshFloat( me.second );
|
||||
|
||||
|
@ -528,7 +528,7 @@ void Parser::ParseLV1MaterialListBlock()
|
|||
ParseLV4MeshLong(iMaterialCount);
|
||||
|
||||
// now allocate enough storage to hold all materials
|
||||
m_vMaterials.resize(iOldMaterialCount+iMaterialCount);
|
||||
m_vMaterials.resize(iOldMaterialCount+iMaterialCount, Material("INVALID"));
|
||||
continue;
|
||||
}
|
||||
if (TokenMatch(filePtr,"MATERIAL",8))
|
||||
|
@ -706,7 +706,7 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
|
|||
ParseLV4MeshLong(iNumSubMaterials);
|
||||
|
||||
// allocate enough storage
|
||||
mat.avSubMaterials.resize(iNumSubMaterials);
|
||||
mat.avSubMaterials.resize(iNumSubMaterials, Material("INVALID SUBMATERIAL"));
|
||||
}
|
||||
// submaterial chunks
|
||||
if (TokenMatch(filePtr,"SUBMATERIAL",11))
|
||||
|
@ -744,6 +744,7 @@ void Parser::ParseLV3MapBlock(Texture& map)
|
|||
// empty the texture won't be used later.
|
||||
// ***********************************************************
|
||||
bool parsePath = true;
|
||||
std::string temp;
|
||||
while (true)
|
||||
{
|
||||
if ('*' == *filePtr)
|
||||
|
@ -752,7 +753,7 @@ void Parser::ParseLV3MapBlock(Texture& map)
|
|||
// type of map
|
||||
if (TokenMatch(filePtr,"MAP_CLASS" ,9))
|
||||
{
|
||||
std::string temp;
|
||||
temp.clear();
|
||||
if(!ParseString(temp,"*MAP_CLASS"))
|
||||
SkipToNextToken();
|
||||
if (temp != "Bitmap" && temp != "Normal Bump")
|
||||
|
@ -1553,7 +1554,7 @@ void Parser::ParseLV3MeshWeightsBlock(ASE::Mesh& mesh)
|
|||
void Parser::ParseLV4MeshBones(unsigned int iNumBones,ASE::Mesh& mesh)
|
||||
{
|
||||
AI_ASE_PARSER_INIT();
|
||||
mesh.mBones.resize(iNumBones);
|
||||
mesh.mBones.resize(iNumBones, Bone("UNNAMED"));
|
||||
while (true)
|
||||
{
|
||||
if ('*' == *filePtr)
|
||||
|
|
139
code/ASEParser.h
139
code/ASEParser.h
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -52,8 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||
|
||||
// for some helper routines like IsSpace()
|
||||
#include "ParsingUtils.h"
|
||||
#include "qnan.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/qnan.h>
|
||||
|
||||
// ASE is quite similar to 3ds. We can reuse some structures
|
||||
#include "3DSLoader.h"
|
||||
|
@ -67,10 +68,53 @@ using namespace D3DS;
|
|||
/** Helper structure representing an ASE material */
|
||||
struct Material : public D3DS::Material
|
||||
{
|
||||
//! Default constructor
|
||||
Material() : pcInstance(NULL), bNeed (false)
|
||||
//! Default constructor has been deleted
|
||||
Material() = delete;
|
||||
|
||||
|
||||
//! Constructor with explicit name
|
||||
explicit Material(const std::string &name)
|
||||
: D3DS::Material(name)
|
||||
, pcInstance(NULL)
|
||||
, bNeed (false)
|
||||
{}
|
||||
|
||||
|
||||
Material(const Material &other) = default;
|
||||
Material &operator=(const Material &other) = default;
|
||||
|
||||
|
||||
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||
Material(Material &&other)
|
||||
: D3DS::Material(std::move(other))
|
||||
, avSubMaterials(std::move(other.avSubMaterials))
|
||||
, pcInstance(std::move(other.pcInstance))
|
||||
, bNeed(std::move(other.bNeed))
|
||||
{
|
||||
other.pcInstance = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Material &operator=(Material &&other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
D3DS::Material::operator=(std::move(other));
|
||||
|
||||
avSubMaterials = std::move(other.avSubMaterials);
|
||||
pcInstance = std::move(other.pcInstance);
|
||||
bNeed = std::move(other.bNeed);
|
||||
|
||||
other.pcInstance = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
~Material() {}
|
||||
|
||||
|
||||
//! Contains all sub materials of this material
|
||||
std::vector<Material> avSubMaterials;
|
||||
|
||||
|
@ -125,15 +169,7 @@ struct Face : public FaceWithSmoothingGroup
|
|||
struct Bone
|
||||
{
|
||||
//! Constructor
|
||||
Bone()
|
||||
{
|
||||
static int iCnt = 0;
|
||||
|
||||
// Generate a default name for the bone
|
||||
char szTemp[128];
|
||||
::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
||||
mName = szTemp;
|
||||
}
|
||||
Bone() = delete;
|
||||
|
||||
//! Construction from an existing name
|
||||
explicit Bone( const std::string& name)
|
||||
|
@ -213,22 +249,19 @@ struct BaseNode
|
|||
{
|
||||
enum Type {Light, Camera, Mesh, Dummy} mType;
|
||||
|
||||
//! Constructor. Creates a default name for the node
|
||||
explicit BaseNode(Type _mType)
|
||||
: mType (_mType)
|
||||
, mProcessed (false)
|
||||
{
|
||||
// generate a default name for the node
|
||||
static int iCnt = 0;
|
||||
char szTemp[128]; // should be sufficiently large
|
||||
::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
||||
mName = szTemp;
|
||||
|
||||
//! Construction from an existing name
|
||||
BaseNode(Type _mType, const std::string &name)
|
||||
: mType (_mType)
|
||||
, mName (name)
|
||||
, mProcessed (false)
|
||||
{
|
||||
// Set mTargetPosition to qnan
|
||||
const ai_real qnan = get_qnan();
|
||||
mTargetPosition.x = qnan;
|
||||
}
|
||||
|
||||
|
||||
//! Name of the mesh
|
||||
std::string mName;
|
||||
|
||||
|
@ -260,19 +293,22 @@ struct BaseNode
|
|||
/** Helper structure to represent an ASE file mesh */
|
||||
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode
|
||||
{
|
||||
//! Constructor.
|
||||
Mesh()
|
||||
: BaseNode (BaseNode::Mesh)
|
||||
, bSkip (false)
|
||||
//! Default constructor has been deleted
|
||||
Mesh() = delete;
|
||||
|
||||
|
||||
//! Construction from an existing name
|
||||
explicit Mesh(const std::string &name)
|
||||
: BaseNode (BaseNode::Mesh, name)
|
||||
, iMaterialIndex(Face::DEFAULT_MATINDEX)
|
||||
, bSkip (false)
|
||||
{
|
||||
// use 2 texture vertex components by default
|
||||
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||
this->mNumUVComponents[c] = 2;
|
||||
|
||||
// setup the default material index by default
|
||||
iMaterialIndex = Face::DEFAULT_MATINDEX;
|
||||
}
|
||||
|
||||
|
||||
//! List of all texture coordinate sets
|
||||
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||
|
||||
|
@ -307,17 +343,21 @@ struct Light : public BaseNode
|
|||
DIRECTIONAL
|
||||
};
|
||||
|
||||
//! Constructor.
|
||||
Light()
|
||||
: BaseNode (BaseNode::Light)
|
||||
, mLightType (OMNI)
|
||||
, mColor (1.f,1.f,1.f)
|
||||
, mIntensity (1.f) // light is white by default
|
||||
, mAngle (45.f)
|
||||
, mFalloff (0.f)
|
||||
//! Default constructor has been deleted
|
||||
Light() = delete;
|
||||
|
||||
//! Construction from an existing name
|
||||
explicit Light(const std::string &name)
|
||||
: BaseNode (BaseNode::Light, name)
|
||||
, mLightType (OMNI)
|
||||
, mColor (1.f,1.f,1.f)
|
||||
, mIntensity (1.f) // light is white by default
|
||||
, mAngle (45.f)
|
||||
, mFalloff (0.f)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LightType mLightType;
|
||||
aiColor3D mColor;
|
||||
ai_real mIntensity;
|
||||
|
@ -335,16 +375,21 @@ struct Camera : public BaseNode
|
|||
TARGET
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
Camera()
|
||||
: BaseNode (BaseNode::Camera)
|
||||
, mFOV (0.75f) // in radians
|
||||
, mNear (0.1f)
|
||||
, mFar (1000.f) // could be zero
|
||||
, mCameraType (FREE)
|
||||
//! Default constructor has been deleted
|
||||
Camera() = delete;
|
||||
|
||||
|
||||
//! Construction from an existing name
|
||||
explicit Camera(const std::string &name)
|
||||
: BaseNode (BaseNode::Camera, name)
|
||||
, mFOV (0.75f) // in radians
|
||||
, mNear (0.1f)
|
||||
, mFar (1000.f) // could be zero
|
||||
, mCameraType (FREE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ai_real mFOV, mNear, mFar;
|
||||
CameraType mCameraType;
|
||||
};
|
||||
|
@ -355,7 +400,7 @@ struct Dummy : public BaseNode
|
|||
{
|
||||
//! Constructor
|
||||
Dummy()
|
||||
: BaseNode (BaseNode::Dummy)
|
||||
: BaseNode (BaseNode::Dummy, "DUMMY")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -41,13 +42,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file AssbinExporter.cpp
|
||||
* ASSBIN exporter main code
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||
|
||||
#include "assbin_chunks.h"
|
||||
#include <assimp/version.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include "ProcessHelper.h"
|
||||
#include "Exceptional.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||
# include <zlib.h>
|
||||
|
@ -57,10 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
namespace Assimp {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -51,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
// internal headers
|
||||
#include "AssbinLoader.h"
|
||||
#include "assbin_chunks.h"
|
||||
#include "MemoryIOWrapper.h"
|
||||
#include <assimp/MemoryIOWrapper.h>
|
||||
#include <assimp/mesh.h>
|
||||
#include <assimp/anim.h>
|
||||
#include <assimp/scene.h>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -46,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_ASSBINIMPORTER_H_INC
|
||||
#define AI_ASSBINIMPORTER_H_INC
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
|
||||
struct aiMesh;
|
||||
struct aiNode;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -50,12 +51,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#include "GenericProperty.h"
|
||||
#include <assimp/GenericProperty.h>
|
||||
#include "CInterfaceIOWrapper.h"
|
||||
#include "Importer.h"
|
||||
#include "Exceptional.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
#include "ScenePrivate.h"
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <list>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -41,6 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file AssxmlExporter.cpp
|
||||
* ASSXML exporter main code
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assimp/version.h>
|
||||
#include "ProcessHelper.h"
|
||||
|
@ -57,9 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
namespace Assimp {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -51,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "B3DImporter.h"
|
||||
#include "TextureTransform.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <memory>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/anim.h>
|
||||
|
@ -93,7 +94,6 @@ void DeleteAllBarePointers(std::vector<T>& x)
|
|||
|
||||
B3DImporter::~B3DImporter()
|
||||
{
|
||||
DeleteAllBarePointers(_animations);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -267,6 +267,21 @@ T *B3DImporter::to_array( const vector<T> &v ){
|
|||
return p;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template<class T>
|
||||
T **unique_to_array( vector<std::unique_ptr<T> > &v ){
|
||||
if( v.empty() ) {
|
||||
return 0;
|
||||
}
|
||||
T **p = new T*[ v.size() ];
|
||||
for( size_t i = 0; i < v.size(); ++i ){
|
||||
p[i] = v[i].release();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void B3DImporter::ReadTEXS(){
|
||||
while( ChunkSize() ){
|
||||
|
@ -295,8 +310,7 @@ void B3DImporter::ReadBRUS(){
|
|||
/*int blend=**/ReadInt();
|
||||
int fx=ReadInt();
|
||||
|
||||
aiMaterial *mat=new aiMaterial;
|
||||
_materials.push_back( mat );
|
||||
std::unique_ptr<aiMaterial> mat(new aiMaterial);
|
||||
|
||||
// Name
|
||||
aiString ainame( name );
|
||||
|
@ -333,6 +347,7 @@ void B3DImporter::ReadBRUS(){
|
|||
mat->AddProperty( &texname,AI_MATKEY_TEXTURE_DIFFUSE(0) );
|
||||
}
|
||||
}
|
||||
_materials.emplace_back( std::move(mat) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,8 +401,7 @@ void B3DImporter::ReadTRIS( int v0 ){
|
|||
Fail( "Bad material id" );
|
||||
}
|
||||
|
||||
aiMesh *mesh=new aiMesh;
|
||||
_meshes.push_back( mesh );
|
||||
std::unique_ptr<aiMesh> mesh(new aiMesh);
|
||||
|
||||
mesh->mMaterialIndex=matid;
|
||||
mesh->mNumFaces=0;
|
||||
|
@ -415,6 +429,8 @@ void B3DImporter::ReadTRIS( int v0 ){
|
|||
++mesh->mNumFaces;
|
||||
++face;
|
||||
}
|
||||
|
||||
_meshes.emplace_back( std::move(mesh) );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -500,11 +516,11 @@ void B3DImporter::ReadANIM(){
|
|||
int frames=ReadInt();
|
||||
float fps=ReadFloat();
|
||||
|
||||
aiAnimation *anim=new aiAnimation;
|
||||
_animations.push_back( anim );
|
||||
std::unique_ptr<aiAnimation> anim(new aiAnimation);
|
||||
|
||||
anim->mDuration=frames;
|
||||
anim->mTicksPerSecond=fps;
|
||||
_animations.emplace_back( std::move(anim) );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -531,7 +547,7 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
|
|||
node->mParent=parent;
|
||||
node->mTransformation=tform;
|
||||
|
||||
aiNodeAnim *nodeAnim=0;
|
||||
std::unique_ptr<aiNodeAnim> nodeAnim;
|
||||
vector<unsigned> meshes;
|
||||
vector<aiNode*> children;
|
||||
|
||||
|
@ -549,11 +565,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
|
|||
ReadANIM();
|
||||
}else if( t=="KEYS" ){
|
||||
if( !nodeAnim ){
|
||||
nodeAnim=new aiNodeAnim;
|
||||
_nodeAnims.push_back( nodeAnim );
|
||||
nodeAnim.reset(new aiNodeAnim);
|
||||
nodeAnim->mNodeName=node->mName;
|
||||
}
|
||||
ReadKEYS( nodeAnim );
|
||||
ReadKEYS( nodeAnim.get() );
|
||||
}else if( t=="NODE" ){
|
||||
aiNode *child=ReadNODE( node );
|
||||
children.push_back( child );
|
||||
|
@ -561,6 +576,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
|
|||
ExitChunk();
|
||||
}
|
||||
|
||||
if (nodeAnim) {
|
||||
_nodeAnims.emplace_back( std::move(nodeAnim) );
|
||||
}
|
||||
|
||||
node->mNumMeshes= static_cast<unsigned int>(meshes.size());
|
||||
node->mMeshes=to_array( meshes );
|
||||
|
||||
|
@ -586,7 +605,6 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
|||
|
||||
_nodeAnims.clear();
|
||||
|
||||
DeleteAllBarePointers(_animations);
|
||||
_animations.clear();
|
||||
|
||||
string t=ReadChunk();
|
||||
|
@ -622,7 +640,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
|||
aiNode *node=_nodes[i];
|
||||
|
||||
for( size_t j=0;j<node->mNumMeshes;++j ){
|
||||
aiMesh *mesh=_meshes[node->mMeshes[j]];
|
||||
aiMesh *mesh = _meshes[node->mMeshes[j]].get();
|
||||
|
||||
int n_tris=mesh->mNumFaces;
|
||||
int n_verts=mesh->mNumVertices=n_tris * 3;
|
||||
|
@ -685,27 +703,28 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
|||
|
||||
//nodes
|
||||
scene->mRootNode=_nodes[0];
|
||||
_nodes.clear(); // node ownership now belongs to scene
|
||||
|
||||
//material
|
||||
if( !_materials.size() ){
|
||||
_materials.push_back( new aiMaterial );
|
||||
_materials.emplace_back( std::unique_ptr<aiMaterial>(new aiMaterial) );
|
||||
}
|
||||
scene->mNumMaterials= static_cast<unsigned int>(_materials.size());
|
||||
scene->mMaterials=to_array( _materials );
|
||||
scene->mMaterials = unique_to_array( _materials );
|
||||
|
||||
//meshes
|
||||
scene->mNumMeshes= static_cast<unsigned int>(_meshes.size());
|
||||
scene->mMeshes=to_array( _meshes );
|
||||
scene->mMeshes = unique_to_array( _meshes );
|
||||
|
||||
//animations
|
||||
if( _animations.size()==1 && _nodeAnims.size() ){
|
||||
|
||||
aiAnimation *anim=_animations.back();
|
||||
aiAnimation *anim = _animations.back().get();
|
||||
anim->mNumChannels=static_cast<unsigned int>(_nodeAnims.size());
|
||||
anim->mChannels=to_array( _nodeAnims );
|
||||
anim->mChannels = unique_to_array( _nodeAnims );
|
||||
|
||||
scene->mNumAnimations=static_cast<unsigned int>(_animations.size());
|
||||
scene->mAnimations=to_array( _animations );
|
||||
scene->mAnimations=unique_to_array( _animations );
|
||||
}
|
||||
|
||||
// convert to RH
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -47,8 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/types.h>
|
||||
#include <assimp/mesh.h>
|
||||
#include <assimp/material.h>
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct aiNodeAnim;
|
||||
|
@ -116,15 +118,15 @@ private:
|
|||
std::vector<unsigned> _stack;
|
||||
|
||||
std::vector<std::string> _textures;
|
||||
std::vector<aiMaterial*> _materials;
|
||||
std::vector<std::unique_ptr<aiMaterial> > _materials;
|
||||
|
||||
int _vflags,_tcsets,_tcsize;
|
||||
std::vector<Vertex> _vertices;
|
||||
|
||||
std::vector<aiNode*> _nodes;
|
||||
std::vector<aiMesh*> _meshes;
|
||||
std::vector<aiNodeAnim*> _nodeAnims;
|
||||
std::vector<aiAnimation*> _animations;
|
||||
std::vector<std::unique_ptr<aiMesh> > _meshes;
|
||||
std::vector<std::unique_ptr<aiNodeAnim> > _nodeAnims;
|
||||
std::vector<std::unique_ptr<aiAnimation> > _animations;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -45,11 +46,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_BVH_IMPORTER
|
||||
|
||||
#include "BVHLoader.h"
|
||||
#include "fast_atof.h"
|
||||
#include "SkeletonMeshBuilder.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/SkeletonMeshBuilder.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <memory>
|
||||
#include "TinyFormatter.h"
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/importerdesc.h>
|
||||
|
@ -198,6 +199,7 @@ aiNode* BVHLoader::ReadNode()
|
|||
Node& internNode = mNodes.back();
|
||||
|
||||
// now read the node's contents
|
||||
std::string siteToken;
|
||||
while( 1)
|
||||
{
|
||||
std::string token = GetNextToken();
|
||||
|
@ -217,7 +219,8 @@ aiNode* BVHLoader::ReadNode()
|
|||
else if( token == "End")
|
||||
{
|
||||
// The real symbol is "End Site". Second part comes in a separate token
|
||||
std::string siteToken = GetNextToken();
|
||||
siteToken.clear();
|
||||
siteToken = GetNextToken();
|
||||
if( siteToken != "Site")
|
||||
ThrowException( format() << "Expected \"End Site\" keyword, but found \"" << token << " " << siteToken << "\"." );
|
||||
|
||||
|
@ -261,21 +264,18 @@ aiNode* BVHLoader::ReadEndSite( const std::string& pParentName)
|
|||
aiNode* node = new aiNode( "EndSite_" + pParentName);
|
||||
|
||||
// now read the node's contents. Only possible entry is "OFFSET"
|
||||
while( 1)
|
||||
{
|
||||
std::string token = GetNextToken();
|
||||
std::string token;
|
||||
while( 1) {
|
||||
token.clear();
|
||||
token = GetNextToken();
|
||||
|
||||
// end node's offset
|
||||
if( token == "OFFSET")
|
||||
{
|
||||
if( token == "OFFSET") {
|
||||
ReadNodeOffset( node);
|
||||
}
|
||||
else if( token == "}")
|
||||
{
|
||||
} else if( token == "}") {
|
||||
// we're done with the end node
|
||||
break;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
// everything else is a parse error
|
||||
ThrowException( format() << "Unknown keyword \"" << token << "\"." );
|
||||
}
|
||||
|
@ -295,8 +295,10 @@ void BVHLoader::ReadNodeOffset( aiNode* pNode)
|
|||
offset.z = GetNextTokenAsFloat();
|
||||
|
||||
// build a transformation matrix from it
|
||||
pNode->mTransformation = aiMatrix4x4( 1.0f, 0.0f, 0.0f, offset.x, 0.0f, 1.0f, 0.0f, offset.y,
|
||||
0.0f, 0.0f, 1.0f, offset.z, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
pNode->mTransformation = aiMatrix4x4( 1.0f, 0.0f, 0.0f, offset.x,
|
||||
0.0f, 1.0f, 0.0f, offset.y,
|
||||
0.0f, 0.0f, 1.0f, offset.z,
|
||||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -48,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_BVHLOADER_H_INC
|
||||
#define AI_BVHLOADER_H_INC
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
|
||||
struct aiNode;
|
||||
|
||||
|
@ -83,7 +84,10 @@ class BVHLoader : public BaseImporter
|
|||
std::vector<ChannelType> mChannels;
|
||||
std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames
|
||||
|
||||
Node() { }
|
||||
Node()
|
||||
: mNode(nullptr)
|
||||
{ }
|
||||
|
||||
explicit Node( const aiNode* pNode) : mNode( pNode) { }
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -44,10 +45,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* @brief Implementation of BaseImporter
|
||||
*/
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include "FileSystemFilter.h"
|
||||
#include "Importer.h"
|
||||
#include "ByteSwapper.h"
|
||||
#include <assimp/ByteSwapper.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/postprocess.h>
|
||||
|
@ -114,13 +115,12 @@ void BaseImporter::SetupProperties(const Importer* /*pImp*/)
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
|
||||
{
|
||||
void BaseImporter::GetExtensionList(std::set<std::string>& extensions) {
|
||||
const aiImporterDesc* desc = GetInfo();
|
||||
ai_assert(desc != NULL);
|
||||
ai_assert(desc != nullptr);
|
||||
|
||||
const char* ext = desc->mFileExtensions;
|
||||
ai_assert(ext != NULL);
|
||||
ai_assert(ext != nullptr );
|
||||
|
||||
const char* last = ext;
|
||||
do {
|
||||
|
@ -144,21 +144,19 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
|
|||
unsigned int searchBytes /* = 200 */,
|
||||
bool tokensSol /* false */)
|
||||
{
|
||||
ai_assert( NULL != tokens );
|
||||
ai_assert( nullptr != tokens );
|
||||
ai_assert( 0 != numTokens );
|
||||
ai_assert( 0 != searchBytes);
|
||||
|
||||
if (!pIOHandler)
|
||||
if ( nullptr == pIOHandler ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
||||
if (pStream.get() ) {
|
||||
// read 200 characters from the file
|
||||
std::unique_ptr<char[]> _buffer (new char[searchBytes+1 /* for the '\0' */]);
|
||||
char* buffer = _buffer.get();
|
||||
if( NULL == buffer ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t read = pStream->Read(buffer,1,searchBytes);
|
||||
if( !read ) {
|
||||
|
@ -180,9 +178,17 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
|
|||
}
|
||||
*cur2 = '\0';
|
||||
|
||||
for (unsigned int i = 0; i < numTokens;++i) {
|
||||
ai_assert(NULL != tokens[i]);
|
||||
const char* r = strstr(buffer,tokens[i]);
|
||||
std::string token;
|
||||
for (unsigned int i = 0; i < numTokens; ++i ) {
|
||||
ai_assert( nullptr != tokens[i] );
|
||||
const size_t len( strlen( tokens[ i ] ) );
|
||||
token.clear();
|
||||
const char *ptr( tokens[ i ] );
|
||||
for ( size_t tokIdx = 0; tokIdx < len; ++tokIdx ) {
|
||||
token.push_back( tolower( *ptr ) );
|
||||
++ptr;
|
||||
}
|
||||
const char* r = strstr( buffer, token.c_str() );
|
||||
if( !r ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -245,7 +251,8 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
|
|||
/* static */ bool BaseImporter::CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile,
|
||||
const void* _magic, unsigned int num, unsigned int offset, unsigned int size)
|
||||
{
|
||||
ai_assert(size <= 16 && _magic);
|
||||
ai_assert( size <= 16 );
|
||||
ai_assert( _magic );
|
||||
|
||||
if (!pIOHandler) {
|
||||
return false;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -42,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of BaseProcess */
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include "BaseProcess.h"
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -44,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define INCLUDED_AI_BASEPROCESS_H
|
||||
|
||||
#include <map>
|
||||
#include "GenericProperty.h"
|
||||
#include <assimp/GenericProperty.h>
|
||||
|
||||
struct aiScene;
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -47,10 +48,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
|
||||
#include "Bitmap.h"
|
||||
#include <assimp/Bitmap.h>
|
||||
#include <assimp/texture.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include "ByteSwapper.h"
|
||||
#include <assimp/ByteSwapper.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
@ -84,7 +85,8 @@ namespace Assimp {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::size_t Copy(uint8_t* data, T& field) {
|
||||
inline
|
||||
std::size_t Copy(uint8_t* data, const T &field) {
|
||||
#ifdef AI_BUILD_BIG_ENDIAN
|
||||
T field_swapped=AI_BE(field);
|
||||
std::memcpy(data, &field_swapped, sizeof(field)); return sizeof(field);
|
||||
|
|
|
@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_BLEND_BMESH_H
|
||||
#define INCLUDED_AI_BLEND_BMESH_H
|
||||
|
||||
#include "LogAux.h"
|
||||
#include <assimp/LogAux.h>
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -47,9 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
|
||||
#include "BlenderDNA.h"
|
||||
#include "StreamReader.h"
|
||||
#include "fast_atof.h"
|
||||
#include "TinyFormatter.h"
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/TinyFormatter.h>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::Blender;
|
||||
|
@ -57,12 +58,11 @@ using namespace Assimp::Formatter;
|
|||
|
||||
static bool match4(StreamReaderAny& stream, const char* string) {
|
||||
ai_assert( nullptr != string );
|
||||
char tmp[] = {
|
||||
(const char)(stream).GetI1(),
|
||||
(const char)(stream).GetI1(),
|
||||
(const char)(stream).GetI1(),
|
||||
(const char)(stream).GetI1()
|
||||
};
|
||||
char tmp[4];
|
||||
tmp[ 0 ] = ( stream ).GetI1();
|
||||
tmp[ 1 ] = ( stream ).GetI1();
|
||||
tmp[ 2 ] = ( stream ).GetI1();
|
||||
tmp[ 3 ] = ( stream ).GetI1();
|
||||
return (tmp[0]==string[0] && tmp[1]==string[1] && tmp[2]==string[2] && tmp[3]==string[3]);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -46,8 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_BLEND_DNA_H
|
||||
#define INCLUDED_AI_BLEND_DNA_H
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include "StreamReader.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
|
@ -204,7 +205,7 @@ enum ErrorPolicy {
|
|||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** Represents a data structure in a BLEND file. A Structure defines n fields
|
||||
* and their locatios and encodings the input stream. Usually, every
|
||||
* and their locations and encodings the input stream. Usually, every
|
||||
* Structure instance pertains to one equally-named data structure in the
|
||||
* BlenderScene.h header. This class defines various utilities to map a
|
||||
* binary `blob` read from the file to such a structure instance with
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -47,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define INCLUDED_AI_BLEND_DNA_INL
|
||||
|
||||
#include <memory>
|
||||
#include "TinyFormatter.h"
|
||||
#include <assimp/TinyFormatter.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Blender {
|
||||
|
@ -501,7 +502,7 @@ const FileBlockHead* Structure :: LocateFileBlockForAddress(const Pointer & ptrv
|
|||
{
|
||||
// the file blocks appear in list sorted by
|
||||
// with ascending base addresses so we can run a
|
||||
// binary search to locate the pointee quickly.
|
||||
// binary search to locate the pointer quickly.
|
||||
|
||||
// NOTE: Blender seems to distinguish between side-by-side
|
||||
// data (stored in the same data block) and far pointers,
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -121,9 +122,11 @@ namespace Blender {
|
|||
# pragma warning(disable:4351)
|
||||
#endif
|
||||
|
||||
// As counter-intuitive as it may seem, a comparator must return false for equal values.
|
||||
// The C++ standard defines and expects this behavior: true if lhs < rhs, false otherwise.
|
||||
struct ObjectCompare {
|
||||
bool operator() (const Object* left, const Object* right) const {
|
||||
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
|
||||
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -142,9 +145,11 @@ namespace Blender {
|
|||
, db(db)
|
||||
{}
|
||||
|
||||
// As counter-intuitive as it may seem, a comparator must return false for equal values.
|
||||
// The C++ standard defines and expects this behavior: true if lhs < rhs, false otherwise.
|
||||
struct ObjectCompare {
|
||||
bool operator() (const Object* left, const Object* right) const {
|
||||
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
|
||||
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -53,13 +54,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "BlenderIntermediate.h"
|
||||
#include "BlenderModifier.h"
|
||||
#include "BlenderBMesh.h"
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/importerdesc.h>
|
||||
|
||||
#include "StringComparison.h"
|
||||
#include "StreamReader.h"
|
||||
#include "MemoryIOWrapper.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/MemoryIOWrapper.h>
|
||||
|
||||
#include <cctype>
|
||||
|
||||
|
@ -153,14 +154,6 @@ void BlenderImporter::SetupProperties(const Importer* /*pImp*/)
|
|||
// nothing to be done for the moment
|
||||
}
|
||||
|
||||
struct free_it {
|
||||
free_it(void* free) : free(free) {}
|
||||
~free_it() {
|
||||
::free(this->free);
|
||||
}
|
||||
|
||||
void* free;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
|
@ -168,8 +161,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
|||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
#ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
|
||||
Bytef* dest = NULL;
|
||||
free_it free_it_really(dest);
|
||||
std::vector<Bytef> uncompressed;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -217,6 +209,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
size_t total = 0l;
|
||||
|
||||
// TODO: be smarter about this, decompress directly into heap buffer
|
||||
// and decompress the data .... do 1k chunks in the hope that we won't kill the stack
|
||||
#define MYBLOCK 1024
|
||||
Bytef block[MYBLOCK];
|
||||
|
@ -231,8 +224,8 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
|||
}
|
||||
const size_t have = MYBLOCK - zstream.avail_out;
|
||||
total += have;
|
||||
dest = reinterpret_cast<Bytef*>( realloc(dest,total) );
|
||||
memcpy(dest + total - have,block,have);
|
||||
uncompressed.resize(total);
|
||||
memcpy(uncompressed.data() + total - have,block,have);
|
||||
}
|
||||
while (ret != Z_STREAM_END);
|
||||
|
||||
|
@ -240,7 +233,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
|||
inflateEnd(&zstream);
|
||||
|
||||
// replace the input stream with a memory stream
|
||||
stream.reset(new MemoryIOStream(reinterpret_cast<uint8_t*>(dest),total));
|
||||
stream.reset(new MemoryIOStream(reinterpret_cast<uint8_t*>(uncompressed.data()),total));
|
||||
|
||||
// .. and retry
|
||||
stream->Read(magic,7,1);
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -45,8 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_BLEND_LOADER_H
|
||||
#define INCLUDED_AI_BLEND_LOADER_H
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include "LogAux.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/LogAux.h>
|
||||
#include <memory>
|
||||
|
||||
struct aiNode;
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -47,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "BlenderModifier.h"
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include "Subdivision.h"
|
||||
#include <assimp/Subdivision.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <memory>
|
||||
|
||||
|
@ -69,34 +70,6 @@ static const fpCreateModifier creators[] = {
|
|||
NULL // sentinel
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// just testing out some new macros to simplify logging
|
||||
#define ASSIMP_LOG_WARN_F(string,...)\
|
||||
DefaultLogger::get()->warn((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_ERROR_F(string,...)\
|
||||
DefaultLogger::get()->error((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_DEBUG_F(string,...)\
|
||||
DefaultLogger::get()->debug((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_INFO_F(string,...)\
|
||||
DefaultLogger::get()->info((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
|
||||
#define ASSIMP_LOG_WARN(string)\
|
||||
DefaultLogger::get()->warn(string)
|
||||
|
||||
#define ASSIMP_LOG_ERROR(string)\
|
||||
DefaultLogger::get()->error(string)
|
||||
|
||||
#define ASSIMP_LOG_DEBUG(string)\
|
||||
DefaultLogger::get()->debug(string)
|
||||
|
||||
#define ASSIMP_LOG_INFO(string)\
|
||||
DefaultLogger::get()->info(string)
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
struct SharedModifierData : ElemBase
|
||||
{
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -46,34 +47,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define INCLUDED_AI_BLEND_MODIFIER_H
|
||||
|
||||
#include "BlenderIntermediate.h"
|
||||
#include "TinyFormatter.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace Blender {
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
/** Dummy base class for all blender modifiers. Modifiers are reused between imports, so
|
||||
* they should be stateless and not try to cache model data. */
|
||||
/**
|
||||
* Dummy base class for all blender modifiers. Modifiers are reused between imports, so
|
||||
* they should be stateless and not try to cache model data.
|
||||
*/
|
||||
// -------------------------------------------------------------------------------------------
|
||||
class BlenderModifier
|
||||
{
|
||||
class BlenderModifier {
|
||||
public:
|
||||
/**
|
||||
* The class destructor, virtual.
|
||||
*/
|
||||
virtual ~BlenderModifier() {
|
||||
// empty
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// --------------------
|
||||
/** Check if *this* modifier is active, given a ModifierData& block.*/
|
||||
/**
|
||||
* Check if *this* modifier is active, given a ModifierData& block.
|
||||
*/
|
||||
virtual bool IsActive( const ModifierData& /*modin*/) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// --------------------
|
||||
/** Apply the modifier to a given output node. The original data used
|
||||
/**
|
||||
* Apply the modifier to a given output node. The original data used
|
||||
* to construct the node is given as well. Not called unless IsActive()
|
||||
* was called and gave positive response. */
|
||||
* was called and gave positive response.
|
||||
*/
|
||||
virtual void DoIt(aiNode& /*out*/,
|
||||
ConversionData& /*conv_data*/,
|
||||
const ElemBase& orig_modifier,
|
||||
|
@ -85,14 +91,13 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
/** Manage all known modifiers and instance and apply them if necessary */
|
||||
/**
|
||||
* Manage all known modifiers and instance and apply them if necessary
|
||||
*/
|
||||
// -------------------------------------------------------------------------------------------
|
||||
class BlenderModifierShowcase
|
||||
{
|
||||
class BlenderModifierShowcase {
|
||||
public:
|
||||
|
||||
// --------------------
|
||||
/** Apply all requested modifiers provided we support them. */
|
||||
void ApplyModifiers(aiNode& out,
|
||||
|
@ -102,25 +107,18 @@ public:
|
|||
);
|
||||
|
||||
private:
|
||||
|
||||
TempArray< std::vector,BlenderModifier > cached_modifiers;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// MODIFIERS
|
||||
|
||||
|
||||
// MODIFIERS /////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
/** Mirror modifier. Status: implemented. */
|
||||
/**
|
||||
* Mirror modifier. Status: implemented.
|
||||
*/
|
||||
// -------------------------------------------------------------------------------------------
|
||||
class BlenderModifier_Mirror : public BlenderModifier
|
||||
{
|
||||
class BlenderModifier_Mirror : public BlenderModifier {
|
||||
public:
|
||||
|
||||
// --------------------
|
||||
virtual bool IsActive( const ModifierData& modin);
|
||||
|
||||
|
@ -136,8 +134,7 @@ public:
|
|||
// -------------------------------------------------------------------------------------------
|
||||
/** Subdivision modifier. Status: dummy. */
|
||||
// -------------------------------------------------------------------------------------------
|
||||
class BlenderModifier_Subdivision : public BlenderModifier
|
||||
{
|
||||
class BlenderModifier_Subdivision : public BlenderModifier {
|
||||
public:
|
||||
|
||||
// --------------------
|
||||
|
@ -152,6 +149,7 @@ public:
|
|||
) ;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
#endif // !INCLUDED_AI_BLEND_MODIFIER_H
|
||||
|
|
|
@ -116,7 +116,7 @@ template <> void Structure :: Convert<MTex> (
|
|||
ReadField<ErrorPolicy_Igno>(temp,"projy",db);
|
||||
dest.projy = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||
ReadField<ErrorPolicy_Igno>(temp,"projz",db);
|
||||
dest.projx = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||
dest.projz = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||
ReadField<ErrorPolicy_Igno>(dest.mapping,"mapping",db);
|
||||
ReadFieldArray<ErrorPolicy_Igno>(dest.ofs,"ofs",db);
|
||||
ReadFieldArray<ErrorPolicy_Igno>(dest.size,"size",db);
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -58,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define ASSIMP_BLEND_WITH_POLY_2_TRI 1
|
||||
#endif
|
||||
|
||||
#include "LogAux.h"
|
||||
#include <assimp/LogAux.h>
|
||||
|
||||
#if ASSIMP_BLEND_WITH_GLU_TESSELLATE
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#endif
|
||||
|
||||
#include "C4DImporter.h"
|
||||
#include "TinyFormatter.h"
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include <memory>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
|
|
@ -44,8 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_CINEMA_4D_LOADER_H
|
||||
#define INCLUDED_AI_CINEMA_4D_LOADER_H
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include "LogAux.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/LogAux.h>
|
||||
|
||||
#include <map>
|
||||
struct aiNode;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Open Asset Import Library (assimp)
|
||||
# ----------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006-2017, assimp team
|
||||
# Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -71,6 +72,7 @@ SET( PUBLIC_HEADERS
|
|||
${HEADER_PATH}/matrix4x4.h
|
||||
${HEADER_PATH}/matrix4x4.inl
|
||||
${HEADER_PATH}/mesh.h
|
||||
${HEADER_PATH}/pbrmaterial.h
|
||||
${HEADER_PATH}/postprocess.h
|
||||
${HEADER_PATH}/quaternion.h
|
||||
${HEADER_PATH}/quaternion.inl
|
||||
|
@ -98,6 +100,40 @@ SET( PUBLIC_HEADERS
|
|||
${HEADER_PATH}/DefaultIOStream.h
|
||||
${HEADER_PATH}/DefaultIOSystem.h
|
||||
${HEADER_PATH}/SceneCombiner.h
|
||||
${HEADER_PATH}/fast_atof.h
|
||||
${HEADER_PATH}/qnan.h
|
||||
${HEADER_PATH}/BaseImporter.h
|
||||
${HEADER_PATH}/Hash.h
|
||||
${HEADER_PATH}/MemoryIOWrapper.h
|
||||
${HEADER_PATH}/ParsingUtils.h
|
||||
${HEADER_PATH}/StreamReader.h
|
||||
${HEADER_PATH}/StreamWriter.h
|
||||
${HEADER_PATH}/StringComparison.h
|
||||
${HEADER_PATH}/StringUtils.h
|
||||
${HEADER_PATH}/SGSpatialSort.h
|
||||
${HEADER_PATH}/GenericProperty.h
|
||||
${HEADER_PATH}/SpatialSort.h
|
||||
${HEADER_PATH}/SkeletonMeshBuilder.h
|
||||
${HEADER_PATH}/SmoothingGroups.h
|
||||
${HEADER_PATH}/SmoothingGroups.inl
|
||||
${HEADER_PATH}/StandardShapes.h
|
||||
${HEADER_PATH}/RemoveComments.h
|
||||
${HEADER_PATH}/Subdivision.h
|
||||
${HEADER_PATH}/Vertex.h
|
||||
${HEADER_PATH}/LineSplitter.h
|
||||
${HEADER_PATH}/TinyFormatter.h
|
||||
${HEADER_PATH}/Profiler.h
|
||||
${HEADER_PATH}/LogAux.h
|
||||
${HEADER_PATH}/Bitmap.h
|
||||
${HEADER_PATH}/XMLTools.h
|
||||
${HEADER_PATH}/IOStreamBuffer.h
|
||||
${HEADER_PATH}/CreateAnimMesh.h
|
||||
${HEADER_PATH}/irrXMLWrapper.h
|
||||
${HEADER_PATH}/BlobIOSystem.h
|
||||
${HEADER_PATH}/MathFunctions.h
|
||||
${HEADER_PATH}/Macros.h
|
||||
${HEADER_PATH}/Exceptional.h
|
||||
${HEADER_PATH}/ByteSwapper.h
|
||||
)
|
||||
|
||||
SET( Core_SRCS
|
||||
|
@ -117,69 +153,41 @@ SET( Logging_SRCS
|
|||
SOURCE_GROUP(Logging FILES ${Logging_SRCS})
|
||||
|
||||
SET( Common_SRCS
|
||||
fast_atof.h
|
||||
qnan.h
|
||||
BaseImporter.cpp
|
||||
BaseImporter.h
|
||||
BaseProcess.cpp
|
||||
BaseProcess.h
|
||||
Importer.h
|
||||
ScenePrivate.h
|
||||
PostStepRegistry.cpp
|
||||
ImporterRegistry.cpp
|
||||
ByteSwapper.h
|
||||
DefaultProgressHandler.h
|
||||
DefaultIOStream.cpp
|
||||
DefaultIOSystem.cpp
|
||||
CInterfaceIOWrapper.cpp
|
||||
CInterfaceIOWrapper.h
|
||||
Hash.h
|
||||
Importer.cpp
|
||||
IFF.h
|
||||
MemoryIOWrapper.h
|
||||
ParsingUtils.h
|
||||
StreamReader.h
|
||||
StreamWriter.h
|
||||
StringComparison.h
|
||||
StringUtils.h
|
||||
SGSpatialSort.cpp
|
||||
SGSpatialSort.h
|
||||
VertexTriangleAdjacency.cpp
|
||||
VertexTriangleAdjacency.h
|
||||
GenericProperty.h
|
||||
SpatialSort.cpp
|
||||
SpatialSort.h
|
||||
SceneCombiner.cpp
|
||||
ScenePreprocessor.cpp
|
||||
ScenePreprocessor.h
|
||||
SkeletonMeshBuilder.cpp
|
||||
SkeletonMeshBuilder.h
|
||||
SplitByBoneCountProcess.cpp
|
||||
SplitByBoneCountProcess.h
|
||||
ScaleProcess.cpp
|
||||
ScaleProcess.h
|
||||
SmoothingGroups.h
|
||||
StandardShapes.cpp
|
||||
StandardShapes.h
|
||||
TargetAnimation.cpp
|
||||
TargetAnimation.h
|
||||
RemoveComments.cpp
|
||||
RemoveComments.h
|
||||
Subdivision.cpp
|
||||
Subdivision.h
|
||||
scene.cpp
|
||||
Vertex.h
|
||||
LineSplitter.h
|
||||
TinyFormatter.h
|
||||
Profiler.h
|
||||
LogAux.h
|
||||
Bitmap.cpp
|
||||
Bitmap.h
|
||||
XMLTools.h
|
||||
Version.cpp
|
||||
IOStreamBuffer.h
|
||||
CreateAnimMesh.h
|
||||
CreateAnimMesh.cpp
|
||||
simd.h
|
||||
simd.cpp
|
||||
)
|
||||
SOURCE_GROUP(Common FILES ${Common_SRCS})
|
||||
|
||||
|
@ -457,30 +465,29 @@ ADD_ASSIMP_IMPORTER( BLEND
|
|||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( IFC
|
||||
IFCLoader.cpp
|
||||
IFCLoader.h
|
||||
IFCReaderGen1.cpp
|
||||
IFCReaderGen2.cpp
|
||||
IFCReaderGen.h
|
||||
IFCUtil.h
|
||||
IFCUtil.cpp
|
||||
IFCGeometry.cpp
|
||||
IFCMaterial.cpp
|
||||
IFCProfile.cpp
|
||||
IFCCurve.cpp
|
||||
IFCBoolean.cpp
|
||||
IFCOpenings.cpp
|
||||
STEPFile.h
|
||||
STEPFileReader.h
|
||||
STEPFileReader.cpp
|
||||
STEPFileEncoding.cpp
|
||||
STEPFileEncoding.h
|
||||
Importer/IFC/IFCLoader.cpp
|
||||
Importer/IFC/IFCLoader.h
|
||||
Importer/IFC/IFCReaderGen1_2x3.cpp
|
||||
Importer/IFC/IFCReaderGen2_2x3.cpp
|
||||
Importer/IFC/IFCReaderGen_2x3.h
|
||||
Importer/IFC/IFCUtil.h
|
||||
Importer/IFC/IFCUtil.cpp
|
||||
Importer/IFC/IFCGeometry.cpp
|
||||
Importer/IFC/IFCMaterial.cpp
|
||||
Importer/IFC/IFCProfile.cpp
|
||||
Importer/IFC/IFCCurve.cpp
|
||||
Importer/IFC/IFCBoolean.cpp
|
||||
Importer/IFC/IFCOpenings.cpp
|
||||
Importer/IFC/STEPFileReader.h
|
||||
Importer/IFC/STEPFileReader.cpp
|
||||
Importer/IFC/STEPFileEncoding.cpp
|
||||
Importer/IFC/STEPFileEncoding.h
|
||||
)
|
||||
if (ASSIMP_BUILD_IFC_IMPORTER)
|
||||
if (MSVC)
|
||||
set_source_files_properties(IFCReaderGen1.cpp IFCReaderGen2.cpp PROPERTIES COMPILE_FLAGS "/bigobj")
|
||||
set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "/bigobj")
|
||||
elseif(CMAKE_COMPILER_IS_MINGW)
|
||||
set_source_files_properties(IFCReaderGen1.cpp IFCReaderGen2.cpp PROPERTIES COMPILE_FLAGS "-O2 -Wa,-mbig-obj")
|
||||
set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "-O2 -Wa,-mbig-obj")
|
||||
endif()
|
||||
endif (ASSIMP_BUILD_IFC_IMPORTER)
|
||||
|
||||
|
@ -516,6 +523,13 @@ ADD_ASSIMP_IMPORTER( FBX
|
|||
FBXDeformer.cpp
|
||||
FBXBinaryTokenizer.cpp
|
||||
FBXDocumentUtil.cpp
|
||||
FBXExporter.h
|
||||
FBXExporter.cpp
|
||||
FBXExportNode.h
|
||||
FBXExportNode.cpp
|
||||
FBXExportProperty.h
|
||||
FBXExportProperty.cpp
|
||||
FBXCommon.h
|
||||
)
|
||||
|
||||
SET( PostProcessing_SRCS
|
||||
|
@ -525,6 +539,8 @@ SET( PostProcessing_SRCS
|
|||
ComputeUVMappingProcess.h
|
||||
ConvertToLHProcess.cpp
|
||||
ConvertToLHProcess.h
|
||||
EmbedTexturesProcess.cpp
|
||||
EmbedTexturesProcess.h
|
||||
FindDegenerates.cpp
|
||||
FindDegenerates.h
|
||||
FindInstancesProcess.cpp
|
||||
|
@ -570,10 +586,12 @@ SET( PostProcessing_SRCS
|
|||
PolyTools.h
|
||||
MakeVerboseFormat.cpp
|
||||
MakeVerboseFormat.h
|
||||
ScaleProcess.cpp
|
||||
ScaleProcess.h
|
||||
)
|
||||
SOURCE_GROUP( PostProcessing FILES ${PostProcessing_SRCS})
|
||||
|
||||
SET( IrrXML_SRCS irrXMLWrapper.h )
|
||||
SET( IrrXML_SRCS ${HEADER_PATH}/irrXMLWrapper.h )
|
||||
SOURCE_GROUP( IrrXML FILES ${IrrXML_SRCS})
|
||||
|
||||
ADD_ASSIMP_IMPORTER( Q3D
|
||||
|
@ -633,7 +651,7 @@ ADD_ASSIMP_IMPORTER( X
|
|||
XFileExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER(X3D
|
||||
ADD_ASSIMP_IMPORTER( X3D
|
||||
X3DExporter.cpp
|
||||
X3DExporter.hpp
|
||||
X3DImporter.cpp
|
||||
|
@ -695,6 +713,7 @@ ADD_ASSIMP_IMPORTER( MMD
|
|||
)
|
||||
|
||||
SET( Step_SRCS
|
||||
STEPFile.h
|
||||
StepExporter.h
|
||||
StepExporter.cpp
|
||||
)
|
||||
|
@ -703,7 +722,7 @@ SOURCE_GROUP( Step FILES ${Step_SRCS})
|
|||
SET( Exporter_SRCS
|
||||
Exporter.cpp
|
||||
AssimpCExport.cpp
|
||||
BlobIOSystem.h
|
||||
${HEADER_PATH}/BlobIOSystem.h
|
||||
)
|
||||
SOURCE_GROUP( Exporter FILES ${Exporter_SRCS})
|
||||
|
||||
|
@ -940,13 +959,13 @@ if (APPLE)
|
|||
|
||||
# PUBLIC_HEADER option does not support directory structure creation
|
||||
# add ./Compiler/*.h to assimp.framework via copy command
|
||||
ADD_CUSTOM_COMMAND(TARGET assimp POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
||||
ADD_CUSTOM_COMMAND(TARGET assimp POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
||||
"../${HEADER_PATH}/Compiler"
|
||||
assimp.framework/Headers/Compiler
|
||||
COMMENT "Copying public ./Compiler/ header files to framework bundle's Headers/Compiler/")
|
||||
endif(BUILD_FRAMEWORK)
|
||||
endif(APPLE)
|
||||
ENDIF(BUILD_FRAMEWORK)
|
||||
ENDIF(APPLE)
|
||||
|
||||
# Build against external unzip, or add ../contrib/unzip so
|
||||
# assimp can #include "unzip.h"
|
||||
|
@ -975,7 +994,7 @@ if (ASSIMP_ANDROID_JNIIOSYSTEM)
|
|||
INSTALL(FILES ${HEADER_PATH}/${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/AndroidJNIIOSystem.h
|
||||
DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}
|
||||
COMPONENT assimp-dev)
|
||||
endif(ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
ENDIF(ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
|
||||
if(MSVC AND ASSIMP_INSTALL_PDB)
|
||||
IF(CMAKE_GENERATOR MATCHES "^Visual Studio")
|
||||
|
@ -997,7 +1016,7 @@ if(MSVC AND ASSIMP_INSTALL_PDB)
|
|||
CONFIGURATIONS RelWithDebInfo
|
||||
)
|
||||
ENDIF()
|
||||
endif ()
|
||||
ENDIF ()
|
||||
|
||||
if (ASSIMP_COVERALLS)
|
||||
include(Coveralls)
|
||||
|
@ -1009,4 +1028,4 @@ if (ASSIMP_COVERALLS)
|
|||
"${COVERAGE_SRCS}" # The source files.
|
||||
ON # If we should upload.
|
||||
"${PROJECT_SOURCE_DIR}/cmake-modules/") # (Optional) Alternate project cmake module path.
|
||||
endif()
|
||||
ENDIF()
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -46,13 +47,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_COB_IMPORTER
|
||||
#include "COBLoader.h"
|
||||
#include "COBScene.h"
|
||||
|
||||
#include "StreamReader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
#include "LineSplitter.h"
|
||||
#include "TinyFormatter.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/LineSplitter.h>
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include <memory>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
@ -104,7 +104,7 @@ COBImporter::~COBImporter()
|
|||
bool COBImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
||||
{
|
||||
const std::string& extension = GetExtension(pFile);
|
||||
if (extension == "cob" || extension == "scn") {
|
||||
if (extension == "cob" || extension == "scn" || extension == "COB" || extension == "SCN") {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -224,6 +224,9 @@ void COBImporter::InternReadFile( const std::string& pFile,
|
|||
}
|
||||
|
||||
pScene->mRootNode = BuildNodes(*root.get(),scene,pScene);
|
||||
//flip normals after import
|
||||
FlipWindingOrderProcess flip;
|
||||
flip.Execute( pScene );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -1298,3 +1301,4 @@ void COBImporter::ReadUnit_Binary(COB::Scene& out, StreamReaderLE& reader, const
|
|||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -45,8 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_COB_LOADER_H
|
||||
#define INCLUDED_AI_COB_LOADER_H
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include "StreamReader.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/StreamReader.h>
|
||||
|
||||
struct aiNode;
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -49,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <deque>
|
||||
#include <map>
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/material.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -49,9 +50,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
|
||||
|
||||
#include "CSMLoader.h"
|
||||
#include "SkeletonMeshBuilder.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/SkeletonMeshBuilder.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <memory>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
@ -135,7 +136,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
|||
TextFileToBuffer(file.get(),mBuffer2);
|
||||
const char* buffer = &mBuffer2[0];
|
||||
|
||||
aiAnimation* anim = new aiAnimation();
|
||||
std::unique_ptr<aiAnimation> anim(new aiAnimation());
|
||||
int first = 0, last = 0x00ffffff;
|
||||
|
||||
// now process the file and look out for '$' sections
|
||||
|
@ -293,8 +294,8 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// Store the one and only animation in the scene
|
||||
pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations=1];
|
||||
pScene->mAnimations[0] = anim;
|
||||
anim->mName.Set("$CSM_MasterAnim");
|
||||
pScene->mAnimations[0] = anim.release();
|
||||
|
||||
// mark the scene as incomplete and run SkeletonMeshBuilder on it
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -45,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_CSM_LOADER_H
|
||||
#define INCLUDED_AI_CSM_LOADER_H
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -47,8 +48,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
// internal headers
|
||||
#include "CalcTangentsProcess.h"
|
||||
#include "ProcessHelper.h"
|
||||
#include "TinyFormatter.h"
|
||||
#include "qnan.h"
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include <assimp/qnan.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -189,7 +190,7 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
|||
float tx = meshTex[p2].x - meshTex[p0].x, ty = meshTex[p2].y - meshTex[p0].y;
|
||||
float dirCorrection = (tx * sy - ty * sx) < 0.0f ? -1.0f : 1.0f;
|
||||
// when t1, t2, t3 in same position in UV space, just use default UV direction.
|
||||
if ( 0 == sx && 0 ==sy && 0 == tx && 0 == ty ) {
|
||||
if ( sx * ty == sy * tx ) {
|
||||
sx = 0.0; sy = 1.0;
|
||||
tx = 1.0; ty = 0.0;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -43,17 +44,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
|
||||
|
||||
#include "ColladaExporter.h"
|
||||
#include "Bitmap.h"
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/Bitmap.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include "StringUtils.h"
|
||||
#include "XMLTools.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/XMLTools.h>
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#include "Exceptional.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#include <memory>
|
||||
#include <ctime>
|
||||
|
@ -1268,7 +1269,8 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
|
||||
mOutput << startstr << "<animation id=\"" + idstrEscaped + "\" name=\"" + animation_name_escaped + "\">" << endstr;
|
||||
PushTag();
|
||||
|
||||
|
||||
std::string node_idstr;
|
||||
for (size_t a = 0; a < anim->mNumChannels; ++a) {
|
||||
const aiNodeAnim * nodeAnim = anim->mChannels[a];
|
||||
|
||||
|
@ -1276,7 +1278,9 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
if ( nodeAnim->mNumPositionKeys != nodeAnim->mNumScalingKeys || nodeAnim->mNumPositionKeys != nodeAnim->mNumRotationKeys ) continue;
|
||||
|
||||
{
|
||||
const std::string node_idstr = nodeAnim->mNodeName.data + std::string("_matrix-input");
|
||||
node_idstr.clear();
|
||||
node_idstr += nodeAnim->mNodeName.data;
|
||||
node_idstr += std::string( "_matrix-input" );
|
||||
|
||||
std::vector<ai_real> frames;
|
||||
for( size_t i = 0; i < nodeAnim->mNumPositionKeys; ++i) {
|
||||
|
@ -1288,12 +1292,14 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
}
|
||||
|
||||
{
|
||||
const std::string node_idstr = nodeAnim->mNodeName.data + std::string("_matrix-output");
|
||||
node_idstr.clear();
|
||||
|
||||
node_idstr += nodeAnim->mNodeName.data;
|
||||
node_idstr += std::string("_matrix-output");
|
||||
|
||||
std::vector<ai_real> keyframes;
|
||||
keyframes.reserve(nodeAnim->mNumPositionKeys * 16);
|
||||
for( size_t i = 0; i < nodeAnim->mNumPositionKeys; ++i) {
|
||||
|
||||
aiVector3D Scaling = nodeAnim->mScalingKeys[i].mValue;
|
||||
aiMatrix4x4 ScalingM; // identity
|
||||
ScalingM[0][0] = Scaling.x; ScalingM[1][1] = Scaling.y; ScalingM[2][2] = Scaling.z;
|
||||
|
@ -1360,7 +1366,6 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
PopTag();
|
||||
mOutput << startstr << "</source>" << endstr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (size_t a = 0; a < anim->mNumChannels; ++a) {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -54,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
struct aiScene;
|
||||
struct aiNode;
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -46,23 +47,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
|
||||
|
||||
#include "ColladaLoader.h"
|
||||
#include "ColladaParser.h"
|
||||
|
||||
#include <assimp/anim.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/Defines.h>
|
||||
|
||||
#include "ColladaParser.h"
|
||||
#include "fast_atof.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "SkeletonMeshBuilder.h"
|
||||
#include "CreateAnimMesh.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/SkeletonMeshBuilder.h>
|
||||
#include <assimp/CreateAnimMesh.h>
|
||||
|
||||
#include "time.h"
|
||||
#include "math.h"
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <assimp/Defines.h>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::Formatter;
|
||||
|
@ -130,6 +132,7 @@ void ColladaLoader::SetupProperties(const Importer* pImp)
|
|||
{
|
||||
noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0;
|
||||
ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION,0) != 0;
|
||||
useColladaName = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES,0) != 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -1119,6 +1122,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
continue;
|
||||
|
||||
// now check all channels if they affect the current node
|
||||
std::string targetID, subElement;
|
||||
for( std::vector<Collada::AnimationChannel>::const_iterator cit = pSrcAnim->mChannels.begin();
|
||||
cit != pSrcAnim->mChannels.end(); ++cit)
|
||||
{
|
||||
|
@ -1145,7 +1149,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
}
|
||||
if( srcChannel.mTarget.find( '/', slashPos+1) != std::string::npos)
|
||||
continue;
|
||||
std::string targetID = srcChannel.mTarget.substr( 0, slashPos);
|
||||
|
||||
targetID.clear();
|
||||
targetID = srcChannel.mTarget.substr( 0, slashPos);
|
||||
if( targetID != srcNode->mID)
|
||||
continue;
|
||||
|
||||
|
@ -1158,7 +1164,8 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
|
||||
entry.mTransformId = srcChannel.mTarget.substr( slashPos+1, dotPos - slashPos - 1);
|
||||
|
||||
std::string subElement = srcChannel.mTarget.substr( dotPos+1);
|
||||
subElement.clear();
|
||||
subElement = srcChannel.mTarget.substr( dotPos+1);
|
||||
if( subElement == "ANGLE")
|
||||
entry.mSubElement = 3; // last number in an Axis-Angle-Transform is the angle
|
||||
else if( subElement == "X")
|
||||
|
@ -1179,7 +1186,8 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
if (bracketPos != std::string::npos)
|
||||
{
|
||||
entry.mTransformId = srcChannel.mTarget.substr(slashPos + 1, bracketPos - slashPos - 1);
|
||||
std::string subElement = srcChannel.mTarget.substr(bracketPos);
|
||||
subElement.clear();
|
||||
subElement = srcChannel.mTarget.substr(bracketPos);
|
||||
|
||||
if (subElement == "(0)(0)")
|
||||
entry.mSubElement = 0;
|
||||
|
@ -1213,7 +1221,6 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
entry.mSubElement = 14;
|
||||
else if (subElement == "(3)(3)")
|
||||
entry.mSubElement = 15;
|
||||
|
||||
}
|
||||
|
||||
// determine which transform step is affected by this channel
|
||||
|
@ -1778,6 +1785,11 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars
|
|||
tex->pcData = (aiTexel*)new char[tex->mWidth];
|
||||
memcpy(tex->pcData,&imIt->second.mImageData[0],tex->mWidth);
|
||||
|
||||
// TODO: check the possibility of using the flag "AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING"
|
||||
// In FBX files textures are now stored internally by Assimp with their filename included
|
||||
// Now Assimp can lookup thru the loaded textures after all data is processed
|
||||
// We need to load all textures before referencing them, as FBX file format order may reference a texture before loading it
|
||||
// This may occur on this case too, it has to be studied
|
||||
// setup texture reference string
|
||||
result.data[0] = '*';
|
||||
result.length = 1 + ASSIMP_itoa10(result.data+1,static_cast<unsigned int>(MAXLEN-1),static_cast<int32_t>(mTextures.size()));
|
||||
|
@ -1907,6 +1919,11 @@ const Collada::Node* ColladaLoader::FindNodeBySID( const Collada::Node* pNode, c
|
|||
// The name must be unique for proper node-bone association.
|
||||
std::string ColladaLoader::FindNameForNode( const Collada::Node* pNode)
|
||||
{
|
||||
// If explicitly requested, just use the collada name.
|
||||
if (useColladaName) {
|
||||
return pNode->mName;
|
||||
}
|
||||
|
||||
// Now setup the name of the assimp node. The collada name might not be
|
||||
// unique, so we use the collada ID.
|
||||
if (!pNode->mID.empty())
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -44,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_COLLADALOADER_H_INC
|
||||
#define AI_COLLADALOADER_H_INC
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include "ColladaParser.h"
|
||||
|
||||
struct aiNode;
|
||||
|
@ -247,6 +248,7 @@ protected:
|
|||
|
||||
bool noSkeletonMesh;
|
||||
bool ignoreUpDirection;
|
||||
bool useColladaName;
|
||||
|
||||
/** Used by FindNameForNode() to generate unique node names */
|
||||
unsigned int mNodeNameCounter;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -49,13 +50,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include "ColladaParser.h"
|
||||
#include "fast_atof.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/light.h>
|
||||
#include "TinyFormatter.h"
|
||||
#include <assimp/TinyFormatter.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -221,6 +222,7 @@ void ColladaParser::ReadStructure()
|
|||
}
|
||||
|
||||
PostProcessRootAnimations();
|
||||
PostProcessControllers();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -359,6 +361,21 @@ void ColladaParser::ReadAnimationClipLibrary()
|
|||
}
|
||||
}
|
||||
|
||||
void ColladaParser::PostProcessControllers()
|
||||
{
|
||||
for (ControllerLibrary::iterator it = mControllerLibrary.begin(); it != mControllerLibrary.end(); ++it)
|
||||
{
|
||||
std::string meshId = it->second.mMeshId;
|
||||
ControllerLibrary::iterator findItr = mControllerLibrary.find(meshId);
|
||||
while(findItr != mControllerLibrary.end()) {
|
||||
meshId = findItr->second.mMeshId;
|
||||
findItr = mControllerLibrary.find(meshId);
|
||||
}
|
||||
|
||||
it->second.mMeshId = meshId;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Re-build animations from animation clip library, if present, otherwise combine single-channel animations
|
||||
void ColladaParser::PostProcessRootAnimations()
|
||||
|
@ -3089,7 +3106,7 @@ const char* ColladaParser::TestTextContent()
|
|||
// read contents of the element
|
||||
if( !mReader->read() )
|
||||
return NULL;
|
||||
if( mReader->getNodeType() != irr::io::EXN_TEXT)
|
||||
if( mReader->getNodeType() != irr::io::EXN_TEXT && mReader->getNodeType() != irr::io::EXN_CDATA)
|
||||
return NULL;
|
||||
|
||||
// skip leading whitespace
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -46,10 +47,10 @@
|
|||
#ifndef AI_COLLADAPARSER_H_INC
|
||||
#define AI_COLLADAPARSER_H_INC
|
||||
|
||||
#include "irrXMLWrapper.h"
|
||||
#include <assimp/irrXMLWrapper.h>
|
||||
#include "ColladaHelper.h"
|
||||
#include <assimp/ai_assert.h>
|
||||
#include "TinyFormatter.h"
|
||||
#include <assimp/TinyFormatter.h>
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
@ -86,6 +87,9 @@ namespace Assimp
|
|||
/** Reads the animation clip library */
|
||||
void ReadAnimationClipLibrary();
|
||||
|
||||
/** Unwrap controllers dependency hierarchy */
|
||||
void PostProcessControllers();
|
||||
|
||||
/** Re-build animations from animation clip library, if present, otherwise combine single-channel animations */
|
||||
void PostProcessRootAnimations();
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -44,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "ComputeUVMappingProcess.h"
|
||||
#include "ProcessHelper.h"
|
||||
#include "Exceptional.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -90,12 +91,14 @@ void MakeLeftHandedProcess::Execute( aiScene* pScene)
|
|||
ProcessNode( pScene->mRootNode, aiMatrix4x4());
|
||||
|
||||
// process the meshes accordingly
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; ++a)
|
||||
ProcessMesh( pScene->mMeshes[a]);
|
||||
for ( unsigned int a = 0; a < pScene->mNumMeshes; ++a ) {
|
||||
ProcessMesh( pScene->mMeshes[ a ] );
|
||||
}
|
||||
|
||||
// process the materials accordingly
|
||||
for( unsigned int a = 0; a < pScene->mNumMaterials; ++a)
|
||||
ProcessMaterial( pScene->mMaterials[a]);
|
||||
for ( unsigned int a = 0; a < pScene->mNumMaterials; ++a ) {
|
||||
ProcessMaterial( pScene->mMaterials[ a ] );
|
||||
}
|
||||
|
||||
// transform all animation channels as well
|
||||
for( unsigned int a = 0; a < pScene->mNumAnimations; a++)
|
||||
|
@ -135,8 +138,11 @@ void MakeLeftHandedProcess::ProcessNode( aiNode* pNode, const aiMatrix4x4& pPare
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Converts a single mesh to left handed coordinates.
|
||||
void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh)
|
||||
{
|
||||
void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) {
|
||||
if ( nullptr == pMesh ) {
|
||||
DefaultLogger::get()->error( "Nullptr to mesh found." );
|
||||
return;
|
||||
}
|
||||
// mirror positions, normals and stuff along the Z axis
|
||||
for( size_t a = 0; a < pMesh->mNumVertices; ++a)
|
||||
{
|
||||
|
@ -172,8 +178,12 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Converts a single material to left handed coordinates.
|
||||
void MakeLeftHandedProcess::ProcessMaterial( aiMaterial* _mat)
|
||||
{
|
||||
void MakeLeftHandedProcess::ProcessMaterial( aiMaterial* _mat) {
|
||||
if ( nullptr == _mat ) {
|
||||
DefaultLogger::get()->error( "Nullptr to aiMaterial found." );
|
||||
return;
|
||||
}
|
||||
|
||||
aiMaterial* mat = (aiMaterial*)_mat;
|
||||
for (unsigned int a = 0; a < mat->mNumProperties;++a) {
|
||||
aiMaterialProperty* prop = mat->mProperties[a];
|
||||
|
@ -182,7 +192,6 @@ void MakeLeftHandedProcess::ProcessMaterial( aiMaterial* _mat)
|
|||
if (!::strcmp( prop->mKey.data, "$tex.mapaxis")) {
|
||||
ai_assert( prop->mDataLength >= sizeof(aiVector3D)); /* something is wrong with the validation if we end up here */
|
||||
aiVector3D* pff = (aiVector3D*)prop->mData;
|
||||
|
||||
pff->z *= -1.f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "CreateAnimMesh.h"
|
||||
#include <assimp/CreateAnimMesh.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -48,8 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#include "Exceptional.h"
|
||||
#include "3MFXmlTags.h"
|
||||
#include "D3MFOpcPackage.h"
|
||||
|
||||
|
@ -115,6 +117,7 @@ bool D3MFExporter::exportArchive( const char *file ) {
|
|||
if ( nullptr == m_zipArchive ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ok |= exportContentTypes();
|
||||
ok |= export3DModel();
|
||||
ok |= exportRelations();
|
||||
|
@ -125,7 +128,6 @@ bool D3MFExporter::exportArchive( const char *file ) {
|
|||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool D3MFExporter::exportContentTypes() {
|
||||
mContentOutput.clear();
|
||||
|
||||
|
@ -152,7 +154,11 @@ bool D3MFExporter::exportRelations() {
|
|||
mRelOutput << "<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">";
|
||||
|
||||
for ( size_t i = 0; i < mRelations.size(); ++i ) {
|
||||
mRelOutput << "<Relationship Target=\"/" << mRelations[ i ]->target << "\" ";
|
||||
if ( mRelations[ i ]->target[ 0 ] == '/' ) {
|
||||
mRelOutput << "<Relationship Target=\"" << mRelations[ i ]->target << "\" ";
|
||||
} else {
|
||||
mRelOutput << "<Relationship Target=\"/" << mRelations[ i ]->target << "\" ";
|
||||
}
|
||||
mRelOutput << "Id=\"" << mRelations[i]->id << "\" ";
|
||||
mRelOutput << "Type=\"" << mRelations[ i ]->type << "\" />";
|
||||
mRelOutput << std::endl;
|
||||
|
@ -176,6 +182,10 @@ bool D3MFExporter::export3DModel() {
|
|||
mModelOutput << "<" << XmlTag::resources << ">";
|
||||
mModelOutput << std::endl;
|
||||
|
||||
writeMetaData();
|
||||
|
||||
writeBaseMaterials();
|
||||
|
||||
writeObjects();
|
||||
|
||||
|
||||
|
@ -202,6 +212,63 @@ void D3MFExporter::writeHeader() {
|
|||
mModelOutput << std::endl;
|
||||
}
|
||||
|
||||
void D3MFExporter::writeMetaData() {
|
||||
if ( nullptr == mScene->mMetaData ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned int numMetaEntries( mScene->mMetaData->mNumProperties );
|
||||
if ( 0 == numMetaEntries ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const aiString *key;
|
||||
const aiMetadataEntry *entry(nullptr);
|
||||
for ( size_t i = 0; i < numMetaEntries; ++i ) {
|
||||
mScene->mMetaData->Get( i, key, entry );
|
||||
std::string k( key->C_Str() );
|
||||
aiString value;
|
||||
mScene->mMetaData->Get( k, value );
|
||||
mModelOutput << "<" << XmlTag::meta << " " << XmlTag::meta_name << "=\"" << key->C_Str() << "\">";
|
||||
mModelOutput << value.C_Str();
|
||||
mModelOutput << "</" << XmlTag::meta << ">" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void D3MFExporter::writeBaseMaterials() {
|
||||
mModelOutput << "<basematerials id=\"1\">\n";
|
||||
std::string strName, hexDiffuseColor , tmp;
|
||||
for ( size_t i = 0; i < mScene->mNumMaterials; ++i ) {
|
||||
aiMaterial *mat = mScene->mMaterials[ i ];
|
||||
aiString name;
|
||||
if ( mat->Get( AI_MATKEY_NAME, name ) != aiReturn_SUCCESS ) {
|
||||
strName = "basemat_" + to_string( i );
|
||||
} else {
|
||||
strName = name.C_Str();
|
||||
}
|
||||
aiColor4D color;
|
||||
if ( mat->Get( AI_MATKEY_COLOR_DIFFUSE, color ) == aiReturn_SUCCESS ) {
|
||||
hexDiffuseColor.clear();
|
||||
tmp.clear();
|
||||
hexDiffuseColor = "#";
|
||||
|
||||
tmp = DecimalToHexa( color.r );
|
||||
hexDiffuseColor += tmp;
|
||||
tmp = DecimalToHexa( color.g );
|
||||
hexDiffuseColor += tmp;
|
||||
tmp = DecimalToHexa( color.b );
|
||||
hexDiffuseColor += tmp;
|
||||
tmp = DecimalToHexa( color.a );
|
||||
hexDiffuseColor += tmp;
|
||||
} else {
|
||||
hexDiffuseColor = "#FFFFFFFF";
|
||||
}
|
||||
|
||||
mModelOutput << "<base name=\""+strName+"\" "+" displaycolor=\""+hexDiffuseColor+"\" />\n";
|
||||
}
|
||||
mModelOutput << "</basematerials>\n";
|
||||
}
|
||||
|
||||
void D3MFExporter::writeObjects() {
|
||||
if ( nullptr == mScene->mRootNode ) {
|
||||
return;
|
||||
|
@ -241,7 +308,9 @@ void D3MFExporter::writeMesh( aiMesh *mesh ) {
|
|||
}
|
||||
mModelOutput << "</" << XmlTag::vertices << ">" << std::endl;
|
||||
|
||||
writeFaces( mesh );
|
||||
const unsigned int matIdx( mesh->mMaterialIndex );
|
||||
|
||||
writeFaces( mesh, matIdx );
|
||||
|
||||
mModelOutput << "</" << XmlTag::mesh << ">" << std::endl;
|
||||
}
|
||||
|
@ -251,7 +320,7 @@ void D3MFExporter::writeVertex( const aiVector3D &pos ) {
|
|||
mModelOutput << std::endl;
|
||||
}
|
||||
|
||||
void D3MFExporter::writeFaces( aiMesh *mesh ) {
|
||||
void D3MFExporter::writeFaces( aiMesh *mesh, unsigned int matIdx ) {
|
||||
if ( nullptr == mesh ) {
|
||||
return;
|
||||
}
|
||||
|
@ -263,7 +332,8 @@ void D3MFExporter::writeFaces( aiMesh *mesh ) {
|
|||
for ( unsigned int i = 0; i < mesh->mNumFaces; ++i ) {
|
||||
aiFace ¤tFace = mesh->mFaces[ i ];
|
||||
mModelOutput << "<" << XmlTag::triangle << " v1=\"" << currentFace.mIndices[ 0 ] << "\" v2=\""
|
||||
<< currentFace.mIndices[ 1 ] << "\" v3=\"" << currentFace.mIndices[ 2 ] << "\"/>";
|
||||
<< currentFace.mIndices[ 1 ] << "\" v3=\"" << currentFace.mIndices[ 2 ]
|
||||
<< "\" pid=\"1\" p1=\""+to_string(matIdx)+"\" />";
|
||||
mModelOutput << std::endl;
|
||||
}
|
||||
mModelOutput << "</" << XmlTag::triangles << ">";
|
||||
|
@ -324,5 +394,5 @@ void D3MFExporter::writeRelInfoToFile( const std::string &folder, const std::str
|
|||
} // Namespace D3MF
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
#endif // ASSIMP_BUILD_NO_3MF_EXPORTER
|
||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -59,7 +60,7 @@ class IOStream;
|
|||
namespace D3MF {
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
#ifndef ASSIMP_BUILD_NO_3MF_EXPORTER
|
||||
|
||||
struct OpcPackageRelationship;
|
||||
|
||||
|
@ -75,10 +76,12 @@ public:
|
|||
|
||||
protected:
|
||||
void writeHeader();
|
||||
void writeMetaData();
|
||||
void writeBaseMaterials();
|
||||
void writeObjects();
|
||||
void writeMesh( aiMesh *mesh );
|
||||
void writeVertex( const aiVector3D &pos );
|
||||
void writeFaces( aiMesh *mesh );
|
||||
void writeFaces( aiMesh *mesh, unsigned int matIdx );
|
||||
void writeBuild();
|
||||
void exportContentTyp( const std::string &filename );
|
||||
void writeModelToArchive( const std::string &folder, const std::string &modelName );
|
||||
|
@ -95,7 +98,7 @@ private:
|
|||
std::vector<OpcPackageRelationship*> mRelations;
|
||||
};
|
||||
|
||||
#endif // ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
#endif // ASSIMP_BUILD_NO_3MF_EXPORTER
|
||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||
|
||||
} // Namespace D3MF
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -47,8 +48,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include "StringComparison.h"
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -57,17 +58,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <memory>
|
||||
|
||||
#include "D3MFOpcPackage.h"
|
||||
#include <contrib/unzip/unzip.h>
|
||||
#include "irrXMLWrapper.h"
|
||||
#include <unzip.h>
|
||||
#include <assimp/irrXMLWrapper.h>
|
||||
#include "3MFXmlTags.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
namespace Assimp {
|
||||
namespace D3MF {
|
||||
|
||||
class XmlSerializer {
|
||||
public:
|
||||
using MatArray = std::vector<aiMaterial*>;
|
||||
using MatId2MatArray = std::map<unsigned int, std::vector<unsigned int>>;
|
||||
|
||||
XmlSerializer(XmlReader* xmlReader)
|
||||
: xmlReader(xmlReader) {
|
||||
: mMeshes()
|
||||
, mMatArray()
|
||||
, mActiveMatGroup( 99999999 )
|
||||
, mMatId2MatArray()
|
||||
, xmlReader(xmlReader){
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -76,14 +87,24 @@ public:
|
|||
}
|
||||
|
||||
void ImportXml(aiScene* scene) {
|
||||
if ( nullptr == scene ) {
|
||||
return;
|
||||
}
|
||||
|
||||
scene->mRootNode = new aiNode();
|
||||
std::vector<aiNode*> children;
|
||||
|
||||
std::string nodeName;
|
||||
while(ReadToEndElement(D3MF::XmlTag::model)) {
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::object) {
|
||||
nodeName = xmlReader->getNodeName();
|
||||
if( nodeName == D3MF::XmlTag::object) {
|
||||
children.push_back(ReadObject(scene));
|
||||
} else if(xmlReader->getNodeName() == D3MF::XmlTag::build) {
|
||||
|
||||
} else if( nodeName == D3MF::XmlTag::build) {
|
||||
//
|
||||
} else if ( nodeName == D3MF::XmlTag::basematerials ) {
|
||||
ReadBaseMaterials();
|
||||
} else if ( nodeName == D3MF::XmlTag::meta ) {
|
||||
ReadMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,31 +112,47 @@ public:
|
|||
scene->mRootNode->mName.Set( "3MF" );
|
||||
}
|
||||
|
||||
scene->mNumMeshes = static_cast<unsigned int>(meshes.size());
|
||||
// import the metadata
|
||||
if ( !mMetaData.empty() ) {
|
||||
const size_t numMeta( mMetaData.size() );
|
||||
scene->mMetaData = aiMetadata::Alloc( numMeta );
|
||||
for ( size_t i = 0; i < numMeta; ++i ) {
|
||||
aiString val( mMetaData[ i ].value );
|
||||
scene->mMetaData->Set( i, mMetaData[ i ].name, val );
|
||||
}
|
||||
}
|
||||
|
||||
// import the meshes
|
||||
scene->mNumMeshes = static_cast<unsigned int>( mMeshes.size());
|
||||
scene->mMeshes = new aiMesh*[scene->mNumMeshes]();
|
||||
std::copy( mMeshes.begin(), mMeshes.end(), scene->mMeshes);
|
||||
|
||||
std::copy(meshes.begin(), meshes.end(), scene->mMeshes);
|
||||
// import the materials
|
||||
scene->mNumMaterials = static_cast<unsigned int>( mMatArray.size() );
|
||||
if ( 0 != scene->mNumMaterials ) {
|
||||
scene->mMaterials = new aiMaterial*[ scene->mNumMaterials ];
|
||||
std::copy( mMatArray.begin(), mMatArray.end(), scene->mMaterials );
|
||||
}
|
||||
|
||||
// create the scenegraph
|
||||
scene->mRootNode->mNumChildren = static_cast<unsigned int>(children.size());
|
||||
scene->mRootNode->mChildren = new aiNode*[scene->mRootNode->mNumChildren]();
|
||||
|
||||
std::copy(children.begin(), children.end(), scene->mRootNode->mChildren);
|
||||
}
|
||||
|
||||
private:
|
||||
aiNode* ReadObject(aiScene* scene)
|
||||
{
|
||||
aiNode* ReadObject(aiScene* scene) {
|
||||
std::unique_ptr<aiNode> node(new aiNode());
|
||||
|
||||
std::vector<unsigned long> meshIds;
|
||||
|
||||
const char *attrib( nullptr );
|
||||
std::string name, type;
|
||||
attrib = xmlReader->getAttributeValue( D3MF::XmlTag::name.c_str() );
|
||||
attrib = xmlReader->getAttributeValue( D3MF::XmlTag::id.c_str() );
|
||||
if ( nullptr != attrib ) {
|
||||
name = attrib;
|
||||
}
|
||||
attrib = xmlReader->getAttributeValue( D3MF::XmlTag::name.c_str() );
|
||||
attrib = xmlReader->getAttributeValue( D3MF::XmlTag::type.c_str() );
|
||||
if ( nullptr != attrib ) {
|
||||
type = attrib;
|
||||
}
|
||||
|
@ -123,19 +160,16 @@ private:
|
|||
node->mParent = scene->mRootNode;
|
||||
node->mName.Set(name);
|
||||
|
||||
size_t meshIdx = meshes.size();
|
||||
size_t meshIdx = mMeshes.size();
|
||||
|
||||
while(ReadToEndElement(D3MF::XmlTag::object))
|
||||
{
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::mesh)
|
||||
{
|
||||
while(ReadToEndElement(D3MF::XmlTag::object)) {
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::mesh) {
|
||||
auto mesh = ReadMesh();
|
||||
|
||||
mesh->mName.Set(name);
|
||||
meshes.push_back(mesh);
|
||||
mMeshes.push_back(mesh);
|
||||
meshIds.push_back(static_cast<unsigned long>(meshIdx));
|
||||
meshIdx++;
|
||||
|
||||
++meshIdx;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,19 +180,14 @@ private:
|
|||
std::copy(meshIds.begin(), meshIds.end(), node->mMeshes);
|
||||
|
||||
return node.release();
|
||||
|
||||
}
|
||||
|
||||
aiMesh* ReadMesh() {
|
||||
aiMesh *ReadMesh() {
|
||||
aiMesh* mesh = new aiMesh();
|
||||
while(ReadToEndElement(D3MF::XmlTag::mesh))
|
||||
{
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::vertices)
|
||||
{
|
||||
while(ReadToEndElement(D3MF::XmlTag::mesh)) {
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::vertices) {
|
||||
ImportVertices(mesh);
|
||||
}
|
||||
else if(xmlReader->getNodeName() == D3MF::XmlTag::triangles)
|
||||
{
|
||||
} else if(xmlReader->getNodeName() == D3MF::XmlTag::triangles) {
|
||||
ImportTriangles(mesh);
|
||||
}
|
||||
}
|
||||
|
@ -166,14 +195,25 @@ private:
|
|||
return mesh;
|
||||
}
|
||||
|
||||
void ImportVertices(aiMesh* mesh)
|
||||
{
|
||||
std::vector<aiVector3D> vertices;
|
||||
void ReadMetadata() {
|
||||
const std::string name = xmlReader->getAttributeValue( D3MF::XmlTag::meta_name.c_str() );
|
||||
xmlReader->read();
|
||||
const std::string value = xmlReader->getNodeData();
|
||||
|
||||
while(ReadToEndElement(D3MF::XmlTag::vertices))
|
||||
{
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::vertex)
|
||||
{
|
||||
if ( name.empty() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
MetaEntry entry;
|
||||
entry.name = name;
|
||||
entry.value = value;
|
||||
mMetaData.push_back( entry );
|
||||
}
|
||||
|
||||
void ImportVertices(aiMesh* mesh) {
|
||||
std::vector<aiVector3D> vertices;
|
||||
while(ReadToEndElement(D3MF::XmlTag::vertices)) {
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::vertex) {
|
||||
vertices.push_back(ReadVertex());
|
||||
}
|
||||
}
|
||||
|
@ -181,11 +221,9 @@ private:
|
|||
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
||||
|
||||
std::copy(vertices.begin(), vertices.end(), mesh->mVertices);
|
||||
|
||||
}
|
||||
|
||||
aiVector3D ReadVertex()
|
||||
{
|
||||
aiVector3D ReadVertex() {
|
||||
aiVector3D vertex;
|
||||
|
||||
vertex.x = ai_strtof(xmlReader->getAttributeValue(D3MF::XmlTag::x.c_str()), nullptr);
|
||||
|
@ -195,16 +233,18 @@ private:
|
|||
return vertex;
|
||||
}
|
||||
|
||||
void ImportTriangles(aiMesh* mesh)
|
||||
{
|
||||
void ImportTriangles(aiMesh* mesh) {
|
||||
std::vector<aiFace> faces;
|
||||
|
||||
|
||||
while(ReadToEndElement(D3MF::XmlTag::triangles))
|
||||
{
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::triangle)
|
||||
{
|
||||
while(ReadToEndElement(D3MF::XmlTag::triangles)) {
|
||||
const std::string nodeName( xmlReader->getNodeName() );
|
||||
if(xmlReader->getNodeName() == D3MF::XmlTag::triangle) {
|
||||
faces.push_back(ReadTriangle());
|
||||
const char *pidToken( xmlReader->getAttributeValue( D3MF::XmlTag::p1.c_str() ) );
|
||||
if ( nullptr != pidToken ) {
|
||||
int matIdx( std::atoi( pidToken ) );
|
||||
mesh->mMaterialIndex = matIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,8 +255,7 @@ private:
|
|||
std::copy(faces.begin(), faces.end(), mesh->mFaces);
|
||||
}
|
||||
|
||||
aiFace ReadTriangle()
|
||||
{
|
||||
aiFace ReadTriangle() {
|
||||
aiFace face;
|
||||
|
||||
face.mNumIndices = 3;
|
||||
|
@ -228,45 +267,150 @@ private:
|
|||
return face;
|
||||
}
|
||||
|
||||
private:
|
||||
bool ReadToStartElement(const std::string& startTag)
|
||||
{
|
||||
while(xmlReader->read())
|
||||
{
|
||||
if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT && xmlReader->getNodeName() == startTag)
|
||||
{
|
||||
return true;
|
||||
void ReadBaseMaterials() {
|
||||
std::vector<unsigned int> MatIdArray;
|
||||
const char *baseMaterialId( xmlReader->getAttributeValue( D3MF::XmlTag::basematerials_id.c_str() ) );
|
||||
if ( nullptr != baseMaterialId ) {
|
||||
unsigned int id = std::atoi( baseMaterialId );
|
||||
const size_t newMatIdx( mMatArray.size() );
|
||||
if ( id != mActiveMatGroup ) {
|
||||
mActiveMatGroup = id;
|
||||
MatId2MatArray::const_iterator it( mMatId2MatArray.find( id ) );
|
||||
if ( mMatId2MatArray.end() == it ) {
|
||||
MatIdArray.clear();
|
||||
mMatId2MatArray[ id ] = MatIdArray;
|
||||
} else {
|
||||
MatIdArray = it->second;
|
||||
}
|
||||
}
|
||||
else if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT_END &&
|
||||
xmlReader->getNodeName() == startTag)
|
||||
{
|
||||
MatIdArray.push_back( static_cast<unsigned int>( newMatIdx ) );
|
||||
mMatId2MatArray[ mActiveMatGroup ] = MatIdArray;
|
||||
}
|
||||
|
||||
while ( ReadToEndElement( D3MF::XmlTag::basematerials ) ) {
|
||||
mMatArray.push_back( readMaterialDef() );
|
||||
}
|
||||
}
|
||||
|
||||
bool parseColor( const char *color, aiColor4D &diffuse ) {
|
||||
if ( nullptr == color ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t len( strlen( color ) );
|
||||
if ( 9 != len ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *buf( color );
|
||||
if ( '#' != *buf ) {
|
||||
return false;
|
||||
}
|
||||
++buf;
|
||||
char comp[ 3 ] = { 0,0,'\0' };
|
||||
|
||||
comp[ 0 ] = *buf;
|
||||
++buf;
|
||||
comp[ 1 ] = *buf;
|
||||
++buf;
|
||||
diffuse.r = static_cast<ai_real>( strtol( comp, NULL, 16 ) );
|
||||
|
||||
|
||||
comp[ 0 ] = *buf;
|
||||
++buf;
|
||||
comp[ 1 ] = *buf;
|
||||
++buf;
|
||||
diffuse.g = static_cast< ai_real >( strtol( comp, NULL, 16 ) );
|
||||
|
||||
comp[ 0 ] = *buf;
|
||||
++buf;
|
||||
comp[ 1 ] = *buf;
|
||||
++buf;
|
||||
diffuse.b = static_cast< ai_real >( strtol( comp, NULL, 16 ) );
|
||||
|
||||
comp[ 0 ] = *buf;
|
||||
++buf;
|
||||
comp[ 1 ] = *buf;
|
||||
++buf;
|
||||
diffuse.a = static_cast< ai_real >( strtol( comp, NULL, 16 ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void assignDiffuseColor( aiMaterial *mat ) {
|
||||
const char *color = xmlReader->getAttributeValue( D3MF::XmlTag::basematerials_displaycolor.c_str() );
|
||||
aiColor4D diffuse;
|
||||
if ( parseColor( color, diffuse ) ) {
|
||||
mat->AddProperty<aiColor4D>( &diffuse, 1, AI_MATKEY_COLOR_DIFFUSE );
|
||||
}
|
||||
|
||||
}
|
||||
aiMaterial *readMaterialDef() {
|
||||
aiMaterial *mat( nullptr );
|
||||
const char *name( nullptr );
|
||||
const std::string nodeName( xmlReader->getNodeName() );
|
||||
if ( nodeName == D3MF::XmlTag::basematerials_base ) {
|
||||
name = xmlReader->getAttributeValue( D3MF::XmlTag::basematerials_name.c_str() );
|
||||
std::string stdMatName;
|
||||
aiString matName;
|
||||
std::string strId( to_string( mActiveMatGroup ) );
|
||||
stdMatName += "id";
|
||||
stdMatName += strId;
|
||||
stdMatName += "_";
|
||||
if ( nullptr != name ) {
|
||||
stdMatName += std::string( name );
|
||||
} else {
|
||||
stdMatName += "basemat";
|
||||
}
|
||||
matName.Set( stdMatName );
|
||||
|
||||
mat = new aiMaterial;
|
||||
mat->AddProperty( &matName, AI_MATKEY_NAME );
|
||||
|
||||
assignDiffuseColor( mat );
|
||||
}
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
private:
|
||||
bool ReadToStartElement(const std::string& startTag) {
|
||||
while(xmlReader->read()) {
|
||||
const std::string &nodeName( xmlReader->getNodeName() );
|
||||
if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT && nodeName == startTag) {
|
||||
return true;
|
||||
} else if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT_END && nodeName == startTag) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//DefaultLogger::get()->error("unexpected EOF, expected closing <" + closeTag + "> tag");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ReadToEndElement(const std::string& closeTag)
|
||||
{
|
||||
while(xmlReader->read())
|
||||
{
|
||||
bool ReadToEndElement(const std::string& closeTag) {
|
||||
while(xmlReader->read()) {
|
||||
const std::string &nodeName( xmlReader->getNodeName() );
|
||||
if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT) {
|
||||
return true;
|
||||
}
|
||||
else if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT_END
|
||||
&& xmlReader->getNodeName() == closeTag)
|
||||
{
|
||||
} else if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT_END && nodeName == closeTag) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DefaultLogger::get()->error("unexpected EOF, expected closing <" + closeTag + "> tag");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::vector<aiMesh*> meshes;
|
||||
struct MetaEntry {
|
||||
std::string name;
|
||||
std::string value;
|
||||
};
|
||||
std::vector<MetaEntry> mMetaData;
|
||||
std::vector<aiMesh*> mMeshes;
|
||||
MatArray mMatArray;
|
||||
unsigned int mActiveMatGroup;
|
||||
MatId2MatArray mMatId2MatArray;
|
||||
XmlReader* xmlReader;
|
||||
};
|
||||
|
||||
|
@ -287,7 +431,6 @@ static const aiImporterDesc desc = {
|
|||
Extension.c_str()
|
||||
};
|
||||
|
||||
|
||||
D3MFImporter::D3MFImporter()
|
||||
: BaseImporter() {
|
||||
// empty
|
||||
|
@ -297,14 +440,19 @@ D3MFImporter::~D3MFImporter() {
|
|||
// empty
|
||||
}
|
||||
|
||||
bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
|
||||
const std::string extension = GetExtension(pFile);
|
||||
bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool checkSig) const {
|
||||
const std::string extension( GetExtension( filename ) );
|
||||
if(extension == Extension ) {
|
||||
return true;
|
||||
} else if ( !extension.length() || checkSig ) {
|
||||
if (nullptr == pIOHandler ) {
|
||||
return true;
|
||||
if ( nullptr == pIOHandler ) {
|
||||
return false;
|
||||
}
|
||||
if ( !D3MF::D3MFOpcPackage::isZipArchive( pIOHandler, filename ) ) {
|
||||
return false;
|
||||
}
|
||||
D3MF::D3MFOpcPackage opcPackage( pIOHandler, filename );
|
||||
return opcPackage.validate();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -318,8 +466,8 @@ const aiImporterDesc *D3MFImporter::GetInfo() const {
|
|||
return &desc;
|
||||
}
|
||||
|
||||
void D3MFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
||||
D3MF::D3MFOpcPackage opcPackage(pIOHandler, pFile);
|
||||
void D3MFImporter::InternReadFile( const std::string &filename, aiScene *pScene, IOSystem *pIOHandler ) {
|
||||
D3MF::D3MFOpcPackage opcPackage(pIOHandler, filename);
|
||||
|
||||
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(opcPackage.RootStream()));
|
||||
std::unique_ptr<D3MF::XmlReader> xmlReader(irr::io::createIrrXMLReader(xmlStream.get()));
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -42,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_D3MFLOADER_H_INCLUDED
|
||||
#define AI_D3MFLOADER_H_INCLUDED
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -42,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
|
||||
|
||||
#include "D3MFOpcPackage.h"
|
||||
#include "Exceptional.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
@ -55,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <contrib/unzip/unzip.h>
|
||||
#include <unzip.h>
|
||||
#include "3MFXmlTags.h"
|
||||
|
||||
namespace Assimp {
|
||||
|
@ -246,13 +247,13 @@ private:
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
D3MFZipArchive::D3MFZipArchive(IOSystem* pIOHandler, const std::string& rFile)
|
||||
: m_ZipFileHandle(NULL)
|
||||
: m_ZipFileHandle( nullptr )
|
||||
, m_ArchiveMap() {
|
||||
if (! rFile.empty()) {
|
||||
zlib_filefunc_def mapping = IOSystem2Unzip::get(pIOHandler);
|
||||
|
||||
m_ZipFileHandle = unzOpen2(rFile.c_str(), &mapping);
|
||||
if(m_ZipFileHandle != NULL) {
|
||||
if(m_ZipFileHandle != nullptr ) {
|
||||
mapArchive();
|
||||
}
|
||||
}
|
||||
|
@ -266,32 +267,32 @@ D3MFZipArchive::~D3MFZipArchive() {
|
|||
}
|
||||
m_ArchiveMap.clear();
|
||||
|
||||
if(m_ZipFileHandle != NULL) {
|
||||
if(m_ZipFileHandle != nullptr) {
|
||||
unzClose(m_ZipFileHandle);
|
||||
m_ZipFileHandle = NULL;
|
||||
m_ZipFileHandle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns true, if the archive is already open.
|
||||
bool D3MFZipArchive::isOpen() const {
|
||||
return (m_ZipFileHandle != NULL);
|
||||
return (m_ZipFileHandle != nullptr );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns true, if the filename is part of the archive.
|
||||
bool D3MFZipArchive::Exists(const char* pFile) const {
|
||||
ai_assert(pFile != NULL);
|
||||
ai_assert(pFile != nullptr );
|
||||
|
||||
bool exist = false;
|
||||
if ( pFile == nullptr ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pFile != NULL) {
|
||||
std::string rFile(pFile);
|
||||
std::map<std::string, ZipFile*>::const_iterator it = m_ArchiveMap.find(rFile);
|
||||
|
||||
if(it != m_ArchiveMap.end()) {
|
||||
exist = true;
|
||||
}
|
||||
std::string filename(pFile);
|
||||
std::map<std::string, ZipFile*>::const_iterator it = m_ArchiveMap.find(filename);
|
||||
bool exist( false );
|
||||
if(it != m_ArchiveMap.end()) {
|
||||
exist = true;
|
||||
}
|
||||
|
||||
return exist;
|
||||
|
@ -433,8 +434,8 @@ public:
|
|||
|
||||
std::vector<OpcPackageRelationshipPtr> m_relationShips;
|
||||
};
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile)
|
||||
: mRootStream(nullptr)
|
||||
, mZipArchive() {
|
||||
|
@ -459,7 +460,7 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile)
|
|||
if ( rootFile.size() > 0 && rootFile[ 0 ] == '/' ) {
|
||||
rootFile = rootFile.substr( 1 );
|
||||
if ( rootFile[ 0 ] == '/' ) {
|
||||
// deal with zipbug
|
||||
// deal with zip-bug
|
||||
rootFile = rootFile.substr( 1 );
|
||||
}
|
||||
}
|
||||
|
@ -469,18 +470,9 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile)
|
|||
mRootStream = mZipArchive->Open(rootFile.c_str());
|
||||
ai_assert( mRootStream != nullptr );
|
||||
if ( nullptr == mRootStream ) {
|
||||
throw DeadlyExportError( "Cannot open rootfile in archive : " + rootFile );
|
||||
throw DeadlyExportError( "Cannot open root-file in archive : " + rootFile );
|
||||
}
|
||||
|
||||
// const size_t size = zipArchive->FileSize();
|
||||
// m_Data.resize( size );
|
||||
|
||||
// const size_t readSize = pMapFile->Read( &m_Data[0], sizeof( char ), size );
|
||||
// if ( readSize != size )
|
||||
// {
|
||||
// m_Data.clear();
|
||||
// return false;
|
||||
// }
|
||||
mZipArchive->Close( fileStream );
|
||||
|
||||
} else if( file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) {
|
||||
|
@ -497,6 +489,25 @@ IOStream* D3MFOpcPackage::RootStream() const {
|
|||
return mRootStream;
|
||||
}
|
||||
|
||||
static const std::string ModelRef = "3D/3dmodel.model";
|
||||
|
||||
bool D3MFOpcPackage::validate() {
|
||||
if ( nullptr == mRootStream || nullptr == mZipArchive ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mZipArchive->Exists( ModelRef.c_str() );
|
||||
}
|
||||
|
||||
bool D3MFOpcPackage::isZipArchive( IOSystem* pIOHandler, const std::string& rFile ) {
|
||||
D3MF::D3MFZipArchive ar( pIOHandler, rFile );
|
||||
if ( !ar.isOpen() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream* stream) {
|
||||
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(stream));
|
||||
std::unique_ptr<XmlReader> xml(irr::io::createIrrXMLReader(xmlStream.get()));
|
||||
|
@ -507,14 +518,14 @@ std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream* stream) {
|
|||
return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE;
|
||||
});
|
||||
|
||||
if(itr == reader.m_relationShips.end())
|
||||
throw DeadlyImportError("Cannot find " + XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE);
|
||||
if ( itr == reader.m_relationShips.end() ) {
|
||||
throw DeadlyImportError( "Cannot find " + XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE );
|
||||
}
|
||||
|
||||
return (*itr)->target;
|
||||
}
|
||||
|
||||
} // Namespace D3MF
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif //ASSIMP_BUILD_NO_3MF_IMPORTER
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -45,13 +46,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <memory>
|
||||
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include "irrXMLWrapper.h"
|
||||
#include <assimp/irrXMLWrapper.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace D3MF {
|
||||
|
||||
typedef irr::io::IrrXMLReader XmlReader;
|
||||
typedef std::shared_ptr<XmlReader> XmlReaderPtr;
|
||||
using XmlReader = irr::io::IrrXMLReader ;
|
||||
using XmlReaderPtr = std::shared_ptr<XmlReader> ;
|
||||
|
||||
struct OpcPackageRelationship {
|
||||
std::string id;
|
||||
|
@ -63,9 +64,11 @@ class D3MFZipArchive;
|
|||
|
||||
class D3MFOpcPackage {
|
||||
public:
|
||||
D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile);
|
||||
D3MFOpcPackage( IOSystem* pIOHandler, const std::string& rFile );
|
||||
~D3MFOpcPackage();
|
||||
IOStream* RootStream() const;
|
||||
bool validate();
|
||||
static bool isZipArchive( IOSystem* pIOHandler, const std::string& rFile );
|
||||
|
||||
protected:
|
||||
std::string ReadPackageRootRelationship(IOStream* stream);
|
||||
|
@ -75,7 +78,7 @@ private:
|
|||
std::unique_ptr<D3MFZipArchive> mZipArchive;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // Namespace D3MF
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif // D3MFOPCPACKAGE_H
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -46,10 +47,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_DXFHELPER_H
|
||||
#define INCLUDED_DXFHELPER_H
|
||||
|
||||
#include "LineSplitter.h"
|
||||
#include "TinyFormatter.h"
|
||||
#include "StreamReader.h"
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/LineSplitter.h>
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <vector>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
|
@ -168,7 +169,6 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
LineSplitter splitter;
|
||||
int groupcode;
|
||||
std::string value;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -48,9 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
|
||||
|
||||
#include "DXFLoader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
|
||||
#include "DXFHelper.h"
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
@ -118,9 +119,18 @@ DXFImporter::~DXFImporter()
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool DXFImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const
|
||||
{
|
||||
return SimpleExtensionCheck(pFile,"dxf");
|
||||
bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const {
|
||||
const std::string& extension = GetExtension( pFile );
|
||||
if ( extension == "dxf" ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( extension.empty() || checkSig ) {
|
||||
static const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
|
||||
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 4 );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -45,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_DXFLOADER_H_INCLUDED
|
||||
#define AI_DXFLOADER_H_INCLUDED
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <map>
|
||||
|
||||
namespace Assimp {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -123,7 +124,8 @@ size_t DefaultIOStream::FileSize() const
|
|||
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
|
||||
#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
|
||||
struct __stat64 fileStat;
|
||||
int err = _stat64( mFilename.c_str(), &fileStat );
|
||||
//using fileno + fstat avoids having to handle the filename
|
||||
int err = _fstat64( _fileno(mFile), &fileStat );
|
||||
if (0 != err)
|
||||
return 0;
|
||||
mCachedSize = (size_t) (fileStat.st_size);
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -41,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
/** @file Default implementation of IOSystem using the standard C file functions */
|
||||
|
||||
#include "StringComparison.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
#include <assimp/DefaultIOStream.h>
|
||||
|
@ -54,31 +55,49 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
DefaultIOSystem::DefaultIOSystem()
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor.
|
||||
DefaultIOSystem::~DefaultIOSystem()
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
// maximum path length
|
||||
// XXX http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
|
||||
#ifdef PATH_MAX
|
||||
# define PATHLIMIT PATH_MAX
|
||||
#else
|
||||
# define PATHLIMIT 4096
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for the existence of a file at the given path.
|
||||
bool DefaultIOSystem::Exists( const char* pFile) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
wchar_t fileName16[PATHLIMIT];
|
||||
|
||||
bool isUnicode = IsTextUnicode(pFile, static_cast<int>(strlen(pFile)), NULL);
|
||||
if (isUnicode) {
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, pFile, -1, fileName16, PATHLIMIT);
|
||||
struct _stat64 filestat;
|
||||
if (0 != _wstat64(fileName16, &filestat)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
FILE* file = ::fopen(pFile, "rb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
::fclose(file);
|
||||
}
|
||||
#else
|
||||
FILE* file = ::fopen( pFile, "rb");
|
||||
if( !file)
|
||||
return false;
|
||||
|
||||
::fclose( file);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -88,10 +107,22 @@ IOStream* DefaultIOSystem::Open( const char* strFile, const char* strMode)
|
|||
{
|
||||
ai_assert(NULL != strFile);
|
||||
ai_assert(NULL != strMode);
|
||||
|
||||
FILE* file = ::fopen( strFile, strMode);
|
||||
if( NULL == file)
|
||||
return NULL;
|
||||
FILE* file;
|
||||
#ifdef _WIN32
|
||||
wchar_t fileName16[PATHLIMIT];
|
||||
bool isUnicode = IsTextUnicode(strFile, static_cast<int>(strlen(strFile)), NULL );
|
||||
if (isUnicode) {
|
||||
MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, strFile, -1, fileName16, PATHLIMIT);
|
||||
std::string mode8(strMode);
|
||||
file = ::_wfopen(fileName16, std::wstring(mode8.begin(), mode8.end()).c_str());
|
||||
} else {
|
||||
file = ::fopen(strFile, strMode);
|
||||
}
|
||||
#else
|
||||
file = ::fopen(strFile, strMode);
|
||||
#endif
|
||||
if (nullptr == file)
|
||||
return nullptr;
|
||||
|
||||
return new DefaultIOStream(file, (std::string) strFile);
|
||||
}
|
||||
|
@ -121,32 +152,47 @@ bool IOSystem::ComparePaths (const char* one, const char* second) const
|
|||
return !ASSIMP_stricmp(one,second);
|
||||
}
|
||||
|
||||
// maximum path length
|
||||
// XXX http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
|
||||
#ifdef PATH_MAX
|
||||
# define PATHLIMIT PATH_MAX
|
||||
#else
|
||||
# define PATHLIMIT 4096
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert a relative path into an absolute path
|
||||
inline void MakeAbsolutePath (const char* in, char* _out)
|
||||
inline static void MakeAbsolutePath (const char* in, char* _out)
|
||||
{
|
||||
ai_assert(in && _out);
|
||||
char* ret;
|
||||
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
||||
ret = ::_fullpath( _out, in, PATHLIMIT );
|
||||
bool isUnicode = IsTextUnicode(in, static_cast<int>(strlen(in)), NULL);
|
||||
if (isUnicode) {
|
||||
wchar_t out16[PATHLIMIT];
|
||||
wchar_t in16[PATHLIMIT];
|
||||
MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, in, -1, out16, PATHLIMIT);
|
||||
wchar_t* ret = ::_wfullpath(out16, in16, PATHLIMIT);
|
||||
if (ret) {
|
||||
WideCharToMultiByte(CP_UTF8, MB_PRECOMPOSED, out16, -1, _out, PATHLIMIT, nullptr, nullptr);
|
||||
}
|
||||
if (!ret) {
|
||||
// preserve the input path, maybe someone else is able to fix
|
||||
// the path before it is accessed (e.g. our file system filter)
|
||||
DefaultLogger::get()->warn("Invalid path: " + std::string(in));
|
||||
strcpy(_out, in);
|
||||
}
|
||||
|
||||
} else {
|
||||
char* ret = :: _fullpath(_out, in, PATHLIMIT);
|
||||
if (!ret) {
|
||||
// preserve the input path, maybe someone else is able to fix
|
||||
// the path before it is accessed (e.g. our file system filter)
|
||||
DefaultLogger::get()->warn("Invalid path: " + std::string(in));
|
||||
strcpy(_out, in);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// use realpath
|
||||
ret = realpath(in, _out);
|
||||
#endif
|
||||
char* ret = realpath(in, _out);
|
||||
if(!ret) {
|
||||
// preserve the input path, maybe someone else is able to fix
|
||||
// the path before it is accessed (e.g. our file system filter)
|
||||
DefaultLogger::get()->warn("Invalid path: "+std::string(in));
|
||||
strcpy(_out,in);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -44,12 +45,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* @brief Implementation of DefaultLogger (and Logger)
|
||||
*/
|
||||
|
||||
|
||||
// Default log streams
|
||||
#include "Win32DebugLogStream.h"
|
||||
#include "StdOStreamLogStream.h"
|
||||
#include "FileLogStream.h"
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
#include <assimp/NullLogger.hpp>
|
||||
|
@ -61,8 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_SINGLETHREADED
|
||||
# include <thread>
|
||||
# include <mutex>
|
||||
|
||||
std::mutex loggerMutex;
|
||||
std::mutex loggerMutex;
|
||||
#endif
|
||||
|
||||
namespace Assimp {
|
||||
|
@ -75,22 +74,19 @@ static const unsigned int SeverityAll = Logger::Info | Logger::Err | Logger::War
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Represents a log-stream + its error severity
|
||||
struct LogStreamInfo
|
||||
{
|
||||
unsigned int m_uiErrorSeverity;
|
||||
LogStream *m_pStream;
|
||||
struct LogStreamInfo {
|
||||
unsigned int m_uiErrorSeverity;
|
||||
LogStream *m_pStream;
|
||||
|
||||
// Constructor
|
||||
LogStreamInfo( unsigned int uiErrorSev, LogStream *pStream ) :
|
||||
m_uiErrorSeverity( uiErrorSev ),
|
||||
m_pStream( pStream )
|
||||
{
|
||||
m_pStream( pStream ) {
|
||||
// empty
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~LogStreamInfo()
|
||||
{
|
||||
~LogStreamInfo() {
|
||||
delete m_pStream;
|
||||
}
|
||||
};
|
||||
|
@ -108,7 +104,7 @@ LogStream* LogStream::createDefaultStream(aiDefaultLogStream streams,
|
|||
#ifdef WIN32
|
||||
return new Win32DebugLogStream();
|
||||
#else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
|
||||
// Platform-independent default streams
|
||||
|
@ -117,7 +113,7 @@ LogStream* LogStream::createDefaultStream(aiDefaultLogStream streams,
|
|||
case aiDefaultLogStream_STDOUT:
|
||||
return new StdOStreamLogStream(std::cout);
|
||||
case aiDefaultLogStream_FILE:
|
||||
return (name && *name ? new FileLogStream(name,io) : NULL);
|
||||
return (name && *name ? new FileLogStream(name,io) : nullptr );
|
||||
default:
|
||||
// We don't know this default log stream, so raise an assertion
|
||||
ai_assert(false);
|
||||
|
@ -133,34 +129,38 @@ LogStream* LogStream::createDefaultStream(aiDefaultLogStream streams,
|
|||
Logger *DefaultLogger::create(const char* name /*= "AssimpLog.txt"*/,
|
||||
LogSeverity severity /*= NORMAL*/,
|
||||
unsigned int defStreams /*= aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE*/,
|
||||
IOSystem* io /*= NULL*/)
|
||||
{
|
||||
IOSystem* io /*= NULL*/) {
|
||||
// enter the mutex here to avoid concurrency problems
|
||||
#ifndef ASSIMP_BUILD_SINGLETHREADED
|
||||
std::lock_guard<std::mutex> lock(loggerMutex);
|
||||
#endif
|
||||
|
||||
if (m_pLogger && !isNullLogger() )
|
||||
if ( m_pLogger && !isNullLogger() ) {
|
||||
delete m_pLogger;
|
||||
}
|
||||
|
||||
m_pLogger = new DefaultLogger( severity );
|
||||
|
||||
// Attach default log streams
|
||||
// Stream the log to the MSVC debugger?
|
||||
if (defStreams & aiDefaultLogStream_DEBUGGER)
|
||||
m_pLogger->attachStream( LogStream::createDefaultStream(aiDefaultLogStream_DEBUGGER));
|
||||
if ( defStreams & aiDefaultLogStream_DEBUGGER ) {
|
||||
m_pLogger->attachStream( LogStream::createDefaultStream( aiDefaultLogStream_DEBUGGER ) );
|
||||
}
|
||||
|
||||
// Stream the log to COUT?
|
||||
if (defStreams & aiDefaultLogStream_STDOUT)
|
||||
m_pLogger->attachStream( LogStream::createDefaultStream(aiDefaultLogStream_STDOUT));
|
||||
if ( defStreams & aiDefaultLogStream_STDOUT ) {
|
||||
m_pLogger->attachStream( LogStream::createDefaultStream( aiDefaultLogStream_STDOUT ) );
|
||||
}
|
||||
|
||||
// Stream the log to CERR?
|
||||
if (defStreams & aiDefaultLogStream_STDERR)
|
||||
m_pLogger->attachStream( LogStream::createDefaultStream(aiDefaultLogStream_STDERR));
|
||||
if ( defStreams & aiDefaultLogStream_STDERR ) {
|
||||
m_pLogger->attachStream( LogStream::createDefaultStream( aiDefaultLogStream_STDERR ) );
|
||||
}
|
||||
|
||||
// Stream the log to a file
|
||||
if (defStreams & aiDefaultLogStream_FILE && name && *name)
|
||||
m_pLogger->attachStream( LogStream::createDefaultStream(aiDefaultLogStream_FILE,name,io));
|
||||
if ( defStreams & aiDefaultLogStream_FILE && name && *name ) {
|
||||
m_pLogger->attachStream( LogStream::createDefaultStream( aiDefaultLogStream_FILE, name, io ) );
|
||||
}
|
||||
|
||||
return m_pLogger;
|
||||
}
|
||||
|
@ -199,7 +199,6 @@ void Logger::warn(const char* message) {
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
void Logger::error(const char* message) {
|
||||
|
||||
// SECURITY FIX: see above
|
||||
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
|
||||
return;
|
||||
|
@ -208,23 +207,24 @@ void Logger::error(const char* message) {
|
|||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
void DefaultLogger::set( Logger *logger )
|
||||
{
|
||||
void DefaultLogger::set( Logger *logger ) {
|
||||
// enter the mutex here to avoid concurrency problems
|
||||
#ifndef ASSIMP_BUILD_SINGLETHREADED
|
||||
std::lock_guard<std::mutex> lock(loggerMutex);
|
||||
#endif
|
||||
|
||||
if (!logger)logger = &s_pNullLogger;
|
||||
if (m_pLogger && !isNullLogger() )
|
||||
if ( nullptr == logger ) {
|
||||
logger = &s_pNullLogger;
|
||||
}
|
||||
if ( nullptr != m_pLogger && !isNullLogger() ) {
|
||||
delete m_pLogger;
|
||||
}
|
||||
|
||||
DefaultLogger::m_pLogger = logger;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
bool DefaultLogger::isNullLogger()
|
||||
{
|
||||
bool DefaultLogger::isNullLogger() {
|
||||
return m_pLogger == &s_pNullLogger;
|
||||
}
|
||||
|
||||
|
@ -235,8 +235,7 @@ Logger *DefaultLogger::get() {
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Kills the only instance
|
||||
void DefaultLogger::kill()
|
||||
{
|
||||
void DefaultLogger::kill() {
|
||||
// enter the mutex here to avoid concurrency problems
|
||||
#ifndef ASSIMP_BUILD_SINGLETHREADED
|
||||
std::lock_guard<std::mutex> lock(loggerMutex);
|
||||
|
@ -251,10 +250,10 @@ void DefaultLogger::kill()
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Debug message
|
||||
void DefaultLogger::OnDebug( const char* message )
|
||||
{
|
||||
if ( m_Severity == Logger::NORMAL )
|
||||
return;
|
||||
void DefaultLogger::OnDebug( const char* message ) {
|
||||
if ( m_Severity == Logger::NORMAL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16;
|
||||
char msg[Size];
|
||||
|
@ -265,8 +264,7 @@ void DefaultLogger::OnDebug( const char* message )
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Logs an info
|
||||
void DefaultLogger::OnInfo( const char* message )
|
||||
{
|
||||
void DefaultLogger::OnInfo( const char* message ){
|
||||
static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16;
|
||||
char msg[Size];
|
||||
ai_snprintf(msg, Size, "Info, T%u: %s", GetThreadID(), message );
|
||||
|
@ -276,8 +274,7 @@ void DefaultLogger::OnInfo( const char* message )
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Logs a warning
|
||||
void DefaultLogger::OnWarn( const char* message )
|
||||
{
|
||||
void DefaultLogger::OnWarn( const char* message ) {
|
||||
static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16;
|
||||
char msg[Size];
|
||||
ai_snprintf(msg, Size, "Warn, T%u: %s", GetThreadID(), message );
|
||||
|
@ -287,8 +284,7 @@ void DefaultLogger::OnWarn( const char* message )
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Logs an error
|
||||
void DefaultLogger::OnError( const char* message )
|
||||
{
|
||||
void DefaultLogger::OnError( const char* message ) {
|
||||
static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16;
|
||||
char msg[ Size ];
|
||||
ai_snprintf(msg, Size, "Error, T%u: %s", GetThreadID(), message );
|
||||
|
@ -298,10 +294,10 @@ void DefaultLogger::OnError( const char* message )
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Will attach a new stream
|
||||
bool DefaultLogger::attachStream( LogStream *pStream, unsigned int severity )
|
||||
{
|
||||
if (!pStream)
|
||||
bool DefaultLogger::attachStream( LogStream *pStream, unsigned int severity ) {
|
||||
if ( nullptr == pStream ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 == severity) {
|
||||
severity = Logger::Info | Logger::Err | Logger::Warn | Logger::Debugging;
|
||||
|
@ -311,8 +307,7 @@ bool DefaultLogger::attachStream( LogStream *pStream, unsigned int severity )
|
|||
it != m_StreamArray.end();
|
||||
++it )
|
||||
{
|
||||
if ( (*it)->m_pStream == pStream )
|
||||
{
|
||||
if ( (*it)->m_pStream == pStream ) {
|
||||
(*it)->m_uiErrorSeverity |= severity;
|
||||
return true;
|
||||
}
|
||||
|
@ -325,34 +320,31 @@ bool DefaultLogger::attachStream( LogStream *pStream, unsigned int severity )
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Detach a stream
|
||||
bool DefaultLogger::detatchStream( LogStream *pStream, unsigned int severity )
|
||||
{
|
||||
if (!pStream)
|
||||
bool DefaultLogger::detatchStream( LogStream *pStream, unsigned int severity ) {
|
||||
if ( nullptr == pStream ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 == severity) {
|
||||
severity = SeverityAll;
|
||||
}
|
||||
|
||||
for ( StreamIt it = m_StreamArray.begin();
|
||||
it != m_StreamArray.end();
|
||||
++it )
|
||||
{
|
||||
if ( (*it)->m_pStream == pStream )
|
||||
{
|
||||
bool res( false );
|
||||
for ( StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it ) {
|
||||
if ( (*it)->m_pStream == pStream ) {
|
||||
(*it)->m_uiErrorSeverity &= ~severity;
|
||||
if ( (*it)->m_uiErrorSeverity == 0 )
|
||||
{
|
||||
if ( (*it)->m_uiErrorSeverity == 0 ) {
|
||||
// don't delete the underlying stream 'cause the caller gains ownership again
|
||||
(**it).m_pStream = NULL;
|
||||
(**it).m_pStream = nullptr;
|
||||
delete *it;
|
||||
m_StreamArray.erase( it );
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return res;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
@ -360,15 +352,13 @@ bool DefaultLogger::detatchStream( LogStream *pStream, unsigned int severity )
|
|||
DefaultLogger::DefaultLogger(LogSeverity severity)
|
||||
: Logger ( severity )
|
||||
, noRepeatMsg (false)
|
||||
, lastLen( 0 )
|
||||
{
|
||||
, lastLen( 0 ) {
|
||||
lastMsg[0] = '\0';
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Destructor
|
||||
DefaultLogger::~DefaultLogger()
|
||||
{
|
||||
DefaultLogger::~DefaultLogger() {
|
||||
for ( StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it ) {
|
||||
// also frees the underlying stream, we are its owner.
|
||||
delete *it;
|
||||
|
@ -377,9 +367,8 @@ DefaultLogger::~DefaultLogger()
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Writes message to stream
|
||||
void DefaultLogger::WriteToStreams(const char *message, ErrorSeverity ErrorSev )
|
||||
{
|
||||
ai_assert(NULL != message);
|
||||
void DefaultLogger::WriteToStreams(const char *message, ErrorSeverity ErrorSev ) {
|
||||
ai_assert(nullptr != message);
|
||||
|
||||
// Check whether this is a repeated message
|
||||
if (! ::strncmp( message,lastMsg, lastLen-1))
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, 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 "EmbedTexturesProcess.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include "ProcessHelper.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
EmbedTexturesProcess::EmbedTexturesProcess()
|
||||
: BaseProcess() {
|
||||
}
|
||||
|
||||
EmbedTexturesProcess::~EmbedTexturesProcess() {
|
||||
}
|
||||
|
||||
bool EmbedTexturesProcess::IsActive(unsigned int pFlags) const {
|
||||
return (pFlags & aiProcess_EmbedTextures) != 0;
|
||||
}
|
||||
|
||||
void EmbedTexturesProcess::SetupProperties(const Importer* pImp) {
|
||||
mRootPath = pImp->GetPropertyString("sourceFilePath");
|
||||
mRootPath = mRootPath.substr(0, mRootPath.find_last_of("\\/") + 1u);
|
||||
}
|
||||
|
||||
void EmbedTexturesProcess::Execute(aiScene* pScene) {
|
||||
if (pScene == nullptr || pScene->mRootNode == nullptr) return;
|
||||
|
||||
aiString path;
|
||||
|
||||
uint32_t embeddedTexturesCount = 0u;
|
||||
|
||||
for (auto matId = 0u; matId < pScene->mNumMaterials; ++matId) {
|
||||
auto material = pScene->mMaterials[matId];
|
||||
|
||||
for (auto ttId = 1u; ttId < AI_TEXTURE_TYPE_MAX; ++ttId) {
|
||||
auto tt = static_cast<aiTextureType>(ttId);
|
||||
auto texturesCount = material->GetTextureCount(tt);
|
||||
|
||||
for (auto texId = 0u; texId < texturesCount; ++texId) {
|
||||
material->GetTexture(tt, texId, &path);
|
||||
if (path.data[0] == '*') continue; // Already embedded
|
||||
|
||||
// Indeed embed
|
||||
if (addTexture(pScene, path.data)) {
|
||||
auto embeddedTextureId = pScene->mNumTextures - 1u;
|
||||
::ai_snprintf(path.data, 1024, "*%u", embeddedTextureId);
|
||||
material->AddProperty(&path, AI_MATKEY_TEXTURE(tt, texId));
|
||||
embeddedTexturesCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char stringBuffer[128];
|
||||
::ai_snprintf(stringBuffer, 128, "EmbedTexturesProcess finished. Embedded %u textures.", embeddedTexturesCount);
|
||||
DefaultLogger::get()->info(stringBuffer);
|
||||
}
|
||||
|
||||
bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
|
||||
std::streampos imageSize = 0;
|
||||
std::string imagePath = path;
|
||||
|
||||
// Test path directly
|
||||
std::ifstream file(imagePath, std::ios::binary | std::ios::ate);
|
||||
if ((imageSize = file.tellg()) == std::streampos(-1)) {
|
||||
DefaultLogger::get()->warn("EmbedTexturesProcess: Cannot find image: " + imagePath + ". Will try to find it in root folder.");
|
||||
|
||||
// Test path in root path
|
||||
imagePath = mRootPath + path;
|
||||
file.open(imagePath, std::ios::binary | std::ios::ate);
|
||||
if ((imageSize = file.tellg()) == std::streampos(-1)) {
|
||||
// Test path basename in root path
|
||||
imagePath = mRootPath + path.substr(path.find_last_of("\\/") + 1u);
|
||||
file.open(imagePath, std::ios::binary | std::ios::ate);
|
||||
if ((imageSize = file.tellg()) == std::streampos(-1)) {
|
||||
DefaultLogger::get()->error("EmbedTexturesProcess: Unable to embed texture: " + path + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aiTexel* imageContent = new aiTexel[1u + imageSize / sizeof(aiTexel)];
|
||||
file.seekg(0, std::ios::beg);
|
||||
file.read(reinterpret_cast<char*>(imageContent), imageSize);
|
||||
|
||||
// Enlarging the textures table
|
||||
auto textureId = pScene->mNumTextures++;
|
||||
auto oldTextures = pScene->mTextures;
|
||||
pScene->mTextures = new aiTexture*[pScene->mNumTextures];
|
||||
memmove(pScene->mTextures, oldTextures, sizeof(aiTexture*) * (pScene->mNumTextures - 1u));
|
||||
|
||||
// Add the new texture
|
||||
auto pTexture = new aiTexture();
|
||||
pTexture->mHeight = 0; // Means that this is still compressed
|
||||
pTexture->mWidth = static_cast<uint32_t>(imageSize);
|
||||
pTexture->pcData = imageContent;
|
||||
|
||||
auto extension = path.substr(path.find_last_of('.') + 1u);
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
||||
if (extension == "jpeg") extension = "jpg";
|
||||
strcpy(pTexture->achFormatHint, extension.c_str());
|
||||
|
||||
pScene->mTextures[textureId] = pTexture;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BaseProcess.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
struct aiNode;
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
/**
|
||||
* Force embedding of textures (using the path = "*1" convention).
|
||||
* If a texture's file does not exist at the specified path
|
||||
* (due, for instance, to an absolute path generated on another system),
|
||||
* it will check if a file with the same name exists at the root folder
|
||||
* of the imported model. And if so, it uses that.
|
||||
*/
|
||||
class ASSIMP_API EmbedTexturesProcess : public BaseProcess {
|
||||
public:
|
||||
/// The default class constructor.
|
||||
EmbedTexturesProcess();
|
||||
|
||||
/// The class destructor.
|
||||
virtual ~EmbedTexturesProcess();
|
||||
|
||||
/// Overwritten, @see BaseProcess
|
||||
virtual bool IsActive(unsigned int pFlags) const;
|
||||
|
||||
/// Overwritten, @see BaseProcess
|
||||
virtual void SetupProperties(const Importer* pImp);
|
||||
|
||||
/// Overwritten, @see BaseProcess
|
||||
virtual void Execute(aiScene* pScene);
|
||||
|
||||
private:
|
||||
// Resolve the path and add the file content to the scene as a texture.
|
||||
bool addTexture(aiScene* pScene, std::string path) const;
|
||||
|
||||
private:
|
||||
std::string mRootPath;
|
||||
};
|
||||
|
||||
} // namespace Assimp
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -53,7 +54,7 @@ Here we implement only the C++ interface (Assimp::Exporter).
|
|||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
|
||||
#include "BlobIOSystem.h"
|
||||
#include <assimp/BlobIOSystem.h>
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include "BaseProcess.h"
|
||||
#include "Importer.h" // need this for GetPostProcessingStepInstanceList()
|
||||
|
@ -61,7 +62,7 @@ Here we implement only the C++ interface (Assimp::Exporter).
|
|||
#include "JoinVerticesProcess.h"
|
||||
#include "MakeVerboseFormat.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include "Exceptional.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
#include "ScenePrivate.h"
|
||||
#include <memory>
|
||||
|
||||
|
@ -92,9 +93,12 @@ void ExportScene3DS(const char*, IOSystem*, const aiScene*, const ExportProperti
|
|||
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 ExportSceneGLB2(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*);
|
||||
void ExportSceneFBX(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneFBXA(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportScene3MF( const char*, IOSystem*, const aiScene*, const ExportProperties* );
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -151,6 +155,8 @@ Exporter::ExportFormatEntry gExporters[] =
|
|||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
Exporter::ExportFormatEntry( "gltf2", "GL Transmission Format v. 2", "gltf2", &ExportSceneGLTF2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
Exporter::ExportFormatEntry( "glb2", "GL Transmission Format v. 2 (binary)", "glb2", &ExportSceneGLB2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||
|
@ -165,7 +171,12 @@ Exporter::ExportFormatEntry gExporters[] =
|
|||
Exporter::ExportFormatEntry( "x3d", "Extensible 3D", "x3d" , &ExportSceneX3D, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
#ifndef ASSIMP_BUILD_NO_FBX_EXPORTER
|
||||
Exporter::ExportFormatEntry( "fbx", "Autodesk FBX (binary)", "fbx", &ExportSceneFBX, 0 ),
|
||||
Exporter::ExportFormatEntry( "fbxa", "Autodesk FBX (ascii)", "fbx", &ExportSceneFBXA, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_3MF_EXPORTER
|
||||
Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 )
|
||||
#endif
|
||||
};
|
||||
|
@ -297,7 +308,8 @@ bool IsVerboseFormat(const aiScene* pScene) {
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing, const ExportProperties* pProperties) {
|
||||
aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const char* pPath,
|
||||
unsigned int pPreprocessing, const ExportProperties* pProperties) {
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
|
||||
// when they create scenes from scratch, users will likely create them not in verbose
|
||||
|
@ -420,7 +432,7 @@ aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const c
|
|||
|
||||
pimpl->mError = std::string("Found no exporter to handle this file format: ") + pFormatId;
|
||||
ASSIMP_END_EXCEPTION_REGION(aiReturn);
|
||||
|
||||
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -50,8 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "FBXUtil.h"
|
||||
#include <assimp/defs.h>
|
||||
#include <stdint.h>
|
||||
#include "Exceptional.h"
|
||||
#include "ByteSwapper.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/ByteSwapper.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace FBX {
|
||||
|
@ -129,30 +130,26 @@ AI_WONT_RETURN void TokenizeError(const std::string& message, unsigned int offse
|
|||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
uint32_t Offset(const char* begin, const char* cursor)
|
||||
{
|
||||
uint32_t Offset(const char* begin, const char* cursor) {
|
||||
ai_assert(begin <= cursor);
|
||||
|
||||
return static_cast<unsigned int>(cursor - begin);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void TokenizeError(const std::string& message, const char* begin, const char* cursor)
|
||||
{
|
||||
void TokenizeError(const std::string& message, const char* begin, const char* cursor) {
|
||||
TokenizeError(message, Offset(begin, cursor));
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
uint32_t ReadWord(const char* input, const char*& cursor, const char* end)
|
||||
{
|
||||
uint32_t ReadWord(const char* input, const char*& cursor, const char* end) {
|
||||
const size_t k_to_read = sizeof( uint32_t );
|
||||
if(Offset(cursor, end) < k_to_read ) {
|
||||
TokenizeError("cannot ReadWord, out of bounds",input, cursor);
|
||||
}
|
||||
|
||||
uint32_t word;
|
||||
memcpy(&word, cursor, 4);
|
||||
::memcpy(&word, cursor, 4);
|
||||
AI_SWAP4(word);
|
||||
|
||||
cursor += k_to_read;
|
||||
|
@ -167,7 +164,8 @@ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end)
|
|||
TokenizeError("cannot ReadDoubleWord, out of bounds",input, cursor);
|
||||
}
|
||||
|
||||
uint64_t dword = *reinterpret_cast<const uint64_t*>(cursor);
|
||||
uint64_t dword /*= *reinterpret_cast<const uint64_t*>(cursor)*/;
|
||||
::memcpy( &dword, cursor, sizeof( uint64_t ) );
|
||||
AI_SWAP8(dword);
|
||||
|
||||
cursor += k_to_read;
|
||||
|
@ -176,24 +174,21 @@ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end)
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
uint8_t ReadByte(const char* input, const char*& cursor, const char* end)
|
||||
{
|
||||
uint8_t ReadByte(const char* input, const char*& cursor, const char* end) {
|
||||
if(Offset(cursor, end) < sizeof( uint8_t ) ) {
|
||||
TokenizeError("cannot ReadByte, out of bounds",input, cursor);
|
||||
}
|
||||
|
||||
uint8_t word = *reinterpret_cast<const uint8_t*>(cursor);
|
||||
uint8_t word;/* = *reinterpret_cast< const uint8_t* >( cursor )*/
|
||||
::memcpy( &word, cursor, sizeof( uint8_t ) );
|
||||
++cursor;
|
||||
|
||||
return word;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end,
|
||||
bool long_length = false,
|
||||
bool allow_null = false)
|
||||
{
|
||||
unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input,
|
||||
const char*& cursor, const char* end, bool long_length = false, bool allow_null = false) {
|
||||
const uint32_t len_len = long_length ? 4 : 1;
|
||||
if(Offset(cursor, end) < len_len) {
|
||||
TokenizeError("cannot ReadString, out of bounds reading length",input, cursor);
|
||||
|
@ -222,8 +217,7 @@ unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const ch
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end)
|
||||
{
|
||||
void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end) {
|
||||
if(Offset(cursor, end) < 1) {
|
||||
TokenizeError("cannot ReadData, out of bounds reading length",input, cursor);
|
||||
}
|
||||
|
@ -422,7 +416,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
|
|||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// TODO: Test FBX Binary files newer than the 7500 version to check if the 64 bits address behaviour is consistent
|
||||
|
@ -434,6 +428,14 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
|
|||
TokenizeError("file is too short",0);
|
||||
}
|
||||
|
||||
//uint32_t offset = 0x15;
|
||||
/* const char* cursor = input + 0x15;
|
||||
|
||||
const uint32_t flags = ReadWord(input, cursor, input + length);
|
||||
|
||||
const uint8_t padding_0 = ReadByte(input, cursor, input + length); // unused
|
||||
const uint8_t padding_1 = ReadByte(input, cursor, input + length); // unused*/
|
||||
|
||||
if (strncmp(input,"Kaydara FBX Binary",18)) {
|
||||
TokenizeError("magic bytes not found",0);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, 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 FBXCommon.h
|
||||
* Some useful constants and enums for dealing with FBX files.
|
||||
*/
|
||||
#ifndef AI_FBXCOMMON_H_INC
|
||||
#define AI_FBXCOMMON_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_FBX_EXPORTER
|
||||
|
||||
|
||||
namespace FBX
|
||||
{
|
||||
const std::string NULL_RECORD = { // 13 null bytes
|
||||
'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'
|
||||
}; // who knows why
|
||||
const std::string SEPARATOR = {'\x00', '\x01'}; // for use inside strings
|
||||
const std::string MAGIC_NODE_TAG = "_$AssimpFbx$"; // from import
|
||||
const int64_t SECOND = 46186158000; // FBX's kTime unit
|
||||
|
||||
// rotation order. We'll probably use EulerXYZ for everything
|
||||
enum RotOrder {
|
||||
RotOrder_EulerXYZ = 0,
|
||||
RotOrder_EulerXZY,
|
||||
RotOrder_EulerYZX,
|
||||
RotOrder_EulerYXZ,
|
||||
RotOrder_EulerZXY,
|
||||
RotOrder_EulerZYX,
|
||||
|
||||
RotOrder_SphericXYZ,
|
||||
|
||||
RotOrder_MAX // end-of-enum sentinel
|
||||
};
|
||||
|
||||
// transformation inheritance method. Most of the time RSrs
|
||||
enum TransformInheritance {
|
||||
TransformInheritance_RrSs = 0,
|
||||
TransformInheritance_RSrs,
|
||||
TransformInheritance_Rrs,
|
||||
|
||||
TransformInheritance_MAX // end-of-enum sentinel
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_FBX_EXPORTER
|
||||
|
||||
#endif // AI_FBXCOMMON_H_INC
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue