Merge branch 'master' into Manage_PCloud_in_Filters
commit
d166e1fd73
|
@ -51,7 +51,8 @@ matrix:
|
||||||
env: ANALYZE=ON
|
env: ANALYZE=ON
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: DISABLE_EXPORTERS=YES ENABLE_COVERALLS=ON
|
# env: DISABLE_EXPORTERS=YES ENABLE_COVERALLS=ON
|
||||||
|
env: ENABLE_COVERALLS=ON
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: SHARED_BUILD=ON
|
env: SHARED_BUILD=ON
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
# - Config file for the FooBar package
|
|
||||||
# It defines the following variables
|
|
||||||
# FOOBAR_INCLUDE_DIRS - include directories for FooBar
|
|
||||||
# FOOBAR_LIBRARIES - libraries to link against
|
|
||||||
# FOOBAR_EXECUTABLE - the bar executable
|
|
||||||
|
|
||||||
# Compute paths
|
|
||||||
get_filename_component(FOOBAR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
|
||||||
if(EXISTS "${FOOBAR_CMAKE_DIR}/CMakeCache.txt")
|
|
||||||
# In build tree
|
|
||||||
include("${FOOBAR_CMAKE_DIR}/FooBarBuildTreeSettings.cmake")
|
|
||||||
else()
|
|
||||||
set(FOOBAR_INCLUDE_DIRS "${FOOBAR_CMAKE_DIR}/@CONF_REL_INCLUDE_DIR@")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Our library dependencies (contains definitions for IMPORTED targets)
|
|
||||||
include("${FOOBAR_CMAKE_DIR}/FooBarLibraryDepends.cmake")
|
|
||||||
|
|
||||||
# These are IMPORTED targets created by FooBarLibraryDepends.cmake
|
|
||||||
set(FOOBAR_LIBRARIES foo)
|
|
||||||
set(FOOBAR_EXECUTABLE bar)
|
|
53
Build.md
53
Build.md
|
@ -1,7 +1,54 @@
|
||||||
# Build instructions
|
# Install CMake
|
||||||
|
Asset-Importer-Lib supports a lot of different OSes and platforms. We are using cmake to generate the build environment for these via cmake. So you have to make sure that you have a working cmake-installation on your system. You can download it at https://cmake.org/
|
||||||
|
|
||||||
|
# Get the source
|
||||||
|
Make sure you have a working git-installation. Open a command prompt and clone the Asset-Importer-Lib via:
|
||||||
|
```
|
||||||
|
git clone https://github.com/assimp/assimp.git
|
||||||
|
```
|
||||||
|
|
||||||
|
# Build instructions for Windows with Visual-Studio
|
||||||
|
|
||||||
|
First you have to install Visual-Studio on your windows-system. You can get the Community-Version for free here: https://visualstudio.microsoft.com/de/downloads/
|
||||||
|
To generate the build environment for your IDE open a command prompt, navigate to your repo and type:
|
||||||
|
|
||||||
|
```
|
||||||
> cmake CMakeLists.txt
|
> cmake CMakeLists.txt
|
||||||
make -j4
|
```
|
||||||
|
This will generate the project files.
|
||||||
|
|
||||||
##UWP
|
# Build instructions for Windows with UWP
|
||||||
See https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app
|
See https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app
|
||||||
|
|
||||||
|
|
||||||
|
# Build instrcutions for Linux / Unix
|
||||||
|
Open a terminal and got to your repository. You can generate the projectfiles and build the library via:
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake CMakeLists.txt
|
||||||
|
make -j4
|
||||||
|
```
|
||||||
|
The option -j descripes the number of parallel processes for the build.
|
||||||
|
|
||||||
|
# CMake build options
|
||||||
|
The cmake-build-environment provides options to configure the build. The following options can be used:
|
||||||
|
- BUILD_SHARED_LIBS ( default ON ): Generation of shared libs ( dll for windows, so for Linux ). Set this to OFF to get a static lib.
|
||||||
|
- BUILD_FRAMEWORK ( default OFF, MacOnly): Build package as Mac OS X Framework bundle
|
||||||
|
- ASSIMP_DOUBLE_PRECISION( default OFF ): All data will be stored as double values.
|
||||||
|
- ASSIMP_OPT_BUILD_PACKAGES ( default OFF): Set to ON to generate CPack configuration files and packaging targets
|
||||||
|
- ASSIMP_ANDROID_JNIIOSYSTEM ( default OFF ): Android JNI IOSystem support is active
|
||||||
|
- ASSIMP_NO_EXPORT ( default OFF ): Disable Assimp's export functionality
|
||||||
|
- ASSIMP_BUILD_ZLIB ( default OFF ): Build your own zlib
|
||||||
|
- ASSIMP_BUILD_ASSIMP_TOOLS ( default ON ): If the supplementary tools for Assimp are built in addition to the library.
|
||||||
|
- ASSIMP_BUILD_SAMPLES ( default OFF ): If the official samples are built as well (needs Glut).
|
||||||
|
- ASSIMP_BUILD_TESTS ( default ON ): If the test suite for Assimp is built in addition to the library.
|
||||||
|
- ASSIMP_COVERALLS ( default OFF ): Enable this to measure test coverage.
|
||||||
|
- ASSIMP_WERROR( default OFF ): Treat warnings as errors.
|
||||||
|
- ASSIMP_ASAN ( default OFF ): Enable AddressSanitizer.
|
||||||
|
- ASSIMP_UBSAN ( default OFF ): Enable Undefined Behavior sanitizer.
|
||||||
|
- SYSTEM_IRRXML ( default OFF ): Use system installed Irrlicht/IrrXML library.
|
||||||
|
- BUILD_DOCS ( default OFF ): Build documentation using Doxygen.
|
||||||
|
- INJECT_DEBUG_POSTFIX( default ON ): Inject debug postfix in .a/.so lib names
|
||||||
|
- IGNORE_GIT_HASH ( default OFF ): Don't call git to get the hash.
|
||||||
|
- ASSIMP_INSTALL_PDB ( default ON ): Install MSVC debug files.
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,11 @@ OPTION( INJECT_DEBUG_POSTFIX
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
OPTION ( IGNORE_GIT_HASH
|
||||||
|
"Don't call git to get the hash."
|
||||||
|
OFF
|
||||||
|
)
|
||||||
|
|
||||||
IF (IOS)
|
IF (IOS)
|
||||||
IF (NOT CMAKE_BUILD_TYPE)
|
IF (NOT CMAKE_BUILD_TYPE)
|
||||||
SET(CMAKE_BUILD_TYPE "Release")
|
SET(CMAKE_BUILD_TYPE "Release")
|
||||||
|
@ -153,6 +158,7 @@ SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used
|
||||||
# Enable C++1 globally
|
# Enable C++1 globally
|
||||||
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
||||||
|
|
||||||
|
IF(NOT IGNORE_GIT_HASH)
|
||||||
# Get the current working branch
|
# Get the current working branch
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
COMMAND git rev-parse --abbrev-ref HEAD
|
COMMAND git rev-parse --abbrev-ref HEAD
|
||||||
|
@ -170,6 +176,7 @@ EXECUTE_PROCESS(
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
ERROR_QUIET
|
ERROR_QUIET
|
||||||
)
|
)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(NOT GIT_COMMIT_HASH)
|
IF(NOT GIT_COMMIT_HASH)
|
||||||
SET(GIT_COMMIT_HASH 0)
|
SET(GIT_COMMIT_HASH 0)
|
||||||
|
@ -216,9 +223,7 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
||||||
ELSEIF(MSVC)
|
ELSEIF(MSVC)
|
||||||
# enable multi-core compilation with MSVC
|
# enable multi-core compilation with MSVC
|
||||||
ADD_COMPILE_OPTIONS(/MP)
|
ADD_COMPILE_OPTIONS(/MP)
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
ADD_COMPILE_OPTIONS( /bigobj )
|
ADD_COMPILE_OPTIONS( /bigobj )
|
||||||
ENDIF()
|
|
||||||
# disable "elements of array '' will be default initialized" warning on MSVC2013
|
# disable "elements of array '' will be default initialized" warning on MSVC2013
|
||||||
IF(MSVC12)
|
IF(MSVC12)
|
||||||
ADD_COMPILE_OPTIONS(/wd4351)
|
ADD_COMPILE_OPTIONS(/wd4351)
|
||||||
|
@ -309,8 +314,18 @@ ENDIF()
|
||||||
|
|
||||||
# cmake configuration files
|
# 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.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
|
||||||
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE)
|
||||||
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-debug.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" @ONLY IMMEDIATE)
|
||||||
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-release.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake" @ONLY IMMEDIATE)
|
||||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-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})
|
#we should generated these scripts after CMake VERSION 3.0.2 using export(EXPORT ...) and write_basic_package_version_file(...)
|
||||||
|
INSTALL(FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake"
|
||||||
|
DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||||
|
|
||||||
FIND_PACKAGE( DirectX )
|
FIND_PACKAGE( DirectX )
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ __Exporters__:
|
||||||
- FBX ( experimental )
|
- FBX ( experimental )
|
||||||
|
|
||||||
### Building ###
|
### 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.
|
Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file. Our build system is CMake, if you used CMake before there is a good chance you know what to do.
|
||||||
|
|
||||||
### Ports ###
|
### Ports ###
|
||||||
* [Android](port/AndroidJNI/README.md)
|
* [Android](port/AndroidJNI/README.md)
|
||||||
|
|
|
@ -1,59 +1 @@
|
||||||
# - Find Assimp Installation
|
include(${CMAKE_CURRENT_LIST_DIR}/assimpTargets.cmake)
|
||||||
#
|
|
||||||
# Users can set the following variables before calling the module:
|
|
||||||
# ASSIMP_DIR - The preferred installation prefix for searching for ASSIMP. Set by the user.
|
|
||||||
#
|
|
||||||
# ASSIMP_ROOT_DIR - the root directory where the installation can be found
|
|
||||||
# ASSIMP_CXX_FLAGS - extra flags for compilation
|
|
||||||
# ASSIMP_LINK_FLAGS - extra flags for linking
|
|
||||||
# ASSIMP_INCLUDE_DIRS - include directories
|
|
||||||
# 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(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
|
|
||||||
if( MSVC70 OR MSVC71 )
|
|
||||||
set(MSVC_PREFIX "vc70")
|
|
||||||
elseif( MSVC80 )
|
|
||||||
set(MSVC_PREFIX "vc80")
|
|
||||||
elseif( MSVC90 )
|
|
||||||
set(MSVC_PREFIX "vc90")
|
|
||||||
elseif( MSVC10 )
|
|
||||||
set(MSVC_PREFIX "vc100")
|
|
||||||
elseif( MSVC11 )
|
|
||||||
set(MSVC_PREFIX "vc110")
|
|
||||||
elseif( MSVC12 )
|
|
||||||
set(MSVC_PREFIX "vc120")
|
|
||||||
elseif( MSVC14 )
|
|
||||||
set(MSVC_PREFIX "vc140")
|
|
||||||
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" )
|
|
||||||
else()
|
|
||||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set( ASSIMP_CXX_FLAGS ) # dynamically linked library
|
|
||||||
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@)
|
|
||||||
|
|
||||||
# for compatibility with pkg-config
|
|
||||||
set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}")
|
|
||||||
set(ASSIMP_LDFLAGS_OTHER "${ASSIMP_LINK_FLAGS}")
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
ASSIMP_ROOT_DIR
|
|
||||||
ASSIMP_CXX_FLAGS
|
|
||||||
ASSIMP_LINK_FLAGS
|
|
||||||
ASSIMP_INCLUDE_DIRS
|
|
||||||
ASSIMP_LIBRARIES
|
|
||||||
ASSIMP_CFLAGS_OTHER
|
|
||||||
ASSIMP_LDFLAGS_OTHER
|
|
||||||
ASSIMP_LIBRARY_SUFFIX
|
|
||||||
)
|
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
# Generated CMake target import file for configuration "Debug".
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
|
||||||
|
# Commands may need to know the format version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
if( MSVC70 OR MSVC71 )
|
||||||
|
set(MSVC_PREFIX "vc70")
|
||||||
|
elseif( MSVC80 )
|
||||||
|
set(MSVC_PREFIX "vc80")
|
||||||
|
elseif( MSVC90 )
|
||||||
|
set(MSVC_PREFIX "vc90")
|
||||||
|
elseif( MSVC10 )
|
||||||
|
set(MSVC_PREFIX "vc100")
|
||||||
|
elseif( MSVC11 )
|
||||||
|
set(MSVC_PREFIX "vc110")
|
||||||
|
elseif( MSVC12 )
|
||||||
|
set(MSVC_PREFIX "vc120")
|
||||||
|
elseif( MSVC14 )
|
||||||
|
set(MSVC_PREFIX "vc140")
|
||||||
|
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" )
|
||||||
|
|
||||||
|
set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||||
|
set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_IMPORT_LIBRARY_SUFFIX@")
|
||||||
|
|
||||||
|
# Import target "assimp::assimp" for configuration "Debug"
|
||||||
|
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||||
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
|
IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}"
|
||||||
|
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
|
||||||
|
)
|
||||||
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}")
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
|
||||||
|
|
||||||
|
else()
|
||||||
|
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" )
|
||||||
|
set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@")
|
||||||
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
|
IMPORTED_SONAME_DEBUG "${sharedLibraryName}"
|
||||||
|
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
|
||||||
|
)
|
||||||
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Commands beyond this point should not need to know the version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
|
||||||
|
get_filename_component(ASSIMP_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" REALPATH)
|
||||||
|
set( ASSIMP_CXX_FLAGS ) # dynamically linked library
|
||||||
|
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 ${sharedLibraryName})
|
||||||
|
|
||||||
|
# for compatibility with pkg-config
|
||||||
|
set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}")
|
||||||
|
set(ASSIMP_LDFLAGS_OTHER "${ASSIMP_LINK_FLAGS}")
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
ASSIMP_ROOT_DIR
|
||||||
|
ASSIMP_CXX_FLAGS
|
||||||
|
ASSIMP_LINK_FLAGS
|
||||||
|
ASSIMP_INCLUDE_DIRS
|
||||||
|
ASSIMP_LIBRARIES
|
||||||
|
ASSIMP_CFLAGS_OTHER
|
||||||
|
ASSIMP_LDFLAGS_OTHER
|
||||||
|
ASSIMP_LIBRARY_SUFFIX
|
||||||
|
)
|
|
@ -0,0 +1,75 @@
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
# Generated CMake target import file for configuration "Release".
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
|
||||||
|
# Commands may need to know the format version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
if( MSVC70 OR MSVC71 )
|
||||||
|
set(MSVC_PREFIX "vc70")
|
||||||
|
elseif( MSVC80 )
|
||||||
|
set(MSVC_PREFIX "vc80")
|
||||||
|
elseif( MSVC90 )
|
||||||
|
set(MSVC_PREFIX "vc90")
|
||||||
|
elseif( MSVC10 )
|
||||||
|
set(MSVC_PREFIX "vc100")
|
||||||
|
elseif( MSVC11 )
|
||||||
|
set(MSVC_PREFIX "vc110")
|
||||||
|
elseif( MSVC12 )
|
||||||
|
set(MSVC_PREFIX "vc120")
|
||||||
|
elseif( MSVC14 )
|
||||||
|
set(MSVC_PREFIX "vc140")
|
||||||
|
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" )
|
||||||
|
|
||||||
|
set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||||
|
set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_IMPORT_LIBRARY_SUFFIX@")
|
||||||
|
|
||||||
|
# Import target "assimp::assimp" for configuration "Release"
|
||||||
|
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||||
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
|
IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}"
|
||||||
|
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
|
||||||
|
)
|
||||||
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}")
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
|
||||||
|
|
||||||
|
else()
|
||||||
|
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" )
|
||||||
|
set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@")
|
||||||
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
|
IMPORTED_SONAME_RELEASE "${sharedLibraryName}"
|
||||||
|
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
|
||||||
|
)
|
||||||
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Commands beyond this point should not need to know the version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
|
||||||
|
get_filename_component(ASSIMP_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" REALPATH)
|
||||||
|
set( ASSIMP_CXX_FLAGS ) # dynamically linked library
|
||||||
|
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 ${sharedLibraryName})
|
||||||
|
|
||||||
|
# for compatibility with pkg-config
|
||||||
|
set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}")
|
||||||
|
set(ASSIMP_LDFLAGS_OTHER "${ASSIMP_LINK_FLAGS}")
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
ASSIMP_ROOT_DIR
|
||||||
|
ASSIMP_CXX_FLAGS
|
||||||
|
ASSIMP_LINK_FLAGS
|
||||||
|
ASSIMP_INCLUDE_DIRS
|
||||||
|
ASSIMP_LIBRARIES
|
||||||
|
ASSIMP_CFLAGS_OTHER
|
||||||
|
ASSIMP_LDFLAGS_OTHER
|
||||||
|
ASSIMP_LIBRARY_SUFFIX
|
||||||
|
)
|
|
@ -0,0 +1,101 @@
|
||||||
|
# Generated by CMake
|
||||||
|
|
||||||
|
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
|
||||||
|
message(FATAL_ERROR "CMake >= 2.6.0 required")
|
||||||
|
endif()
|
||||||
|
cmake_policy(PUSH)
|
||||||
|
cmake_policy(VERSION 2.6)
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
# Generated CMake target import file.
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
|
||||||
|
# Commands may need to know the format version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
|
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
||||||
|
set(_targetsDefined)
|
||||||
|
set(_targetsNotDefined)
|
||||||
|
set(_expectedTargets)
|
||||||
|
foreach(_expectedTarget assimp::assimp)
|
||||||
|
list(APPEND _expectedTargets ${_expectedTarget})
|
||||||
|
if(NOT TARGET ${_expectedTarget})
|
||||||
|
list(APPEND _targetsNotDefined ${_expectedTarget})
|
||||||
|
endif()
|
||||||
|
if(TARGET ${_expectedTarget})
|
||||||
|
list(APPEND _targetsDefined ${_expectedTarget})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
|
||||||
|
unset(_targetsDefined)
|
||||||
|
unset(_targetsNotDefined)
|
||||||
|
unset(_expectedTargets)
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
cmake_policy(POP)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
if(NOT "${_targetsDefined}" STREQUAL "")
|
||||||
|
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
|
||||||
|
endif()
|
||||||
|
unset(_targetsDefined)
|
||||||
|
unset(_targetsNotDefined)
|
||||||
|
unset(_expectedTargets)
|
||||||
|
|
||||||
|
|
||||||
|
# Compute the installation prefix relative to this file.
|
||||||
|
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||||
|
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||||
|
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||||
|
if(_IMPORT_PREFIX STREQUAL "/")
|
||||||
|
set(_IMPORT_PREFIX "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Create imported target assimp::assimp
|
||||||
|
add_library(assimp::assimp SHARED IMPORTED)
|
||||||
|
|
||||||
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
|
COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION"
|
||||||
|
INTERFACE_assimp_MAJOR_VERSION "1"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include"
|
||||||
|
#INTERFACE_LINK_LIBRARIES "TxtUtils::TxtUtils;MealyMachine::MealyMachine"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||||
|
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Load information for each installed configuration.
|
||||||
|
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
file(GLOB CONFIG_FILES "${_DIR}/assimpTargets-*.cmake")
|
||||||
|
foreach(f ${CONFIG_FILES})
|
||||||
|
include(${f})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Cleanup temporary variables.
|
||||||
|
set(_IMPORT_PREFIX)
|
||||||
|
|
||||||
|
# Loop over all imported files and verify that they actually exist
|
||||||
|
foreach(target ${_IMPORT_CHECK_TARGETS} )
|
||||||
|
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
|
||||||
|
if(NOT EXISTS "${file}" )
|
||||||
|
message(FATAL_ERROR "The imported target \"${target}\" references the file
|
||||||
|
\"${file}\"
|
||||||
|
but this file does not exist. Possible reasons include:
|
||||||
|
* The file was deleted, renamed, or moved to another location.
|
||||||
|
* An install or uninstall procedure did not complete successfully.
|
||||||
|
* The installation package was faulty and contained
|
||||||
|
\"${CMAKE_CURRENT_LIST_FILE}\"
|
||||||
|
but not all the files it references.
|
||||||
|
")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
unset(_IMPORT_CHECK_FILES_FOR_${target})
|
||||||
|
endforeach()
|
||||||
|
unset(_IMPORT_CHECK_TARGETS)
|
||||||
|
|
||||||
|
# This file does not depend on other imported targets which have
|
||||||
|
# been exported from the same project but in a separate export set.
|
||||||
|
|
||||||
|
# Commands beyond this point should not need to know the version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
cmake_policy(POP)
|
|
@ -58,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace D3DS {
|
namespace D3DS {
|
||||||
|
|
||||||
#include "./../include/assimp/Compiler/pushpack1.h"
|
#include <assimp/Compiler/pushpack1.h>
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Discreet3DS class: Helper class for loading 3ds files. Defines chunks
|
/** Discreet3DS class: Helper class for loading 3ds files. Defines chunks
|
||||||
|
@ -66,7 +66,7 @@ namespace D3DS {
|
||||||
*/
|
*/
|
||||||
class Discreet3DS {
|
class Discreet3DS {
|
||||||
private:
|
private:
|
||||||
Discreet3DS() {
|
Discreet3DS() AI_NO_EXCEPT {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,10 +328,9 @@ struct Face : public FaceWithSmoothingGroup
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure representing a texture */
|
/** Helper structure representing a texture */
|
||||||
struct Texture
|
struct Texture {
|
||||||
{
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
Texture()
|
Texture() AI_NO_EXCEPT
|
||||||
: mOffsetU (0.0)
|
: mOffsetU (0.0)
|
||||||
, mOffsetV (0.0)
|
, mOffsetV (0.0)
|
||||||
, mScaleU (1.0)
|
, mScaleU (1.0)
|
||||||
|
@ -339,8 +338,7 @@ struct Texture
|
||||||
, mRotation (0.0)
|
, mRotation (0.0)
|
||||||
, mMapMode (aiTextureMapMode_Wrap)
|
, mMapMode (aiTextureMapMode_Wrap)
|
||||||
, bPrivate()
|
, bPrivate()
|
||||||
, iUVSrc (0)
|
, iUVSrc (0) {
|
||||||
{
|
|
||||||
mTextureBlend = get_qnan();
|
mTextureBlend = get_qnan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +363,7 @@ struct Texture
|
||||||
int iUVSrc;
|
int iUVSrc;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "./../include/assimp/Compiler/poppack1.h"
|
#include <assimp/Compiler/poppack1.h>
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure representing a 3ds material */
|
/** Helper structure representing a 3ds material */
|
||||||
|
@ -394,7 +392,7 @@ struct Material
|
||||||
|
|
||||||
|
|
||||||
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||||
Material(Material &&other)
|
Material(Material &&other) AI_NO_EXCEPT
|
||||||
: mName(std::move(other.mName))
|
: mName(std::move(other.mName))
|
||||||
, mDiffuse(std::move(other.mDiffuse))
|
, mDiffuse(std::move(other.mDiffuse))
|
||||||
, mSpecularExponent(std::move(other.mSpecularExponent))
|
, mSpecularExponent(std::move(other.mSpecularExponent))
|
||||||
|
@ -418,7 +416,7 @@ struct Material
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Material &operator=(Material &&other) {
|
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
||||||
if (this == &other) {
|
if (this == &other) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -447,7 +445,7 @@ struct Material
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
~Material() {}
|
virtual ~Material() {}
|
||||||
|
|
||||||
|
|
||||||
//! Name of the material
|
//! Name of the material
|
||||||
|
|
|
@ -63,8 +63,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// Header files, stdlib.
|
// Header files, stdlib.
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
|
||||||
/// \class AMFImporter
|
/// \class AMFImporter
|
||||||
/// Class that holding scene graph which include: geometry, metadata, materials etc.
|
/// Class that holding scene graph which include: geometry, metadata, materials etc.
|
||||||
///
|
///
|
||||||
|
@ -99,34 +99,25 @@ namespace Assimp
|
||||||
/// new - <texmap> and children <utex1>, <utex2>, <utex3>, <vtex1>, <vtex2>, <vtex3>
|
/// new - <texmap> and children <utex1>, <utex2>, <utex3>, <vtex1>, <vtex2>, <vtex3>
|
||||||
/// old - <map> and children <u1>, <u2>, <u3>, <v1>, <v2>, <v3>
|
/// old - <map> and children <u1>, <u2>, <u3>, <v1>, <v2>, <v3>
|
||||||
///
|
///
|
||||||
class AMFImporter : public BaseImporter
|
class AMFImporter : public BaseImporter {
|
||||||
{
|
|
||||||
/***********************************************/
|
|
||||||
/******************** Types ********************/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct SPP_Material;// forward declaration
|
struct SPP_Material;// forward declaration
|
||||||
|
|
||||||
/// \struct SPP_Composite
|
/// \struct SPP_Composite
|
||||||
/// Data type for postprocessing step. More suitable container for part of material's composition.
|
/// Data type for post-processing step. More suitable container for part of material's composition.
|
||||||
struct SPP_Composite
|
struct SPP_Composite {
|
||||||
{
|
|
||||||
SPP_Material* Material;///< Pointer to material - part of composition.
|
SPP_Material* Material;///< Pointer to material - part of composition.
|
||||||
std::string Formula;///< Formula for calculating ratio of \ref Material.
|
std::string Formula;///< Formula for calculating ratio of \ref Material.
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \struct SPP_Material
|
/// \struct SPP_Material
|
||||||
/// Data type for postprocessing step. More suitable container for material.
|
/// Data type for post-processing step. More suitable container for material.
|
||||||
struct SPP_Material
|
struct SPP_Material {
|
||||||
{
|
|
||||||
std::string ID;///< Material ID.
|
std::string ID;///< Material ID.
|
||||||
std::list<CAMFImporter_NodeElement_Metadata*> Metadata;///< Metadata of material.
|
std::list<CAMFImporter_NodeElement_Metadata*> Metadata;///< Metadata of material.
|
||||||
CAMFImporter_NodeElement_Color* Color;///< Color of material.
|
CAMFImporter_NodeElement_Color* Color;///< Color of material.
|
||||||
std::list<SPP_Composite> Composition;///< List of child materials if current material is composition of few another.
|
std::list<SPP_Composite> Composition;///< List of child materials if current material is composition of few another.
|
||||||
|
|
||||||
/// \fn aiColor4D GetColor(const float pX, const float pY, const float pZ) const
|
|
||||||
/// Return color calculated for specified coordinate.
|
/// Return color calculated for specified coordinate.
|
||||||
/// \param [in] pX - "x" coordinate.
|
/// \param [in] pX - "x" coordinate.
|
||||||
/// \param [in] pY - "y" coordinate.
|
/// \param [in] pY - "y" coordinate.
|
||||||
|
@ -135,10 +126,8 @@ private:
|
||||||
aiColor4D GetColor(const float pX, const float pY, const float pZ) const;
|
aiColor4D GetColor(const float pX, const float pY, const float pZ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \struct SPP_Texture
|
|
||||||
/// Data type for post-processing step. More suitable container for texture.
|
/// Data type for post-processing step. More suitable container for texture.
|
||||||
struct SPP_Texture
|
struct SPP_Texture {
|
||||||
{
|
|
||||||
std::string ID;
|
std::string ID;
|
||||||
size_t Width, Height, Depth;
|
size_t Width, Height, Depth;
|
||||||
bool Tiled;
|
bool Tiled;
|
||||||
|
@ -146,53 +135,13 @@ private:
|
||||||
uint8_t *Data;
|
uint8_t *Data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \struct SComplexFace
|
|
||||||
/// Data type for post-processing step. Contain face data.
|
/// Data type for post-processing step. Contain face data.
|
||||||
struct SComplexFace
|
struct SComplexFace {
|
||||||
{
|
|
||||||
aiFace Face;///< Face vertices.
|
aiFace Face;///< Face vertices.
|
||||||
const CAMFImporter_NodeElement_Color* Color;///< Face color. Equal to nullptr if color is not set for the face.
|
const CAMFImporter_NodeElement_Color* Color;///< Face color. Equal to nullptr if color is not set for the face.
|
||||||
const CAMFImporter_NodeElement_TexMap* TexMap;///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face.
|
const CAMFImporter_NodeElement_TexMap* TexMap;///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/****************** Constants ******************/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
static const aiImporterDesc Description;
|
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/****************** Variables ******************/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element.
|
|
||||||
std::list<CAMFImporter_NodeElement*> mNodeElement_List;///< All elements of scene graph.
|
|
||||||
irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object
|
|
||||||
std::string mUnit;
|
|
||||||
std::list<SPP_Material> mMaterial_Converted;///< List of converted materials for postprocessing step.
|
|
||||||
std::list<SPP_Texture> mTexture_Converted;///< List of converted textures for postprocessing step.
|
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/****************** Functions ******************/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/// \fn AMFImporter(const AMFImporter& pScene)
|
|
||||||
/// Disabled copy constructor.
|
|
||||||
AMFImporter(const AMFImporter& pScene);
|
|
||||||
|
|
||||||
/// \fn AMFImporter& operator=(const AMFImporter& pScene)
|
|
||||||
/// Disabled assign operator.
|
|
||||||
AMFImporter& operator=(const AMFImporter& pScene);
|
|
||||||
|
|
||||||
/// \fn void Clear()
|
|
||||||
/// Clear all temporary data.
|
/// Clear all temporary data.
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
@ -200,7 +149,6 @@ private:
|
||||||
/************* Functions: find set *************/
|
/************* Functions: find set *************/
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
|
|
||||||
/// \fn bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, aiNode** pNode) const
|
|
||||||
/// Find specified node element in node elements list ( \ref mNodeElement_List).
|
/// Find specified node element in node elements list ( \ref mNodeElement_List).
|
||||||
/// \param [in] pID - ID(name) of requested node element.
|
/// \param [in] pID - ID(name) of requested node element.
|
||||||
/// \param [in] pType - type of node element.
|
/// \param [in] pType - type of node element.
|
||||||
|
@ -208,7 +156,6 @@ private:
|
||||||
/// \return true - if the node element is found, else - false.
|
/// \return true - if the node element is found, else - false.
|
||||||
bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const;
|
bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const;
|
||||||
|
|
||||||
/// \fn bool Find_ConvertedNode(const std::string& pID, std::list<aiNode*>& pNodeList, aiNode** pNode) const
|
|
||||||
/// Find requested aiNode in node list.
|
/// Find requested aiNode in node list.
|
||||||
/// \param [in] pID - ID(name) of requested node.
|
/// \param [in] pID - ID(name) of requested node.
|
||||||
/// \param [in] pNodeList - list of nodes where to find the node.
|
/// \param [in] pNodeList - list of nodes where to find the node.
|
||||||
|
@ -216,14 +163,12 @@ private:
|
||||||
/// \return true - if the node is found, else - false.
|
/// \return true - if the node is found, else - false.
|
||||||
bool Find_ConvertedNode(const std::string& pID, std::list<aiNode*>& pNodeList, aiNode** pNode) const;
|
bool Find_ConvertedNode(const std::string& pID, std::list<aiNode*>& pNodeList, aiNode** pNode) const;
|
||||||
|
|
||||||
/// \fn bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const
|
|
||||||
/// Find material in list for converted materials. Use at postprocessing step.
|
/// Find material in list for converted materials. Use at postprocessing step.
|
||||||
/// \param [in] pID - material ID.
|
/// \param [in] pID - material ID.
|
||||||
/// \param [out] pConvertedMaterial - pointer to found converted material (\ref SPP_Material).
|
/// \param [out] pConvertedMaterial - pointer to found converted material (\ref SPP_Material).
|
||||||
/// \return true - if the material is found, else - false.
|
/// \return true - if the material is found, else - false.
|
||||||
bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const;
|
bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const;
|
||||||
|
|
||||||
/// \fn bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A, uint32_t* pConvertedTextureIndex = nullptr) const
|
|
||||||
/// Find texture in list of converted textures. Use at postprocessing step,
|
/// Find texture in list of converted textures. Use at postprocessing step,
|
||||||
/// \param [in] pID_R - ID of source "red" texture.
|
/// \param [in] pID_R - ID of source "red" texture.
|
||||||
/// \param [in] pID_G - ID of source "green" texture.
|
/// \param [in] pID_G - ID of source "green" texture.
|
||||||
|
@ -235,11 +180,7 @@ private:
|
||||||
bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A,
|
bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A,
|
||||||
uint32_t* pConvertedTextureIndex = nullptr) const;
|
uint32_t* pConvertedTextureIndex = nullptr) const;
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/********* Functions: postprocess set **********/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
/// \fn void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray, std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const
|
|
||||||
/// Get data stored in <vertices> and place it to arrays.
|
/// Get data stored in <vertices> and place it to arrays.
|
||||||
/// \param [in] pNodeElement - reference to node element which kept <object> data.
|
/// \param [in] pNodeElement - reference to node element which kept <object> data.
|
||||||
/// \param [in] pVertexCoordinateArray - reference to vertices coordinates kept in <vertices>.
|
/// \param [in] pVertexCoordinateArray - reference to vertices coordinates kept in <vertices>.
|
||||||
|
@ -248,7 +189,6 @@ private:
|
||||||
void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray,
|
void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray,
|
||||||
std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const;
|
std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const;
|
||||||
|
|
||||||
/// \fn size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A)
|
|
||||||
/// Return converted texture ID which related to specified source textures ID's. If converted texture does not exist then it will be created and ID on new
|
/// Return converted texture ID which related to specified source textures ID's. If converted texture does not exist then it will be created and ID on new
|
||||||
/// converted texture will be returned. Conversion: set of textures from \ref CAMFImporter_NodeElement_Texture to one \ref SPP_Texture and place it
|
/// converted texture will be returned. Conversion: set of textures from \ref CAMFImporter_NodeElement_Texture to one \ref SPP_Texture and place it
|
||||||
/// to converted textures list.
|
/// to converted textures list.
|
||||||
|
@ -260,27 +200,23 @@ private:
|
||||||
/// \return index of the texture in array of the converted textures.
|
/// \return index of the texture in array of the converted textures.
|
||||||
size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A);
|
size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A);
|
||||||
|
|
||||||
/// \fn void PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> > pOutputList_Separated)
|
|
||||||
/// Separate input list by texture IDs. This step is needed because aiMesh can contain mesh which is use only one texture (or set: diffuse, bump etc).
|
/// Separate input list by texture IDs. This step is needed because aiMesh can contain mesh which is use only one texture (or set: diffuse, bump etc).
|
||||||
/// \param [in] pInputList - input list with faces. Some of them can contain color or texture mapping, or both of them, or nothing. Will be cleared after
|
/// \param [in] pInputList - input list with faces. Some of them can contain color or texture mapping, or both of them, or nothing. Will be cleared after
|
||||||
/// processing.
|
/// processing.
|
||||||
/// \param [out] pOutputList_Separated - output list of the faces lists. Separated faces list by used texture IDs. Will be cleared before processing.
|
/// \param [out] pOutputList_Separated - output list of the faces lists. Separated faces list by used texture IDs. Will be cleared before processing.
|
||||||
void PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> >& pOutputList_Separated);
|
void PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> >& pOutputList_Separated);
|
||||||
|
|
||||||
/// \fn void Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& pMetadataList, aiNode& pSceneNode) const
|
|
||||||
/// Check if child elements of node element is metadata and add it to scene node.
|
/// Check if child elements of node element is metadata and add it to scene node.
|
||||||
/// \param [in] pMetadataList - reference to list with collected metadata.
|
/// \param [in] pMetadataList - reference to list with collected metadata.
|
||||||
/// \param [out] pSceneNode - scene node in which metadata will be added.
|
/// \param [out] pSceneNode - scene node in which metadata will be added.
|
||||||
void Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& pMetadataList, aiNode& pSceneNode) const;
|
void Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& pMetadataList, aiNode& pSceneNode) const;
|
||||||
|
|
||||||
/// \fn void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list<aiMesh*>& pMeshList, aiNode** pSceneNode)
|
|
||||||
/// To create aiMesh and aiNode for it from <object>.
|
/// To create aiMesh and aiNode for it from <object>.
|
||||||
/// \param [in] pNodeElement - reference to node element which kept <object> data.
|
/// \param [in] pNodeElement - reference to node element which kept <object> data.
|
||||||
/// \param [out] pMeshList - reference to a list with all aiMesh of the scene.
|
/// \param [out] pMeshList - reference to a list with all aiMesh of the scene.
|
||||||
/// \param [out] pSceneNode - pointer to place where new aiNode will be created.
|
/// \param [out] pSceneNode - pointer to place where new aiNode will be created.
|
||||||
void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list<aiMesh*>& pMeshList, aiNode** pSceneNode);
|
void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list<aiMesh*>& pMeshList, aiNode** pSceneNode);
|
||||||
|
|
||||||
/// \fn void Postprocess_BuildMeshSet(const CAMFImporter_NodeElement_Mesh& pNodeElement, const std::vector<aiVector3D>& pVertexCoordinateArray, const std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor, std::list<aiMesh*>& pMeshList, aiNode& pSceneNode)
|
|
||||||
/// Create mesh for every <volume> in <mesh>.
|
/// Create mesh for every <volume> in <mesh>.
|
||||||
/// \param [in] pNodeElement - reference to node element which kept <mesh> data.
|
/// \param [in] pNodeElement - reference to node element which kept <mesh> data.
|
||||||
/// \param [in] pVertexCoordinateArray - reference to vertices coordinates for all <volume>'s.
|
/// \param [in] pVertexCoordinateArray - reference to vertices coordinates for all <volume>'s.
|
||||||
|
@ -294,27 +230,20 @@ private:
|
||||||
const std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor,
|
const std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor,
|
||||||
std::list<aiMesh*>& pMeshList, aiNode& pSceneNode);
|
std::list<aiMesh*>& pMeshList, aiNode& pSceneNode);
|
||||||
|
|
||||||
/// \fn void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial)
|
|
||||||
/// Convert material from \ref CAMFImporter_NodeElement_Material to \ref SPP_Material.
|
/// Convert material from \ref CAMFImporter_NodeElement_Material to \ref SPP_Material.
|
||||||
/// \param [in] pMaterial - source CAMFImporter_NodeElement_Material.
|
/// \param [in] pMaterial - source CAMFImporter_NodeElement_Material.
|
||||||
void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial);
|
void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial);
|
||||||
|
|
||||||
/// \fn void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list<aiNode*>& pNodeList) const
|
|
||||||
/// Create and add to aiNode's list new part of scene graph defined by <constellation>.
|
/// Create and add to aiNode's list new part of scene graph defined by <constellation>.
|
||||||
/// \param [in] pConstellation - reference to <constellation> node.
|
/// \param [in] pConstellation - reference to <constellation> node.
|
||||||
/// \param [out] pNodeList - reference to aiNode's list.
|
/// \param [out] pNodeList - reference to aiNode's list.
|
||||||
void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list<aiNode*>& pNodeList) const;
|
void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list<aiNode*>& pNodeList) const;
|
||||||
|
|
||||||
/// \fn void Postprocess_BuildScene()
|
|
||||||
/// Build Assimp scene graph in aiScene from collected data.
|
/// Build Assimp scene graph in aiScene from collected data.
|
||||||
/// \param [out] pScene - pointer to aiScene where tree will be built.
|
/// \param [out] pScene - pointer to aiScene where tree will be built.
|
||||||
void Postprocess_BuildScene(aiScene* pScene);
|
void Postprocess_BuildScene(aiScene* pScene);
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/************* Functions: throw set ************/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
/// \fn void Throw_CloseNotFound(const std::string& pNode)
|
|
||||||
/// Call that function when close tag of node not found and exception must be raised.
|
/// Call that function when close tag of node not found and exception must be raised.
|
||||||
/// E.g.:
|
/// E.g.:
|
||||||
/// <amf>
|
/// <amf>
|
||||||
|
@ -324,19 +253,16 @@ private:
|
||||||
/// \param [in] pNode - node name in which exception happened.
|
/// \param [in] pNode - node name in which exception happened.
|
||||||
void Throw_CloseNotFound(const std::string& pNode);
|
void Throw_CloseNotFound(const std::string& pNode);
|
||||||
|
|
||||||
/// \fn void Throw_IncorrectAttr(const std::string& pAttrName)
|
|
||||||
/// Call that function when attribute name is incorrect and exception must be raised.
|
/// Call that function when attribute name is incorrect and exception must be raised.
|
||||||
/// \param [in] pAttrName - attribute name.
|
/// \param [in] pAttrName - attribute name.
|
||||||
/// \throw DeadlyImportError.
|
/// \throw DeadlyImportError.
|
||||||
void Throw_IncorrectAttr(const std::string& pAttrName);
|
void Throw_IncorrectAttr(const std::string& pAttrName);
|
||||||
|
|
||||||
/// \fn void Throw_IncorrectAttrValue(const std::string& pAttrName)
|
|
||||||
/// Call that function when attribute value is incorrect and exception must be raised.
|
/// Call that function when attribute value is incorrect and exception must be raised.
|
||||||
/// \param [in] pAttrName - attribute name.
|
/// \param [in] pAttrName - attribute name.
|
||||||
/// \throw DeadlyImportError.
|
/// \throw DeadlyImportError.
|
||||||
void Throw_IncorrectAttrValue(const std::string& pAttrName);
|
void Throw_IncorrectAttrValue(const std::string& pAttrName);
|
||||||
|
|
||||||
/// \fn void Throw_MoreThanOnceDefined(const std::string& pNode, const std::string& pDescription)
|
|
||||||
/// Call that function when some type of nodes are defined twice or more when must be used only once and exception must be raised.
|
/// Call that function when some type of nodes are defined twice or more when must be used only once and exception must be raised.
|
||||||
/// E.g.:
|
/// E.g.:
|
||||||
/// <object>
|
/// <object>
|
||||||
|
@ -348,204 +274,158 @@ private:
|
||||||
/// \param [in] pDescription - message about error. E.g. what the node defined while exception raised.
|
/// \param [in] pDescription - message about error. E.g. what the node defined while exception raised.
|
||||||
void Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription);
|
void Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription);
|
||||||
|
|
||||||
/// \fn void Throw_ID_NotFound(const std::string& pID) const
|
|
||||||
/// Call that function when referenced element ID are not found in graph and exception must be raised.
|
/// Call that function when referenced element ID are not found in graph and exception must be raised.
|
||||||
/// \param [in] pID - ID of of element which not found.
|
/// \param [in] pID - ID of of element which not found.
|
||||||
/// \throw DeadlyImportError.
|
/// \throw DeadlyImportError.
|
||||||
void Throw_ID_NotFound(const std::string& pID) const;
|
void Throw_ID_NotFound(const std::string& pID) const;
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/************** Functions: LOG set *************/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/************** Functions: XML set *************/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
/// \fn void XML_CheckNode_MustHaveChildren()
|
|
||||||
/// Check if current node have children: <node>...</node>. If not then exception will throwed.
|
/// Check if current node have children: <node>...</node>. If not then exception will throwed.
|
||||||
void XML_CheckNode_MustHaveChildren();
|
void XML_CheckNode_MustHaveChildren();
|
||||||
|
|
||||||
/// \fn bool XML_CheckNode_NameEqual(const std::string& pNodeName)
|
|
||||||
/// Check if current node name is equal to pNodeName.
|
/// Check if current node name is equal to pNodeName.
|
||||||
/// \param [in] pNodeName - name for checking.
|
/// \param [in] pNodeName - name for checking.
|
||||||
/// return true if current node name is equal to pNodeName, else - false.
|
/// return true if current node name is equal to pNodeName, else - false.
|
||||||
bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; }
|
bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; }
|
||||||
|
|
||||||
/// \fn void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName)
|
|
||||||
/// Skip unsupported node and report about that. Depend on node name can be skipped begin tag of node all whole node.
|
/// Skip unsupported node and report about that. Depend on node name can be skipped begin tag of node all whole node.
|
||||||
/// \param [in] pParentNodeName - parent node name. Used for reporting.
|
/// \param [in] pParentNodeName - parent node name. Used for reporting.
|
||||||
void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName);
|
void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName);
|
||||||
|
|
||||||
/// \fn bool XML_SearchNode(const std::string& pNodeName)
|
|
||||||
/// Search for specified node in file. XML file read pointer(mReader) will point to found node or file end after search is end.
|
/// Search for specified node in file. XML file read pointer(mReader) will point to found node or file end after search is end.
|
||||||
/// \param [in] pNodeName - requested node name.
|
/// \param [in] pNodeName - requested node name.
|
||||||
/// return true - if node is found, else - false.
|
/// return true - if node is found, else - false.
|
||||||
bool XML_SearchNode(const std::string& pNodeName);
|
bool XML_SearchNode(const std::string& pNodeName);
|
||||||
|
|
||||||
/// \fn bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx)
|
|
||||||
/// Read attribute value.
|
/// Read attribute value.
|
||||||
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
||||||
/// \return read data.
|
/// \return read data.
|
||||||
bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx);
|
bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx);
|
||||||
|
|
||||||
/// \fn float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx)
|
|
||||||
/// Read attribute value.
|
/// Read attribute value.
|
||||||
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
||||||
/// \return read data.
|
/// \return read data.
|
||||||
float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx);
|
float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx);
|
||||||
|
|
||||||
/// \fn uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx)
|
|
||||||
/// Read attribute value.
|
/// Read attribute value.
|
||||||
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
||||||
/// \return read data.
|
/// \return read data.
|
||||||
uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx);
|
uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx);
|
||||||
|
|
||||||
/// \fn float XML_ReadNode_GetVal_AsFloat()
|
|
||||||
/// Read node value.
|
/// Read node value.
|
||||||
/// \return read data.
|
/// \return read data.
|
||||||
float XML_ReadNode_GetVal_AsFloat();
|
float XML_ReadNode_GetVal_AsFloat();
|
||||||
|
|
||||||
/// \fn uint32_t XML_ReadNode_GetVal_AsU32()
|
|
||||||
/// Read node value.
|
/// Read node value.
|
||||||
/// \return read data.
|
/// \return read data.
|
||||||
uint32_t XML_ReadNode_GetVal_AsU32();
|
uint32_t XML_ReadNode_GetVal_AsU32();
|
||||||
|
|
||||||
/// \fn void XML_ReadNode_GetVal_AsString(std::string& pValue)
|
|
||||||
/// Read node value.
|
/// Read node value.
|
||||||
/// \return read data.
|
/// \return read data.
|
||||||
void XML_ReadNode_GetVal_AsString(std::string& pValue);
|
void XML_ReadNode_GetVal_AsString(std::string& pValue);
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/******** Functions: parse set private *********/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
/// \fn void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode)
|
|
||||||
/// Make pNode as current and enter deeper for parsing child nodes. At end \ref ParseHelper_Node_Exit must be called.
|
/// Make pNode as current and enter deeper for parsing child nodes. At end \ref ParseHelper_Node_Exit must be called.
|
||||||
/// \param [in] pNode - new current node.
|
/// \param [in] pNode - new current node.
|
||||||
void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode);
|
void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode);
|
||||||
|
|
||||||
/// \fn void ParseHelper_Group_End()
|
|
||||||
/// This function must be called when exiting from grouping node. \ref ParseHelper_Group_Begin.
|
/// This function must be called when exiting from grouping node. \ref ParseHelper_Group_Begin.
|
||||||
void ParseHelper_Node_Exit();
|
void ParseHelper_Node_Exit();
|
||||||
|
|
||||||
/// \fn void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString)
|
|
||||||
/// Attribute values of floating point types can take form ".x"(without leading zero). irrXMLReader can not read this form of values and it
|
/// Attribute values of floating point types can take form ".x"(without leading zero). irrXMLReader can not read this form of values and it
|
||||||
/// must be converted to right form - "0.xxx".
|
/// must be converted to right form - "0.xxx".
|
||||||
/// \param [in] pInStr - pointer to input string which can contain incorrect form of values.
|
/// \param [in] pInStr - pointer to input string which can contain incorrect form of values.
|
||||||
/// \param [out[ pOutString - output string with right form of values.
|
/// \param [out[ pOutString - output string with right form of values.
|
||||||
void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString);
|
void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString);
|
||||||
|
|
||||||
/// \fn void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const
|
|
||||||
/// Decode Base64-encoded data.
|
/// Decode Base64-encoded data.
|
||||||
/// \param [in] pInputBase64 - reference to input Base64-encoded string.
|
/// \param [in] pInputBase64 - reference to input Base64-encoded string.
|
||||||
/// \param [out] pOutputData - reference to output array for decoded data.
|
/// \param [out] pOutputData - reference to output array for decoded data.
|
||||||
void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const;
|
void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const;
|
||||||
|
|
||||||
/// \fn void ParseNode_Root()
|
|
||||||
/// Parse <AMF> node of the file.
|
/// Parse <AMF> node of the file.
|
||||||
void ParseNode_Root();
|
void ParseNode_Root();
|
||||||
|
|
||||||
/******** Functions: top nodes *********/
|
|
||||||
|
|
||||||
/// \fn void ParseNode_Constellation()
|
|
||||||
/// Parse <constellation> node of the file.
|
/// Parse <constellation> node of the file.
|
||||||
void ParseNode_Constellation();
|
void ParseNode_Constellation();
|
||||||
|
|
||||||
/// \fn void ParseNode_Constellation()
|
|
||||||
/// Parse <instance> node of the file.
|
/// Parse <instance> node of the file.
|
||||||
void ParseNode_Instance();
|
void ParseNode_Instance();
|
||||||
|
|
||||||
/// \fn void ParseNode_Material()
|
|
||||||
/// Parse <material> node of the file.
|
/// Parse <material> node of the file.
|
||||||
void ParseNode_Material();
|
void ParseNode_Material();
|
||||||
|
|
||||||
/// \fn void ParseNode_Metadata()
|
|
||||||
/// Parse <metadata> node.
|
/// Parse <metadata> node.
|
||||||
void ParseNode_Metadata();
|
void ParseNode_Metadata();
|
||||||
|
|
||||||
/// \fn void ParseNode_Object()
|
|
||||||
/// Parse <object> node of the file.
|
/// Parse <object> node of the file.
|
||||||
void ParseNode_Object();
|
void ParseNode_Object();
|
||||||
|
|
||||||
/// \fn void ParseNode_Texture()
|
|
||||||
/// Parse <texture> node of the file.
|
/// Parse <texture> node of the file.
|
||||||
void ParseNode_Texture();
|
void ParseNode_Texture();
|
||||||
|
|
||||||
/******** Functions: geometry nodes *********/
|
|
||||||
|
|
||||||
/// \fn void ParseNode_Coordinates()
|
|
||||||
/// Parse <coordinates> node of the file.
|
/// Parse <coordinates> node of the file.
|
||||||
void ParseNode_Coordinates();
|
void ParseNode_Coordinates();
|
||||||
|
|
||||||
/// \fn void ParseNode_Edge()
|
|
||||||
/// Parse <edge> node of the file.
|
/// Parse <edge> node of the file.
|
||||||
void ParseNode_Edge();
|
void ParseNode_Edge();
|
||||||
|
|
||||||
/// \fn void ParseNode_Mesh()
|
|
||||||
/// Parse <mesh> node of the file.
|
/// Parse <mesh> node of the file.
|
||||||
void ParseNode_Mesh();
|
void ParseNode_Mesh();
|
||||||
|
|
||||||
/// \fn void ParseNode_Triangle()
|
|
||||||
/// Parse <triangle> node of the file.
|
/// Parse <triangle> node of the file.
|
||||||
void ParseNode_Triangle();
|
void ParseNode_Triangle();
|
||||||
|
|
||||||
/// \fn void ParseNode_Vertex()
|
|
||||||
/// Parse <vertex> node of the file.
|
/// Parse <vertex> node of the file.
|
||||||
void ParseNode_Vertex();
|
void ParseNode_Vertex();
|
||||||
|
|
||||||
/// \fn void ParseNode_Vertices()
|
|
||||||
/// Parse <vertices> node of the file.
|
/// Parse <vertices> node of the file.
|
||||||
void ParseNode_Vertices();
|
void ParseNode_Vertices();
|
||||||
|
|
||||||
/// \fn void ParseNode_Volume()
|
|
||||||
/// Parse <volume> node of the file.
|
/// Parse <volume> node of the file.
|
||||||
void ParseNode_Volume();
|
void ParseNode_Volume();
|
||||||
|
|
||||||
/******** Functions: material nodes *********/
|
|
||||||
|
|
||||||
/// \fn void ParseNode_Color()
|
|
||||||
/// Parse <color> node of the file.
|
/// Parse <color> node of the file.
|
||||||
void ParseNode_Color();
|
void ParseNode_Color();
|
||||||
|
|
||||||
/// \fn void ParseNode_TexMap(const bool pUseOldName = false)
|
|
||||||
/// Parse <texmap> of <map> node of the file.
|
/// Parse <texmap> of <map> node of the file.
|
||||||
/// \param [in] pUseOldName - if true then use old name of node(and children) - <map>, instead of new name - <texmap>.
|
/// \param [in] pUseOldName - if true then use old name of node(and children) - <map>, instead of new name - <texmap>.
|
||||||
void ParseNode_TexMap(const bool pUseOldName = false);
|
void ParseNode_TexMap(const bool pUseOldName = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// \fn AMFImporter()
|
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
AMFImporter()
|
AMFImporter() AI_NO_EXCEPT
|
||||||
: mNodeElement_Cur(nullptr), mReader(nullptr)
|
: mNodeElement_Cur(nullptr)
|
||||||
{}
|
, mReader(nullptr) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
/// \fn ~AMFImporter()
|
|
||||||
/// Default destructor.
|
/// Default destructor.
|
||||||
~AMFImporter();
|
~AMFImporter();
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/******** Functions: parse set, public *********/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
/// \fn void ParseFile(const std::string& pFile, IOSystem* pIOHandler)
|
|
||||||
/// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph.
|
/// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph.
|
||||||
/// Also exception can be throwed if trouble will found.
|
/// Also exception can be thrown if trouble will found.
|
||||||
/// \param [in] pFile - name of file to be parsed.
|
/// \param [in] pFile - name of file to be parsed.
|
||||||
/// \param [in] pIOHandler - pointer to IO helper object.
|
/// \param [in] pIOHandler - pointer to IO helper object.
|
||||||
void ParseFile(const std::string& pFile, IOSystem* pIOHandler);
|
void ParseFile(const std::string& pFile, IOSystem* pIOHandler);
|
||||||
|
|
||||||
/***********************************************/
|
|
||||||
/********* Functions: BaseImporter set *********/
|
|
||||||
/***********************************************/
|
|
||||||
|
|
||||||
bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const;
|
bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const;
|
||||||
void GetExtensionList(std::set<std::string>& pExtensionList);
|
void GetExtensionList(std::set<std::string>& pExtensionList);
|
||||||
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
||||||
const aiImporterDesc* GetInfo ()const;
|
const aiImporterDesc* GetInfo ()const;
|
||||||
|
|
||||||
};// class AMFImporter
|
AMFImporter(const AMFImporter& pScene) = delete;
|
||||||
|
AMFImporter& operator=(const AMFImporter& pScene) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const aiImporterDesc Description;
|
||||||
|
|
||||||
|
CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element.
|
||||||
|
std::list<CAMFImporter_NodeElement*> mNodeElement_List;///< All elements of scene graph.
|
||||||
|
irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object
|
||||||
|
std::string mUnit;
|
||||||
|
std::list<SPP_Material> mMaterial_Converted;///< List of converted materials for postprocessing step.
|
||||||
|
std::list<SPP_Texture> mTexture_Converted;///< List of converted textures for postprocessing step.
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}// namespace Assimp
|
}// namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,7 @@ namespace Assimp
|
||||||
// Multi elements - No.
|
// Multi elements - No.
|
||||||
// Red, Greed, Blue and Alpha (transparency) component of a color in sRGB space, values ranging from 0 to 1. The
|
// Red, Greed, Blue and Alpha (transparency) component of a color in sRGB space, values ranging from 0 to 1. The
|
||||||
// values can be specified as constants, or as a formula depending on the coordinates.
|
// values can be specified as constants, or as a formula depending on the coordinates.
|
||||||
void AMFImporter::ParseNode_Color()
|
void AMFImporter::ParseNode_Color() {
|
||||||
{
|
|
||||||
std::string profile;
|
std::string profile;
|
||||||
CAMFImporter_NodeElement* ne;
|
CAMFImporter_NodeElement* ne;
|
||||||
|
|
||||||
|
@ -98,15 +97,19 @@ CAMFImporter_NodeElement* ne;
|
||||||
MACRO_NODECHECK_LOOPEND("color");
|
MACRO_NODECHECK_LOOPEND("color");
|
||||||
ParseHelper_Node_Exit();
|
ParseHelper_Node_Exit();
|
||||||
// check that all components was defined
|
// check that all components was defined
|
||||||
if(!(read_flag[0] && read_flag[1] && read_flag[2])) throw DeadlyImportError("Not all color components are defined.");
|
if (!(read_flag[0] && read_flag[1] && read_flag[2])) {
|
||||||
// check if <a> is absent. Then manually add "a == 1".
|
throw DeadlyImportError("Not all color components are defined.");
|
||||||
if(!read_flag[3]) als.Color.a = 1;
|
}
|
||||||
|
|
||||||
}// if(!mReader->isEmptyElement())
|
// check if <a> is absent. Then manually add "a == 1".
|
||||||
|
if (!read_flag[3]) {
|
||||||
|
als.Color.a = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
|
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
|
||||||
}// if(!mReader->isEmptyElement()) else
|
}
|
||||||
|
|
||||||
als.Composed = false;
|
als.Composed = false;
|
||||||
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
|
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
|
||||||
|
@ -119,8 +122,7 @@ CAMFImporter_NodeElement* ne;
|
||||||
// An available material.
|
// An available material.
|
||||||
// Multi elements - Yes.
|
// Multi elements - Yes.
|
||||||
// Parent element - <amf>.
|
// Parent element - <amf>.
|
||||||
void AMFImporter::ParseNode_Material()
|
void AMFImporter::ParseNode_Material() {
|
||||||
{
|
|
||||||
std::string id;
|
std::string id;
|
||||||
CAMFImporter_NodeElement* ne;
|
CAMFImporter_NodeElement* ne;
|
||||||
|
|
||||||
|
@ -131,8 +133,10 @@ CAMFImporter_NodeElement* ne;
|
||||||
|
|
||||||
// create new object.
|
// create new object.
|
||||||
ne = new CAMFImporter_NodeElement_Material(mNodeElement_Cur);
|
ne = new CAMFImporter_NodeElement_Material(mNodeElement_Cur);
|
||||||
|
|
||||||
// and assign read data
|
// and assign read data
|
||||||
((CAMFImporter_NodeElement_Material*)ne)->ID = id;
|
((CAMFImporter_NodeElement_Material*)ne)->ID = id;
|
||||||
|
|
||||||
// Check for child nodes
|
// Check for child nodes
|
||||||
if(!mReader->isEmptyElement())
|
if(!mReader->isEmptyElement())
|
||||||
{
|
{
|
||||||
|
@ -154,11 +158,11 @@ CAMFImporter_NodeElement* ne;
|
||||||
if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; }
|
if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; }
|
||||||
MACRO_NODECHECK_LOOPEND("material");
|
MACRO_NODECHECK_LOOPEND("material");
|
||||||
ParseHelper_Node_Exit();
|
ParseHelper_Node_Exit();
|
||||||
}// if(!mReader->isEmptyElement())
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
|
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
|
||||||
}// if(!mReader->isEmptyElement()) else
|
}
|
||||||
|
|
||||||
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
|
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
|
||||||
}
|
}
|
||||||
|
@ -188,7 +192,6 @@ uint32_t depth = 1;
|
||||||
std::string type;
|
std::string type;
|
||||||
bool tiled = false;
|
bool tiled = false;
|
||||||
std::string enc64_data;
|
std::string enc64_data;
|
||||||
CAMFImporter_NodeElement* ne;
|
|
||||||
|
|
||||||
// Read attributes for node <color>.
|
// Read attributes for node <color>.
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
|
@ -201,20 +204,34 @@ CAMFImporter_NodeElement* ne;
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
// create new texture object.
|
// create new texture object.
|
||||||
ne = new CAMFImporter_NodeElement_Texture(mNodeElement_Cur);
|
CAMFImporter_NodeElement *ne = new CAMFImporter_NodeElement_Texture(mNodeElement_Cur);
|
||||||
|
|
||||||
CAMFImporter_NodeElement_Texture& als = *((CAMFImporter_NodeElement_Texture*)ne);// alias for convenience
|
CAMFImporter_NodeElement_Texture& als = *((CAMFImporter_NodeElement_Texture*)ne);// alias for convenience
|
||||||
|
|
||||||
// Check for child nodes
|
// Check for child nodes
|
||||||
if(!mReader->isEmptyElement()) XML_ReadNode_GetVal_AsString(enc64_data);
|
if (!mReader->isEmptyElement()) {
|
||||||
|
XML_ReadNode_GetVal_AsString(enc64_data);
|
||||||
|
}
|
||||||
|
|
||||||
// check that all components was defined
|
// check that all components was defined
|
||||||
if(id.empty()) throw DeadlyImportError("ID for texture must be defined.");
|
if (id.empty()) {
|
||||||
if(width < 1) Throw_IncorrectAttrValue("width");
|
throw DeadlyImportError("ID for texture must be defined.");
|
||||||
if(height < 1) Throw_IncorrectAttrValue("height");
|
}
|
||||||
if(depth < 1) Throw_IncorrectAttrValue("depth");
|
if (width < 1) {
|
||||||
if(type != "grayscale") Throw_IncorrectAttrValue("type");
|
Throw_IncorrectAttrValue("width");
|
||||||
if(enc64_data.empty()) throw DeadlyImportError("Texture data not defined.");
|
}
|
||||||
|
if (height < 1) {
|
||||||
|
Throw_IncorrectAttrValue("height");
|
||||||
|
}
|
||||||
|
if (depth < 1) {
|
||||||
|
Throw_IncorrectAttrValue("depth");
|
||||||
|
}
|
||||||
|
if (type != "grayscale") {
|
||||||
|
Throw_IncorrectAttrValue("type");
|
||||||
|
}
|
||||||
|
if (enc64_data.empty()) {
|
||||||
|
throw DeadlyImportError("Texture data not defined.");
|
||||||
|
}
|
||||||
// copy data
|
// copy data
|
||||||
als.ID = id;
|
als.ID = id;
|
||||||
als.Width = width;
|
als.Width = width;
|
||||||
|
@ -222,8 +239,11 @@ CAMFImporter_NodeElement* ne;
|
||||||
als.Depth = depth;
|
als.Depth = depth;
|
||||||
als.Tiled = tiled;
|
als.Tiled = tiled;
|
||||||
ParseHelper_Decode_Base64(enc64_data, als.Data);
|
ParseHelper_Decode_Base64(enc64_data, als.Data);
|
||||||
|
|
||||||
// check data size
|
// check data size
|
||||||
if((width * height * depth) != als.Data.size()) throw DeadlyImportError("Texture has incorrect data size.");
|
if ((width * height * depth) != als.Data.size()) {
|
||||||
|
throw DeadlyImportError("Texture has incorrect data size.");
|
||||||
|
}
|
||||||
|
|
||||||
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
|
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
|
||||||
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
|
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
|
||||||
|
@ -243,10 +263,8 @@ CAMFImporter_NodeElement* ne;
|
||||||
// <utex1>, <utex2>, <utex3>, <vtex1>, <vtex2>, <vtex3>. Old name: <u1>, <u2>, <u3>, <v1>, <v2>, <v3>.
|
// <utex1>, <utex2>, <utex3>, <vtex1>, <vtex2>, <vtex3>. Old name: <u1>, <u2>, <u3>, <v1>, <v2>, <v3>.
|
||||||
// Multi elements - No.
|
// Multi elements - No.
|
||||||
// Texture coordinates for every vertex of triangle.
|
// Texture coordinates for every vertex of triangle.
|
||||||
void AMFImporter::ParseNode_TexMap(const bool pUseOldName)
|
void AMFImporter::ParseNode_TexMap(const bool pUseOldName) {
|
||||||
{
|
|
||||||
std::string rtexid, gtexid, btexid, atexid;
|
std::string rtexid, gtexid, btexid, atexid;
|
||||||
CAMFImporter_NodeElement* ne;
|
|
||||||
|
|
||||||
// Read attributes for node <color>.
|
// Read attributes for node <color>.
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
|
@ -257,7 +275,7 @@ CAMFImporter_NodeElement* ne;
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
// create new texture coordinates object.
|
// create new texture coordinates object.
|
||||||
ne = new CAMFImporter_NodeElement_TexMap(mNodeElement_Cur);
|
CAMFImporter_NodeElement *ne = new CAMFImporter_NodeElement_TexMap(mNodeElement_Cur);
|
||||||
|
|
||||||
CAMFImporter_NodeElement_TexMap& als = *((CAMFImporter_NodeElement_TexMap*)ne);// alias for convenience
|
CAMFImporter_NodeElement_TexMap& als = *((CAMFImporter_NodeElement_TexMap*)ne);// alias for convenience
|
||||||
// check data
|
// check data
|
||||||
|
|
|
@ -62,7 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/// \class CAMFImporter_NodeElement
|
/// \class CAMFImporter_NodeElement
|
||||||
/// Base class for elements of nodes.
|
/// Base class for elements of nodes.
|
||||||
class CAMFImporter_NodeElement {
|
class CAMFImporter_NodeElement {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Define what data type contain node element.
|
/// Define what data type contain node element.
|
||||||
enum EType {
|
enum EType {
|
||||||
|
@ -96,15 +95,11 @@ public: /// Destructor, virtual..
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
/// Disabled copy constructor and co.
|
||||||
/// Disabled copy constructor.
|
CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement) = delete;
|
||||||
CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement);
|
CAMFImporter_NodeElement(CAMFImporter_NodeElement&&) = delete;
|
||||||
|
CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement) = delete;
|
||||||
/// Disabled assign operator.
|
CAMFImporter_NodeElement() = delete;
|
||||||
CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement);
|
|
||||||
|
|
||||||
/// Disabled default constructor.
|
|
||||||
CAMFImporter_NodeElement();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// In constructor inheritor must set element type.
|
/// In constructor inheritor must set element type.
|
||||||
|
@ -121,9 +116,7 @@ protected:
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Constellation
|
/// \struct CAMFImporter_NodeElement_Constellation
|
||||||
/// A collection of objects or constellations with specific relative locations.
|
/// A collection of objects or constellations with specific relative locations.
|
||||||
struct CAMFImporter_NodeElement_Constellation : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Constellation : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/// \fn CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent)
|
||||||
|
@ -134,9 +127,7 @@ struct CAMFImporter_NodeElement_Constellation : public CAMFImporter_NodeElement
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Instance
|
/// \struct CAMFImporter_NodeElement_Instance
|
||||||
/// Part of constellation.
|
/// Part of constellation.
|
||||||
struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/****************** Variables ******************/
|
|
||||||
|
|
||||||
std::string ObjectID;///< ID of object for instantiation.
|
std::string ObjectID;///< ID of object for instantiation.
|
||||||
/// \var Delta - The distance of translation in the x, y, or z direction, respectively, in the referenced object's coordinate system, to
|
/// \var Delta - The distance of translation in the x, y, or z direction, respectively, in the referenced object's coordinate system, to
|
||||||
|
@ -147,237 +138,185 @@ struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement
|
||||||
/// instance of the object in the current constellation. Rotations shall be executed in order of x first, then y, then z.
|
/// instance of the object in the current constellation. Rotations shall be executed in order of x first, then y, then z.
|
||||||
aiVector3D Rotation;
|
aiVector3D Rotation;
|
||||||
|
|
||||||
/****************** Functions ******************/
|
|
||||||
|
|
||||||
/// \fn CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Instance, pParent)
|
: CAMFImporter_NodeElement(ENET_Instance, pParent)
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
};// struct CAMFImporter_NodeElement_Instance
|
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Metadata
|
/// \struct CAMFImporter_NodeElement_Metadata
|
||||||
/// Structure that define metadata node.
|
/// Structure that define metadata node.
|
||||||
struct CAMFImporter_NodeElement_Metadata : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Metadata : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/****************** Variables ******************/
|
|
||||||
|
|
||||||
std::string Type;///< Type of "Value".
|
std::string Type;///< Type of "Value".
|
||||||
std::string Value;///< Value.
|
std::string Value;///< Value.
|
||||||
|
|
||||||
/****************** Functions ******************/
|
|
||||||
|
|
||||||
/// \fn CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Metadata, pParent)
|
: CAMFImporter_NodeElement(ENET_Metadata, pParent)
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
};// struct CAMFImporter_NodeElement_Metadata
|
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Root
|
/// \struct CAMFImporter_NodeElement_Root
|
||||||
/// Structure that define root node.
|
/// Structure that define root node.
|
||||||
struct CAMFImporter_NodeElement_Root : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Root : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/****************** Variables ******************/
|
|
||||||
|
|
||||||
std::string Unit;///< The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron".
|
std::string Unit;///< The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron".
|
||||||
std::string Version;///< Version of format.
|
std::string Version;///< Version of format.
|
||||||
|
|
||||||
/****************** Functions ******************/
|
|
||||||
|
|
||||||
/// \fn CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Root, pParent)
|
: CAMFImporter_NodeElement(ENET_Root, pParent)
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
};// struct CAMFImporter_NodeElement_Root
|
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Color
|
/// \struct CAMFImporter_NodeElement_Color
|
||||||
/// Structure that define object node.
|
/// Structure that define object node.
|
||||||
struct CAMFImporter_NodeElement_Color : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Color : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/****************** Variables ******************/
|
|
||||||
|
|
||||||
bool Composed; ///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color.
|
bool Composed; ///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color.
|
||||||
std::string Color_Composed[4];///< By components formulas of composed color. [0..3] => RGBA.
|
std::string Color_Composed[4]; ///< By components formulas of composed color. [0..3] - RGBA.
|
||||||
aiColor4D Color; ///< Constant color.
|
aiColor4D Color; ///< Constant color.
|
||||||
std::string Profile;///< The ICC color space used to interpret the three color channels <r>, <g> and <b>..
|
std::string Profile; ///< The ICC color space used to interpret the three color channels r, g and b..
|
||||||
|
|
||||||
/****************** Functions ******************/
|
/// @brief Constructor.
|
||||||
|
/// @param [in] pParent - pointer to parent node.
|
||||||
/// \fn CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
|
||||||
/// \param [in] pParent - pointer to parent node.
|
|
||||||
CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Color, pParent)
|
: CAMFImporter_NodeElement(ENET_Color, pParent)
|
||||||
{}
|
, Composed( false )
|
||||||
|
, Color()
|
||||||
};// struct CAMFImporter_NodeElement_Color
|
, Profile() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Material
|
/// \struct CAMFImporter_NodeElement_Material
|
||||||
/// Structure that define material node.
|
/// Structure that define material node.
|
||||||
struct CAMFImporter_NodeElement_Material : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Material : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/// \fn CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Material, pParent)
|
: CAMFImporter_NodeElement(ENET_Material, pParent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
};// struct CAMFImporter_NodeElement_Material
|
};
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Object
|
/// \struct CAMFImporter_NodeElement_Object
|
||||||
/// Structure that define object node.
|
/// Structure that define object node.
|
||||||
struct CAMFImporter_NodeElement_Object : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Object : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/// \fn CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Object, pParent)
|
: CAMFImporter_NodeElement(ENET_Object, pParent)
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
};// struct CAMFImporter_NodeElement_Object
|
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Mesh
|
/// \struct CAMFImporter_NodeElement_Mesh
|
||||||
/// Structure that define mesh node.
|
/// Structure that define mesh node.
|
||||||
struct CAMFImporter_NodeElement_Mesh : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Mesh : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/// \fn CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Mesh, pParent)
|
: CAMFImporter_NodeElement(ENET_Mesh, pParent)
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
};// struct CAMFImporter_NodeElement_Mesh
|
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Vertex
|
/// \struct CAMFImporter_NodeElement_Vertex
|
||||||
/// Structure that define vertex node.
|
/// Structure that define vertex node.
|
||||||
struct CAMFImporter_NodeElement_Vertex : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Vertex : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/// \fn CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Vertex, pParent)
|
: CAMFImporter_NodeElement(ENET_Vertex, pParent)
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
};// struct CAMFImporter_NodeElement_Vertex
|
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Edge
|
/// \struct CAMFImporter_NodeElement_Edge
|
||||||
/// Structure that define edge node.
|
/// Structure that define edge node.
|
||||||
struct CAMFImporter_NodeElement_Edge : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Edge : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/// \fn CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Edge, pParent)
|
: CAMFImporter_NodeElement(ENET_Edge, pParent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
};// struct CAMFImporter_NodeElement_Vertex
|
};
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Vertices
|
/// \struct CAMFImporter_NodeElement_Vertices
|
||||||
/// Structure that define vertices node.
|
/// Structure that define vertices node.
|
||||||
struct CAMFImporter_NodeElement_Vertices : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Vertices : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/// \fn CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Vertices, pParent)
|
: CAMFImporter_NodeElement(ENET_Vertices, pParent)
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
};// struct CAMFImporter_NodeElement_Vertices
|
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Volume
|
/// \struct CAMFImporter_NodeElement_Volume
|
||||||
/// Structure that define volume node.
|
/// Structure that define volume node.
|
||||||
struct CAMFImporter_NodeElement_Volume : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Volume : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/****************** Variables ******************/
|
|
||||||
|
|
||||||
std::string MaterialID;///< Which material to use.
|
std::string MaterialID;///< Which material to use.
|
||||||
std::string Type;///< What this volume describes can be “region” or “support”. If none specified, “object” is assumed.
|
std::string Type;///< What this volume describes can be “region” or “support”. If none specified, “object” is assumed.
|
||||||
|
|
||||||
/****************** Functions ******************/
|
|
||||||
|
|
||||||
/// \fn CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Volume, pParent)
|
: CAMFImporter_NodeElement(ENET_Volume, pParent)
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
};// struct CAMFImporter_NodeElement_Volume
|
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Coordinates
|
/// \struct CAMFImporter_NodeElement_Coordinates
|
||||||
/// Structure that define coordinates node.
|
/// Structure that define coordinates node.
|
||||||
struct CAMFImporter_NodeElement_Coordinates : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Coordinates : public CAMFImporter_NodeElement
|
||||||
{
|
{
|
||||||
/****************** Variables ******************/
|
|
||||||
|
|
||||||
aiVector3D Coordinate;///< Coordinate.
|
aiVector3D Coordinate;///< Coordinate.
|
||||||
|
|
||||||
/****************** Functions ******************/
|
|
||||||
|
|
||||||
/// \fn CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Coordinates, pParent)
|
: CAMFImporter_NodeElement(ENET_Coordinates, pParent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
};// struct CAMFImporter_NodeElement_Coordinates
|
};
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_TexMap
|
/// \struct CAMFImporter_NodeElement_TexMap
|
||||||
/// Structure that define texture coordinates node.
|
/// Structure that define texture coordinates node.
|
||||||
struct CAMFImporter_NodeElement_TexMap : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_TexMap : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/****************** Variables ******************/
|
|
||||||
|
|
||||||
aiVector3D TextureCoordinate[3];///< Texture coordinates.
|
aiVector3D TextureCoordinate[3];///< Texture coordinates.
|
||||||
std::string TextureID_R;///< Texture ID for red color component.
|
std::string TextureID_R;///< Texture ID for red color component.
|
||||||
std::string TextureID_G;///< Texture ID for green color component.
|
std::string TextureID_G;///< Texture ID for green color component.
|
||||||
std::string TextureID_B;///< Texture ID for blue color component.
|
std::string TextureID_B;///< Texture ID for blue color component.
|
||||||
std::string TextureID_A;///< Texture ID for alpha color component.
|
std::string TextureID_A;///< Texture ID for alpha color component.
|
||||||
|
|
||||||
/****************** Functions ******************/
|
|
||||||
|
|
||||||
/// \fn CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_TexMap, pParent)
|
: CAMFImporter_NodeElement(ENET_TexMap, pParent)
|
||||||
{}
|
, TextureCoordinate{}
|
||||||
|
, TextureID_R()
|
||||||
};// struct CAMFImporter_NodeElement_TexMap
|
, TextureID_G()
|
||||||
|
, TextureID_B()
|
||||||
|
, TextureID_A() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// \struct CAMFImporter_NodeElement_Triangle
|
/// \struct CAMFImporter_NodeElement_Triangle
|
||||||
/// Structure that define triangle node.
|
/// Structure that define triangle node.
|
||||||
struct CAMFImporter_NodeElement_Triangle : public CAMFImporter_NodeElement
|
struct CAMFImporter_NodeElement_Triangle : public CAMFImporter_NodeElement {
|
||||||
{
|
|
||||||
/****************** Variables ******************/
|
|
||||||
|
|
||||||
size_t V[3];///< Triangle vertices.
|
size_t V[3];///< Triangle vertices.
|
||||||
|
|
||||||
/****************** Functions ******************/
|
|
||||||
|
|
||||||
/// \fn CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent)
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pParent - pointer to parent node.
|
/// \param [in] pParent - pointer to parent node.
|
||||||
CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent)
|
CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent)
|
||||||
: CAMFImporter_NodeElement(ENET_Triangle, pParent)
|
: CAMFImporter_NodeElement(ENET_Triangle, pParent) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
};// struct CAMFImporter_NodeElement_Triangle
|
};
|
||||||
|
|
||||||
/// Structure that define texture node.
|
/// Structure that define texture node.
|
||||||
struct CAMFImporter_NodeElement_Texture : public CAMFImporter_NodeElement {
|
struct CAMFImporter_NodeElement_Texture : public CAMFImporter_NodeElement {
|
||||||
|
@ -396,6 +335,6 @@ struct CAMFImporter_NodeElement_Texture : public CAMFImporter_NodeElement {
|
||||||
, Tiled( false ){
|
, Tiled( false ){
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
};// struct CAMFImporter_NodeElement_Texture
|
};
|
||||||
|
|
||||||
#endif // INCLUDED_AI_AMF_IMPORTER_NODE_H
|
#endif // INCLUDED_AI_AMF_IMPORTER_NODE_H
|
||||||
|
|
111
code/ASEParser.h
111
code/ASEParser.h
|
@ -71,21 +71,20 @@ struct Material : public D3DS::Material
|
||||||
//! Default constructor has been deleted
|
//! Default constructor has been deleted
|
||||||
Material() = delete;
|
Material() = delete;
|
||||||
|
|
||||||
|
|
||||||
//! Constructor with explicit name
|
//! Constructor with explicit name
|
||||||
explicit Material(const std::string &name)
|
explicit Material(const std::string &name)
|
||||||
: D3DS::Material(name)
|
: D3DS::Material(name)
|
||||||
, pcInstance(NULL)
|
, pcInstance(NULL)
|
||||||
, bNeed (false)
|
, bNeed (false) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
Material(const Material &other) = default;
|
Material(const Material &other) = default;
|
||||||
Material &operator=(const Material &other) = default;
|
Material &operator=(const Material &other) = default;
|
||||||
|
|
||||||
|
|
||||||
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||||
Material(Material &&other)
|
Material(Material &&other) AI_NO_EXCEPT
|
||||||
: D3DS::Material(std::move(other))
|
: D3DS::Material(std::move(other))
|
||||||
, avSubMaterials(std::move(other.avSubMaterials))
|
, avSubMaterials(std::move(other.avSubMaterials))
|
||||||
, pcInstance(std::move(other.pcInstance))
|
, pcInstance(std::move(other.pcInstance))
|
||||||
|
@ -95,7 +94,7 @@ struct Material : public D3DS::Material
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Material &operator=(Material &&other) {
|
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
||||||
if (this == &other) {
|
if (this == &other) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -127,19 +126,12 @@ struct Material : public D3DS::Material
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent an ASE file face */
|
/** Helper structure to represent an ASE file face */
|
||||||
struct Face : public FaceWithSmoothingGroup
|
struct Face : public FaceWithSmoothingGroup {
|
||||||
{
|
|
||||||
//! Default constructor. Initializes everything with 0
|
//! Default constructor. Initializes everything with 0
|
||||||
Face()
|
Face() AI_NO_EXCEPT
|
||||||
{
|
: iMaterial(DEFAULT_MATINDEX)
|
||||||
mColorIndices[0] = mColorIndices[1] = mColorIndices[2] = 0;
|
, iFace(0) {
|
||||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
// empty
|
||||||
{
|
|
||||||
amUVIndices[i][0] = amUVIndices[i][1] = amUVIndices[i][2] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
iMaterial = DEFAULT_MATINDEX;
|
|
||||||
iFace = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! special value to indicate that no material index has
|
//! special value to indicate that no material index has
|
||||||
|
@ -147,8 +139,6 @@ struct Face : public FaceWithSmoothingGroup
|
||||||
//! will replace this value later.
|
//! will replace this value later.
|
||||||
static const unsigned int DEFAULT_MATINDEX = 0xFFFFFFFF;
|
static const unsigned int DEFAULT_MATINDEX = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Indices into each list of texture coordinates
|
//! Indices into each list of texture coordinates
|
||||||
unsigned int amUVIndices[AI_MAX_NUMBER_OF_TEXTURECOORDS][3];
|
unsigned int amUVIndices[AI_MAX_NUMBER_OF_TEXTURECOORDS][3];
|
||||||
|
|
||||||
|
@ -166,15 +156,15 @@ struct Face : public FaceWithSmoothingGroup
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent an ASE file bone */
|
/** Helper structure to represent an ASE file bone */
|
||||||
struct Bone
|
struct Bone {
|
||||||
{
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
Bone() = delete;
|
Bone() = delete;
|
||||||
|
|
||||||
//! Construction from an existing name
|
//! Construction from an existing name
|
||||||
explicit Bone( const std::string& name)
|
explicit Bone( const std::string& name)
|
||||||
: mName (name)
|
: mName(name) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! Name of the bone
|
//! Name of the bone
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
@ -182,29 +172,22 @@ struct Bone
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent an ASE file bone vertex */
|
/** Helper structure to represent an ASE file bone vertex */
|
||||||
struct BoneVertex
|
struct BoneVertex {
|
||||||
{
|
|
||||||
//! Bone and corresponding vertex weight.
|
//! Bone and corresponding vertex weight.
|
||||||
//! -1 for unrequired bones ....
|
//! -1 for unrequired bones ....
|
||||||
std::vector<std::pair<int,float> > mBoneWeights;
|
std::vector<std::pair<int,float> > mBoneWeights;
|
||||||
|
|
||||||
//! Position of the bone vertex.
|
|
||||||
//! MUST be identical to the vertex position
|
|
||||||
//aiVector3D mPosition;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent an ASE file animation */
|
/** Helper structure to represent an ASE file animation */
|
||||||
struct Animation
|
struct Animation {
|
||||||
{
|
enum Type {
|
||||||
enum Type
|
|
||||||
{
|
|
||||||
TRACK = 0x0,
|
TRACK = 0x0,
|
||||||
BEZIER = 0x1,
|
BEZIER = 0x1,
|
||||||
TCB = 0x2
|
TCB = 0x2
|
||||||
} mRotationType, mScalingType, mPositionType;
|
} mRotationType, mScalingType, mPositionType;
|
||||||
|
|
||||||
Animation()
|
Animation() AI_NO_EXCEPT
|
||||||
: mRotationType (TRACK)
|
: mRotationType (TRACK)
|
||||||
, mScalingType (TRACK)
|
, mScalingType (TRACK)
|
||||||
, mPositionType (TRACK)
|
, mPositionType (TRACK)
|
||||||
|
@ -218,20 +201,17 @@ struct Animation
|
||||||
|
|
||||||
//! List of track scaling keyframes
|
//! List of track scaling keyframes
|
||||||
std::vector< aiVectorKey > akeyScaling;
|
std::vector< aiVectorKey > akeyScaling;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent the inheritance information of an ASE node */
|
/** Helper structure to represent the inheritance information of an ASE node */
|
||||||
struct InheritanceInfo
|
struct InheritanceInfo {
|
||||||
{
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
InheritanceInfo()
|
InheritanceInfo() AI_NO_EXCEPT {
|
||||||
{
|
for ( size_t i=0; i<3; ++i ) {
|
||||||
// set the inheritance flag for all axes by default to true
|
|
||||||
for (unsigned int i = 0; i < 3;++i)
|
|
||||||
abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true;
|
abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! Inherit the parent's position?, axis order is x,y,z
|
//! Inherit the parent's position?, axis order is x,y,z
|
||||||
bool abInheritPosition[3];
|
bool abInheritPosition[3];
|
||||||
|
@ -245,17 +225,19 @@ struct InheritanceInfo
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Represents an ASE file node. Base class for mesh, light and cameras */
|
/** Represents an ASE file node. Base class for mesh, light and cameras */
|
||||||
struct BaseNode
|
struct BaseNode {
|
||||||
{
|
enum Type {
|
||||||
enum Type {Light, Camera, Mesh, Dummy} mType;
|
Light,
|
||||||
|
Camera,
|
||||||
|
Mesh,
|
||||||
|
Dummy
|
||||||
|
} mType;
|
||||||
|
|
||||||
//! Construction from an existing name
|
//! Construction from an existing name
|
||||||
BaseNode(Type _mType, const std::string &name)
|
BaseNode(Type _mType, const std::string &name)
|
||||||
: mType (_mType)
|
: mType (_mType)
|
||||||
, mName (name)
|
, mName (name)
|
||||||
, mProcessed (false)
|
, mProcessed (false) {
|
||||||
{
|
|
||||||
// Set mTargetPosition to qnan
|
// Set mTargetPosition to qnan
|
||||||
const ai_real qnan = get_qnan();
|
const ai_real qnan = get_qnan();
|
||||||
mTargetPosition.x = qnan;
|
mTargetPosition.x = qnan;
|
||||||
|
@ -291,23 +273,22 @@ struct BaseNode
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent an ASE file mesh */
|
/** Helper structure to represent an ASE file mesh */
|
||||||
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode
|
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode {
|
||||||
{
|
|
||||||
//! Default constructor has been deleted
|
//! Default constructor has been deleted
|
||||||
Mesh() = delete;
|
Mesh() = delete;
|
||||||
|
|
||||||
|
|
||||||
//! Construction from an existing name
|
//! Construction from an existing name
|
||||||
explicit Mesh(const std::string &name)
|
explicit Mesh(const std::string &name)
|
||||||
: BaseNode( BaseNode::Mesh, name )
|
: BaseNode( BaseNode::Mesh, name )
|
||||||
|
, mVertexColors()
|
||||||
|
, mBoneVertices()
|
||||||
|
, mBones()
|
||||||
, iMaterialIndex(Face::DEFAULT_MATINDEX)
|
, iMaterialIndex(Face::DEFAULT_MATINDEX)
|
||||||
, bSkip (false)
|
, bSkip (false) {
|
||||||
{
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) {
|
||||||
// use 2 texture vertex components by default
|
|
||||||
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
|
||||||
this->mNumUVComponents[c] = 2;
|
this->mNumUVComponents[c] = 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! List of all texture coordinate sets
|
//! List of all texture coordinate sets
|
||||||
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
@ -396,12 +377,11 @@ struct Camera : public BaseNode
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent an ASE helper object (dummy) */
|
/** Helper structure to represent an ASE helper object (dummy) */
|
||||||
struct Dummy : public BaseNode
|
struct Dummy : public BaseNode {
|
||||||
{
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
Dummy()
|
Dummy() AI_NO_EXCEPT
|
||||||
: BaseNode (BaseNode::Dummy, "DUMMY")
|
: BaseNode (BaseNode::Dummy, "DUMMY") {
|
||||||
{
|
// empty
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -416,12 +396,11 @@ struct Dummy : public BaseNode
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
/** \brief Class to parse ASE files
|
/** \brief Class to parse ASE files
|
||||||
*/
|
*/
|
||||||
class Parser
|
class Parser {
|
||||||
{
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Parser() AI_NO_EXCEPT {
|
||||||
Parser() {}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ using namespace Assimp;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
BaseImporter::BaseImporter()
|
BaseImporter::BaseImporter() AI_NO_EXCEPT
|
||||||
: m_progress() {
|
: m_progress() {
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ using namespace Assimp;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
BaseProcess::BaseProcess()
|
BaseProcess::BaseProcess() AI_NO_EXCEPT
|
||||||
: shared()
|
: shared()
|
||||||
, progress()
|
, progress()
|
||||||
{
|
{
|
||||||
|
|
|
@ -211,20 +211,16 @@ private:
|
||||||
* should be executed. If the function returns true, the class' Execute()
|
* should be executed. If the function returns true, the class' Execute()
|
||||||
* function is called subsequently.
|
* function is called subsequently.
|
||||||
*/
|
*/
|
||||||
class ASSIMP_API_WINONLY BaseProcess
|
class ASSIMP_API_WINONLY BaseProcess {
|
||||||
{
|
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Constructor to be privately used by Importer */
|
/** Constructor to be privately used by Importer */
|
||||||
BaseProcess();
|
BaseProcess() AI_NO_EXCEPT;
|
||||||
|
|
||||||
/** Destructor, private as well */
|
/** Destructor, private as well */
|
||||||
virtual ~BaseProcess();
|
virtual ~BaseProcess();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the processing step is present in the given flag.
|
/** Returns whether the processing step is present in the given flag.
|
||||||
* @param pFlags The processing flags the importer was called with. A
|
* @param pFlags The processing flags the importer was called with. A
|
||||||
|
|
|
@ -405,7 +405,7 @@ bool Structure::ReadFieldPtrVector(vector<TOUT<T>>&out, const char* name, const
|
||||||
++db.stats().fields_read;
|
++db.stats().fields_read;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1206,7 +1206,7 @@ aiCamera* BlenderImporter::ConvertCamera(const Scene& /*in*/, const Object* obj,
|
||||||
out->mUp = aiVector3D(0.f, 1.f, 0.f);
|
out->mUp = aiVector3D(0.f, 1.f, 0.f);
|
||||||
out->mLookAt = aiVector3D(0.f, 0.f, -1.f);
|
out->mLookAt = aiVector3D(0.f, 0.f, -1.f);
|
||||||
if (cam->sensor_x && cam->lens) {
|
if (cam->sensor_x && cam->lens) {
|
||||||
out->mHorizontalFOV = std::atan2(cam->sensor_x, 2.f * cam->lens);
|
out->mHorizontalFOV = 2.f * std::atan2(cam->sensor_x, 2.f * cam->lens);
|
||||||
}
|
}
|
||||||
out->mClipPlaneNear = cam->clipsta;
|
out->mClipPlaneNear = cam->clipsta;
|
||||||
out->mClipPlaneFar = cam->clipend;
|
out->mClipPlaneFar = cam->clipend;
|
||||||
|
|
|
@ -910,6 +910,7 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||||
ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||||
|
|
||||||
ADD_LIBRARY( assimp ${assimp_src} )
|
ADD_LIBRARY( assimp ${assimp_src} )
|
||||||
|
ADD_LIBRARY(assimp::asimp ALIAS assimp)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
|
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
||||||
|
|
|
@ -137,9 +137,7 @@ void COBImporter::SetupProperties(const Importer* /*pImp*/)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void COBImporter::InternReadFile( const std::string& pFile,
|
void COBImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
|
||||||
{
|
|
||||||
COB::Scene scene;
|
COB::Scene scene;
|
||||||
std::unique_ptr<StreamReaderLE> stream(new StreamReaderLE( pIOHandler->Open(pFile,"rb")) );
|
std::unique_ptr<StreamReaderLE> stream(new StreamReaderLE( pIOHandler->Open(pFile,"rb")) );
|
||||||
|
|
||||||
|
|
|
@ -314,20 +314,20 @@ private:
|
||||||
++buf;
|
++buf;
|
||||||
comp[ 1 ] = *buf;
|
comp[ 1 ] = *buf;
|
||||||
++buf;
|
++buf;
|
||||||
diffuse.r = static_cast<ai_real>( strtol( comp, NULL, 16 ) ) / 255.0;
|
diffuse.r = static_cast<ai_real>( strtol( comp, NULL, 16 ) ) / ai_real(255.0);
|
||||||
|
|
||||||
|
|
||||||
comp[ 0 ] = *buf;
|
comp[ 0 ] = *buf;
|
||||||
++buf;
|
++buf;
|
||||||
comp[ 1 ] = *buf;
|
comp[ 1 ] = *buf;
|
||||||
++buf;
|
++buf;
|
||||||
diffuse.g = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / 255.0;
|
diffuse.g = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / ai_real(255.0);
|
||||||
|
|
||||||
comp[ 0 ] = *buf;
|
comp[ 0 ] = *buf;
|
||||||
++buf;
|
++buf;
|
||||||
comp[ 1 ] = *buf;
|
comp[ 1 ] = *buf;
|
||||||
++buf;
|
++buf;
|
||||||
diffuse.b = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / 255.0;
|
diffuse.b = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / ai_real(255.0);
|
||||||
|
|
||||||
if(7 == len)
|
if(7 == len)
|
||||||
return true;
|
return true;
|
||||||
|
@ -335,7 +335,7 @@ private:
|
||||||
++buf;
|
++buf;
|
||||||
comp[ 1 ] = *buf;
|
comp[ 1 ] = *buf;
|
||||||
++buf;
|
++buf;
|
||||||
diffuse.a = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / 255.0;
|
diffuse.a = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / ai_real(255.0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aiTexel* imageContent = new aiTexel[1u + imageSize / sizeof(aiTexel)];
|
aiTexel* imageContent = new aiTexel[ 1ul + static_cast<unsigned long>( imageSize ) / sizeof(aiTexel)];
|
||||||
file.seekg(0, std::ios::beg);
|
file.seekg(0, std::ios::beg);
|
||||||
file.read(reinterpret_cast<char*>(imageContent), imageSize);
|
file.read(reinterpret_cast<char*>(imageContent), imageSize);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef INCLUDED_AI_FBX_DOCUMENT_UTIL_H
|
#ifndef INCLUDED_AI_FBX_DOCUMENT_UTIL_H
|
||||||
#define INCLUDED_AI_FBX_DOCUMENT_UTIL_H
|
#define INCLUDED_AI_FBX_DOCUMENT_UTIL_H
|
||||||
|
|
||||||
#include "../include/assimp/defs.h"
|
#include <assimp/defs.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "FBXDocument.h"
|
#include "FBXDocument.h"
|
||||||
|
|
|
@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace HMP {
|
namespace HMP {
|
||||||
|
|
||||||
#include "./../include/assimp/Compiler/pushpack1.h"
|
#include <assimp/Compiler/pushpack1.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
// to make it easier for us, we test the magic word against both "endianesses"
|
// to make it easier for us, we test the magic word against both "endianesses"
|
||||||
|
@ -131,7 +131,7 @@ struct Vertex_HMP7
|
||||||
int8_t normal_x,normal_y;
|
int8_t normal_x,normal_y;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
#include "./../include/assimp/Compiler/poppack1.h"
|
#include <assimp/Compiler/poppack1.h>
|
||||||
|
|
||||||
} //! namespace HMP
|
} //! namespace HMP
|
||||||
} //! namespace Assimp
|
} //! namespace Assimp
|
||||||
|
|
|
@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_MDLFILEHELPER2_H_INC
|
#ifndef AI_MDLFILEHELPER2_H_INC
|
||||||
#define AI_MDLFILEHELPER2_H_INC
|
#define AI_MDLFILEHELPER2_H_INC
|
||||||
|
|
||||||
#include "./../include/assimp/Compiler/pushpack1.h"
|
#include <assimp/Compiler/pushpack1.h>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace MDL {
|
namespace MDL {
|
||||||
|
@ -141,7 +141,7 @@ struct Header_HL2 {
|
||||||
int32_t transitionindex;
|
int32_t transitionindex;
|
||||||
} /* PACK_STRUCT */;
|
} /* PACK_STRUCT */;
|
||||||
|
|
||||||
#include "./../include/assimp/Compiler/poppack1.h"
|
#include <assimp/Compiler/poppack1.h>
|
||||||
|
|
||||||
}
|
}
|
||||||
} // end namespaces
|
} // end namespaces
|
||||||
|
|
|
@ -120,11 +120,11 @@ public:
|
||||||
SharedPostProcessInfo* mPPShared;
|
SharedPostProcessInfo* mPPShared;
|
||||||
|
|
||||||
/// The default class constructor.
|
/// The default class constructor.
|
||||||
ImporterPimpl();
|
ImporterPimpl() AI_NO_EXCEPT;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
ImporterPimpl::ImporterPimpl()
|
ImporterPimpl::ImporterPimpl() AI_NO_EXCEPT
|
||||||
: mIOHandler( nullptr )
|
: mIOHandler( nullptr )
|
||||||
, mIsDefaultHandler( false )
|
, mIsDefaultHandler( false )
|
||||||
, mProgressHandler( nullptr )
|
, mProgressHandler( nullptr )
|
||||||
|
|
|
@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
|
||||||
|
|
||||||
#include "AssimpPCH.h"
|
#include "AssimpPCH.h"
|
||||||
#include "IFCReaderGen4.h"
|
#include "IFCReaderGen_4.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
using namespace IFC;
|
using namespace IFC;
|
||||||
|
|
|
@ -113,14 +113,14 @@ enum PrePostBehaviour
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a LWO animation keyframe
|
/** \brief Data structure for a LWO animation keyframe
|
||||||
*/
|
*/
|
||||||
struct Key
|
struct Key {
|
||||||
{
|
Key() AI_NO_EXCEPT
|
||||||
Key()
|
: time()
|
||||||
: time(),
|
, value()
|
||||||
value(),
|
, inter(IT_LINE)
|
||||||
inter (IT_LINE),
|
, params() {
|
||||||
params()
|
// empty
|
||||||
{}
|
}
|
||||||
|
|
||||||
//! Current time
|
//! Current time
|
||||||
double time;
|
double time;
|
||||||
|
@ -144,17 +144,16 @@ struct Key
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a LWO animation envelope
|
/** \brief Data structure for a LWO animation envelope
|
||||||
*/
|
*/
|
||||||
struct Envelope
|
struct Envelope {
|
||||||
{
|
Envelope() AI_NO_EXCEPT
|
||||||
Envelope()
|
|
||||||
: index()
|
: index()
|
||||||
, type(EnvelopeType_Unknown)
|
, type(EnvelopeType_Unknown)
|
||||||
, pre(PrePostBehaviour_Constant)
|
, pre(PrePostBehaviour_Constant)
|
||||||
, post(PrePostBehaviour_Constant)
|
, post(PrePostBehaviour_Constant)
|
||||||
|
|
||||||
, old_first(0)
|
, old_first(0)
|
||||||
, old_last (0)
|
, old_last(0) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! Index of this envelope
|
//! Index of this envelope
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
@ -162,7 +161,7 @@ struct Envelope
|
||||||
//! Type of envelope
|
//! Type of envelope
|
||||||
EnvelopeType type;
|
EnvelopeType type;
|
||||||
|
|
||||||
//! Pre and post-behaviour
|
//! Pre- and post-behavior
|
||||||
PrePostBehaviour pre,post;
|
PrePostBehaviour pre,post;
|
||||||
|
|
||||||
//! Keyframes for this envelope
|
//! Keyframes for this envelope
|
||||||
|
|
|
@ -261,14 +261,14 @@ namespace LWO {
|
||||||
* \note We can't use the code in SmoothingGroups.inl here - the mesh
|
* \note We can't use the code in SmoothingGroups.inl here - the mesh
|
||||||
* structures of 3DS/ASE and LWO are too different.
|
* structures of 3DS/ASE and LWO are too different.
|
||||||
*/
|
*/
|
||||||
struct Face : public aiFace
|
struct Face : public aiFace {
|
||||||
{
|
|
||||||
//! Default construction
|
//! Default construction
|
||||||
Face()
|
Face() AI_NO_EXCEPT
|
||||||
: surfaceIndex( 0 )
|
: surfaceIndex( 0 )
|
||||||
, smoothGroup( 0 )
|
, smoothGroup( 0 )
|
||||||
, type (AI_LWO_FACE)
|
, type( AI_LWO_FACE ) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! Construction from given type
|
//! Construction from given type
|
||||||
explicit Face(uint32_t _type)
|
explicit Face(uint32_t _type)
|
||||||
|
|
|
@ -120,7 +120,7 @@ public:
|
||||||
{
|
{
|
||||||
unsigned int mBone; ///< Index of the bone
|
unsigned int mBone; ///< Index of the bone
|
||||||
float mWeight; ///< Weight of that bone on this vertex
|
float mWeight; ///< Weight of that bone on this vertex
|
||||||
Weight()
|
Weight() AI_NO_EXCEPT
|
||||||
: mBone(0)
|
: mBone(0)
|
||||||
, mWeight(0.0f)
|
, mWeight(0.0f)
|
||||||
{ }
|
{ }
|
||||||
|
|
|
@ -246,7 +246,7 @@ struct Vertex
|
||||||
uint16_t NORMAL;
|
uint16_t NORMAL;
|
||||||
} /*PACK_STRUCT*/;
|
} /*PACK_STRUCT*/;
|
||||||
|
|
||||||
#include "./../include/assimp/Compiler/poppack1.h"
|
#include <assimp/Compiler/poppack1.h>
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
/** @brief Unpack a Q3 16 bit vector to its full float3 representation
|
/** @brief Unpack a Q3 16 bit vector to its full float3 representation
|
||||||
|
|
|
@ -125,7 +125,7 @@ enum AlphaTestFunc
|
||||||
*/
|
*/
|
||||||
struct ShaderMapBlock
|
struct ShaderMapBlock
|
||||||
{
|
{
|
||||||
ShaderMapBlock()
|
ShaderMapBlock() AI_NO_EXCEPT
|
||||||
: blend_src (BLEND_NONE)
|
: blend_src (BLEND_NONE)
|
||||||
, blend_dest (BLEND_NONE)
|
, blend_dest (BLEND_NONE)
|
||||||
, alpha_test (AT_NONE)
|
, alpha_test (AT_NONE)
|
||||||
|
@ -150,7 +150,7 @@ struct ShaderMapBlock
|
||||||
*/
|
*/
|
||||||
struct ShaderDataBlock
|
struct ShaderDataBlock
|
||||||
{
|
{
|
||||||
ShaderDataBlock()
|
ShaderDataBlock() AI_NO_EXCEPT
|
||||||
: cull (CULL_CW)
|
: cull (CULL_CW)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "../include/assimp/types.h"
|
#include <assimp/types.h>
|
||||||
#include "../include/assimp/mesh.h"
|
#include <assimp/mesh.h>
|
||||||
#include "../include/assimp/anim.h"
|
#include <assimp/anim.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||||
# pragma pack(push,1)
|
# pragma pack(push,1)
|
||||||
|
|
|
@ -192,14 +192,14 @@ typedef std::vector< FrameDesc > FrameList;
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Represents a vertex descriptor in a MD5 file
|
/** Represents a vertex descriptor in a MD5 file
|
||||||
*/
|
*/
|
||||||
struct VertexDesc
|
struct VertexDesc {
|
||||||
{
|
VertexDesc() AI_NO_EXCEPT
|
||||||
VertexDesc()
|
|
||||||
: mFirstWeight(0)
|
: mFirstWeight(0)
|
||||||
, mNumWeights (0)
|
, mNumWeights(0) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! UV cordinate of the vertex
|
//! UV coordinate of the vertex
|
||||||
aiVector2D mUV;
|
aiVector2D mUV;
|
||||||
|
|
||||||
//! Index of the first weight of the vertex in
|
//! Index of the first weight of the vertex in
|
||||||
|
|
|
@ -61,7 +61,6 @@ http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace MDC {
|
namespace MDC {
|
||||||
|
|
||||||
|
|
||||||
// to make it easier for us, we test the magic word against both "endianesses"
|
// to make it easier for us, we test the magic word against both "endianesses"
|
||||||
#define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI")
|
#define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI")
|
||||||
#define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC")
|
#define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC")
|
||||||
|
@ -79,8 +78,7 @@ namespace MDC {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a MDC file's main header
|
/** \brief Data structure for a MDC file's main header
|
||||||
*/
|
*/
|
||||||
struct Header
|
struct Header {
|
||||||
{
|
|
||||||
uint32_t ulIdent ;
|
uint32_t ulIdent ;
|
||||||
uint32_t ulVersion ;
|
uint32_t ulVersion ;
|
||||||
char ucName [ AI_MDC_MAXQPATH ] ;
|
char ucName [ AI_MDC_MAXQPATH ] ;
|
||||||
|
@ -100,8 +98,7 @@ struct Header
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a MDC file's surface header
|
/** \brief Data structure for a MDC file's surface header
|
||||||
*/
|
*/
|
||||||
struct Surface
|
struct Surface {
|
||||||
{
|
|
||||||
uint32_t ulIdent ;
|
uint32_t ulIdent ;
|
||||||
char ucName [ AI_MDC_MAXQPATH ] ;
|
char ucName [ AI_MDC_MAXQPATH ] ;
|
||||||
uint32_t ulFlags ;
|
uint32_t ulFlags ;
|
||||||
|
@ -118,23 +115,22 @@ struct Surface
|
||||||
uint32_t ulOffsetFrameBaseFrames ;
|
uint32_t ulOffsetFrameBaseFrames ;
|
||||||
uint32_t ulOffsetFrameCompFrames ;
|
uint32_t ulOffsetFrameCompFrames ;
|
||||||
uint32_t ulOffsetEnd;
|
uint32_t ulOffsetEnd;
|
||||||
Surface()
|
Surface() AI_NO_EXCEPT
|
||||||
: ulIdent(),
|
: ulIdent()
|
||||||
ulFlags(),
|
, ulFlags()
|
||||||
ulNumCompFrames(),
|
, ulNumCompFrames()
|
||||||
ulNumBaseFrames(),
|
, ulNumBaseFrames()
|
||||||
ulNumShaders(),
|
, ulNumShaders()
|
||||||
ulNumVertices(),
|
, ulNumVertices()
|
||||||
ulNumTriangles(),
|
, ulNumTriangles()
|
||||||
ulOffsetTriangles(),
|
, ulOffsetTriangles()
|
||||||
ulOffsetShaders(),
|
, ulOffsetShaders()
|
||||||
ulOffsetTexCoords(),
|
, ulOffsetTexCoords()
|
||||||
ulOffsetBaseVerts(),
|
, ulOffsetBaseVerts()
|
||||||
ulOffsetCompVerts(),
|
, ulOffsetCompVerts()
|
||||||
ulOffsetFrameBaseFrames(),
|
, ulOffsetFrameBaseFrames()
|
||||||
ulOffsetFrameCompFrames(),
|
, ulOffsetFrameCompFrames()
|
||||||
ulOffsetEnd()
|
, ulOffsetEnd() {
|
||||||
{
|
|
||||||
ucName[AI_MDC_MAXQPATH-1] = '\0';
|
ucName[AI_MDC_MAXQPATH-1] = '\0';
|
||||||
}
|
}
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
@ -142,8 +138,7 @@ struct Surface
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a MDC frame
|
/** \brief Data structure for a MDC frame
|
||||||
*/
|
*/
|
||||||
struct Frame
|
struct Frame {
|
||||||
{
|
|
||||||
//! bounding box minimum coords
|
//! bounding box minimum coords
|
||||||
aiVector3D bboxMin ;
|
aiVector3D bboxMin ;
|
||||||
|
|
||||||
|
@ -163,24 +158,21 @@ struct Frame
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a MDC triangle
|
/** \brief Data structure for a MDC triangle
|
||||||
*/
|
*/
|
||||||
struct Triangle
|
struct Triangle {
|
||||||
{
|
|
||||||
uint32_t aiIndices[3];
|
uint32_t aiIndices[3];
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a MDC texture coordinate
|
/** \brief Data structure for a MDC texture coordinate
|
||||||
*/
|
*/
|
||||||
struct TexturCoord
|
struct TexturCoord {
|
||||||
{
|
|
||||||
float u,v;
|
float u,v;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a MDC base vertex
|
/** \brief Data structure for a MDC base vertex
|
||||||
*/
|
*/
|
||||||
struct BaseVertex
|
struct BaseVertex {
|
||||||
{
|
|
||||||
int16_t x,y,z;
|
int16_t x,y,z;
|
||||||
uint16_t normal;
|
uint16_t normal;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
@ -188,25 +180,20 @@ struct BaseVertex
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a MDC compressed vertex
|
/** \brief Data structure for a MDC compressed vertex
|
||||||
*/
|
*/
|
||||||
struct CompressedVertex
|
struct CompressedVertex {
|
||||||
{
|
|
||||||
uint8_t xd,yd,zd,nd;
|
uint8_t xd,yd,zd,nd;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a MDC shader
|
/** \brief Data structure for a MDC shader
|
||||||
*/
|
*/
|
||||||
struct Shader
|
struct Shader {
|
||||||
{
|
|
||||||
char ucName [ AI_MDC_MAXQPATH ] ;
|
char ucName [ AI_MDC_MAXQPATH ] ;
|
||||||
uint32_t ulPath;
|
uint32_t ulPath;
|
||||||
|
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
#include <assimp/Compiler/poppack1.h>
|
#include <assimp/Compiler/poppack1.h>
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Build a floating point vertex from the compressed data in MDC files
|
/** Build a floating point vertex from the compressed data in MDC files
|
||||||
*/
|
*/
|
||||||
|
@ -215,6 +202,7 @@ void BuildVertex(const Frame& frame,
|
||||||
const CompressedVertex& cvert,
|
const CompressedVertex& cvert,
|
||||||
aiVector3D& vXYZOut,
|
aiVector3D& vXYZOut,
|
||||||
aiVector3D& vNorOut);
|
aiVector3D& vNorOut);
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !! AI_MDCFILEHELPER_H_INC
|
#endif // !! AI_MDCFILEHELPER_H_INC
|
||||||
|
|
|
@ -709,7 +709,7 @@ struct GroupFrame
|
||||||
SimpleFrame *frames;
|
SimpleFrame *frames;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
#include "./../include/assimp/Compiler/poppack1.h"
|
#include <assimp/Compiler/poppack1.h>
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
/** \struct IntFace_MDL7
|
/** \struct IntFace_MDL7
|
||||||
|
@ -717,11 +717,9 @@ struct GroupFrame
|
||||||
*/
|
*/
|
||||||
struct IntFace_MDL7 {
|
struct IntFace_MDL7 {
|
||||||
// provide a constructor for our own convenience
|
// provide a constructor for our own convenience
|
||||||
IntFace_MDL7()
|
IntFace_MDL7() AI_NO_EXCEPT {
|
||||||
{
|
::memset( mIndices, 0, sizeof(uint32_t) *3);
|
||||||
// set everything to zero
|
::memset( iMatIndex, 0, sizeof( unsigned int) *2);
|
||||||
mIndices[0] = mIndices[1] = mIndices[2] = 0;
|
|
||||||
iMatIndex[0] = iMatIndex[1] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Vertex indices
|
//! Vertex indices
|
||||||
|
@ -737,13 +735,11 @@ struct IntFace_MDL7 {
|
||||||
* which has been created from two single materials along with the
|
* which has been created from two single materials along with the
|
||||||
* original material indices.
|
* original material indices.
|
||||||
*/
|
*/
|
||||||
struct IntMaterial_MDL7
|
struct IntMaterial_MDL7 {
|
||||||
{
|
|
||||||
// provide a constructor for our own convenience
|
// provide a constructor for our own convenience
|
||||||
IntMaterial_MDL7()
|
IntMaterial_MDL7() AI_NO_EXCEPT
|
||||||
{
|
: pcMat( nullptr ) {
|
||||||
pcMat = NULL;
|
::memset( iOldMatIndices, 0, sizeof(unsigned int) *2);
|
||||||
iOldMatIndices[0] = iOldMatIndices[1] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Material instance
|
//! Material instance
|
||||||
|
@ -761,7 +757,7 @@ struct IntMaterial_MDL7
|
||||||
struct IntBone_MDL7 : aiBone
|
struct IntBone_MDL7 : aiBone
|
||||||
{
|
{
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
IntBone_MDL7() : iParent (0xffff)
|
IntBone_MDL7() AI_NO_EXCEPT : iParent (0xffff)
|
||||||
{
|
{
|
||||||
pkeyPositions.reserve(30);
|
pkeyPositions.reserve(30);
|
||||||
pkeyScalings.reserve(30);
|
pkeyScalings.reserve(30);
|
||||||
|
@ -806,12 +802,12 @@ struct IntFrameInfo_MDL7
|
||||||
struct IntGroupInfo_MDL7
|
struct IntGroupInfo_MDL7
|
||||||
{
|
{
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
IntGroupInfo_MDL7()
|
IntGroupInfo_MDL7() AI_NO_EXCEPT
|
||||||
: iIndex(0)
|
: iIndex(0)
|
||||||
, pcGroup(NULL)
|
, pcGroup(nullptr)
|
||||||
, pcGroupUVs(NULL)
|
, pcGroupUVs(nullptr)
|
||||||
, pcGroupTris(NULL)
|
, pcGroupTris(nullptr)
|
||||||
, pcGroupVerts(NULL)
|
, pcGroupVerts(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Construction from an existing group header
|
//! Construction from an existing group header
|
||||||
|
@ -843,7 +839,7 @@ struct IntGroupInfo_MDL7
|
||||||
//! Holds the data that belongs to a MDL7 mesh group
|
//! Holds the data that belongs to a MDL7 mesh group
|
||||||
struct IntGroupData_MDL7
|
struct IntGroupData_MDL7
|
||||||
{
|
{
|
||||||
IntGroupData_MDL7()
|
IntGroupData_MDL7() AI_NO_EXCEPT
|
||||||
: bNeed2UV(false)
|
: bNeed2UV(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -872,10 +868,9 @@ struct IntGroupData_MDL7
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
//! Holds data from an MDL7 file that is shared by all mesh groups
|
//! Holds data from an MDL7 file that is shared by all mesh groups
|
||||||
struct IntSharedData_MDL7
|
struct IntSharedData_MDL7 {
|
||||||
{
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
IntSharedData_MDL7()
|
IntSharedData_MDL7() AI_NO_EXCEPT
|
||||||
: apcOutBones(),
|
: apcOutBones(),
|
||||||
iNum()
|
iNum()
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,9 +72,8 @@ using namespace std;
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Default constructor
|
// Default constructor
|
||||||
MMDImporter::MMDImporter()
|
MMDImporter::MMDImporter()
|
||||||
: m_Buffer(),
|
: m_Buffer()
|
||||||
// m_pRootObject( NULL ),
|
, m_strAbsPath("") {
|
||||||
m_strAbsPath("") {
|
|
||||||
DefaultIOSystem io;
|
DefaultIOSystem io;
|
||||||
m_strAbsPath = io.getOsSeparator();
|
m_strAbsPath = io.getOsSeparator();
|
||||||
}
|
}
|
||||||
|
@ -82,8 +81,7 @@ MMDImporter::MMDImporter()
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor.
|
// Destructor.
|
||||||
MMDImporter::~MMDImporter() {
|
MMDImporter::~MMDImporter() {
|
||||||
// delete m_pRootObject;
|
// empty
|
||||||
// m_pRootObject = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -96,8 +94,7 @@ bool MMDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||||
} else // Check file Header
|
} else // Check file Header
|
||||||
{
|
{
|
||||||
static const char *pTokens[] = {"PMX "};
|
static const char *pTokens[] = {"PMX "};
|
||||||
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens,
|
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 1);
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,8 +351,11 @@ aiMaterial *MMDImporter::CreateMaterial(const pmx::PmxMaterial *pMat,
|
||||||
float shininess = pMat->specularlity;
|
float shininess = pMat->specularlity;
|
||||||
mat->AddProperty(&shininess, 1, AI_MATKEY_SHININESS_STRENGTH);
|
mat->AddProperty(&shininess, 1, AI_MATKEY_SHININESS_STRENGTH);
|
||||||
|
|
||||||
|
if(pMat->diffuse_texture_index >= 0) {
|
||||||
aiString texture_path(pModel->textures[pMat->diffuse_texture_index]);
|
aiString texture_path(pModel->textures[pMat->diffuse_texture_index]);
|
||||||
mat->AddProperty(&texture_path, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));
|
mat->AddProperty(&texture_path, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));
|
||||||
|
}
|
||||||
|
|
||||||
int mapping_uvwsrc = 0;
|
int mapping_uvwsrc = 0;
|
||||||
mat->AddProperty(&mapping_uvwsrc, 1,
|
mat->AddProperty(&mapping_uvwsrc, 1,
|
||||||
AI_MATKEY_UVWSRC(aiTextureType_DIFFUSE, 0));
|
AI_MATKEY_UVWSRC(aiTextureType_DIFFUSE, 0));
|
||||||
|
|
|
@ -94,16 +94,15 @@ namespace pmx
|
||||||
if (encoding == 0)
|
if (encoding == 0)
|
||||||
{
|
{
|
||||||
// UTF16 to UTF8
|
// UTF16 to UTF8
|
||||||
std::string result;
|
const uint16_t* sourceStart = (uint16_t*)buffer.data();
|
||||||
|
|
||||||
const char* sourceStart = buffer.data();
|
|
||||||
const unsigned int targetSize = size * 3; // enough to encode
|
const unsigned int targetSize = size * 3; // enough to encode
|
||||||
char* targetStart = new char[targetSize]();
|
char *targetStart = new char[targetSize];
|
||||||
const char* targetReserved = targetStart;
|
std::memset(targetStart, 0, targetSize * sizeof(char));
|
||||||
utf8::utf16to8( sourceStart, sourceStart + size, targetStart );
|
|
||||||
|
|
||||||
result.assign(targetReserved, targetStart - targetReserved);
|
utf8::utf16to8( sourceStart, sourceStart + size/2, targetStart );
|
||||||
delete[] targetReserved;
|
|
||||||
|
std::string result(targetStart);
|
||||||
|
delete [] targetStart;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -475,7 +474,6 @@ namespace pmx
|
||||||
|
|
||||||
void PmxSoftBody::Read(std::istream * /*stream*/, PmxSetting * /*setting*/)
|
void PmxSoftBody::Read(std::istream * /*stream*/, PmxSetting * /*setting*/)
|
||||||
{
|
{
|
||||||
// 未実装
|
|
||||||
std::cerr << "Not Implemented Exception" << std::endl;
|
std::cerr << "Not Implemented Exception" << std::endl;
|
||||||
throw DeadlyImportError("MMD: Not Implemented Exception");
|
throw DeadlyImportError("MMD: Not Implemented Exception");
|
||||||
}
|
}
|
||||||
|
@ -511,7 +509,6 @@ namespace pmx
|
||||||
|
|
||||||
void PmxModel::Read(std::istream *stream)
|
void PmxModel::Read(std::istream *stream)
|
||||||
{
|
{
|
||||||
// マジック
|
|
||||||
char magic[4];
|
char magic[4];
|
||||||
stream->read((char*) magic, sizeof(char) * 4);
|
stream->read((char*) magic, sizeof(char) * 4);
|
||||||
if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20)
|
if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20)
|
||||||
|
@ -519,23 +516,20 @@ namespace pmx
|
||||||
std::cerr << "invalid magic number." << std::endl;
|
std::cerr << "invalid magic number." << std::endl;
|
||||||
throw DeadlyImportError("MMD: invalid magic number.");
|
throw DeadlyImportError("MMD: invalid magic number.");
|
||||||
}
|
}
|
||||||
// バージョン
|
|
||||||
stream->read((char*) &version, sizeof(float));
|
stream->read((char*) &version, sizeof(float));
|
||||||
if (version != 2.0f && version != 2.1f)
|
if (version != 2.0f && version != 2.1f)
|
||||||
{
|
{
|
||||||
std::cerr << "this is not ver2.0 or ver2.1 but " << version << "." << std::endl;
|
std::cerr << "this is not ver2.0 or ver2.1 but " << version << "." << std::endl;
|
||||||
throw DeadlyImportError("MMD: this is not ver2.0 or ver2.1 but " + to_string(version));
|
throw DeadlyImportError("MMD: this is not ver2.0 or ver2.1 but " + to_string(version));
|
||||||
}
|
}
|
||||||
// ファイル設定
|
|
||||||
this->setting.Read(stream);
|
this->setting.Read(stream);
|
||||||
|
|
||||||
// モデル情報
|
|
||||||
this->model_name = ReadString(stream, setting.encoding);
|
this->model_name = ReadString(stream, setting.encoding);
|
||||||
this->model_english_name = ReadString(stream, setting.encoding);
|
this->model_english_name = ReadString(stream, setting.encoding);
|
||||||
this->model_comment = ReadString(stream, setting.encoding);
|
this->model_comment = ReadString(stream, setting.encoding);
|
||||||
this->model_english_comment = ReadString(stream, setting.encoding);
|
this->model_english_comment = ReadString(stream, setting.encoding);
|
||||||
|
|
||||||
// 頂点
|
// read vertices
|
||||||
stream->read((char*) &vertex_count, sizeof(int));
|
stream->read((char*) &vertex_count, sizeof(int));
|
||||||
this->vertices = mmd::make_unique<PmxVertex []>(vertex_count);
|
this->vertices = mmd::make_unique<PmxVertex []>(vertex_count);
|
||||||
for (int i = 0; i < vertex_count; i++)
|
for (int i = 0; i < vertex_count; i++)
|
||||||
|
@ -543,7 +537,7 @@ namespace pmx
|
||||||
vertices[i].Read(stream, &setting);
|
vertices[i].Read(stream, &setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 面
|
// read indices
|
||||||
stream->read((char*) &index_count, sizeof(int));
|
stream->read((char*) &index_count, sizeof(int));
|
||||||
this->indices = mmd::make_unique<int []>(index_count);
|
this->indices = mmd::make_unique<int []>(index_count);
|
||||||
for (int i = 0; i < index_count; i++)
|
for (int i = 0; i < index_count; i++)
|
||||||
|
@ -551,7 +545,7 @@ namespace pmx
|
||||||
this->indices[i] = ReadIndex(stream, setting.vertex_index_size);
|
this->indices[i] = ReadIndex(stream, setting.vertex_index_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// テクスチャ
|
// read texture names
|
||||||
stream->read((char*) &texture_count, sizeof(int));
|
stream->read((char*) &texture_count, sizeof(int));
|
||||||
this->textures = mmd::make_unique<std::string []>(texture_count);
|
this->textures = mmd::make_unique<std::string []>(texture_count);
|
||||||
for (int i = 0; i < texture_count; i++)
|
for (int i = 0; i < texture_count; i++)
|
||||||
|
@ -559,7 +553,7 @@ namespace pmx
|
||||||
this->textures[i] = ReadString(stream, setting.encoding);
|
this->textures[i] = ReadString(stream, setting.encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
// マテリアル
|
// read materials
|
||||||
stream->read((char*) &material_count, sizeof(int));
|
stream->read((char*) &material_count, sizeof(int));
|
||||||
this->materials = mmd::make_unique<PmxMaterial []>(material_count);
|
this->materials = mmd::make_unique<PmxMaterial []>(material_count);
|
||||||
for (int i = 0; i < material_count; i++)
|
for (int i = 0; i < material_count; i++)
|
||||||
|
@ -567,7 +561,7 @@ namespace pmx
|
||||||
this->materials[i].Read(stream, &setting);
|
this->materials[i].Read(stream, &setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ボーン
|
// read bones
|
||||||
stream->read((char*) &this->bone_count, sizeof(int));
|
stream->read((char*) &this->bone_count, sizeof(int));
|
||||||
this->bones = mmd::make_unique<PmxBone []>(this->bone_count);
|
this->bones = mmd::make_unique<PmxBone []>(this->bone_count);
|
||||||
for (int i = 0; i < this->bone_count; i++)
|
for (int i = 0; i < this->bone_count; i++)
|
||||||
|
@ -575,7 +569,7 @@ namespace pmx
|
||||||
this->bones[i].Read(stream, &setting);
|
this->bones[i].Read(stream, &setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// モーフ
|
// read morphs
|
||||||
stream->read((char*) &this->morph_count, sizeof(int));
|
stream->read((char*) &this->morph_count, sizeof(int));
|
||||||
this->morphs = mmd::make_unique<PmxMorph []>(this->morph_count);
|
this->morphs = mmd::make_unique<PmxMorph []>(this->morph_count);
|
||||||
for (int i = 0; i < this->morph_count; i++)
|
for (int i = 0; i < this->morph_count; i++)
|
||||||
|
@ -583,7 +577,7 @@ namespace pmx
|
||||||
this->morphs[i].Read(stream, &setting);
|
this->morphs[i].Read(stream, &setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表示枠
|
// read display frames
|
||||||
stream->read((char*) &this->frame_count, sizeof(int));
|
stream->read((char*) &this->frame_count, sizeof(int));
|
||||||
this->frames = mmd::make_unique<PmxFrame []>(this->frame_count);
|
this->frames = mmd::make_unique<PmxFrame []>(this->frame_count);
|
||||||
for (int i = 0; i < this->frame_count; i++)
|
for (int i = 0; i < this->frame_count; i++)
|
||||||
|
@ -591,7 +585,7 @@ namespace pmx
|
||||||
this->frames[i].Read(stream, &setting);
|
this->frames[i].Read(stream, &setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 剛体
|
// read rigid bodies
|
||||||
stream->read((char*) &this->rigid_body_count, sizeof(int));
|
stream->read((char*) &this->rigid_body_count, sizeof(int));
|
||||||
this->rigid_bodies = mmd::make_unique<PmxRigidBody []>(this->rigid_body_count);
|
this->rigid_bodies = mmd::make_unique<PmxRigidBody []>(this->rigid_body_count);
|
||||||
for (int i = 0; i < this->rigid_body_count; i++)
|
for (int i = 0; i < this->rigid_body_count; i++)
|
||||||
|
@ -599,7 +593,7 @@ namespace pmx
|
||||||
this->rigid_bodies[i].Read(stream, &setting);
|
this->rigid_bodies[i].Read(stream, &setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ジョイント
|
// read joints
|
||||||
stream->read((char*) &this->joint_count, sizeof(int));
|
stream->read((char*) &this->joint_count, sizeof(int));
|
||||||
this->joints = mmd::make_unique<PmxJoint []>(this->joint_count);
|
this->joints = mmd::make_unique<PmxJoint []>(this->joint_count);
|
||||||
for (int i = 0; i < this->joint_count; i++)
|
for (int i = 0; i < this->joint_count; i++)
|
||||||
|
|
|
@ -251,7 +251,7 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model* pModel, aiScene
|
||||||
|
|
||||||
std::unique_ptr<aiMesh> mesh( new aiMesh );
|
std::unique_ptr<aiMesh> mesh( new aiMesh );
|
||||||
mesh->mPrimitiveTypes = aiPrimitiveType_POINT;
|
mesh->mPrimitiveTypes = aiPrimitiveType_POINT;
|
||||||
unsigned int n = pModel->m_Vertices.size();
|
unsigned int n = (unsigned int)pModel->m_Vertices.size();
|
||||||
mesh->mNumVertices = n;
|
mesh->mNumVertices = n;
|
||||||
|
|
||||||
mesh->mVertices = new aiVector3D[n];
|
mesh->mVertices = new aiVector3D[n];
|
||||||
|
|
|
@ -67,20 +67,22 @@ namespace Assimp {
|
||||||
class OptimizeMeshesProcess : public BaseProcess
|
class OptimizeMeshesProcess : public BaseProcess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// @brief The class constructor.
|
||||||
OptimizeMeshesProcess();
|
OptimizeMeshesProcess();
|
||||||
|
|
||||||
|
/// @brief The class destcructor,
|
||||||
~OptimizeMeshesProcess();
|
~OptimizeMeshesProcess();
|
||||||
|
|
||||||
|
|
||||||
/** @brief Internal utility to store additional mesh info
|
/** @brief Internal utility to store additional mesh info
|
||||||
*/
|
*/
|
||||||
struct MeshInfo
|
struct MeshInfo {
|
||||||
{
|
MeshInfo() AI_NO_EXCEPT
|
||||||
MeshInfo()
|
|
||||||
: instance_cnt(0)
|
: instance_cnt(0)
|
||||||
, vertex_format(0)
|
, vertex_format(0)
|
||||||
, output_id (0xffffffff)
|
, output_id(0xffffffff) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! Number of times this mesh is referenced
|
//! Number of times this mesh is referenced
|
||||||
unsigned int instance_cnt;
|
unsigned int instance_cnt;
|
||||||
|
|
|
@ -209,7 +209,7 @@ enum EElementSemantic {
|
||||||
class Property {
|
class Property {
|
||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
Property()
|
Property() AI_NO_EXCEPT
|
||||||
: eType (EDT_Int)
|
: eType (EDT_Int)
|
||||||
, Semantic()
|
, Semantic()
|
||||||
, bIsList(false)
|
, bIsList(false)
|
||||||
|
@ -257,7 +257,7 @@ public:
|
||||||
class Element {
|
class Element {
|
||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
Element()
|
Element() AI_NO_EXCEPT
|
||||||
: eSemantic (EEST_INVALID)
|
: eSemantic (EEST_INVALID)
|
||||||
, NumOccur(0) {
|
, NumOccur(0) {
|
||||||
// empty
|
// empty
|
||||||
|
@ -297,8 +297,9 @@ class PropertyInstance
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
PropertyInstance ()
|
PropertyInstance() AI_NO_EXCEPT {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
union ValueUnion
|
union ValueUnion
|
||||||
{
|
{
|
||||||
|
@ -356,13 +357,13 @@ public:
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Class for an element instance in a PLY file
|
/** \brief Class for an element instance in a PLY file
|
||||||
*/
|
*/
|
||||||
class ElementInstance
|
class ElementInstance {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
ElementInstance ()
|
ElementInstance() AI_NO_EXCEPT
|
||||||
{}
|
: alProperties() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! List of all parsed properties
|
//! List of all parsed properties
|
||||||
std::vector< PropertyInstance > alProperties;
|
std::vector< PropertyInstance > alProperties;
|
||||||
|
@ -386,8 +387,10 @@ class ElementInstanceList
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
ElementInstanceList ()
|
ElementInstanceList() AI_NO_EXCEPT
|
||||||
{}
|
: alInstances() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! List of all element instances
|
//! List of all element instances
|
||||||
std::vector< ElementInstance > alInstances;
|
std::vector< ElementInstance > alInstances;
|
||||||
|
@ -411,8 +414,11 @@ class DOM
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
DOM()
|
DOM() AI_NO_EXCEPT
|
||||||
{}
|
: alElements()
|
||||||
|
, alElementData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Contains all elements of the file format
|
//! Contains all elements of the file format
|
||||||
|
|
|
@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define ASSIMP_Q3BSPFILEDATA_H_INC
|
#define ASSIMP_Q3BSPFILEDATA_H_INC
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string.h> //memset
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -77,25 +77,21 @@ struct sQ3BSPHeader {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Describes an entry.
|
/// Describes an entry.
|
||||||
struct sQ3BSPLump
|
struct sQ3BSPLump {
|
||||||
{
|
|
||||||
int iOffset; ///< Offset from start pointer of file
|
int iOffset; ///< Offset from start pointer of file
|
||||||
int iSize; ///< Size of part
|
int iSize; ///< Size of part
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vec2f
|
struct vec2f {
|
||||||
{
|
|
||||||
float x,y;
|
float x,y;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vec3f
|
struct vec3f {
|
||||||
{
|
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Vertex of a Q3 level
|
/// Vertex of a Q3 level
|
||||||
struct sQ3BSPVertex
|
struct sQ3BSPVertex {
|
||||||
{
|
|
||||||
vec3f vPosition; ///< Position of vertex
|
vec3f vPosition; ///< Position of vertex
|
||||||
vec2f vTexCoord; ///< (u,v) Texturecoordinate of detailtexture
|
vec2f vTexCoord; ///< (u,v) Texturecoordinate of detailtexture
|
||||||
vec2f vLightmap; ///< (u,v) Texturecoordinate of lightmap
|
vec2f vLightmap; ///< (u,v) Texturecoordinate of lightmap
|
||||||
|
@ -104,8 +100,7 @@ struct sQ3BSPVertex
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A face in bsp format info
|
/// A face in bsp format info
|
||||||
struct sQ3BSPFace
|
struct sQ3BSPFace {
|
||||||
{
|
|
||||||
int iTextureID; ///< Index in texture array
|
int iTextureID; ///< Index in texture array
|
||||||
int iEffect; ///< Index in effect array (-1 = no effect)
|
int iEffect; ///< Index in effect array (-1 = no effect)
|
||||||
int iType; ///< 1=Polygon, 2=Patch, 3=Mesh, 4=Billboard
|
int iType; ///< 1=Polygon, 2=Patch, 3=Mesh, 4=Billboard
|
||||||
|
|
|
@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "Q3BSPFileParser.h"
|
#include "Q3BSPFileParser.h"
|
||||||
#include "Q3BSPFileData.h"
|
#include "Q3BSPFileData.h"
|
||||||
|
|
||||||
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||||
# include <zlib.h>
|
# include <zlib.h>
|
||||||
#else
|
#else
|
||||||
|
@ -82,39 +84,39 @@ using namespace Q3BSP;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Local function to create a material key name.
|
// Local function to create a material key name.
|
||||||
static void createKey( int id1, int id2, std::string &rKey )
|
static void createKey( int id1, int id2, std::string &key ) {
|
||||||
{
|
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << id1 << "." << id2;
|
str << id1 << "." << id2;
|
||||||
rKey = str.str();
|
key = str.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Local function to extract the texture ids from a material key-name.
|
// Local function to extract the texture ids from a material key-name.
|
||||||
static void extractIds( const std::string &rKey, int &rId1, int &rId2 )
|
static void extractIds( const std::string &key, int &id1, int &id2 ) {
|
||||||
{
|
id1 = -1;
|
||||||
rId1 = -1;
|
id2 = -1;
|
||||||
rId2 = -1;
|
if (key.empty()) {
|
||||||
if ( rKey.empty() )
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::string::size_type pos = rKey.find( "." );
|
const std::string::size_type pos = key.find( "." );
|
||||||
if ( std::string::npos == pos )
|
if (std::string::npos == pos) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::string tmp1 = rKey.substr( 0, pos );
|
std::string tmp1 = key.substr( 0, pos );
|
||||||
std::string tmp2 = rKey.substr( pos + 1, rKey.size() - pos - 1 );
|
std::string tmp2 = key.substr( pos + 1, key.size() - pos - 1 );
|
||||||
rId1 = atoi( tmp1.c_str() );
|
id1 = atoi( tmp1.c_str() );
|
||||||
rId2 = atoi( tmp2.c_str() );
|
id2 = atoi( tmp2.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Local helper function to normalize filenames.
|
// Local helper function to normalize filenames.
|
||||||
static void normalizePathName( const std::string &rPath, std::string &rNormalizedPath )
|
static void normalizePathName( const std::string &rPath, std::string &normalizedPath ) {
|
||||||
{
|
normalizedPath = "";
|
||||||
rNormalizedPath = "";
|
if (rPath.empty()) {
|
||||||
if ( rPath.empty() )
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::string sep = "\\";
|
std::string sep = "\\";
|
||||||
|
@ -124,14 +126,11 @@ static void normalizePathName( const std::string &rPath, std::string &rNormalize
|
||||||
|
|
||||||
static const unsigned int numDelimiters = 2;
|
static const unsigned int numDelimiters = 2;
|
||||||
const char delimiters[ numDelimiters ] = { '/', '\\' };
|
const char delimiters[ numDelimiters ] = { '/', '\\' };
|
||||||
rNormalizedPath = rPath;
|
normalizedPath = rPath;
|
||||||
for (const char delimiter : delimiters)
|
for (const char delimiter : delimiters) {
|
||||||
{
|
for ( size_t j=0; j<normalizedPath.size(); ++j ) {
|
||||||
for ( size_t j=0; j<rNormalizedPath.size(); j++ )
|
if ( normalizedPath[j] == delimiter ) {
|
||||||
{
|
normalizedPath[ j ] = sep[ 0 ];
|
||||||
if ( rNormalizedPath[j] == delimiter )
|
|
||||||
{
|
|
||||||
rNormalizedPath[ j ] = sep[ 0 ];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,20 +138,19 @@ static void normalizePathName( const std::string &rPath, std::string &rNormalize
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor.
|
// Constructor.
|
||||||
Q3BSPFileImporter::Q3BSPFileImporter() :
|
Q3BSPFileImporter::Q3BSPFileImporter()
|
||||||
m_pCurrentMesh( NULL ),
|
: m_pCurrentMesh( nullptr )
|
||||||
m_pCurrentFace( NULL ),
|
, m_pCurrentFace(nullptr)
|
||||||
m_MaterialLookupMap(),
|
, m_MaterialLookupMap()
|
||||||
mTextures()
|
, mTextures() {
|
||||||
{
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor.
|
// Destructor.
|
||||||
Q3BSPFileImporter::~Q3BSPFileImporter() {
|
Q3BSPFileImporter::~Q3BSPFileImporter() {
|
||||||
m_pCurrentMesh = NULL;
|
m_pCurrentMesh = nullptr;
|
||||||
m_pCurrentFace = NULL;
|
m_pCurrentFace = nullptr;
|
||||||
|
|
||||||
// Clear face-to-material map
|
// Clear face-to-material map
|
||||||
for ( FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it ) {
|
for ( FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it ) {
|
||||||
|
@ -166,92 +164,80 @@ Q3BSPFileImporter::~Q3BSPFileImporter() {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns true, if the loader can read this.
|
// Returns true, if the loader can read this.
|
||||||
bool Q3BSPFileImporter::CanRead( const std::string& rFile, IOSystem* /*pIOHandler*/, bool checkSig ) const
|
bool Q3BSPFileImporter::CanRead( const std::string& rFile, IOSystem* /*pIOHandler*/, bool checkSig ) const {
|
||||||
{
|
|
||||||
if(!checkSig) {
|
if(!checkSig) {
|
||||||
return SimpleExtensionCheck( rFile, "pk3", "bsp" );
|
return SimpleExtensionCheck( rFile, "pk3", "bsp" );
|
||||||
}
|
}
|
||||||
// TODO perhaps add keyword based detection
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Adds extensions.
|
// Adds extensions.
|
||||||
const aiImporterDesc* Q3BSPFileImporter::GetInfo () const
|
const aiImporterDesc* Q3BSPFileImporter::GetInfo () const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Import method.
|
// Import method.
|
||||||
void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene* pScene, IOSystem* pIOHandler)
|
void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene* scene, IOSystem* ioHandler) {
|
||||||
{
|
Q3BSPZipArchive Archive( ioHandler, rFile );
|
||||||
Q3BSPZipArchive Archive( pIOHandler, rFile );
|
if ( !Archive.isOpen() ) {
|
||||||
if ( !Archive.isOpen() )
|
|
||||||
{
|
|
||||||
throw DeadlyImportError( "Failed to open file " + rFile + "." );
|
throw DeadlyImportError( "Failed to open file " + rFile + "." );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string archiveName( "" ), mapName( "" );
|
std::string archiveName( "" ), mapName( "" );
|
||||||
separateMapName( rFile, archiveName, mapName );
|
separateMapName( rFile, archiveName, mapName );
|
||||||
|
|
||||||
if ( mapName.empty() )
|
if ( mapName.empty() ) {
|
||||||
{
|
if ( !findFirstMapInArchive( Archive, mapName ) ) {
|
||||||
if ( !findFirstMapInArchive( Archive, mapName ) )
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Q3BSPFileParser fileParser( mapName, &Archive );
|
Q3BSPFileParser fileParser( mapName, &Archive );
|
||||||
Q3BSPModel *pBSPModel = fileParser.getModel();
|
Q3BSPModel *pBSPModel = fileParser.getModel();
|
||||||
if ( NULL != pBSPModel )
|
if ( nullptr != pBSPModel ) {
|
||||||
{
|
CreateDataFromImport( pBSPModel, scene, &Archive );
|
||||||
CreateDataFromImport( pBSPModel, pScene, &Archive );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Separates the map name from the import name.
|
// Separates the map name from the import name.
|
||||||
void Q3BSPFileImporter::separateMapName( const std::string &rImportName, std::string &rArchiveName,
|
void Q3BSPFileImporter::separateMapName( const std::string &importName, std::string &archiveName, std::string &mapName ) {
|
||||||
std::string &rMapName )
|
archiveName = "";
|
||||||
{
|
mapName = "";
|
||||||
rArchiveName = "";
|
if (importName.empty()) {
|
||||||
rMapName = "";
|
|
||||||
if ( rImportName.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::string::size_type pos = rImportName.rfind( "," );
|
|
||||||
if ( std::string::npos == pos )
|
|
||||||
{
|
|
||||||
rArchiveName = rImportName;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rArchiveName = rImportName.substr( 0, pos );
|
const std::string::size_type pos = importName.rfind( "," );
|
||||||
rMapName = rImportName.substr( pos, rImportName.size() - pos - 1 );
|
if ( std::string::npos == pos ) {
|
||||||
|
archiveName = importName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
archiveName = importName.substr( 0, pos );
|
||||||
|
mapName = importName.substr( pos, importName.size() - pos - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns the first map in the map archive.
|
// Returns the first map in the map archive.
|
||||||
bool Q3BSPFileImporter::findFirstMapInArchive( Q3BSPZipArchive &rArchive, std::string &rMapName )
|
bool Q3BSPFileImporter::findFirstMapInArchive( Q3BSPZipArchive &bspArchive, std::string &mapName ) {
|
||||||
{
|
mapName = "";
|
||||||
rMapName = "";
|
|
||||||
std::vector<std::string> fileList;
|
std::vector<std::string> fileList;
|
||||||
rArchive.getFileList( fileList );
|
bspArchive.getFileList( fileList );
|
||||||
if ( fileList.empty() )
|
if (fileList.empty()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for ( std::vector<std::string>::iterator it = fileList.begin(); it != fileList.end();
|
std::vector<std::string>::iterator it( fileList.begin() );
|
||||||
++it )
|
for ( ; it != fileList.end(); ++it ) {
|
||||||
{
|
const std::string::size_type pos = (*it).find( "maps/" );
|
||||||
std::string::size_type pos = (*it).find( "maps/" );
|
if ( std::string::npos != pos ) {
|
||||||
if ( std::string::npos != pos )
|
|
||||||
{
|
|
||||||
std::string::size_type extPos = (*it).find( ".bsp" );
|
std::string::size_type extPos = (*it).find( ".bsp" );
|
||||||
if ( std::string::npos != extPos )
|
if ( std::string::npos != extPos ) {
|
||||||
{
|
mapName = *it;
|
||||||
rMapName = *it;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,14 +249,13 @@ bool Q3BSPFileImporter::findFirstMapInArchive( Q3BSPZipArchive &rArchive, std::s
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates the assimp specific data.
|
// Creates the assimp specific data.
|
||||||
void Q3BSPFileImporter::CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
|
void Q3BSPFileImporter::CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
|
||||||
Q3BSPZipArchive *pArchive )
|
Q3BSPZipArchive *pArchive ) {
|
||||||
{
|
if (nullptr == pModel || nullptr == pScene) {
|
||||||
if ( NULL == pModel || NULL == pScene )
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pScene->mRootNode = new aiNode;
|
pScene->mRootNode = new aiNode;
|
||||||
if ( !pModel->m_ModelName.empty() )
|
if ( !pModel->m_ModelName.empty() ) {
|
||||||
{
|
|
||||||
pScene->mRootNode->mName.Set( pModel->m_ModelName );
|
pScene->mRootNode->mName.Set( pModel->m_ModelName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,47 +272,34 @@ void Q3BSPFileImporter::CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, a
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates all assimp nodes.
|
// Creates all assimp nodes.
|
||||||
void Q3BSPFileImporter::CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
|
void Q3BSPFileImporter::CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
|
||||||
aiNode *pParent )
|
aiNode *pParent ) {
|
||||||
{
|
if ( nullptr == pModel ) {
|
||||||
ai_assert( NULL != pModel );
|
|
||||||
if ( NULL == pModel )
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int matIdx = 0;
|
unsigned int matIdx( 0 );
|
||||||
std::vector<aiMesh*> MeshArray;
|
std::vector<aiMesh*> MeshArray;
|
||||||
std::vector<aiNode*> NodeArray;
|
std::vector<aiNode*> NodeArray;
|
||||||
for ( FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it )
|
for ( FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it ) {
|
||||||
{
|
|
||||||
std::vector<Q3BSP::sQ3BSPFace*> *pArray = (*it).second;
|
std::vector<Q3BSP::sQ3BSPFace*> *pArray = (*it).second;
|
||||||
size_t numVerts = countData( *pArray );
|
size_t numVerts = countData( *pArray );
|
||||||
if ( 0 != numVerts )
|
if ( 0 != numVerts ) {
|
||||||
{
|
aiMesh *pMesh( nullptr );
|
||||||
aiMesh* pMesh = new aiMesh;
|
aiNode *pNode = CreateTopology( pModel, matIdx, *pArray, &pMesh );
|
||||||
aiNode *pNode = CreateTopology( pModel, matIdx, *pArray, pMesh );
|
if ( nullptr != pNode ) {
|
||||||
if ( NULL != pNode )
|
|
||||||
{
|
|
||||||
NodeArray.push_back( pNode );
|
NodeArray.push_back( pNode );
|
||||||
MeshArray.push_back( pMesh );
|
MeshArray.push_back( pMesh );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
delete pMesh;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
matIdx++;
|
matIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pScene->mNumMeshes = static_cast<unsigned int>( MeshArray.size() );
|
pScene->mNumMeshes = static_cast<unsigned int>( MeshArray.size() );
|
||||||
if ( pScene->mNumMeshes > 0 )
|
if ( pScene->mNumMeshes > 0 ) {
|
||||||
{
|
|
||||||
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
|
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
|
||||||
for ( size_t i = 0; i < MeshArray.size(); i++ )
|
for ( size_t i = 0; i < MeshArray.size(); i++ ) {
|
||||||
{
|
|
||||||
aiMesh *pMesh = MeshArray[ i ];
|
aiMesh *pMesh = MeshArray[ i ];
|
||||||
if ( NULL != pMesh )
|
if ( nullptr != pMesh ) {
|
||||||
{
|
|
||||||
pScene->mMeshes[ i ] = pMesh;
|
pScene->mMeshes[ i ] = pMesh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,8 +307,7 @@ void Q3BSPFileImporter::CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* p
|
||||||
|
|
||||||
pParent->mNumChildren = static_cast<unsigned int>(MeshArray.size());
|
pParent->mNumChildren = static_cast<unsigned int>(MeshArray.size());
|
||||||
pParent->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren ];
|
pParent->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren ];
|
||||||
for ( size_t i=0; i<NodeArray.size(); i++ )
|
for ( size_t i=0; i<NodeArray.size(); i++ ) {
|
||||||
{
|
|
||||||
aiNode *pNode = NodeArray[ i ];
|
aiNode *pNode = NodeArray[ i ];
|
||||||
pNode->mParent = pParent;
|
pNode->mParent = pParent;
|
||||||
pParent->mChildren[ i ] = pNode;
|
pParent->mChildren[ i ] = pNode;
|
||||||
|
@ -346,54 +317,46 @@ void Q3BSPFileImporter::CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* p
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates the topology.
|
// Creates the topology.
|
||||||
aiNode *Q3BSPFileImporter::CreateTopology( const Q3BSP::Q3BSPModel *pModel,
|
aiNode *Q3BSPFileImporter::CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx,
|
||||||
unsigned int materialIdx,
|
std::vector<sQ3BSPFace*> &rArray, aiMesh **pMesh ) {
|
||||||
std::vector<sQ3BSPFace*> &rArray,
|
|
||||||
aiMesh* pMesh )
|
|
||||||
{
|
|
||||||
size_t numVerts = countData( rArray );
|
size_t numVerts = countData( rArray );
|
||||||
if ( 0 == numVerts )
|
if ( 0 == numVerts ) {
|
||||||
{
|
return nullptr;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t numFaces = countFaces( rArray );
|
size_t numFaces = countFaces( rArray );
|
||||||
if ( 0 == numFaces )
|
if ( 0 == numFaces ) {
|
||||||
{
|
return nullptr;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aiMesh *mesh = new aiMesh;
|
||||||
size_t numTriangles = countTriangles( rArray );
|
size_t numTriangles = countTriangles( rArray );
|
||||||
pMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||||
|
|
||||||
pMesh->mFaces = new aiFace[ numTriangles ];
|
mesh->mFaces = new aiFace[ numTriangles ];
|
||||||
pMesh->mNumFaces = static_cast<unsigned int>(numTriangles);
|
mesh->mNumFaces = static_cast<unsigned int>(numTriangles);
|
||||||
|
|
||||||
pMesh->mNumVertices = static_cast<unsigned int>(numVerts);
|
mesh->mNumVertices = static_cast<unsigned int>(numVerts);
|
||||||
pMesh->mVertices = new aiVector3D[ numVerts ];
|
mesh->mVertices = new aiVector3D[ numVerts ];
|
||||||
pMesh->mNormals = new aiVector3D[ numVerts ];
|
mesh->mNormals = new aiVector3D[ numVerts ];
|
||||||
pMesh->mTextureCoords[ 0 ] = new aiVector3D[ numVerts ];
|
mesh->mTextureCoords[ 0 ] = new aiVector3D[ numVerts ];
|
||||||
pMesh->mTextureCoords[ 1 ] = new aiVector3D[ numVerts ];
|
mesh->mTextureCoords[ 1 ] = new aiVector3D[ numVerts ];
|
||||||
pMesh->mMaterialIndex = materialIdx;
|
mesh->mMaterialIndex = materialIdx;
|
||||||
|
|
||||||
unsigned int faceIdx = 0;
|
unsigned int faceIdx = 0;
|
||||||
unsigned int vertIdx = 0;
|
unsigned int vertIdx = 0;
|
||||||
pMesh->mNumUVComponents[ 0 ] = 2;
|
mesh->mNumUVComponents[ 0 ] = 2;
|
||||||
pMesh->mNumUVComponents[ 1 ] = 2;
|
mesh->mNumUVComponents[ 1 ] = 2;
|
||||||
for ( std::vector<sQ3BSPFace*>::const_iterator it = rArray.begin(); it != rArray.end(); ++it )
|
for ( std::vector<sQ3BSPFace*>::const_iterator it = rArray.begin(); it != rArray.end(); ++it ) {
|
||||||
{
|
|
||||||
Q3BSP::sQ3BSPFace *pQ3BSPFace = *it;
|
Q3BSP::sQ3BSPFace *pQ3BSPFace = *it;
|
||||||
ai_assert( NULL != pQ3BSPFace );
|
ai_assert( NULL != pQ3BSPFace );
|
||||||
if ( NULL == pQ3BSPFace )
|
if ( nullptr == pQ3BSPFace ) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pQ3BSPFace->iNumOfFaceVerts > 0 )
|
if ( pQ3BSPFace->iNumOfFaceVerts > 0 ) {
|
||||||
{
|
if ( pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh ) {
|
||||||
if ( pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh )
|
createTriangleTopology( pModel, pQ3BSPFace, mesh, faceIdx, vertIdx );
|
||||||
{
|
|
||||||
createTriangleTopology( pModel, pQ3BSPFace, pMesh, faceIdx, vertIdx );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,79 +364,63 @@ aiNode *Q3BSPFileImporter::CreateTopology( const Q3BSP::Q3BSPModel *pModel,
|
||||||
aiNode *pNode = new aiNode;
|
aiNode *pNode = new aiNode;
|
||||||
pNode->mNumMeshes = 1;
|
pNode->mNumMeshes = 1;
|
||||||
pNode->mMeshes = new unsigned int[ 1 ];
|
pNode->mMeshes = new unsigned int[ 1 ];
|
||||||
|
*pMesh = mesh;
|
||||||
|
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates the triangle topology from a face array.
|
// Creates the triangle topology from a face array.
|
||||||
void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel,
|
void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, sQ3BSPFace *pQ3BSPFace,
|
||||||
Q3BSP::sQ3BSPFace *pQ3BSPFace,
|
aiMesh* pMesh, unsigned int &faceIdx, unsigned int &vertIdx ) {
|
||||||
aiMesh* pMesh,
|
ai_assert( faceIdx < pMesh->mNumFaces );
|
||||||
unsigned int &rFaceIdx,
|
|
||||||
unsigned int &rVertIdx )
|
|
||||||
{
|
|
||||||
ai_assert( rFaceIdx < pMesh->mNumFaces );
|
|
||||||
|
|
||||||
m_pCurrentFace = getNextFace( pMesh, rFaceIdx );
|
m_pCurrentFace = getNextFace( pMesh, faceIdx );
|
||||||
ai_assert( NULL != m_pCurrentFace );
|
if ( nullptr == m_pCurrentFace ) {
|
||||||
if ( NULL == m_pCurrentFace )
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pCurrentFace->mNumIndices = 3;
|
m_pCurrentFace->mNumIndices = 3;
|
||||||
m_pCurrentFace->mIndices = new unsigned int[ m_pCurrentFace->mNumIndices ];
|
m_pCurrentFace->mIndices = new unsigned int[ m_pCurrentFace->mNumIndices ];
|
||||||
|
|
||||||
size_t idx = 0;
|
size_t idx( 0 );
|
||||||
for ( size_t i = 0; i < (size_t) pQ3BSPFace->iNumOfFaceVerts; i++ )
|
for ( size_t i = 0; i < (size_t) pQ3BSPFace->iNumOfFaceVerts; ++i ) {
|
||||||
{
|
|
||||||
const size_t index = pQ3BSPFace->iVertexIndex + pModel->m_Indices[ pQ3BSPFace->iFaceVertexIndex + i ];
|
const size_t index = pQ3BSPFace->iVertexIndex + pModel->m_Indices[ pQ3BSPFace->iFaceVertexIndex + i ];
|
||||||
ai_assert( index < pModel->m_Vertices.size() );
|
if ( index >= pModel->m_Vertices.size() ) {
|
||||||
if ( index >= pModel->m_Vertices.size() )
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sQ3BSPVertex *pVertex = pModel->m_Vertices[ index ];
|
sQ3BSPVertex *pVertex = pModel->m_Vertices[ index ];
|
||||||
ai_assert( NULL != pVertex );
|
if ( nullptr == pVertex ) {
|
||||||
if ( NULL == pVertex )
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (idx > 2) {
|
||||||
pMesh->mVertices[ rVertIdx ].Set( pVertex->vPosition.x, pVertex->vPosition.y, pVertex->vPosition.z );
|
|
||||||
pMesh->mNormals[ rVertIdx ].Set( pVertex->vNormal.x, pVertex->vNormal.y, pVertex->vNormal.z );
|
|
||||||
|
|
||||||
pMesh->mTextureCoords[ 0 ][ rVertIdx ].Set( pVertex->vTexCoord.x, pVertex->vTexCoord.y, 0.0f );
|
|
||||||
pMesh->mTextureCoords[ 1 ][ rVertIdx ].Set( pVertex->vLightmap.x, pVertex->vLightmap.y, 0.0f );
|
|
||||||
|
|
||||||
ai_assert( m_pCurrentFace );
|
|
||||||
m_pCurrentFace->mIndices[ idx ] = rVertIdx;
|
|
||||||
rVertIdx++;
|
|
||||||
|
|
||||||
idx++;
|
|
||||||
if ( idx > 2 )
|
|
||||||
{
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
m_pCurrentFace = getNextFace( pMesh, rFaceIdx );
|
m_pCurrentFace = getNextFace(pMesh, faceIdx);
|
||||||
if ( NULL != m_pCurrentFace )
|
if (nullptr != m_pCurrentFace) {
|
||||||
{
|
|
||||||
m_pCurrentFace->mNumIndices = 3;
|
m_pCurrentFace->mNumIndices = 3;
|
||||||
m_pCurrentFace->mIndices = new unsigned int[3];
|
m_pCurrentFace->mIndices = new unsigned int[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pMesh->mVertices[ vertIdx ].Set( pVertex->vPosition.x, pVertex->vPosition.y, pVertex->vPosition.z );
|
||||||
|
pMesh->mNormals[ vertIdx ].Set( pVertex->vNormal.x, pVertex->vNormal.y, pVertex->vNormal.z );
|
||||||
|
|
||||||
|
pMesh->mTextureCoords[ 0 ][ vertIdx ].Set( pVertex->vTexCoord.x, pVertex->vTexCoord.y, 0.0f );
|
||||||
|
pMesh->mTextureCoords[ 1 ][ vertIdx ].Set( pVertex->vLightmap.x, pVertex->vLightmap.y, 0.0f );
|
||||||
|
|
||||||
|
m_pCurrentFace->mIndices[ idx ] = vertIdx;
|
||||||
|
vertIdx++;
|
||||||
|
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
rFaceIdx--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates all referenced materials.
|
// Creates all referenced materials.
|
||||||
void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
|
void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
|
||||||
Q3BSPZipArchive *pArchive )
|
Q3BSPZipArchive *pArchive ) {
|
||||||
{
|
if ( m_MaterialLookupMap.empty() ) {
|
||||||
if ( m_MaterialLookupMap.empty() )
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,11 +428,9 @@ void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScen
|
||||||
aiString aiMatName;
|
aiString aiMatName;
|
||||||
int textureId( -1 ), lightmapId( -1 );
|
int textureId( -1 ), lightmapId( -1 );
|
||||||
for ( FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end();
|
for ( FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end();
|
||||||
++it )
|
++it ) {
|
||||||
{
|
const std::string matName( it->first );
|
||||||
const std::string matName = (*it).first;
|
if ( matName.empty() ) {
|
||||||
if ( matName.empty() )
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,18 +441,16 @@ void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScen
|
||||||
extractIds( matName, textureId, lightmapId );
|
extractIds( matName, textureId, lightmapId );
|
||||||
|
|
||||||
// Adding the texture
|
// Adding the texture
|
||||||
if ( -1 != textureId )
|
if ( -1 != textureId ) {
|
||||||
{
|
|
||||||
sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ];
|
sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ];
|
||||||
if ( NULL != pTexture )
|
if ( nullptr != pTexture ) {
|
||||||
{
|
|
||||||
std::string tmp( "*" ), texName( "" );
|
std::string tmp( "*" ), texName( "" );
|
||||||
tmp += pTexture->strName;
|
tmp += pTexture->strName;
|
||||||
tmp += ".jpg";
|
tmp += ".jpg";
|
||||||
normalizePathName( tmp, texName );
|
normalizePathName( tmp, texName );
|
||||||
|
|
||||||
if ( !importTextureFromArchive( pModel, pArchive, pScene, pMatHelper, textureId ) )
|
if ( !importTextureFromArchive( pModel, pArchive, pScene, pMatHelper, textureId ) ) {
|
||||||
{
|
ASSIMP_LOG_ERROR("Cannot import texture from archive " + texName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,17 +469,16 @@ void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScen
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Counts the number of referenced vertices.
|
// Counts the number of referenced vertices.
|
||||||
size_t Q3BSPFileImporter::countData( const std::vector<sQ3BSPFace*> &rArray ) const
|
size_t Q3BSPFileImporter::countData( const std::vector<sQ3BSPFace*> &faceArray ) const {
|
||||||
{
|
size_t numVerts( 0 );
|
||||||
size_t numVerts = 0;
|
for ( std::vector<sQ3BSPFace*>::const_iterator it = faceArray.begin(); it != faceArray.end();
|
||||||
for ( std::vector<sQ3BSPFace*>::const_iterator it = rArray.begin(); it != rArray.end();
|
|
||||||
++it )
|
++it )
|
||||||
{
|
{
|
||||||
sQ3BSPFace *pQ3BSPFace = *it;
|
sQ3BSPFace *pQ3BSPFace = *it;
|
||||||
if ( pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh )
|
if ( pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh )
|
||||||
{
|
{
|
||||||
Q3BSP::sQ3BSPFace *pQ3BSPFace = *it;
|
Q3BSP::sQ3BSPFace *pQ3BSPFace = *it;
|
||||||
ai_assert( NULL != pQ3BSPFace );
|
ai_assert( nullptr != pQ3BSPFace );
|
||||||
numVerts += pQ3BSPFace->iNumOfFaceVerts;
|
numVerts += pQ3BSPFace->iNumOfFaceVerts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,8 +524,7 @@ size_t Q3BSPFileImporter::countTriangles( const std::vector<Q3BSP::sQ3BSPFace*>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates the faces-to-material map.
|
// Creates the faces-to-material map.
|
||||||
void Q3BSPFileImporter::createMaterialMap( const Q3BSP::Q3BSPModel *pModel )
|
void Q3BSPFileImporter::createMaterialMap( const Q3BSP::Q3BSPModel *pModel ) {
|
||||||
{
|
|
||||||
std::string key( "" );
|
std::string key( "" );
|
||||||
std::vector<sQ3BSPFace*> *pCurFaceArray = NULL;
|
std::vector<sQ3BSPFace*> *pCurFaceArray = NULL;
|
||||||
for ( size_t idx = 0; idx < pModel->m_Faces.size(); idx++ )
|
for ( size_t idx = 0; idx < pModel->m_Faces.size(); idx++ )
|
||||||
|
@ -593,8 +534,7 @@ void Q3BSPFileImporter::createMaterialMap( const Q3BSP::Q3BSPModel *pModel )
|
||||||
const int lightMapId = pQ3BSPFace->iLightmapID;
|
const int lightMapId = pQ3BSPFace->iLightmapID;
|
||||||
createKey( texId, lightMapId, key );
|
createKey( texId, lightMapId, key );
|
||||||
FaceMapIt it = m_MaterialLookupMap.find( key );
|
FaceMapIt it = m_MaterialLookupMap.find( key );
|
||||||
if ( m_MaterialLookupMap.end() == it )
|
if ( m_MaterialLookupMap.end() == it ) {
|
||||||
{
|
|
||||||
pCurFaceArray = new std::vector<Q3BSP::sQ3BSPFace*>;
|
pCurFaceArray = new std::vector<Q3BSP::sQ3BSPFace*>;
|
||||||
m_MaterialLookupMap[ key ] = pCurFaceArray;
|
m_MaterialLookupMap[ key ] = pCurFaceArray;
|
||||||
}
|
}
|
||||||
|
@ -602,8 +542,8 @@ void Q3BSPFileImporter::createMaterialMap( const Q3BSP::Q3BSPModel *pModel )
|
||||||
{
|
{
|
||||||
pCurFaceArray = (*it).second;
|
pCurFaceArray = (*it).second;
|
||||||
}
|
}
|
||||||
ai_assert( NULL != pCurFaceArray );
|
ai_assert( nullptr != pCurFaceArray );
|
||||||
if ( NULL != pCurFaceArray )
|
if (nullptr != pCurFaceArray )
|
||||||
{
|
{
|
||||||
pCurFaceArray->push_back( pQ3BSPFace );
|
pCurFaceArray->push_back( pQ3BSPFace );
|
||||||
}
|
}
|
||||||
|
@ -612,32 +552,31 @@ void Q3BSPFileImporter::createMaterialMap( const Q3BSP::Q3BSPModel *pModel )
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns the next face.
|
// Returns the next face.
|
||||||
aiFace *Q3BSPFileImporter::getNextFace( aiMesh *pMesh, unsigned int &rFaceIdx )
|
aiFace *Q3BSPFileImporter::getNextFace( aiMesh *mesh, unsigned int &faceIdx ) {
|
||||||
{
|
aiFace *face( nullptr );
|
||||||
aiFace *pFace( NULL );
|
if ( faceIdx < mesh->mNumFaces ) {
|
||||||
if ( rFaceIdx < pMesh->mNumFaces ) {
|
face = &mesh->mFaces[ faceIdx ];
|
||||||
pFace = &pMesh->mFaces[ rFaceIdx ];
|
++faceIdx;
|
||||||
rFaceIdx++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pFace;
|
return face;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports a texture file.
|
// Imports a texture file.
|
||||||
bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *pModel,
|
bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model,
|
||||||
Q3BSP::Q3BSPZipArchive *pArchive, aiScene*,
|
Q3BSP::Q3BSPZipArchive *archive, aiScene*,
|
||||||
aiMaterial *pMatHelper, int textureId ) {
|
aiMaterial *pMatHelper, int textureId ) {
|
||||||
if ( NULL == pArchive || NULL == pMatHelper ) {
|
if (nullptr == archive || nullptr == pMatHelper ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( textureId < 0 || textureId >= static_cast<int>( pModel->m_Textures.size() ) ) {
|
if ( textureId < 0 || textureId >= static_cast<int>( model->m_Textures.size() ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool res = true;
|
bool res = true;
|
||||||
sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ];
|
sQ3BSPTexture *pTexture = model->m_Textures[ textureId ];
|
||||||
if ( !pTexture ) {
|
if ( !pTexture ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -647,8 +586,8 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *pMode
|
||||||
supportedExtensions.push_back( ".png" );
|
supportedExtensions.push_back( ".png" );
|
||||||
supportedExtensions.push_back( ".tga" );
|
supportedExtensions.push_back( ".tga" );
|
||||||
std::string textureName, ext;
|
std::string textureName, ext;
|
||||||
if ( expandFile( pArchive, pTexture->strName, supportedExtensions, textureName, ext ) ) {
|
if ( expandFile( archive, pTexture->strName, supportedExtensions, textureName, ext ) ) {
|
||||||
IOStream *pTextureStream = pArchive->Open( textureName.c_str() );
|
IOStream *pTextureStream = archive->Open( textureName.c_str() );
|
||||||
if ( pTextureStream ) {
|
if ( pTextureStream ) {
|
||||||
size_t texSize = pTextureStream->FileSize();
|
size_t texSize = pTextureStream->FileSize();
|
||||||
aiTexture *pTexture = new aiTexture;
|
aiTexture *pTexture = new aiTexture;
|
||||||
|
@ -669,7 +608,7 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *pMode
|
||||||
name.data[ 0 ] = '*';
|
name.data[ 0 ] = '*';
|
||||||
name.length = 1 + ASSIMP_itoa10( name.data + 1, static_cast<unsigned int>(MAXLEN-1), static_cast<int32_t>(mTextures.size()) );
|
name.length = 1 + ASSIMP_itoa10( name.data + 1, static_cast<unsigned int>(MAXLEN-1), static_cast<int32_t>(mTextures.size()) );
|
||||||
|
|
||||||
pArchive->Close( pTextureStream );
|
archive->Close( pTextureStream );
|
||||||
|
|
||||||
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
|
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
|
||||||
mTextures.push_back( pTexture );
|
mTextures.push_back( pTexture );
|
||||||
|
@ -691,19 +630,16 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *pMode
|
||||||
bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
|
bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
|
||||||
aiMaterial *pMatHelper, int lightmapId )
|
aiMaterial *pMatHelper, int lightmapId )
|
||||||
{
|
{
|
||||||
if ( NULL == pModel || NULL == pScene || NULL == pMatHelper )
|
if (nullptr == pModel || nullptr == pScene || nullptr == pMatHelper ) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( lightmapId < 0 || lightmapId >= static_cast<int>( pModel->m_Lightmaps.size() ) )
|
if ( lightmapId < 0 || lightmapId >= static_cast<int>( pModel->m_Lightmaps.size() ) ) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sQ3BSPLightmap *pLightMap = pModel->m_Lightmaps[ lightmapId ];
|
sQ3BSPLightmap *pLightMap = pModel->m_Lightmaps[ lightmapId ];
|
||||||
if ( NULL == pLightMap )
|
if (nullptr == pLightMap ) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,8 +651,7 @@ bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene
|
||||||
|
|
||||||
::memcpy( pTexture->pcData, pLightMap->bLMapData, pTexture->mWidth );
|
::memcpy( pTexture->pcData, pLightMap->bLMapData, pTexture->mWidth );
|
||||||
size_t p = 0;
|
size_t p = 0;
|
||||||
for ( size_t i = 0; i < CE_BSP_LIGHTMAPWIDTH * CE_BSP_LIGHTMAPHEIGHT; ++i )
|
for ( size_t i = 0; i < CE_BSP_LIGHTMAPWIDTH * CE_BSP_LIGHTMAPHEIGHT; ++i ) {
|
||||||
{
|
|
||||||
pTexture->pcData[ i ].r = pLightMap->bLMapData[ p++ ];
|
pTexture->pcData[ i ].r = pLightMap->bLMapData[ p++ ];
|
||||||
pTexture->pcData[ i ].g = pLightMap->bLMapData[ p++ ];
|
pTexture->pcData[ i ].g = pLightMap->bLMapData[ p++ ];
|
||||||
pTexture->pcData[ i ].b = pLightMap->bLMapData[ p++ ];
|
pTexture->pcData[ i ].b = pLightMap->bLMapData[ p++ ];
|
||||||
|
@ -733,7 +668,6 @@ bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Will search for a supported extension.
|
// Will search for a supported extension.
|
||||||
bool Q3BSPFileImporter::expandFile( Q3BSP::Q3BSPZipArchive *pArchive, const std::string &rFilename,
|
bool Q3BSPFileImporter::expandFile( Q3BSP::Q3BSPZipArchive *pArchive, const std::string &rFilename,
|
||||||
|
|
|
@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/BaseImporter.h>
|
#include <assimp/BaseImporter.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct aiMesh;
|
struct aiMesh;
|
||||||
struct aiNode;
|
struct aiNode;
|
||||||
|
@ -53,6 +54,7 @@ struct aiMaterial;
|
||||||
struct aiTexture;
|
struct aiTexture;
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
namespace Q3BSP {
|
namespace Q3BSP {
|
||||||
class Q3BSPZipArchive;
|
class Q3BSPZipArchive;
|
||||||
struct Q3BSPModel;
|
struct Q3BSPModel;
|
||||||
|
@ -71,12 +73,11 @@ public:
|
||||||
/// @brief Destructor.
|
/// @brief Destructor.
|
||||||
~Q3BSPFileImporter();
|
~Q3BSPFileImporter();
|
||||||
|
|
||||||
public:
|
|
||||||
/// @brief Returns whether the class can handle the format of the given file.
|
/// @brief Returns whether the class can handle the format of the given file.
|
||||||
/// @remark See BaseImporter::CanRead() for details.
|
/// @remark See BaseImporter::CanRead() for details.
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const;
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*> FaceMap;
|
typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*> FaceMap;
|
||||||
typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>* >::iterator FaceMapIt;
|
typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>* >::iterator FaceMapIt;
|
||||||
typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*>::const_iterator FaceMapConstIt;
|
typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*>::const_iterator FaceMapConstIt;
|
||||||
|
@ -88,7 +89,7 @@ private:
|
||||||
void CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, Q3BSP::Q3BSPZipArchive *pArchive );
|
void CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, Q3BSP::Q3BSPZipArchive *pArchive );
|
||||||
void CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, aiNode *pParent );
|
void CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, aiNode *pParent );
|
||||||
aiNode *CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx,
|
aiNode *CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx,
|
||||||
std::vector<Q3BSP::sQ3BSPFace*> &rArray, aiMesh* pMesh );
|
std::vector<Q3BSP::sQ3BSPFace*> &rArray, aiMesh **pMesh );
|
||||||
void createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, Q3BSP::sQ3BSPFace *pQ3BSPFace, aiMesh* pMesh, unsigned int &rFaceIdx,
|
void createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, Q3BSP::sQ3BSPFace *pQ3BSPFace, aiMesh* pMesh, unsigned int &rFaceIdx,
|
||||||
unsigned int &rVertIdx );
|
unsigned int &rVertIdx );
|
||||||
void createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, Q3BSP::Q3BSPZipArchive *pArchive );
|
void createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, Q3BSP::Q3BSPZipArchive *pArchive );
|
||||||
|
@ -115,5 +116,4 @@ private:
|
||||||
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
||||||
|
|
||||||
#endif // ASSIMP_Q3BSPFILEIMPORTER_H_INC
|
#endif // ASSIMP_Q3BSPFILEIMPORTER_H_INC
|
||||||
|
|
|
@ -55,56 +55,51 @@ namespace Assimp {
|
||||||
using namespace Q3BSP;
|
using namespace Q3BSP;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Q3BSPFileParser::Q3BSPFileParser( const std::string &rMapName, Q3BSPZipArchive *pZipArchive ) :
|
Q3BSPFileParser::Q3BSPFileParser( const std::string &mapName, Q3BSPZipArchive *pZipArchive ) :
|
||||||
m_sOffset( 0 ),
|
m_sOffset( 0 ),
|
||||||
m_Data(),
|
m_Data(),
|
||||||
m_pModel( NULL ),
|
m_pModel(nullptr),
|
||||||
m_pZipArchive( pZipArchive )
|
m_pZipArchive( pZipArchive )
|
||||||
{
|
{
|
||||||
ai_assert( NULL != m_pZipArchive );
|
ai_assert(nullptr != m_pZipArchive );
|
||||||
ai_assert( !rMapName.empty() );
|
ai_assert( !mapName.empty() );
|
||||||
|
|
||||||
if ( !readData( rMapName ) )
|
if ( !readData( mapName ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_pModel = new Q3BSPModel;
|
m_pModel = new Q3BSPModel;
|
||||||
m_pModel->m_ModelName = rMapName;
|
m_pModel->m_ModelName = mapName;
|
||||||
if ( !parseFile() )
|
if ( !parseFile() ) {
|
||||||
{
|
|
||||||
delete m_pModel;
|
delete m_pModel;
|
||||||
m_pModel = NULL;
|
m_pModel = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Q3BSPFileParser::~Q3BSPFileParser()
|
Q3BSPFileParser::~Q3BSPFileParser() {
|
||||||
{
|
|
||||||
delete m_pModel;
|
delete m_pModel;
|
||||||
m_pModel = NULL;
|
m_pModel = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Q3BSP::Q3BSPModel *Q3BSPFileParser::getModel() const
|
Q3BSP::Q3BSPModel *Q3BSPFileParser::getModel() const {
|
||||||
{
|
|
||||||
return m_pModel;
|
return m_pModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool Q3BSPFileParser::readData( const std::string &rMapName )
|
bool Q3BSPFileParser::readData( const std::string &rMapName ) {
|
||||||
{
|
|
||||||
if ( !m_pZipArchive->Exists( rMapName.c_str() ) )
|
if ( !m_pZipArchive->Exists( rMapName.c_str() ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
IOStream *pMapFile = m_pZipArchive->Open( rMapName.c_str() );
|
IOStream *pMapFile = m_pZipArchive->Open( rMapName.c_str() );
|
||||||
if ( NULL == pMapFile )
|
if ( nullptr == pMapFile )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const size_t size = pMapFile->FileSize();
|
const size_t size = pMapFile->FileSize();
|
||||||
m_Data.resize( size );
|
m_Data.resize( size );
|
||||||
|
|
||||||
const size_t readSize = pMapFile->Read( &m_Data[0], sizeof( char ), size );
|
const size_t readSize = pMapFile->Read( &m_Data[0], sizeof( char ), size );
|
||||||
if ( readSize != size )
|
if ( readSize != size ) {
|
||||||
{
|
|
||||||
m_Data.clear();
|
m_Data.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -114,10 +109,8 @@ bool Q3BSPFileParser::readData( const std::string &rMapName )
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool Q3BSPFileParser::parseFile()
|
bool Q3BSPFileParser::parseFile() {
|
||||||
{
|
if ( m_Data.empty() ) {
|
||||||
if ( m_Data.empty() )
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +122,7 @@ bool Q3BSPFileParser::parseFile()
|
||||||
// Imports the dictionary of the level
|
// Imports the dictionary of the level
|
||||||
getLumps();
|
getLumps();
|
||||||
|
|
||||||
// Conunt data and prepare model data
|
// Count data and prepare model data
|
||||||
countLumps();
|
countLumps();
|
||||||
|
|
||||||
// Read in Vertices
|
// Read in Vertices
|
||||||
|
@ -209,7 +202,7 @@ void Q3BSPFileParser::getVertices()
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Q3BSPFileParser::getIndices()
|
void Q3BSPFileParser::getIndices()
|
||||||
{
|
{
|
||||||
ai_assert( NULL != m_pModel );
|
ai_assert(nullptr != m_pModel );
|
||||||
|
|
||||||
sQ3BSPLump *lump = m_pModel->m_Lumps[ kMeshVerts ];
|
sQ3BSPLump *lump = m_pModel->m_Lumps[ kMeshVerts ];
|
||||||
size_t Offset = (size_t) lump->iOffset;
|
size_t Offset = (size_t) lump->iOffset;
|
||||||
|
@ -221,7 +214,7 @@ void Q3BSPFileParser::getIndices()
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Q3BSPFileParser::getFaces()
|
void Q3BSPFileParser::getFaces()
|
||||||
{
|
{
|
||||||
ai_assert( NULL != m_pModel );
|
ai_assert(nullptr != m_pModel );
|
||||||
|
|
||||||
size_t Offset = m_pModel->m_Lumps[ kFaces ]->iOffset;
|
size_t Offset = m_pModel->m_Lumps[ kFaces ]->iOffset;
|
||||||
for ( size_t idx = 0; idx < m_pModel->m_Faces.size(); idx++ )
|
for ( size_t idx = 0; idx < m_pModel->m_Faces.size(); idx++ )
|
||||||
|
@ -236,7 +229,7 @@ void Q3BSPFileParser::getFaces()
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Q3BSPFileParser::getTextures()
|
void Q3BSPFileParser::getTextures()
|
||||||
{
|
{
|
||||||
ai_assert( NULL != m_pModel );
|
ai_assert(nullptr != m_pModel );
|
||||||
|
|
||||||
size_t Offset = m_pModel->m_Lumps[ kTextures ]->iOffset;
|
size_t Offset = m_pModel->m_Lumps[ kTextures ]->iOffset;
|
||||||
for ( size_t idx=0; idx < m_pModel->m_Textures.size(); idx++ )
|
for ( size_t idx=0; idx < m_pModel->m_Textures.size(); idx++ )
|
||||||
|
@ -251,7 +244,7 @@ void Q3BSPFileParser::getTextures()
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Q3BSPFileParser::getLightMaps()
|
void Q3BSPFileParser::getLightMaps()
|
||||||
{
|
{
|
||||||
ai_assert( NULL != m_pModel );
|
ai_assert(nullptr != m_pModel );
|
||||||
|
|
||||||
size_t Offset = m_pModel->m_Lumps[kLightmaps]->iOffset;
|
size_t Offset = m_pModel->m_Lumps[kLightmaps]->iOffset;
|
||||||
for ( size_t idx=0; idx < m_pModel->m_Lightmaps.size(); idx++ )
|
for ( size_t idx=0; idx < m_pModel->m_Lightmaps.size(); idx++ )
|
||||||
|
@ -264,12 +257,10 @@ void Q3BSPFileParser::getLightMaps()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Q3BSPFileParser::getEntities()
|
void Q3BSPFileParser::getEntities() {
|
||||||
{
|
const int size = m_pModel->m_Lumps[ kEntities ]->iSize;
|
||||||
int size = m_pModel->m_Lumps[ kEntities ]->iSize;
|
|
||||||
m_pModel->m_EntityData.resize( size );
|
m_pModel->m_EntityData.resize( size );
|
||||||
if ( size > 0 )
|
if ( size > 0 ) {
|
||||||
{
|
|
||||||
size_t Offset = m_pModel->m_Lumps[ kEntities ]->iOffset;
|
size_t Offset = m_pModel->m_Lumps[ kEntities ]->iOffset;
|
||||||
memcpy( &m_pModel->m_EntityData[ 0 ], &m_Data[ Offset ], sizeof( char ) * size );
|
memcpy( &m_pModel->m_EntityData[ 0 ], &m_Data[ Offset ], sizeof( char ) * size );
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ Q3BSPZipArchive::Q3BSPZipArchive(IOSystem* pIOHandler, const std::string& rFile)
|
||||||
|
|
||||||
m_ZipFileHandle = unzOpen2(rFile.c_str(), &mapping);
|
m_ZipFileHandle = unzOpen2(rFile.c_str(), &mapping);
|
||||||
|
|
||||||
if(m_ZipFileHandle != NULL) {
|
if(m_ZipFileHandle != nullptr) {
|
||||||
mapArchive();
|
mapArchive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,26 +197,23 @@ Q3BSPZipArchive::~Q3BSPZipArchive() {
|
||||||
}
|
}
|
||||||
m_ArchiveMap.clear();
|
m_ArchiveMap.clear();
|
||||||
|
|
||||||
if(m_ZipFileHandle != NULL) {
|
if(m_ZipFileHandle != nullptr) {
|
||||||
unzClose(m_ZipFileHandle);
|
unzClose(m_ZipFileHandle);
|
||||||
m_ZipFileHandle = NULL;
|
m_ZipFileHandle = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns true, if the archive is already open.
|
// Returns true, if the archive is already open.
|
||||||
bool Q3BSPZipArchive::isOpen() const {
|
bool Q3BSPZipArchive::isOpen() const {
|
||||||
return (m_ZipFileHandle != NULL);
|
return (m_ZipFileHandle != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns true, if the filename is part of the archive.
|
// Returns true, if the filename is part of the archive.
|
||||||
bool Q3BSPZipArchive::Exists(const char* pFile) const {
|
bool Q3BSPZipArchive::Exists(const char* pFile) const {
|
||||||
ai_assert(pFile != NULL);
|
|
||||||
|
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
|
if (pFile != nullptr) {
|
||||||
if (pFile != NULL) {
|
|
||||||
std::string rFile(pFile);
|
std::string rFile(pFile);
|
||||||
std::map<std::string, ZipFile*>::const_iterator it = m_ArchiveMap.find(rFile);
|
std::map<std::string, ZipFile*>::const_iterator it = m_ArchiveMap.find(rFile);
|
||||||
|
|
||||||
|
@ -241,9 +238,9 @@ char Q3BSPZipArchive::getOsSeparator() const {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Opens a file, which is part of the archive.
|
// Opens a file, which is part of the archive.
|
||||||
IOStream *Q3BSPZipArchive::Open(const char* pFile, const char* /*pMode*/) {
|
IOStream *Q3BSPZipArchive::Open(const char* pFile, const char* /*pMode*/) {
|
||||||
ai_assert(pFile != NULL);
|
ai_assert(pFile != nullptr);
|
||||||
|
|
||||||
IOStream* result = NULL;
|
IOStream* result = nullptr;
|
||||||
|
|
||||||
std::map<std::string, ZipFile*>::iterator it = m_ArchiveMap.find(pFile);
|
std::map<std::string, ZipFile*>::iterator it = m_ArchiveMap.find(pFile);
|
||||||
|
|
||||||
|
@ -258,7 +255,7 @@ IOStream *Q3BSPZipArchive::Open(const char* pFile, const char* /*pMode*/) {
|
||||||
// Close a filestream.
|
// Close a filestream.
|
||||||
void Q3BSPZipArchive::Close(IOStream *pFile) {
|
void Q3BSPZipArchive::Close(IOStream *pFile) {
|
||||||
(void)(pFile);
|
(void)(pFile);
|
||||||
ai_assert(pFile != NULL);
|
ai_assert(pFile != nullptr);
|
||||||
|
|
||||||
// We don't do anything in case the file would be opened again in the future
|
// We don't do anything in case the file would be opened again in the future
|
||||||
}
|
}
|
||||||
|
@ -277,7 +274,7 @@ void Q3BSPZipArchive::getFileList(std::vector<std::string> &rFileList) {
|
||||||
bool Q3BSPZipArchive::mapArchive() {
|
bool Q3BSPZipArchive::mapArchive() {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
if(m_ZipFileHandle != NULL) {
|
if(m_ZipFileHandle != nullptr) {
|
||||||
if(m_ArchiveMap.empty()) {
|
if(m_ArchiveMap.empty()) {
|
||||||
// At first ensure file is already open
|
// At first ensure file is already open
|
||||||
if(unzGoToFirstFile(m_ZipFileHandle) == UNZ_OK) {
|
if(unzGoToFirstFile(m_ZipFileHandle) == UNZ_OK) {
|
||||||
|
|
|
@ -1,141 +0,0 @@
|
||||||
/*
|
|
||||||
Open Asset Import Library (assimp)
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
|
||||||
with or without modification, are permitted provided that the
|
|
||||||
following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
|
||||||
contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Small helper classes to optimize finding vertices close to a given location
|
|
||||||
*/
|
|
||||||
#ifndef AI_D3DSSPATIALSORT_H_INC
|
|
||||||
#define AI_D3DSSPATIALSORT_H_INC
|
|
||||||
|
|
||||||
#include <assimp/types.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace Assimp {
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
|
||||||
/** Specialized version of SpatialSort to support smoothing groups
|
|
||||||
* This is used in by the 3DS, ASE and LWO loaders. 3DS and ASE share their
|
|
||||||
* normal computation code in SmoothingGroups.inl, the LWO loader has its own
|
|
||||||
* implementation to handle all details of its file format correctly.
|
|
||||||
*/
|
|
||||||
// ----------------------------------------------------------------------------------
|
|
||||||
class ASSIMP_API SGSpatialSort
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
SGSpatialSort();
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Construction from a given face array, handling smoothing groups
|
|
||||||
* properly
|
|
||||||
*/
|
|
||||||
explicit SGSpatialSort(const std::vector<aiVector3D>& vPositions);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Add a vertex to the spatial sort
|
|
||||||
* @param vPosition Vertex position to be added
|
|
||||||
* @param index Index of the vrtex
|
|
||||||
* @param smoothingGroup SmoothingGroup for this vertex
|
|
||||||
*/
|
|
||||||
void Add(const aiVector3D& vPosition, unsigned int index,
|
|
||||||
unsigned int smoothingGroup);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Prepare the spatial sorter for use. This step runs in O(logn)
|
|
||||||
*/
|
|
||||||
void Prepare();
|
|
||||||
|
|
||||||
/** Destructor */
|
|
||||||
~SGSpatialSort();
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Returns an iterator for all positions close to the given position.
|
|
||||||
* @param pPosition The position to look for vertices.
|
|
||||||
* @param pSG Only included vertices with at least one shared smooth group
|
|
||||||
* @param pRadius Maximal distance from the position a vertex may have
|
|
||||||
* to be counted in.
|
|
||||||
* @param poResults The container to store the indices of the found
|
|
||||||
* positions. Will be emptied by the call so it may contain anything.
|
|
||||||
* @param exactMatch Specifies whether smoothing groups are bit masks
|
|
||||||
* (false) or integral values (true). In the latter case, a vertex
|
|
||||||
* cannot belong to more than one smoothing group.
|
|
||||||
* @return An iterator to iterate over all vertices in the given area.
|
|
||||||
*/
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
void FindPositions( const aiVector3D& pPosition, uint32_t pSG,
|
|
||||||
float pRadius, std::vector<unsigned int>& poResults,
|
|
||||||
bool exactMatch = false) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
|
||||||
aiVector3D mPlaneNormal;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** An entry in a spatially sorted position array. Consists of a
|
|
||||||
* vertex index, its position and its precalculated distance from
|
|
||||||
* the reference plane */
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
struct Entry
|
|
||||||
{
|
|
||||||
unsigned int mIndex; ///< The vertex referred by this entry
|
|
||||||
aiVector3D mPosition; ///< Position
|
|
||||||
uint32_t mSmoothGroups;
|
|
||||||
float mDistance; ///< Distance of this vertex to the sorting plane
|
|
||||||
|
|
||||||
Entry() { /** intentionally not initialized.*/ }
|
|
||||||
Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
|
|
||||||
:
|
|
||||||
mIndex( pIndex),
|
|
||||||
mPosition( pPosition),
|
|
||||||
mSmoothGroups (pSG),
|
|
||||||
mDistance( pDistance)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// all positions, sorted by distance to the sorting plane
|
|
||||||
std::vector<Entry> mPositions;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end of namespace Assimp
|
|
||||||
|
|
||||||
#endif // AI_SPATIALSORT_H_INC
|
|
|
@ -63,16 +63,16 @@ struct aiNode;
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
namespace SMD {
|
namespace SMD {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Data structure for a vertex in a SMD file
|
/** Data structure for a vertex in a SMD file
|
||||||
*/
|
*/
|
||||||
struct Vertex
|
struct Vertex {
|
||||||
{
|
Vertex() AI_NO_EXCEPT
|
||||||
Vertex() : iParentNode(UINT_MAX)
|
: iParentNode(UINT_MAX) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! Vertex position, normal and texture coordinate
|
//! Vertex position, normal and texture coordinate
|
||||||
aiVector3D pos,nor,uv;
|
aiVector3D pos,nor,uv;
|
||||||
|
@ -90,10 +90,12 @@ struct Vertex
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Data structure for a face in a SMD file
|
/** Data structure for a face in a SMD file
|
||||||
*/
|
*/
|
||||||
struct Face
|
struct Face {
|
||||||
{
|
Face() AI_NO_EXCEPT
|
||||||
Face() : iTexture(0x0)
|
: iTexture(0x0)
|
||||||
{}
|
, avVertices{} {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! Texture index for the face
|
//! Texture index for the face
|
||||||
unsigned int iTexture;
|
unsigned int iTexture;
|
||||||
|
@ -105,11 +107,12 @@ struct Face
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Data structure for a bone in a SMD file
|
/** Data structure for a bone in a SMD file
|
||||||
*/
|
*/
|
||||||
struct Bone
|
struct Bone {
|
||||||
{
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
Bone() : iParent(UINT_MAX), bIsUsed(false)
|
Bone() AI_NO_EXCEPT
|
||||||
{
|
: iParent(UINT_MAX)
|
||||||
|
, bIsUsed(false) {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
|
@ -124,12 +127,10 @@ struct Bone
|
||||||
uint32_t iParent;
|
uint32_t iParent;
|
||||||
|
|
||||||
//! Animation of the bone
|
//! Animation of the bone
|
||||||
struct Animation
|
struct Animation {
|
||||||
{
|
|
||||||
//! Public default constructor
|
//! Public default constructor
|
||||||
Animation()
|
Animation() AI_NO_EXCEPT
|
||||||
: iFirstTimeKey()
|
: iFirstTimeKey() {
|
||||||
{
|
|
||||||
asKeys.reserve(20);
|
asKeys.reserve(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class Importer;
|
||||||
|
|
||||||
struct ScenePrivateData {
|
struct ScenePrivateData {
|
||||||
// The struct constructor.
|
// The struct constructor.
|
||||||
ScenePrivateData();
|
ScenePrivateData() AI_NO_EXCEPT;
|
||||||
|
|
||||||
// Importer that originally loaded the scene though the C-API
|
// Importer that originally loaded the scene though the C-API
|
||||||
// If set, this object is owned by this private data instance.
|
// If set, this object is owned by this private data instance.
|
||||||
|
@ -74,7 +74,7 @@ struct ScenePrivateData {
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
ScenePrivateData::ScenePrivateData()
|
ScenePrivateData::ScenePrivateData() AI_NO_EXCEPT
|
||||||
: mOrigImporter( nullptr )
|
: mOrigImporter( nullptr )
|
||||||
, mPPStepsApplied( 0 )
|
, mPPStepsApplied( 0 )
|
||||||
, mIsCopy( false ) {
|
, mIsCopy( false ) {
|
||||||
|
|
|
@ -65,14 +65,14 @@ namespace Assimp {
|
||||||
/** Small helper structure representing a shortcut into the material list
|
/** Small helper structure representing a shortcut into the material list
|
||||||
* to be able to update some values quickly.
|
* to be able to update some values quickly.
|
||||||
*/
|
*/
|
||||||
struct TTUpdateInfo
|
struct TTUpdateInfo {
|
||||||
{
|
TTUpdateInfo() AI_NO_EXCEPT
|
||||||
TTUpdateInfo() :
|
: directShortcut(nullptr)
|
||||||
directShortcut (NULL)
|
, mat(nullptr)
|
||||||
, mat (NULL)
|
|
||||||
, semantic(0)
|
, semantic(0)
|
||||||
, index (0)
|
, index(0) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! Direct shortcut, if available
|
//! Direct shortcut, if available
|
||||||
unsigned int* directShortcut;
|
unsigned int* directShortcut;
|
||||||
|
@ -88,15 +88,14 @@ struct TTUpdateInfo
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper class representing texture coordinate transformations
|
/** Helper class representing texture coordinate transformations
|
||||||
*/
|
*/
|
||||||
struct STransformVecInfo : public aiUVTransform
|
struct STransformVecInfo : public aiUVTransform {
|
||||||
{
|
STransformVecInfo() AI_NO_EXCEPT
|
||||||
|
|
||||||
STransformVecInfo()
|
|
||||||
: uvIndex(0)
|
: uvIndex(0)
|
||||||
, mapU(aiTextureMapMode_Wrap)
|
, mapU(aiTextureMapMode_Wrap)
|
||||||
, mapV(aiTextureMapMode_Wrap)
|
, mapV(aiTextureMapMode_Wrap)
|
||||||
, lockedPos (AI_TT_UV_IDX_LOCK_NONE)
|
, lockedPos(AI_TT_UV_IDX_LOCK_NONE) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
//! Source texture coordinate index
|
//! Source texture coordinate index
|
||||||
unsigned int uvIndex;
|
unsigned int uvIndex;
|
||||||
|
|
|
@ -55,32 +55,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/anim.h>
|
#include <assimp/anim.h>
|
||||||
#include <assimp/Defines.h>
|
#include <assimp/Defines.h>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
namespace XFile {
|
||||||
namespace XFile
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Helper structure representing a XFile mesh face */
|
/** Helper structure representing a XFile mesh face */
|
||||||
struct Face
|
struct Face {
|
||||||
{
|
|
||||||
std::vector<unsigned int> mIndices;
|
std::vector<unsigned int> mIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper structure representing a texture filename inside a material and its potential source */
|
/** Helper structure representing a texture filename inside a material and its potential source */
|
||||||
struct TexEntry
|
struct TexEntry {
|
||||||
{
|
|
||||||
std::string mName;
|
std::string mName;
|
||||||
bool mIsNormalMap; // true if the texname was specified in a NormalmapFilename tag
|
bool mIsNormalMap; // true if the texname was specified in a NormalmapFilename tag
|
||||||
|
|
||||||
TexEntry() { mIsNormalMap = false; }
|
TexEntry() AI_NO_EXCEPT
|
||||||
|
: mName()
|
||||||
|
, mIsNormalMap(false) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
TexEntry(const std::string& pName, bool pIsNormalMap = false)
|
TexEntry(const std::string& pName, bool pIsNormalMap = false)
|
||||||
: mName( pName), mIsNormalMap( pIsNormalMap)
|
: mName(pName)
|
||||||
{ /* done */ }
|
, mIsNormalMap(pIsNormalMap) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper structure representing a XFile material */
|
/** Helper structure representing a XFile material */
|
||||||
struct Material
|
struct Material {
|
||||||
{
|
|
||||||
std::string mName;
|
std::string mName;
|
||||||
bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list
|
bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list
|
||||||
aiColor4D mDiffuse;
|
aiColor4D mDiffuse;
|
||||||
|
@ -88,19 +89,18 @@ struct Material
|
||||||
aiColor3D mSpecular;
|
aiColor3D mSpecular;
|
||||||
aiColor3D mEmissive;
|
aiColor3D mEmissive;
|
||||||
std::vector<TexEntry> mTextures;
|
std::vector<TexEntry> mTextures;
|
||||||
|
|
||||||
size_t sceneIndex; ///< the index under which it was stored in the scene's material list
|
size_t sceneIndex; ///< the index under which it was stored in the scene's material list
|
||||||
|
|
||||||
Material()
|
Material() AI_NO_EXCEPT
|
||||||
: mIsReference(false),
|
: mIsReference(false)
|
||||||
mSpecularExponent(),
|
, mSpecularExponent()
|
||||||
sceneIndex(SIZE_MAX)
|
, sceneIndex(SIZE_MAX) {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper structure to represent a bone weight */
|
/** Helper structure to represent a bone weight */
|
||||||
struct BoneWeight
|
struct BoneWeight {
|
||||||
{
|
|
||||||
unsigned int mVertex;
|
unsigned int mVertex;
|
||||||
ai_real mWeight;
|
ai_real mWeight;
|
||||||
};
|
};
|
||||||
|
@ -114,8 +114,7 @@ struct Bone
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper structure to represent an XFile mesh */
|
/** Helper structure to represent an XFile mesh */
|
||||||
struct Mesh
|
struct Mesh {
|
||||||
{
|
|
||||||
std::string mName;
|
std::string mName;
|
||||||
std::vector<aiVector3D> mPositions;
|
std::vector<aiVector3D> mPositions;
|
||||||
std::vector<Face> mPosFaces;
|
std::vector<Face> mPosFaces;
|
||||||
|
@ -131,38 +130,65 @@ struct Mesh
|
||||||
|
|
||||||
std::vector<Bone> mBones;
|
std::vector<Bone> mBones;
|
||||||
|
|
||||||
explicit Mesh(const std::string &pName = "") { mName = pName; mNumTextures = 0; mNumColorSets = 0; }
|
explicit Mesh(const std::string &pName = "") AI_NO_EXCEPT
|
||||||
|
: mName( pName )
|
||||||
|
, mPositions()
|
||||||
|
, mPosFaces()
|
||||||
|
, mNormals()
|
||||||
|
, mNormFaces()
|
||||||
|
, mNumTextures(0)
|
||||||
|
, mTexCoords{}
|
||||||
|
, mNumColorSets(0)
|
||||||
|
, mColors{}
|
||||||
|
, mFaceMaterials()
|
||||||
|
, mMaterials()
|
||||||
|
, mBones() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper structure to represent a XFile frame */
|
/** Helper structure to represent a XFile frame */
|
||||||
struct Node
|
struct Node {
|
||||||
{
|
|
||||||
std::string mName;
|
std::string mName;
|
||||||
aiMatrix4x4 mTrafoMatrix;
|
aiMatrix4x4 mTrafoMatrix;
|
||||||
Node* mParent;
|
Node* mParent;
|
||||||
std::vector<Node*> mChildren;
|
std::vector<Node*> mChildren;
|
||||||
std::vector<Mesh*> mMeshes;
|
std::vector<Mesh*> mMeshes;
|
||||||
|
|
||||||
Node() { mParent = NULL; }
|
Node() AI_NO_EXCEPT
|
||||||
explicit Node( Node* pParent) { mParent = pParent; }
|
: mName()
|
||||||
~Node()
|
, mTrafoMatrix()
|
||||||
{
|
, mParent(nullptr)
|
||||||
for( unsigned int a = 0; a < mChildren.size(); a++)
|
, mChildren()
|
||||||
|
, mMeshes() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
explicit Node( Node* pParent)
|
||||||
|
: mName()
|
||||||
|
, mTrafoMatrix()
|
||||||
|
, mParent(pParent)
|
||||||
|
, mChildren()
|
||||||
|
, mMeshes() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
~Node() {
|
||||||
|
for (unsigned int a = 0; a < mChildren.size(); ++a ) {
|
||||||
delete mChildren[a];
|
delete mChildren[a];
|
||||||
for( unsigned int a = 0; a < mMeshes.size(); a++)
|
}
|
||||||
|
for (unsigned int a = 0; a < mMeshes.size(); ++a) {
|
||||||
delete mMeshes[a];
|
delete mMeshes[a];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MatrixKey
|
struct MatrixKey {
|
||||||
{
|
|
||||||
double mTime;
|
double mTime;
|
||||||
aiMatrix4x4 mMatrix;
|
aiMatrix4x4 mMatrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper structure representing a single animated bone in a XFile */
|
/** Helper structure representing a single animated bone in a XFile */
|
||||||
struct AnimBone
|
struct AnimBone {
|
||||||
{
|
|
||||||
std::string mBoneName;
|
std::string mBoneName;
|
||||||
std::vector<aiVectorKey> mPosKeys; // either three separate key sequences for position, rotation, scaling
|
std::vector<aiVectorKey> mPosKeys; // either three separate key sequences for position, rotation, scaling
|
||||||
std::vector<aiQuatKey> mRotKeys;
|
std::vector<aiQuatKey> mRotKeys;
|
||||||
|
@ -194,15 +220,23 @@ struct Scene
|
||||||
std::vector<Animation*> mAnims;
|
std::vector<Animation*> mAnims;
|
||||||
unsigned int mAnimTicksPerSecond;
|
unsigned int mAnimTicksPerSecond;
|
||||||
|
|
||||||
Scene() { mRootNode = NULL; mAnimTicksPerSecond = 0; }
|
Scene() AI_NO_EXCEPT
|
||||||
~Scene()
|
: mRootNode(nullptr)
|
||||||
{
|
, mGlobalMeshes()
|
||||||
|
, mGlobalMaterials()
|
||||||
|
, mAnimTicksPerSecond(0) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
~Scene() {
|
||||||
delete mRootNode;
|
delete mRootNode;
|
||||||
for( unsigned int a = 0; a < mGlobalMeshes.size(); a++)
|
mRootNode = nullptr;
|
||||||
|
for (unsigned int a = 0; a < mGlobalMeshes.size(); ++a ) {
|
||||||
delete mGlobalMeshes[a];
|
delete mGlobalMeshes[a];
|
||||||
for( unsigned int a = 0; a < mAnims.size(); a++)
|
}
|
||||||
|
for (unsigned int a = 0; a < mAnims.size(); ++a ) {
|
||||||
delete mAnims[a];
|
delete mAnims[a];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace XFile
|
} // end of namespace XFile
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace glTF2
|
||||||
#include <assimp/pbrmaterial.h>
|
#include <assimp/pbrmaterial.h>
|
||||||
|
|
||||||
#ifdef ASSIMP_API
|
#ifdef ASSIMP_API
|
||||||
#include "./../include/assimp/Compiler/pushpack1.h"
|
#include <assimp/Compiler/pushpack1.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! For binary .glb files
|
//! For binary .glb files
|
||||||
|
@ -189,7 +189,7 @@ namespace glTF2
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
#ifdef ASSIMP_API
|
#ifdef ASSIMP_API
|
||||||
#include "./../include/assimp/Compiler/poppack1.h"
|
#include <assimp/Compiler/poppack1.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ namespace glTF2
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t* mData;
|
std::unique_ptr<uint8_t[]> mData;
|
||||||
size_t mDataLength;
|
size_t mDataLength;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -674,7 +674,7 @@ namespace glTF2
|
||||||
{ return mDataLength; }
|
{ return mDataLength; }
|
||||||
|
|
||||||
inline const uint8_t* GetData() const
|
inline const uint8_t* GetData() const
|
||||||
{ return mData; }
|
{ return mData.get(); }
|
||||||
|
|
||||||
inline uint8_t* StealData();
|
inline uint8_t* StealData();
|
||||||
|
|
||||||
|
|
|
@ -688,7 +688,6 @@ T Accessor::Indexer::GetValue(int i)
|
||||||
inline Image::Image()
|
inline Image::Image()
|
||||||
: width(0)
|
: width(0)
|
||||||
, height(0)
|
, height(0)
|
||||||
, mData(0)
|
|
||||||
, mDataLength(0)
|
, mDataLength(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -704,7 +703,9 @@ inline void Image::Read(Value& obj, Asset& r)
|
||||||
if (ParseDataURI(uristr, uri->GetStringLength(), dataURI)) {
|
if (ParseDataURI(uristr, uri->GetStringLength(), dataURI)) {
|
||||||
mimeType = dataURI.mediaType;
|
mimeType = dataURI.mediaType;
|
||||||
if (dataURI.base64) {
|
if (dataURI.base64) {
|
||||||
mDataLength = Util::DecodeBase64(dataURI.data, dataURI.dataLength, mData);
|
uint8_t *ptr = nullptr;
|
||||||
|
mDataLength = Util::DecodeBase64(dataURI.data, dataURI.dataLength, ptr);
|
||||||
|
mData.reset(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -717,8 +718,9 @@ inline void Image::Read(Value& obj, Asset& r)
|
||||||
|
|
||||||
this->mDataLength = this->bufferView->byteLength;
|
this->mDataLength = this->bufferView->byteLength;
|
||||||
// maybe this memcpy could be avoided if aiTexture does not delete[] pcData at destruction.
|
// maybe this memcpy could be avoided if aiTexture does not delete[] pcData at destruction.
|
||||||
this->mData = new uint8_t [this->mDataLength];
|
|
||||||
memcpy(this->mData, buffer->GetPointer() + this->bufferView->byteOffset, this->mDataLength);
|
this->mData.reset(new uint8_t[this->mDataLength]);
|
||||||
|
memcpy(this->mData.get(), buffer->GetPointer() + this->bufferView->byteOffset, this->mDataLength);
|
||||||
|
|
||||||
if (Value* mtype = FindString(obj, "mimeType")) {
|
if (Value* mtype = FindString(obj, "mimeType")) {
|
||||||
this->mimeType = mtype->GetString();
|
this->mimeType = mtype->GetString();
|
||||||
|
@ -729,10 +731,8 @@ inline void Image::Read(Value& obj, Asset& r)
|
||||||
|
|
||||||
inline uint8_t* Image::StealData()
|
inline uint8_t* Image::StealData()
|
||||||
{
|
{
|
||||||
uint8_t* data = mData;
|
|
||||||
mDataLength = 0;
|
mDataLength = 0;
|
||||||
mData = 0;
|
return mData.release();
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Image::SetData(uint8_t* data, size_t length, Asset& r)
|
inline void Image::SetData(uint8_t* data, size_t length, Asset& r)
|
||||||
|
@ -747,7 +747,7 @@ inline void Image::SetData(uint8_t* data, size_t length, Asset& r)
|
||||||
bufferView->byteOffset = b->AppendData(data, length);
|
bufferView->byteOffset = b->AppendData(data, length);
|
||||||
}
|
}
|
||||||
else { // text file: will be stored as a data uri
|
else { // text file: will be stored as a data uri
|
||||||
this->mData = data;
|
this->mData.reset(data);
|
||||||
this->mDataLength = length;
|
this->mDataLength = length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,12 @@ inline void Mesh::Read(Value& pJSON_Object, Asset& pAsset_Root)
|
||||||
|
|
||||||
inline void Camera::Read(Value& obj, Asset& /*r*/)
|
inline void Camera::Read(Value& obj, Asset& /*r*/)
|
||||||
{
|
{
|
||||||
type = MemberOrDefault(obj, "type", Camera::Perspective);
|
std::string type_string = std::string(MemberOrDefault(obj, "type", "perspective"));
|
||||||
|
if (type_string == "orthographic") {
|
||||||
|
type = Camera::Orthographic;
|
||||||
|
} else {
|
||||||
|
type = Camera::Perspective;
|
||||||
|
}
|
||||||
|
|
||||||
const char* subobjId = (type == Camera::Orthographic) ? "orthographic" : "perspective";
|
const char* subobjId = (type == Camera::Orthographic) ? "orthographic" : "perspective";
|
||||||
|
|
||||||
|
|
|
@ -641,7 +641,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
|
||||||
unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType);
|
unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType);
|
||||||
size_t s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp;
|
size_t s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp;
|
||||||
Ref<Buffer> buf = vertexJointAccessor->bufferView->buffer;
|
Ref<Buffer> buf = vertexJointAccessor->bufferView->buffer;
|
||||||
uint8_t* arrys = new uint8_t[s_bytesLen];
|
uint8_t* arrys = new uint8_t[bytesLen];
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for ( unsigned int j = 0; j <= bytesLen; j += bytesPerComp ){
|
for ( unsigned int j = 0; j <= bytesLen; j += bytesPerComp ){
|
||||||
size_t len_p = offset + j;
|
size_t len_p = offset + j;
|
||||||
|
@ -652,8 +652,9 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
|
||||||
memcpy(&arrys[i*s_bytesPerComp], data, s_bytesPerComp);
|
memcpy(&arrys[i*s_bytesPerComp], data, s_bytesPerComp);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
buf->ReplaceData_joint(offset, bytesLen, arrys, s_bytesLen);
|
buf->ReplaceData_joint(offset, bytesLen, arrys, bytesLen);
|
||||||
vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT;
|
vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT;
|
||||||
|
vertexJointAccessor->bufferView->byteLength = s_bytesLen;
|
||||||
|
|
||||||
p.attributes.joint.push_back( vertexJointAccessor );
|
p.attributes.joint.push_back( vertexJointAccessor );
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,7 +454,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
||||||
|
|
||||||
std::vector<Mesh::Primitive::Target>& targets = prim.targets;
|
std::vector<Mesh::Primitive::Target>& targets = prim.targets;
|
||||||
if (targets.size() > 0) {
|
if (targets.size() > 0) {
|
||||||
aim->mNumAnimMeshes = targets.size();
|
aim->mNumAnimMeshes = (unsigned int)targets.size();
|
||||||
aim->mAnimMeshes = new aiAnimMesh*[aim->mNumAnimMeshes];
|
aim->mAnimMeshes = new aiAnimMesh*[aim->mNumAnimMeshes];
|
||||||
for (size_t i = 0; i < targets.size(); i++) {
|
for (size_t i = 0; i < targets.size(); i++) {
|
||||||
aim->mAnimMeshes[i] = aiCreateAnimMesh(aim);
|
aim->mAnimMeshes[i] = aiCreateAnimMesh(aim);
|
||||||
|
@ -818,7 +818,7 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset& r)
|
||||||
|
|
||||||
// Add the embedded textures
|
// Add the embedded textures
|
||||||
for (size_t i = 0; i < r.images.Size(); ++i) {
|
for (size_t i = 0; i < r.images.Size(); ++i) {
|
||||||
Image img = r.images[i];
|
Image &img = r.images[i];
|
||||||
if (!img.HasData()) continue;
|
if (!img.HasData()) continue;
|
||||||
|
|
||||||
int idx = mScene->mNumTextures++;
|
int idx = mScene->mNumTextures++;
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace glTF
|
||||||
#define AI_GLB_MAGIC_NUMBER "glTF"
|
#define AI_GLB_MAGIC_NUMBER "glTF"
|
||||||
|
|
||||||
#ifdef ASSIMP_API
|
#ifdef ASSIMP_API
|
||||||
#include "./../include/assimp/Compiler/pushpack1.h"
|
#include <assimp/Compiler/pushpack1.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! For the KHR_binary_glTF extension (binary .glb file)
|
//! For the KHR_binary_glTF extension (binary .glb file)
|
||||||
|
@ -185,7 +185,7 @@ namespace glTF
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
#ifdef ASSIMP_API
|
#ifdef ASSIMP_API
|
||||||
#include "./../include/assimp/Compiler/poppack1.h"
|
#include <assimp/Compiler/poppack1.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ class array
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
array()
|
array()
|
||||||
: data(0), allocated(0), used(0),
|
: data(0), allocated(0), used(0),
|
||||||
free_when_destroyed(true), is_sorted(true)
|
free_when_destroyed(true), is_sorted(true)
|
||||||
|
|
|
@ -77,19 +77,17 @@ class IOStream;
|
||||||
* imports the given file. ReadFile is not overridable, it just calls
|
* imports the given file. ReadFile is not overridable, it just calls
|
||||||
* InternReadFile() and catches any ImportErrorException that might occur.
|
* InternReadFile() and catches any ImportErrorException that might occur.
|
||||||
*/
|
*/
|
||||||
class ASSIMP_API BaseImporter
|
class ASSIMP_API BaseImporter {
|
||||||
{
|
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Constructor to be privately used by #Importer */
|
/** Constructor to be privately used by #Importer */
|
||||||
BaseImporter();
|
BaseImporter() AI_NO_EXCEPT;
|
||||||
|
|
||||||
/** Destructor, private as well */
|
/** Destructor, private as well */
|
||||||
virtual ~BaseImporter();
|
virtual ~BaseImporter();
|
||||||
|
|
||||||
public:
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
*
|
*
|
||||||
|
|
|
@ -60,9 +60,8 @@ namespace Assimp {
|
||||||
* This is required to read big-endian model formats on little-endian machines,
|
* This is required to read big-endian model formats on little-endian machines,
|
||||||
* and vice versa. Direct use of this class is DEPRECATED. Use #StreamReader instead. */
|
* and vice versa. Direct use of this class is DEPRECATED. Use #StreamReader instead. */
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
class ByteSwap
|
class ByteSwap {
|
||||||
{
|
ByteSwap() AI_NO_EXCEPT {}
|
||||||
ByteSwap() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ class ASSIMP_API DefaultIOStream : public IOStream
|
||||||
#endif // __ANDROID__
|
#endif // __ANDROID__
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DefaultIOStream();
|
DefaultIOStream() AI_NO_EXCEPT;
|
||||||
DefaultIOStream(FILE* pFile, const std::string &strFilename);
|
DefaultIOStream(FILE* pFile, const std::string &strFilename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -111,27 +111,25 @@ private:
|
||||||
FILE* mFile;
|
FILE* mFile;
|
||||||
// Filename
|
// Filename
|
||||||
std::string mFilename;
|
std::string mFilename;
|
||||||
|
|
||||||
// Cached file size
|
// Cached file size
|
||||||
mutable size_t mCachedSize;
|
mutable size_t mCachedSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
inline DefaultIOStream::DefaultIOStream () :
|
inline
|
||||||
mFile (NULL),
|
DefaultIOStream::DefaultIOStream() AI_NO_EXCEPT
|
||||||
mFilename (""),
|
: mFile(nullptr)
|
||||||
mCachedSize(SIZE_MAX)
|
, mFilename("")
|
||||||
{
|
, mCachedSize(SIZE_MAX) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
inline DefaultIOStream::DefaultIOStream (FILE* pFile,
|
inline
|
||||||
const std::string &strFilename) :
|
DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename)
|
||||||
mFile(pFile),
|
: mFile(pFile)
|
||||||
mFilename(strFilename),
|
, mFilename(strFilename)
|
||||||
mCachedSize(SIZE_MAX)
|
, mCachedSize(SIZE_MAX) {
|
||||||
{
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -71,7 +71,7 @@ class ASSIMP_API IOStream
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/** Constructor protected, use IOSystem::Open() to create an instance. */
|
/** Constructor protected, use IOSystem::Open() to create an instance. */
|
||||||
IOStream();
|
IOStream() AI_NO_EXCEPT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -126,7 +126,7 @@ public:
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
inline
|
inline
|
||||||
IOStream::IOStream() {
|
IOStream::IOStream() AI_NO_EXCEPT {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
* Create an instance of your derived class and assign it to an
|
* Create an instance of your derived class and assign it to an
|
||||||
* #Assimp::Importer instance by calling Importer::SetIOHandler().
|
* #Assimp::Importer instance by calling Importer::SetIOHandler().
|
||||||
*/
|
*/
|
||||||
IOSystem();
|
IOSystem() AI_NO_EXCEPT;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Virtual destructor.
|
/** @brief Virtual destructor.
|
||||||
|
@ -105,9 +105,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual ~IOSystem();
|
virtual ~IOSystem();
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief For backward compatibility
|
/** @brief For backward compatibility
|
||||||
* @see Exists(const char*)
|
* @see Exists(const char*)
|
||||||
|
@ -233,7 +230,7 @@ private:
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
AI_FORCE_INLINE
|
AI_FORCE_INLINE
|
||||||
IOSystem::IOSystem()
|
IOSystem::IOSystem() AI_NO_EXCEPT
|
||||||
: m_pathStack() {
|
: m_pathStack() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ASSIMP_API LogStream
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/** @brief Default constructor */
|
/** @brief Default constructor */
|
||||||
LogStream();
|
LogStream() AI_NO_EXCEPT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** @brief Virtual destructor */
|
/** @brief Virtual destructor */
|
||||||
|
@ -91,12 +91,12 @@ public:
|
||||||
* @return New LogStream instance. */
|
* @return New LogStream instance. */
|
||||||
static LogStream* createDefaultStream(aiDefaultLogStream stream,
|
static LogStream* createDefaultStream(aiDefaultLogStream stream,
|
||||||
const char* name = "AssimpLog.txt",
|
const char* name = "AssimpLog.txt",
|
||||||
IOSystem* io = NULL);
|
IOSystem* io = nullptr );
|
||||||
|
|
||||||
}; // !class LogStream
|
}; // !class LogStream
|
||||||
|
|
||||||
inline
|
inline
|
||||||
LogStream::LogStream() {
|
LogStream::LogStream() AI_NO_EXCEPT {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ protected:
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
Logger();
|
Logger() AI_NO_EXCEPT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construction with a given log severity
|
* Construction with a given log severity
|
||||||
|
@ -215,8 +215,9 @@ protected:
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// Default constructor
|
// Default constructor
|
||||||
inline
|
inline
|
||||||
Logger::Logger() {
|
Logger::Logger() AI_NO_EXCEPT
|
||||||
setLogSeverity(NORMAL);
|
: m_Severity(NORMAL) {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ -229,8 +230,9 @@ Logger::~Logger() {
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// Construction with given logging severity
|
// Construction with given logging severity
|
||||||
inline
|
inline
|
||||||
Logger::Logger(LogSeverity severity) {
|
Logger::Logger(LogSeverity severity)
|
||||||
setLogSeverity(severity);
|
: m_Severity(severity) {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -63,7 +63,7 @@ class ASSIMP_API ProgressHandler
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/** @brief Default constructor */
|
/** @brief Default constructor */
|
||||||
ProgressHandler () {
|
ProgressHandler () AI_NO_EXCEPT {
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
/** @brief Virtual destructor */
|
/** @brief Virtual destructor */
|
||||||
|
|
|
@ -111,26 +111,34 @@ protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** An entry in a spatially sorted position array. Consists of a
|
/** An entry in a spatially sorted position array. Consists of a
|
||||||
* vertex index, its position and its precalculated distance from
|
* vertex index, its position and its pre-calculated distance from
|
||||||
* the reference plane */
|
* the reference plane */
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
struct Entry
|
struct Entry {
|
||||||
{
|
|
||||||
unsigned int mIndex; ///< The vertex referred by this entry
|
unsigned int mIndex; ///< The vertex referred by this entry
|
||||||
aiVector3D mPosition; ///< Position
|
aiVector3D mPosition; ///< Position
|
||||||
uint32_t mSmoothGroups;
|
uint32_t mSmoothGroups;
|
||||||
float mDistance; ///< Distance of this vertex to the sorting plane
|
float mDistance; ///< Distance of this vertex to the sorting plane
|
||||||
|
|
||||||
Entry() { /** intentionally not initialized.*/ }
|
Entry() AI_NO_EXCEPT
|
||||||
Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
|
: mIndex(0)
|
||||||
:
|
, mPosition()
|
||||||
mIndex( pIndex),
|
, mSmoothGroups(0)
|
||||||
mPosition( pPosition),
|
, mDistance(0.0f) {
|
||||||
mSmoothGroups (pSG),
|
// empty
|
||||||
mDistance( pDistance)
|
}
|
||||||
{ }
|
|
||||||
|
|
||||||
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
|
Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
|
||||||
|
: mIndex( pIndex)
|
||||||
|
, mPosition( pPosition)
|
||||||
|
, mSmoothGroups(pSG)
|
||||||
|
, mDistance( pDistance) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const Entry& e) const {
|
||||||
|
return mDistance < e.mDistance;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// all positions, sorted by distance to the sorting plane
|
// all positions, sorted by distance to the sorting plane
|
||||||
|
|
|
@ -52,12 +52,10 @@ http://www.jalix.org/ressources/graphics/3DS/_unofficials/3ds-unofficial.txt */
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure representing a face with smoothing groups assigned */
|
/** Helper structure representing a face with smoothing groups assigned */
|
||||||
struct FaceWithSmoothingGroup
|
struct FaceWithSmoothingGroup {
|
||||||
{
|
FaceWithSmoothingGroup() AI_NO_EXCEPT
|
||||||
FaceWithSmoothingGroup()
|
: mIndices()
|
||||||
: mIndices(),
|
, iSmoothGroup(0) {
|
||||||
iSmoothGroup(0)
|
|
||||||
{
|
|
||||||
// in debug builds set all indices to a common magic value
|
// in debug builds set all indices to a common magic value
|
||||||
#ifdef ASSIMP_BUILD_DEBUG
|
#ifdef ASSIMP_BUILD_DEBUG
|
||||||
this->mIndices[0] = 0xffffffff;
|
this->mIndices[0] = 0xffffffff;
|
||||||
|
|
|
@ -153,7 +153,7 @@ protected:
|
||||||
aiVector3D mPosition; ///< Position
|
aiVector3D mPosition; ///< Position
|
||||||
ai_real mDistance; ///< Distance of this vertex to the sorting plane
|
ai_real mDistance; ///< Distance of this vertex to the sorting plane
|
||||||
|
|
||||||
Entry()
|
Entry() AI_NO_EXCEPT
|
||||||
: mIndex( 999999999 ), mPosition(), mDistance( 99999. ) {
|
: mIndex( 999999999 ), mPosition(), mDistance( 99999. ) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ struct aiVectorKey
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
/// @brief The default constructor.
|
/// @brief The default constructor.
|
||||||
aiVectorKey()
|
aiVectorKey() AI_NO_EXCEPT
|
||||||
: mTime( 0.0 )
|
: mTime( 0.0 )
|
||||||
, mValue() {
|
, mValue() {
|
||||||
// empty
|
// empty
|
||||||
|
@ -116,7 +116,7 @@ struct aiQuatKey
|
||||||
C_STRUCT aiQuaternion mValue;
|
C_STRUCT aiQuaternion mValue;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiQuatKey()
|
aiQuatKey() AI_NO_EXCEPT
|
||||||
: mTime( 0.0 )
|
: mTime( 0.0 )
|
||||||
, mValue() {
|
, mValue() {
|
||||||
// empty
|
// empty
|
||||||
|
@ -163,7 +163,7 @@ struct aiMeshKey
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
aiMeshKey()
|
aiMeshKey() AI_NO_EXCEPT
|
||||||
: mTime(0.0)
|
: mTime(0.0)
|
||||||
, mValue(0)
|
, mValue(0)
|
||||||
{
|
{
|
||||||
|
@ -210,10 +210,10 @@ struct aiMeshMorphKey
|
||||||
/** The number of values and weights */
|
/** The number of values and weights */
|
||||||
unsigned int mNumValuesAndWeights;
|
unsigned int mNumValuesAndWeights;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiMeshMorphKey()
|
aiMeshMorphKey() AI_NO_EXCEPT
|
||||||
: mTime(0.0)
|
: mTime(0.0)
|
||||||
, mValues(NULL)
|
, mValues(nullptr)
|
||||||
, mWeights(NULL)
|
, mWeights(nullptr)
|
||||||
, mNumValuesAndWeights(0)
|
, mNumValuesAndWeights(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -324,13 +324,13 @@ struct aiNodeAnim {
|
||||||
C_ENUM aiAnimBehaviour mPostState;
|
C_ENUM aiAnimBehaviour mPostState;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiNodeAnim()
|
aiNodeAnim() AI_NO_EXCEPT
|
||||||
: mNumPositionKeys( 0 )
|
: mNumPositionKeys( 0 )
|
||||||
, mPositionKeys( NULL )
|
, mPositionKeys( nullptr )
|
||||||
, mNumRotationKeys( 0 )
|
, mNumRotationKeys( 0 )
|
||||||
, mRotationKeys( NULL )
|
, mRotationKeys( nullptr )
|
||||||
, mNumScalingKeys( 0 )
|
, mNumScalingKeys( 0 )
|
||||||
, mScalingKeys( NULL )
|
, mScalingKeys( nullptr )
|
||||||
, mPreState( aiAnimBehaviour_DEFAULT )
|
, mPreState( aiAnimBehaviour_DEFAULT )
|
||||||
, mPostState( aiAnimBehaviour_DEFAULT ) {
|
, mPostState( aiAnimBehaviour_DEFAULT ) {
|
||||||
// empty
|
// empty
|
||||||
|
@ -366,7 +366,7 @@ struct aiMeshAnim
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
aiMeshAnim()
|
aiMeshAnim() AI_NO_EXCEPT
|
||||||
: mNumKeys()
|
: mNumKeys()
|
||||||
, mKeys()
|
, mKeys()
|
||||||
{}
|
{}
|
||||||
|
@ -397,7 +397,7 @@ struct aiMeshMorphAnim
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
aiMeshMorphAnim()
|
aiMeshMorphAnim() AI_NO_EXCEPT
|
||||||
: mNumKeys()
|
: mNumKeys()
|
||||||
, mKeys()
|
, mKeys()
|
||||||
{}
|
{}
|
||||||
|
@ -451,15 +451,15 @@ struct aiAnimation {
|
||||||
C_STRUCT aiMeshMorphAnim **mMorphMeshChannels;
|
C_STRUCT aiMeshMorphAnim **mMorphMeshChannels;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiAnimation()
|
aiAnimation() AI_NO_EXCEPT
|
||||||
: mDuration(-1.)
|
: mDuration(-1.)
|
||||||
, mTicksPerSecond(0.)
|
, mTicksPerSecond(0.)
|
||||||
, mNumChannels(0)
|
, mNumChannels(0)
|
||||||
, mChannels(NULL)
|
, mChannels(nullptr)
|
||||||
, mNumMeshChannels(0)
|
, mNumMeshChannels(0)
|
||||||
, mMeshChannels(NULL)
|
, mMeshChannels(nullptr)
|
||||||
, mNumMorphMeshChannels(0)
|
, mNumMorphMeshChannels(0)
|
||||||
, mMorphMeshChannels(NULL) {
|
, mMorphMeshChannels(nullptr) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ struct aiCamera
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
aiCamera()
|
aiCamera() AI_NO_EXCEPT
|
||||||
: mUp (0.f,1.f,0.f)
|
: mUp (0.f,1.f,0.f)
|
||||||
, mLookAt (0.f,0.f,1.f)
|
, mLookAt (0.f,0.f,1.f)
|
||||||
, mHorizontalFOV (0.25f * (float)AI_MATH_PI)
|
, mHorizontalFOV (0.25f * (float)AI_MATH_PI)
|
||||||
|
|
|
@ -59,7 +59,7 @@ template <typename TReal>
|
||||||
class aiColor4t
|
class aiColor4t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
aiColor4t () : r(), g(), b(), a() {}
|
aiColor4t() AI_NO_EXCEPT : r(), g(), b(), a() {}
|
||||||
aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
|
aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
|
||||||
: r(_r), g(_g), b(_b), a(_a) {}
|
: r(_r), g(_g), b(_b), a(_a) {}
|
||||||
explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
|
explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
|
||||||
|
|
|
@ -289,4 +289,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
|
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
# define AI_NO_EXCEPT noexcept
|
||||||
|
#else
|
||||||
|
# if (_MSC_VER == 1915 )
|
||||||
|
# define AI_NO_EXCEPT noexcept
|
||||||
|
# else
|
||||||
|
# define AI_NO_EXCEPT
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // !! AI_DEFINES_H_INC
|
#endif // !! AI_DEFINES_H_INC
|
||||||
|
|
|
@ -195,7 +195,7 @@ uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_ino
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t new_value = ( value * 10 ) + ( *in - '0' );
|
const uint64_t new_value = ( value * (uint64_t) 10 ) + ( (uint64_t) ( *in - '0' ) );
|
||||||
|
|
||||||
// numeric overflow, we rely on you
|
// numeric overflow, we rely on you
|
||||||
if ( new_value < value ) {
|
if ( new_value < value ) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// some long includes ....
|
// some long includes ....
|
||||||
#include <irrXML.h>
|
#include <irrXML.h>
|
||||||
#include "./../include/assimp/IOStream.hpp"
|
#include "IOStream.hpp"
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ struct aiLight
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
aiLight()
|
aiLight() AI_NO_EXCEPT
|
||||||
: mType (aiLightSource_UNDEFINED)
|
: mType (aiLightSource_UNDEFINED)
|
||||||
, mAttenuationConstant (0.f)
|
, mAttenuationConstant (0.f)
|
||||||
, mAttenuationLinear (1.f)
|
, mAttenuationLinear (1.f)
|
||||||
|
|
|
@ -483,7 +483,7 @@ struct aiUVTransform
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiUVTransform()
|
aiUVTransform() AI_NO_EXCEPT
|
||||||
: mTranslation (0.0,0.0)
|
: mTranslation (0.0,0.0)
|
||||||
, mScaling (1.0,1.0)
|
, mScaling (1.0,1.0)
|
||||||
, mRotation (0.0)
|
, mRotation (0.0)
|
||||||
|
@ -607,7 +607,7 @@ struct aiMaterialProperty
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
aiMaterialProperty()
|
aiMaterialProperty() AI_NO_EXCEPT
|
||||||
: mSemantic( 0 )
|
: mSemantic( 0 )
|
||||||
, mIndex( 0 )
|
, mIndex( 0 )
|
||||||
, mDataLength( 0 )
|
, mDataLength( 0 )
|
||||||
|
|
|
@ -69,7 +69,7 @@ class aiMatrix3x3t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
aiMatrix3x3t () :
|
aiMatrix3x3t() AI_NO_EXCEPT :
|
||||||
a1(static_cast<TReal>(1.0f)), a2(), a3(),
|
a1(static_cast<TReal>(1.0f)), a2(), a3(),
|
||||||
b1(), b2(static_cast<TReal>(1.0f)), b3(),
|
b1(), b2(static_cast<TReal>(1.0f)), b3(),
|
||||||
c1(), c2(), c3(static_cast<TReal>(1.0f)) {}
|
c1(), c2(), c3(static_cast<TReal>(1.0f)) {}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class aiMatrix4x4t
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** set to identity */
|
/** set to identity */
|
||||||
aiMatrix4x4t ();
|
aiMatrix4x4t() AI_NO_EXCEPT;
|
||||||
|
|
||||||
/** construction from single values */
|
/** construction from single values */
|
||||||
aiMatrix4x4t ( TReal _a1, TReal _a2, TReal _a3, TReal _a4,
|
aiMatrix4x4t ( TReal _a1, TReal _a2, TReal _a3, TReal _a4,
|
||||||
|
|
|
@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
template <typename TReal>
|
template <typename TReal>
|
||||||
aiMatrix4x4t<TReal> ::aiMatrix4x4t () :
|
aiMatrix4x4t<TReal>::aiMatrix4x4t() AI_NO_EXCEPT :
|
||||||
a1(1.0f), a2(), a3(), a4(),
|
a1(1.0f), a2(), a3(), a4(),
|
||||||
b1(), b2(1.0f), b3(), b4(),
|
b1(), b2(1.0f), b3(), b4(),
|
||||||
c1(), c2(), c3(1.0f), c4(),
|
c1(), c2(), c3(1.0f), c4(),
|
||||||
|
|
|
@ -136,10 +136,10 @@ struct aiFace
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
aiFace()
|
aiFace() AI_NO_EXCEPT
|
||||||
: mNumIndices( 0 )
|
: mNumIndices( 0 )
|
||||||
, mIndices( NULL )
|
, mIndices( nullptr ) {
|
||||||
{
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Default destructor. Delete the index array
|
//! Default destructor. Delete the index array
|
||||||
|
@ -150,47 +150,56 @@ struct aiFace
|
||||||
|
|
||||||
//! Copy constructor. Copy the index array
|
//! Copy constructor. Copy the index array
|
||||||
aiFace( const aiFace& o)
|
aiFace( const aiFace& o)
|
||||||
: mIndices( NULL )
|
: mNumIndices(0)
|
||||||
{
|
, mIndices( nullptr ) {
|
||||||
*this = o;
|
*this = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Assignment operator. Copy the index array
|
//! Assignment operator. Copy the index array
|
||||||
aiFace& operator = ( const aiFace& o)
|
aiFace& operator = ( const aiFace& o) {
|
||||||
{
|
if (&o == this) {
|
||||||
if (&o == this)
|
|
||||||
return *this;
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
delete[] mIndices;
|
delete[] mIndices;
|
||||||
mNumIndices = o.mNumIndices;
|
mNumIndices = o.mNumIndices;
|
||||||
if (mNumIndices) {
|
if (mNumIndices) {
|
||||||
mIndices = new unsigned int[mNumIndices];
|
mIndices = new unsigned int[mNumIndices];
|
||||||
::memcpy( mIndices, o.mIndices, mNumIndices * sizeof( unsigned int));
|
::memcpy( mIndices, o.mIndices, mNumIndices * sizeof( unsigned int));
|
||||||
|
} else {
|
||||||
|
mIndices = nullptr;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
mIndices = NULL;
|
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Comparison operator. Checks whether the index array
|
//! Comparison operator. Checks whether the index array
|
||||||
//! of two faces is identical
|
//! of two faces is identical
|
||||||
bool operator== (const aiFace& o) const
|
bool operator== (const aiFace& o) const {
|
||||||
{
|
if (mIndices == o.mIndices) {
|
||||||
if (mIndices == o.mIndices)return true;
|
|
||||||
else if (mIndices && mNumIndices == o.mNumIndices)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0;i < this->mNumIndices;++i)
|
|
||||||
if (mIndices[i] != o.mIndices[i])return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nullptr != mIndices && mNumIndices != o.mNumIndices) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nullptr == mIndices) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < this->mNumIndices; ++i) {
|
||||||
|
if (mIndices[i] != o.mIndices[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//! Inverse comparison operator. Checks whether the index
|
//! Inverse comparison operator. Checks whether the index
|
||||||
//! array of two faces is NOT identical
|
//! array of two faces is NOT identical
|
||||||
bool operator != (const aiFace& o) const
|
bool operator != (const aiFace& o) const {
|
||||||
{
|
|
||||||
return !(*this == o);
|
return !(*this == o);
|
||||||
}
|
}
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -211,13 +220,13 @@ struct aiVertexWeight {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
aiVertexWeight()
|
aiVertexWeight() AI_NO_EXCEPT
|
||||||
: mVertexId(0)
|
: mVertexId(0)
|
||||||
, mWeight(0.0f) {
|
, mWeight(0.0f) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Initialisation from a given index and vertex weight factor
|
//! Initialization from a given index and vertex weight factor
|
||||||
//! \param pID ID
|
//! \param pID ID
|
||||||
//! \param pWeight Vertex weight factor
|
//! \param pWeight Vertex weight factor
|
||||||
aiVertexWeight( unsigned int pID, float pWeight )
|
aiVertexWeight( unsigned int pID, float pWeight )
|
||||||
|
@ -273,10 +282,11 @@ struct aiBone {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
aiBone()
|
aiBone() AI_NO_EXCEPT
|
||||||
: mName()
|
: mName()
|
||||||
, mNumWeights( 0 )
|
, mNumWeights( 0 )
|
||||||
, mWeights( nullptr ) {
|
, mWeights( nullptr )
|
||||||
|
, mOffsetMatrix() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,10 +294,9 @@ struct aiBone {
|
||||||
aiBone(const aiBone& other)
|
aiBone(const aiBone& other)
|
||||||
: mName( other.mName )
|
: mName( other.mName )
|
||||||
, mNumWeights( other.mNumWeights )
|
, mNumWeights( other.mNumWeights )
|
||||||
, mOffsetMatrix( other.mOffsetMatrix )
|
, mWeights(nullptr)
|
||||||
{
|
, mOffsetMatrix( other.mOffsetMatrix ) {
|
||||||
if (other.mWeights && other.mNumWeights)
|
if (other.mWeights && other.mNumWeights) {
|
||||||
{
|
|
||||||
mWeights = new aiVertexWeight[mNumWeights];
|
mWeights = new aiVertexWeight[mNumWeights];
|
||||||
::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight));
|
::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight));
|
||||||
}
|
}
|
||||||
|
@ -295,8 +304,7 @@ struct aiBone {
|
||||||
|
|
||||||
|
|
||||||
//! Assignment operator
|
//! Assignment operator
|
||||||
aiBone &operator=(const aiBone& other)
|
aiBone &operator=(const aiBone& other) {
|
||||||
{
|
|
||||||
if (this == &other) {
|
if (this == &other) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -332,8 +340,7 @@ struct aiBone {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//! Destructor - deletes the array of vertex weights
|
//! Destructor - deletes the array of vertex weights
|
||||||
~aiBone()
|
~aiBone() {
|
||||||
{
|
|
||||||
delete [] mWeights;
|
delete [] mWeights;
|
||||||
}
|
}
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -447,11 +454,13 @@ struct aiAnimMesh
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
aiAnimMesh()
|
aiAnimMesh() AI_NO_EXCEPT
|
||||||
: mVertices( NULL )
|
: mVertices( nullptr )
|
||||||
, mNormals( NULL )
|
, mNormals(nullptr)
|
||||||
, mTangents( NULL )
|
, mTangents(nullptr)
|
||||||
, mBitangents( NULL )
|
, mBitangents(nullptr)
|
||||||
|
, mColors()
|
||||||
|
, mTextureCoords()
|
||||||
, mNumVertices( 0 )
|
, mNumVertices( 0 )
|
||||||
, mWeight( 0.0f )
|
, mWeight( 0.0f )
|
||||||
{
|
{
|
||||||
|
@ -706,35 +715,36 @@ struct aiMesh
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
//! Default constructor. Initializes all members to 0
|
//! Default constructor. Initializes all members to 0
|
||||||
aiMesh()
|
aiMesh() AI_NO_EXCEPT
|
||||||
: mPrimitiveTypes( 0 )
|
: mPrimitiveTypes( 0 )
|
||||||
, mNumVertices( 0 )
|
, mNumVertices( 0 )
|
||||||
, mNumFaces( 0 )
|
, mNumFaces( 0 )
|
||||||
, mVertices( NULL )
|
, mVertices( nullptr )
|
||||||
, mNormals( NULL )
|
, mNormals(nullptr)
|
||||||
, mTangents( NULL )
|
, mTangents(nullptr)
|
||||||
, mBitangents( NULL )
|
, mBitangents(nullptr)
|
||||||
, mFaces( NULL )
|
, mColors()
|
||||||
|
, mTextureCoords()
|
||||||
|
, mNumUVComponents()
|
||||||
|
, mFaces(nullptr)
|
||||||
, mNumBones( 0 )
|
, mNumBones( 0 )
|
||||||
, mBones( NULL )
|
, mBones(nullptr)
|
||||||
, mMaterialIndex( 0 )
|
, mMaterialIndex( 0 )
|
||||||
, mNumAnimMeshes( 0 )
|
, mNumAnimMeshes( 0 )
|
||||||
, mAnimMeshes( NULL )
|
, mAnimMeshes(nullptr)
|
||||||
, mMethod( 0 )
|
, mMethod( 0 ) {
|
||||||
{
|
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) {
|
||||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
|
|
||||||
{
|
|
||||||
mNumUVComponents[a] = 0;
|
mNumUVComponents[a] = 0;
|
||||||
mTextureCoords[a] = NULL;
|
mTextureCoords[a] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
|
||||||
mColors[a] = NULL;
|
mColors[a] = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Deletes all storage allocated for the mesh
|
//! Deletes all storage allocated for the mesh
|
||||||
~aiMesh()
|
~aiMesh() {
|
||||||
{
|
|
||||||
delete [] mVertices;
|
delete [] mVertices;
|
||||||
delete [] mNormals;
|
delete [] mNormals;
|
||||||
delete [] mTangents;
|
delete [] mTangents;
|
||||||
|
@ -767,63 +777,67 @@ struct aiMesh
|
||||||
//! Check whether the mesh contains positions. Provided no special
|
//! Check whether the mesh contains positions. Provided no special
|
||||||
//! scene flags are set, this will always be true
|
//! scene flags are set, this will always be true
|
||||||
bool HasPositions() const
|
bool HasPositions() const
|
||||||
{ return mVertices != NULL && mNumVertices > 0; }
|
{ return mVertices != nullptr && mNumVertices > 0; }
|
||||||
|
|
||||||
//! Check whether the mesh contains faces. If no special scene flags
|
//! Check whether the mesh contains faces. If no special scene flags
|
||||||
//! are set this should always return true
|
//! are set this should always return true
|
||||||
bool HasFaces() const
|
bool HasFaces() const
|
||||||
{ return mFaces != NULL && mNumFaces > 0; }
|
{ return mFaces != nullptr && mNumFaces > 0; }
|
||||||
|
|
||||||
//! Check whether the mesh contains normal vectors
|
//! Check whether the mesh contains normal vectors
|
||||||
bool HasNormals() const
|
bool HasNormals() const
|
||||||
{ return mNormals != NULL && mNumVertices > 0; }
|
{ return mNormals != nullptr && mNumVertices > 0; }
|
||||||
|
|
||||||
//! Check whether the mesh contains tangent and bitangent vectors
|
//! Check whether the mesh contains tangent and bitangent vectors
|
||||||
//! It is not possible that it contains tangents and no bitangents
|
//! It is not possible that it contains tangents and no bitangents
|
||||||
//! (or the other way round). The existence of one of them
|
//! (or the other way round). The existence of one of them
|
||||||
//! implies that the second is there, too.
|
//! implies that the second is there, too.
|
||||||
bool HasTangentsAndBitangents() const
|
bool HasTangentsAndBitangents() const
|
||||||
{ return mTangents != NULL && mBitangents != NULL && mNumVertices > 0; }
|
{ return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; }
|
||||||
|
|
||||||
//! Check whether the mesh contains a vertex color set
|
//! Check whether the mesh contains a vertex color set
|
||||||
//! \param pIndex Index of the vertex color set
|
//! \param pIndex Index of the vertex color set
|
||||||
bool HasVertexColors( unsigned int pIndex) const
|
bool HasVertexColors( unsigned int pIndex) const {
|
||||||
{
|
if (pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) {
|
||||||
if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
|
|
||||||
return false;
|
return false;
|
||||||
else
|
} else {
|
||||||
return mColors[pIndex] != NULL && mNumVertices > 0;
|
return mColors[pIndex] != nullptr && mNumVertices > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains a texture coordinate set
|
//! Check whether the mesh contains a texture coordinate set
|
||||||
//! \param pIndex Index of the texture coordinates set
|
//! \param pIndex Index of the texture coordinates set
|
||||||
bool HasTextureCoords( unsigned int pIndex) const
|
bool HasTextureCoords( unsigned int pIndex) const {
|
||||||
{
|
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||||
if( pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
|
||||||
return false;
|
return false;
|
||||||
else
|
} else {
|
||||||
return mTextureCoords[pIndex] != NULL && mNumVertices > 0;
|
return mTextureCoords[pIndex] != nullptr && mNumVertices > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get the number of UV channels the mesh contains
|
//! Get the number of UV channels the mesh contains
|
||||||
unsigned int GetNumUVChannels() const
|
unsigned int GetNumUVChannels() const {
|
||||||
{
|
unsigned int n( 0 );
|
||||||
unsigned int n = 0;
|
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
|
||||||
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n])++n;
|
++n;
|
||||||
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get the number of vertex color channels the mesh contains
|
//! Get the number of vertex color channels the mesh contains
|
||||||
unsigned int GetNumColorChannels() const
|
unsigned int GetNumColorChannels() const {
|
||||||
{
|
unsigned int n(0);
|
||||||
unsigned int n = 0;
|
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) {
|
||||||
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n])++n;
|
++n;
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains bones
|
//! Check whether the mesh contains bones
|
||||||
inline bool HasBones() const
|
bool HasBones() const {
|
||||||
{ return mBones != NULL && mNumBones > 0; }
|
return mBones != nullptr && mNumBones > 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
|
@ -129,7 +129,7 @@ struct aiMetadata {
|
||||||
/**
|
/**
|
||||||
* @brief The default constructor, set all members to zero by default.
|
* @brief The default constructor, set all members to zero by default.
|
||||||
*/
|
*/
|
||||||
aiMetadata()
|
aiMetadata() AI_NO_EXCEPT
|
||||||
: mNumProperties(0)
|
: mNumProperties(0)
|
||||||
, mKeys(nullptr)
|
, mKeys(nullptr)
|
||||||
, mValues(nullptr) {
|
, mValues(nullptr) {
|
||||||
|
@ -141,11 +141,11 @@ struct aiMetadata {
|
||||||
, mKeys( nullptr )
|
, mKeys( nullptr )
|
||||||
, mValues( nullptr ) {
|
, mValues( nullptr ) {
|
||||||
mKeys = new aiString[ mNumProperties ];
|
mKeys = new aiString[ mNumProperties ];
|
||||||
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
|
for ( size_t i = 0; i < static_cast<size_t>( mNumProperties ); ++i ) {
|
||||||
mKeys[ i ] = rhs.mKeys[ i ];
|
mKeys[ i ] = rhs.mKeys[ i ];
|
||||||
}
|
}
|
||||||
mValues = new aiMetadataEntry[ mNumProperties ];
|
mValues = new aiMetadataEntry[ mNumProperties ];
|
||||||
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
|
for ( size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i ) {
|
||||||
mValues[ i ].mType = rhs.mValues[ i ].mType;
|
mValues[ i ].mType = rhs.mValues[ i ].mType;
|
||||||
switch ( rhs.mValues[ i ].mType ) {
|
switch ( rhs.mValues[ i ].mType ) {
|
||||||
case AI_BOOL:
|
case AI_BOOL:
|
||||||
|
|
|
@ -60,7 +60,7 @@ template <typename TReal>
|
||||||
class aiQuaterniont
|
class aiQuaterniont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
aiQuaterniont() : w(1.0), x(), y(), z() {}
|
aiQuaterniont() AI_NO_EXCEPT : w(1.0), x(), y(), z() {}
|
||||||
aiQuaterniont(TReal pw, TReal px, TReal py, TReal pz)
|
aiQuaterniont(TReal pw, TReal px, TReal py, TReal pz)
|
||||||
: w(pw), x(px), y(py), z(pz) {}
|
: w(pw), x(px), y(py), z(pz) {}
|
||||||
|
|
||||||
|
|
|
@ -131,8 +131,7 @@ struct aiTexel
|
||||||
* as the texture paths (a single asterisk character followed by the
|
* as the texture paths (a single asterisk character followed by the
|
||||||
* zero-based index of the texture in the aiScene::mTextures array).
|
* zero-based index of the texture in the aiScene::mTextures array).
|
||||||
*/
|
*/
|
||||||
struct aiTexture
|
struct aiTexture {
|
||||||
{
|
|
||||||
/** Width of the texture, in pixels
|
/** Width of the texture, in pixels
|
||||||
*
|
*
|
||||||
* If mHeight is zero the texture is compressed in a format
|
* If mHeight is zero the texture is compressed in a format
|
||||||
|
@ -193,24 +192,26 @@ struct aiTexture
|
||||||
//! @param s Input string. 3 characters are maximally processed.
|
//! @param s Input string. 3 characters are maximally processed.
|
||||||
//! Example values: "jpg", "png"
|
//! Example values: "jpg", "png"
|
||||||
//! @return true if the given string matches the format hint
|
//! @return true if the given string matches the format hint
|
||||||
bool CheckFormat(const char* s) const
|
bool CheckFormat(const char* s) const {
|
||||||
{
|
if (nullptr == s) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (0 == ::strncmp(achFormatHint, s, sizeof(achFormatHint)));
|
return (0 == ::strncmp(achFormatHint, s, sizeof(achFormatHint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construction
|
// Construction
|
||||||
aiTexture ()
|
aiTexture() AI_NO_EXCEPT
|
||||||
: mWidth(0)
|
: mWidth(0)
|
||||||
, mHeight(0)
|
, mHeight(0)
|
||||||
, pcData (NULL)
|
, pcData(nullptr)
|
||||||
{
|
, mFilename() {
|
||||||
achFormatHint[0] = achFormatHint[1] = 0;
|
achFormatHint[0] = achFormatHint[1] = 0;
|
||||||
achFormatHint[2] = achFormatHint[3] = 0;
|
achFormatHint[2] = achFormatHint[3] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destruction
|
// Destruction
|
||||||
~aiTexture ()
|
~aiTexture () {
|
||||||
{
|
|
||||||
delete[] pcData;
|
delete[] pcData;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -119,10 +119,9 @@ extern "C" {
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
/** Represents a plane in a three-dimensional, euclidean space
|
/** Represents a plane in a three-dimensional, euclidean space
|
||||||
*/
|
*/
|
||||||
struct aiPlane
|
struct aiPlane {
|
||||||
{
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiPlane () : a(0.f), b(0.f), c(0.f), d(0.f) {}
|
aiPlane () AI_NO_EXCEPT : a(0.f), b(0.f), c(0.f), d(0.f) {}
|
||||||
aiPlane (ai_real _a, ai_real _b, ai_real _c, ai_real _d)
|
aiPlane (ai_real _a, ai_real _b, ai_real _c, ai_real _d)
|
||||||
: a(_a), b(_b), c(_c), d(_d) {}
|
: a(_a), b(_b), c(_c), d(_d) {}
|
||||||
|
|
||||||
|
@ -137,10 +136,9 @@ struct aiPlane
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
/** Represents a ray
|
/** Represents a ray
|
||||||
*/
|
*/
|
||||||
struct aiRay
|
struct aiRay {
|
||||||
{
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiRay () {}
|
aiRay () AI_NO_EXCEPT {}
|
||||||
aiRay (const aiVector3D& _pos, const aiVector3D& _dir)
|
aiRay (const aiVector3D& _pos, const aiVector3D& _dir)
|
||||||
: pos(_pos), dir(_dir) {}
|
: pos(_pos), dir(_dir) {}
|
||||||
|
|
||||||
|
@ -158,7 +156,7 @@ struct aiRay
|
||||||
struct aiColor3D
|
struct aiColor3D
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
|
aiColor3D () AI_NO_EXCEPT : r(0.0f), g(0.0f), b(0.0f) {}
|
||||||
aiColor3D (ai_real _r, ai_real _g, ai_real _b) : r(_r), g(_g), b(_b) {}
|
aiColor3D (ai_real _r, ai_real _g, ai_real _b) : r(_r), g(_g), b(_b) {}
|
||||||
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
|
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
|
||||||
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
||||||
|
@ -253,9 +251,8 @@ struct aiString
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
/** Default constructor, the string is set to have zero length */
|
/** Default constructor, the string is set to have zero length */
|
||||||
aiString() :
|
aiString() AI_NO_EXCEPT
|
||||||
length(0)
|
: length( 0 ) {
|
||||||
{
|
|
||||||
data[0] = '\0';
|
data[0] = '\0';
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_DEBUG
|
#ifdef ASSIMP_BUILD_DEBUG
|
||||||
|
@ -305,7 +302,7 @@ struct aiString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Assigment operator */
|
/** Assignment operator */
|
||||||
aiString& operator = (const aiString &rOther) {
|
aiString& operator = (const aiString &rOther) {
|
||||||
if (this == &rOther) {
|
if (this == &rOther) {
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -373,7 +370,7 @@ struct aiString
|
||||||
#endif // !__cplusplus
|
#endif // !__cplusplus
|
||||||
|
|
||||||
/** Binary length of the string excluding the terminal 0. This is NOT the
|
/** Binary length of the string excluding the terminal 0. This is NOT the
|
||||||
* logical length of strings containing UTF-8 multibyte sequences! It's
|
* logical length of strings containing UTF-8 multi-byte sequences! It's
|
||||||
* the number of bytes from the beginning of the string to its end.*/
|
* the number of bytes from the beginning of the string to its end.*/
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
|
@ -479,7 +476,7 @@ struct aiMemoryInfo
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
aiMemoryInfo()
|
aiMemoryInfo() AI_NO_EXCEPT
|
||||||
: textures (0)
|
: textures (0)
|
||||||
, materials (0)
|
, materials (0)
|
||||||
, meshes (0)
|
, meshes (0)
|
||||||
|
|
|
@ -66,7 +66,7 @@ template <typename TReal>
|
||||||
class aiVector3t
|
class aiVector3t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
aiVector3t() : x(), y(), z() {}
|
aiVector3t() AI_NO_EXCEPT : x(), y(), z() {}
|
||||||
aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
|
aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
|
||||||
explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
|
explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
|
||||||
aiVector3t( const aiVector3t& o ) : x(o.x), y(o.y), z(o.z) {}
|
aiVector3t( const aiVector3t& o ) : x(o.x), y(o.y), z(o.z) {}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Please check the following github-repo for the source: https://github.com/kebby/assimp-net
|
Please check the following git-repo for the source: https://bitbucket.org/Starnick/assimpnet
|
||||||
|
|
|
@ -35,7 +35,7 @@ class AssimpLib(object):
|
||||||
"""
|
"""
|
||||||
Assimp-Singleton
|
Assimp-Singleton
|
||||||
"""
|
"""
|
||||||
load, load_mem, export, release, dll = helper.search_library()
|
load, load_mem, export, export_blob, release, dll = helper.search_library()
|
||||||
_assimp_lib = AssimpLib()
|
_assimp_lib = AssimpLib()
|
||||||
|
|
||||||
def make_tuple(ai_obj, type = None):
|
def make_tuple(ai_obj, type = None):
|
||||||
|
@ -352,6 +352,33 @@ def export(scene,
|
||||||
if exportStatus != 0:
|
if exportStatus != 0:
|
||||||
raise AssimpError('Could not export scene!')
|
raise AssimpError('Could not export scene!')
|
||||||
|
|
||||||
|
def export_blob(scene,
|
||||||
|
file_type = None,
|
||||||
|
processing = postprocess.aiProcess_Triangulate):
|
||||||
|
'''
|
||||||
|
Export a scene and return a blob in the correct format. On failure throws AssimpError.
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
---------
|
||||||
|
scene: scene to export.
|
||||||
|
file_type: string of file exporter to use. For example "collada".
|
||||||
|
processing: assimp postprocessing parameters. Verbose keywords are imported
|
||||||
|
from postprocessing, and the parameters can be combined bitwise to
|
||||||
|
generate the final processing value. Note that the default value will
|
||||||
|
triangulate quad faces. Example of generating other possible values:
|
||||||
|
processing = (pyassimp.postprocess.aiProcess_Triangulate |
|
||||||
|
pyassimp.postprocess.aiProcess_OptimizeMeshes)
|
||||||
|
Returns
|
||||||
|
---------
|
||||||
|
Pointer to structs.ExportDataBlob
|
||||||
|
'''
|
||||||
|
from ctypes import pointer
|
||||||
|
exportBlobPtr = _assimp_lib.export_blob(pointer(scene), file_type.encode("ascii"), processing)
|
||||||
|
|
||||||
|
if exportBlobPtr == 0:
|
||||||
|
raise AssimpError('Could not export scene to blob!')
|
||||||
|
return exportBlobPtr
|
||||||
|
|
||||||
def release(scene):
|
def release(scene):
|
||||||
from ctypes import pointer
|
from ctypes import pointer
|
||||||
_assimp_lib.release(pointer(scene))
|
_assimp_lib.release(pointer(scene))
|
||||||
|
|
|
@ -176,6 +176,7 @@ def try_load_functions(library_path, dll):
|
||||||
load from filename function,
|
load from filename function,
|
||||||
load from memory function,
|
load from memory function,
|
||||||
export to filename function,
|
export to filename function,
|
||||||
|
export to blob function,
|
||||||
release function,
|
release function,
|
||||||
ctypes handle to assimp library)
|
ctypes handle to assimp library)
|
||||||
'''
|
'''
|
||||||
|
@ -185,15 +186,17 @@ def try_load_functions(library_path, dll):
|
||||||
release = dll.aiReleaseImport
|
release = dll.aiReleaseImport
|
||||||
load_mem = dll.aiImportFileFromMemory
|
load_mem = dll.aiImportFileFromMemory
|
||||||
export = dll.aiExportScene
|
export = dll.aiExportScene
|
||||||
|
export2blob = dll.aiExportSceneToBlob
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
#OK, this is a library, but it doesn't have the functions we need
|
#OK, this is a library, but it doesn't have the functions we need
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# library found!
|
# library found!
|
||||||
from .structs import Scene
|
from .structs import Scene, ExportDataBlob
|
||||||
load.restype = POINTER(Scene)
|
load.restype = POINTER(Scene)
|
||||||
load_mem.restype = POINTER(Scene)
|
load_mem.restype = POINTER(Scene)
|
||||||
return (library_path, load, load_mem, export, release, dll)
|
export2blob.restype = POINTER(ExportDataBlob)
|
||||||
|
return (library_path, load, load_mem, export, export2blob, release, dll)
|
||||||
|
|
||||||
def search_library():
|
def search_library():
|
||||||
'''
|
'''
|
||||||
|
@ -203,6 +206,7 @@ def search_library():
|
||||||
Returns: tuple, (load from filename function,
|
Returns: tuple, (load from filename function,
|
||||||
load from memory function,
|
load from memory function,
|
||||||
export to filename function,
|
export to filename function,
|
||||||
|
export to blob function,
|
||||||
release function,
|
release function,
|
||||||
dll)
|
dll)
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -996,6 +996,39 @@ class Animation(Structure):
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class ExportDataBlob(Structure):
|
||||||
|
"""
|
||||||
|
See 'cexport.h' for details.
|
||||||
|
|
||||||
|
Note that the '_fields_' definition is outside the class to allow the 'next' field to be recursive
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
ExportDataBlob._fields_ = [
|
||||||
|
# Size of the data in bytes
|
||||||
|
("size", c_size_t),
|
||||||
|
|
||||||
|
# The data.
|
||||||
|
("data", c_void_p),
|
||||||
|
|
||||||
|
# Name of the blob. An empty string always
|
||||||
|
# indicates the first (and primary) blob,
|
||||||
|
# which contains the actual file data.
|
||||||
|
# Any other blobs are auxiliary files produced
|
||||||
|
# by exporters (i.e. material files). Existence
|
||||||
|
# of such files depends on the file format. Most
|
||||||
|
# formats don't split assets across multiple files.
|
||||||
|
#
|
||||||
|
# If used, blob names usually contain the file
|
||||||
|
# extension that should be used when writing
|
||||||
|
# the data to disc.
|
||||||
|
("name", String),
|
||||||
|
|
||||||
|
# Pointer to the next blob in the chain or NULL if there is none.
|
||||||
|
("next", POINTER(ExportDataBlob)),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Scene(Structure):
|
class Scene(Structure):
|
||||||
"""
|
"""
|
||||||
See 'aiScene.h' for details.
|
See 'aiScene.h' for details.
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# Open Asset Import Library (ASSIMP)
|
# Open Asset Import Library (ASSIMP)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006-2010, ASSIMP Development Team
|
# Copyright (c) 2006-2018, ASSIMP Development Team
|
||||||
#
|
#
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -280,8 +280,3 @@ def work(filename):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(work(sys.argv[1] if len(sys.argv)>1 else 'schema.exp'))
|
sys.exit(work(sys.argv[1] if len(sys.argv)>1 else 'schema.exp'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -117,6 +117,9 @@ SET( IMPORTERS
|
||||||
unit/utB3DImportExport.cpp
|
unit/utB3DImportExport.cpp
|
||||||
unit/utMDCImportExport.cpp
|
unit/utMDCImportExport.cpp
|
||||||
unit/utAssbinImportExport.cpp
|
unit/utAssbinImportExport.cpp
|
||||||
|
unit/ImportExport/utCOBImportExport.cpp
|
||||||
|
unit/ImportExport/utOgreImportExport.cpp
|
||||||
|
unit/ImportExport/utQ3BSPFileImportExport.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( MATERIAL
|
SET( MATERIAL
|
||||||
|
@ -174,6 +177,7 @@ add_executable( unit
|
||||||
)
|
)
|
||||||
|
|
||||||
add_definitions(-DASSIMP_TEST_MODELS_DIR="${CMAKE_CURRENT_LIST_DIR}/models")
|
add_definitions(-DASSIMP_TEST_MODELS_DIR="${CMAKE_CURRENT_LIST_DIR}/models")
|
||||||
|
add_definitions(-DASSIMP_TEST_MODELS_NONBSD_DIR="${CMAKE_CURRENT_LIST_DIR}/models-nonbsd")
|
||||||
|
|
||||||
SET_PROPERTY( TARGET assimp PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} )
|
SET_PROPERTY( TARGET assimp PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} )
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<amf unit="inch" version="1.1">
|
||||||
|
<metadata type="name">Split Pyramid</metadata>
|
||||||
|
<metadata type="author">John Smith</metadata>
|
||||||
|
<object id="1">
|
||||||
|
<mesh>
|
||||||
|
<vertices>
|
||||||
|
<vertex><coordinates><x>0</x><y>0</y><z>0</z></coordinates></vertex>
|
||||||
|
<vertex><coordinates><x>1</x><y>0</y><z>0</z></coordinates></vertex>
|
||||||
|
<vertex><coordinates><x>0</x><y>1</y><z>0</z></coordinates></vertex>
|
||||||
|
<vertex><coordinates><x>1</x><y>1</y><z>0</z></coordinates></vertex>
|
||||||
|
<vertex><coordinates><x>0.5</x><y>0.5</y><z>1</z></coordinates></vertex>
|
||||||
|
</vertices>
|
||||||
|
<volume materialid="2">
|
||||||
|
<metadata type="name">Hard side</metadata>
|
||||||
|
<triangle><v1>2</v1><v2>1</v2><v3>0</v3></triangle>
|
||||||
|
<triangle><v1>0</v1><v2>1</v2><v3>4</v3></triangle>
|
||||||
|
<triangle><v1>4</v1><v2>1</v2><v3>2</v3></triangle>
|
||||||
|
<triangle><v1>0</v1><v2>4</v2><v3>2</v3></triangle>
|
||||||
|
</volume>
|
||||||
|
<volume materialid="3">
|
||||||
|
<metadata type="name">Soft side</metadata>
|
||||||
|
<triangle><v1>2</v1><v2>3</v2><v3>1</v3></triangle>
|
||||||
|
<triangle><v1>1</v1><v2>3</v2><v3>4</v3></triangle>
|
||||||
|
<triangle><v1>4</v1><v2>3</v2><v3>2</v3></triangle>
|
||||||
|
<triangle><v1>4</v1><v2>2</v2><v3>1</v3></triangle>
|
||||||
|
</volume>
|
||||||
|
</mesh>
|
||||||
|
</object>
|
||||||
|
<material id="2">
|
||||||
|
<metadata type="name">Hard material</metadata>
|
||||||
|
<color><r>0.1</r><g>0.1</g><b>0.1</b></color>
|
||||||
|
</material>
|
||||||
|
<material id="3">
|
||||||
|
<metadata type="name">Soft material</metadata>
|
||||||
|
<color><r>0</r><g>0.9</g><b>0.9</b><a>0.5</a></color>
|
||||||
|
</material>
|
||||||
|
</amf>
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
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 "UnitTestPCH.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utCOBImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule.cob", aiProcess_ValidateDataStructure);
|
||||||
|
return nullptr != scene;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utCOBImportExport, importAMFFromFileTest) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
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 "UnitTestPCH.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utOgreImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Ogre/TheThing/Mesh.mesh.xml", aiProcess_ValidateDataStructure);
|
||||||
|
return nullptr != scene;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utOgreImportExport, importerTest ) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
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 "UnitTestPCH.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utQ3BSPImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/PK3/SGDTT3.pk3", 0);
|
||||||
|
return nullptr != scene;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utQ3BSPImportExport, importerTest) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
|
@ -59,6 +59,14 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utAMFImportExport, importACFromFileTest ) {
|
TEST_F( utAMFImportExport, importAMFFromFileTest ) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE( importerTest() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TEST_F(utAMFImportExport, importAMFWithMatFromFileTest) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test_with_mat.amf", aiProcess_ValidateDataStructure);
|
||||||
|
EXPECT_NE(nullptr, scene);
|
||||||
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ TEST_F( utSceneCombiner, MergeMeshes_ValidNames_Test ) {
|
||||||
EXPECT_EQ( "mesh_1.mesh_2.mesh_3", outName );
|
EXPECT_EQ( "mesh_1.mesh_2.mesh_3", outName );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utSceneCombiner, CopySceneWithNullptr_NoException ) {
|
TEST_F( utSceneCombiner, CopySceneWithNullptr_AI_NO_EXCEPTion ) {
|
||||||
EXPECT_NO_THROW( SceneCombiner::CopyScene( nullptr, nullptr ) );
|
EXPECT_NO_THROW( SceneCombiner::CopyScene( nullptr, nullptr ) );
|
||||||
EXPECT_NO_THROW( SceneCombiner::CopySceneFlat( nullptr, nullptr ) );
|
EXPECT_NO_THROW( SceneCombiner::CopySceneFlat( nullptr, nullptr ) );
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue