Merge branch 'master' into sample-simpleopengl-minor-improvements
commit
20c125218d
|
@ -1,2 +1,2 @@
|
||||||
patreon: assimp
|
patreon: assimp
|
||||||
Paypal: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4
|
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4
|
||||||
|
|
|
@ -7,12 +7,11 @@ on:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-ubuntu:
|
linux:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: configure
|
- name: configure
|
||||||
run: cmake CMakeLists.txt
|
run: cmake CMakeLists.txt
|
||||||
- name: build
|
- name: build
|
||||||
|
@ -20,3 +19,28 @@ jobs:
|
||||||
- name: test
|
- name: test
|
||||||
run: cd bin && ./unit
|
run: cd bin && ./unit
|
||||||
|
|
||||||
|
mac:
|
||||||
|
runs-on: macos-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: configure
|
||||||
|
run: cmake CMakeLists.txt
|
||||||
|
- name: build
|
||||||
|
run: cmake --build .
|
||||||
|
- name: test
|
||||||
|
run: cd bin && ./unit
|
||||||
|
|
||||||
|
windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: configure
|
||||||
|
run: cmake CMakeLists.txt
|
||||||
|
- name: build
|
||||||
|
run: cmake --build . --config Release
|
||||||
|
- name: test
|
||||||
|
run: |
|
||||||
|
cd bin\Release
|
||||||
|
.\unit
|
||||||
|
|
|
@ -39,9 +39,9 @@ SET(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
|
||||||
CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )
|
CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )
|
||||||
|
|
||||||
# Toggles the use of the hunter package manager
|
# Toggles the use of the hunter package manager
|
||||||
option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
|
option(ASSIMP_HUNTER_ENABLED "Enable Hunter package manager support" OFF)
|
||||||
|
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
include("cmake/HunterGate.cmake")
|
include("cmake/HunterGate.cmake")
|
||||||
HunterGate(
|
HunterGate(
|
||||||
URL "https://github.com/ruslo/hunter/archive/v0.23.176.tar.gz"
|
URL "https://github.com/ruslo/hunter/archive/v0.23.176.tar.gz"
|
||||||
|
@ -60,7 +60,7 @@ OPTION( BUILD_SHARED_LIBS
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION( BUILD_FRAMEWORK
|
OPTION( ASSIMP_BUILD_FRAMEWORK
|
||||||
"Build package as Mac OS X Framework bundle."
|
"Build package as Mac OS X Framework bundle."
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
@ -101,7 +101,7 @@ OPTION ( ASSIMP_COVERALLS
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
OPTION( ASSIMP_INSTALL
|
OPTION( ASSIMP_INSTALL
|
||||||
"DIsable this if you want to use assimp as a submodule."
|
"Disable this if you want to use assimp as a submodule."
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
OPTION ( ASSIMP_ERROR_MAX
|
OPTION ( ASSIMP_ERROR_MAX
|
||||||
|
@ -120,25 +120,25 @@ OPTION ( ASSIMP_UBSAN
|
||||||
"Enable Undefined Behavior sanitizer."
|
"Enable Undefined Behavior sanitizer."
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
OPTION ( SYSTEM_IRRXML
|
OPTION ( ASSIMP_SYSTEM_IRRXML
|
||||||
"Use system installed Irrlicht/IrrXML library."
|
"Use system installed Irrlicht/IrrXML library."
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
OPTION ( BUILD_DOCS
|
OPTION ( ASSIMP_BUILD_DOCS
|
||||||
"Build documentation using Doxygen."
|
"Build documentation using Doxygen."
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
OPTION( INJECT_DEBUG_POSTFIX
|
OPTION( ASSIMP_INJECT_DEBUG_POSTFIX
|
||||||
"Inject debug postfix in .a/.so/.dll lib names"
|
"Inject debug postfix in .a/.so/.dll lib names"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION ( IGNORE_GIT_HASH
|
OPTION ( ASSIMP_IGNORE_GIT_HASH
|
||||||
"Don't call git to get the hash."
|
"Don't call git to get the hash."
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (IOS AND NOT HUNTER_ENABLED)
|
IF (IOS AND NOT ASSIMP_HUNTER_ENABLED)
|
||||||
IF (NOT CMAKE_BUILD_TYPE)
|
IF (NOT CMAKE_BUILD_TYPE)
|
||||||
SET(CMAKE_BUILD_TYPE "Release")
|
SET(CMAKE_BUILD_TYPE "Release")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
@ -161,7 +161,7 @@ IF(MSVC)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF (BUILD_FRAMEWORK)
|
IF (ASSIMP_BUILD_FRAMEWORK)
|
||||||
SET (BUILD_SHARED_LIBS ON)
|
SET (BUILD_SHARED_LIBS ON)
|
||||||
MESSAGE(STATUS "Framework bundle building enabled")
|
MESSAGE(STATUS "Framework bundle building enabled")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
@ -181,12 +181,12 @@ SET (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VER
|
||||||
SET (ASSIMP_SOVERSION 5)
|
SET (ASSIMP_SOVERSION 5)
|
||||||
|
|
||||||
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
|
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
|
||||||
if(NOT HUNTER_ENABLED)
|
if(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
# Enable C++11 support globally
|
# Enable C++11 support globally
|
||||||
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF(NOT IGNORE_GIT_HASH)
|
IF(NOT ASSIMP_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
|
||||||
|
@ -238,14 +238,9 @@ SET(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_M
|
||||||
SET(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev)
|
SET(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev)
|
||||||
SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
|
SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
|
||||||
|
|
||||||
IF( UNIX )
|
|
||||||
# Use GNUInstallDirs for Unix predefined directories
|
|
||||||
INCLUDE(GNUInstallDirs)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# Grouped compiler settings
|
# Grouped compiler settings
|
||||||
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
||||||
IF(NOT HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++0x ${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++0x ${CMAKE_CXX_FLAGS}")
|
||||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
@ -262,7 +257,7 @@ ELSEIF(MSVC)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
||||||
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
||||||
IF(NOT HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
@ -274,7 +269,7 @@ ELSEIF( CMAKE_COMPILER_IS_MINGW )
|
||||||
ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
|
ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
|
||||||
message(WARNING "MinGW is old, if you experience errors, update MinGW.")
|
message(WARNING "MinGW is old, if you experience errors, update MinGW.")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF(NOT HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
@ -283,7 +278,7 @@ ELSEIF( CMAKE_COMPILER_IS_MINGW )
|
||||||
ADD_DEFINITIONS( -U__STRICT_ANSI__ )
|
ADD_DEFINITIONS( -U__STRICT_ANSI__ )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF ( IOS AND NOT HUNTER_ENABLED)
|
IF ( IOS AND NOT ASSIMP_HUNTER_ENABLED)
|
||||||
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -Og")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -Og")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -Og")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -Og")
|
||||||
|
@ -350,17 +345,9 @@ ELSE()
|
||||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
# Cache these to allow the user to override them manually.
|
|
||||||
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING
|
|
||||||
"Path the built library files are installed to." )
|
|
||||||
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
|
|
||||||
"Path the header files are installed to." )
|
|
||||||
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
|
|
||||||
"Path the tool executables are installed to." )
|
|
||||||
|
|
||||||
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
|
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
|
||||||
|
|
||||||
IF (INJECT_DEBUG_POSTFIX AND (is_multi_config OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
IF (ASSIMP_INJECT_DEBUG_POSTFIX AND (is_multi_config OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||||
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfix for lib, samples and tools")
|
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfix for lib, samples and tools")
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Debug Postfix for lib, samples and tools")
|
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Debug Postfix for lib, samples and tools")
|
||||||
|
@ -373,7 +360,7 @@ IF (NOT TARGET uninstall)
|
||||||
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
set(CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
|
set(CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
|
||||||
set(INCLUDE_INSTALL_DIR "include")
|
set(INCLUDE_INSTALL_DIR "include")
|
||||||
|
|
||||||
|
@ -417,6 +404,28 @@ ELSE()
|
||||||
else()
|
else()
|
||||||
set(BUILD_LIB_TYPE STATIC)
|
set(BUILD_LIB_TYPE STATIC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
IF( UNIX )
|
||||||
|
# Use GNUInstallDirs for Unix predefined directories
|
||||||
|
INCLUDE(GNUInstallDirs)
|
||||||
|
|
||||||
|
SET( ASSIMP_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
SET( ASSIMP_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
SET( ASSIMP_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
|
||||||
|
ELSE()
|
||||||
|
# Cache these to allow the user to override them on non-Unix platforms
|
||||||
|
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING
|
||||||
|
"Path the built library files are installed to." )
|
||||||
|
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
|
||||||
|
"Path the header files are installed to." )
|
||||||
|
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
|
||||||
|
"Path the tool executables are installed to." )
|
||||||
|
|
||||||
|
SET(CMAKE_INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_INCLUDE_INSTALL_DIR})
|
||||||
|
SET(CMAKE_INSTALL_FULL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR})
|
||||||
|
SET(CMAKE_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_BIN_INSTALL_DIR})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
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.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE)
|
||||||
IF (is_multi_config)
|
IF (is_multi_config)
|
||||||
|
@ -440,18 +449,18 @@ ELSE()
|
||||||
DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF( BUILD_DOCS )
|
IF( ASSIMP_BUILD_DOCS )
|
||||||
ADD_SUBDIRECTORY(doc)
|
ADD_SUBDIRECTORY(doc)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Look for system installed irrXML
|
# Look for system installed irrXML
|
||||||
IF ( SYSTEM_IRRXML )
|
IF ( ASSIMP_SYSTEM_IRRXML )
|
||||||
FIND_PACKAGE( IrrXML REQUIRED )
|
FIND_PACKAGE( IrrXML REQUIRED )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Search for external dependencies, and build them from source if not found
|
# Search for external dependencies, and build them from source if not found
|
||||||
# Search for zlib
|
# Search for zlib
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(ZLIB)
|
hunter_add_package(ZLIB)
|
||||||
find_package(ZLIB CONFIG REQUIRED)
|
find_package(ZLIB CONFIG REQUIRED)
|
||||||
|
|
||||||
|
@ -575,7 +584,7 @@ ELSE ()
|
||||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_C4D_IMPORTER )
|
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_C4D_IMPORTER )
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF(NOT HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
ADD_SUBDIRECTORY(contrib)
|
ADD_SUBDIRECTORY(contrib)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||||
exec_prefix=@CMAKE_INSTALL_PREFIX@/
|
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||||
libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@
|
|
||||||
includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@
|
|
||||||
|
|
||||||
Name: @CMAKE_PROJECT_NAME@
|
Name: @CMAKE_PROJECT_NAME@
|
||||||
Description: Import various well-known 3D model formats in an uniform manner.
|
Description: Import various well-known 3D model formats in an uniform manner.
|
||||||
|
|
|
@ -7,6 +7,14 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
||||||
|
|
||||||
|
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||||
|
|
||||||
|
if ("${LIB64}" STREQUAL "TRUE")
|
||||||
|
set(LIBSUFFIX 64)
|
||||||
|
else()
|
||||||
|
set(LIBSUFFIX "")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
if(MSVC_TOOLSET_VERSION)
|
if(MSVC_TOOLSET_VERSION)
|
||||||
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||||
|
@ -44,22 +52,22 @@ if(MSVC)
|
||||||
# Import target "assimp::assimp" for configuration "Debug"
|
# Import target "assimp::assimp" for configuration "Debug"
|
||||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}"
|
IMPORTED_IMPLIB_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}"
|
||||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
|
IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
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 "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}")
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" )
|
||||||
else()
|
else()
|
||||||
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||||
|
|
||||||
# Import target "assimp::assimp" for configuration "Debug"
|
# Import target "assimp::assimp" for configuration "Debug"
|
||||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}")
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
@ -75,23 +83,20 @@ else()
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_SONAME_DEBUG "${sharedLibraryName}"
|
IMPORTED_SONAME_DEBUG "${sharedLibraryName}"
|
||||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
|
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${sharedLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${sharedLibraryName}" )
|
||||||
else()
|
else()
|
||||||
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${staticLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${staticLibraryName}" )
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Commands beyond this point should not need to know the version.
|
# Commands beyond this point should not need to know the version.
|
||||||
set(CMAKE_IMPORT_FILE_VERSION)
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,14 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
||||||
|
|
||||||
|
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||||
|
|
||||||
|
if ("${LIB64}" STREQUAL "TRUE")
|
||||||
|
set(LIBSUFFIX 64)
|
||||||
|
else()
|
||||||
|
set(LIBSUFFIX "")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
if(MSVC_TOOLSET_VERSION)
|
if(MSVC_TOOLSET_VERSION)
|
||||||
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||||
|
@ -44,12 +52,12 @@ if(MSVC)
|
||||||
# Import target "assimp::assimp" for configuration "Release"
|
# Import target "assimp::assimp" for configuration "Release"
|
||||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}"
|
IMPORTED_IMPLIB_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}"
|
||||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
|
IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
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 "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}")
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" )
|
||||||
else()
|
else()
|
||||||
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||||
|
|
||||||
|
@ -59,7 +67,7 @@ if(MSVC)
|
||||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}")
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
@ -75,18 +83,17 @@ else()
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_SONAME_RELEASE "${sharedLibraryName}"
|
IMPORTED_SONAME_RELEASE "${sharedLibraryName}"
|
||||||
|
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${sharedLibraryName}"
|
||||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
|
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${sharedLibraryName}" )
|
||||||
else()
|
else()
|
||||||
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${staticLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${staticLibraryName}" )
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -43,23 +43,13 @@ unset(_targetsDefined)
|
||||||
unset(_targetsNotDefined)
|
unset(_targetsNotDefined)
|
||||||
unset(_expectedTargets)
|
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
|
# Create imported target assimp::assimp
|
||||||
add_library(assimp::assimp @BUILD_LIB_TYPE@ IMPORTED)
|
add_library(assimp::assimp @BUILD_LIB_TYPE@ IMPORTED)
|
||||||
|
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION"
|
COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION"
|
||||||
INTERFACE_assimp_MAJOR_VERSION "1"
|
INTERFACE_assimp_MAJOR_VERSION "1"
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include"
|
INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_FULL_INCLUDEDIR@"
|
||||||
#INTERFACE_LINK_LIBRARIES "TxtUtils::TxtUtils;MealyMachine::MealyMachine"
|
#INTERFACE_LINK_LIBRARIES "TxtUtils::TxtUtils;MealyMachine::MealyMachine"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -74,9 +64,6 @@ foreach(f ${CONFIG_FILES})
|
||||||
include(${f})
|
include(${f})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Cleanup temporary variables.
|
|
||||||
set(_IMPORT_PREFIX)
|
|
||||||
|
|
||||||
# Loop over all imported files and verify that they actually exist
|
# Loop over all imported files and verify that they actually exist
|
||||||
foreach(target ${_IMPORT_CHECK_TARGETS} )
|
foreach(target ${_IMPORT_CHECK_TARGETS} )
|
||||||
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
|
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -43,7 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Implementation of the 3ds importer class */
|
/** @file Implementation of the 3ds importer class */
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||||
|
|
||||||
// internal headers
|
// internal headers
|
||||||
|
|
|
@ -322,7 +322,7 @@ struct Face : public FaceWithSmoothingGroup {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# pragma warning(disable : 4315)
|
#pragma warning(disable : 4315)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -441,12 +441,33 @@ struct Material {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
Material(const Material &other) = default;
|
Material(const Material &other) :
|
||||||
Material &operator=(const Material &other) = default;
|
mName(other.mName),
|
||||||
|
mDiffuse(other.mDiffuse),
|
||||||
|
mSpecularExponent(other.mSpecularExponent),
|
||||||
|
mShininessStrength(other.mShininessStrength),
|
||||||
|
mSpecular(other.mSpecular),
|
||||||
|
mAmbient(other.mAmbient),
|
||||||
|
mShading(other.mShading),
|
||||||
|
mTransparency(other.mTransparency),
|
||||||
|
sTexDiffuse(other.sTexDiffuse),
|
||||||
|
sTexOpacity(other.sTexOpacity),
|
||||||
|
sTexSpecular(other.sTexSpecular),
|
||||||
|
sTexReflective(other.sTexReflective),
|
||||||
|
sTexBump(other.sTexBump),
|
||||||
|
sTexEmissive(other.sTexEmissive),
|
||||||
|
sTexShininess(other.sTexShininess),
|
||||||
|
mBumpHeight(other.mBumpHeight),
|
||||||
|
mEmissive(other.mEmissive),
|
||||||
|
sTexAmbient(other.sTexAmbient),
|
||||||
|
mTwoSided(other.mTwoSided) {
|
||||||
|
// empty
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//! 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) AI_NO_EXCEPT
|
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)),
|
||||||
mShininessStrength(std::move(other.mShininessStrength)),
|
mShininessStrength(std::move(other.mShininessStrength)),
|
||||||
|
@ -465,6 +486,7 @@ struct Material {
|
||||||
mEmissive(std::move(other.mEmissive)),
|
mEmissive(std::move(other.mEmissive)),
|
||||||
sTexAmbient(std::move(other.sTexAmbient)),
|
sTexAmbient(std::move(other.sTexAmbient)),
|
||||||
mTwoSided(std::move(other.mTwoSided)) {
|
mTwoSided(std::move(other.mTwoSided)) {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -72,7 +70,6 @@ static const aiImporterDesc desc = {
|
||||||
"3ds prj"
|
"3ds prj"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Begins a new parsing block
|
// Begins a new parsing block
|
||||||
// - Reads the current chunk and validates it
|
// - Reads the current chunk and validates it
|
||||||
|
@ -141,15 +138,13 @@ bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandle
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Loader registry entry
|
// Loader registry entry
|
||||||
const aiImporterDesc* Discreet3DSImporter::GetInfo () const
|
const aiImporterDesc* Discreet3DSImporter::GetInfo () const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup configuration properties
|
// Setup configuration properties
|
||||||
void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/)
|
void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/) {
|
||||||
{
|
|
||||||
// nothing to be done for the moment
|
// nothing to be done for the moment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +195,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
|
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace all occurences of the default material with a
|
// Replace all occurrences of the default material with a
|
||||||
// valid material. Generate it if no material containing
|
// valid material. Generate it if no material containing
|
||||||
// DEFAULT in its name has been found in the file
|
// DEFAULT in its name has been found in the file
|
||||||
ReplaceDefaultMaterial();
|
ReplaceDefaultMaterial();
|
||||||
|
@ -227,8 +222,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Applies a master-scaling factor to the imported scene
|
// Applies a master-scaling factor to the imported scene
|
||||||
void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene)
|
void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene) {
|
||||||
{
|
|
||||||
// There are some 3DS files with a zero scaling factor
|
// There are some 3DS files with a zero scaling factor
|
||||||
if (!mMasterScale)mMasterScale = 1.0f;
|
if (!mMasterScale)mMasterScale = 1.0f;
|
||||||
else mMasterScale = 1.0f / mMasterScale;
|
else mMasterScale = 1.0f / mMasterScale;
|
||||||
|
@ -1084,7 +1078,7 @@ void Discreet3DSImporter::ParseMeshChunk()
|
||||||
mMesh.mFaceMaterials.resize(mMesh.mFaces.size(),0xcdcdcdcd);
|
mMesh.mFaceMaterials.resize(mMesh.mFaces.size(),0xcdcdcdcd);
|
||||||
|
|
||||||
// Larger 3DS files could have multiple FACE chunks here
|
// Larger 3DS files could have multiple FACE chunks here
|
||||||
chunkSize = stream->GetRemainingSizeToLimit();
|
chunkSize = (int)stream->GetRemainingSizeToLimit();
|
||||||
if ( chunkSize > (int) sizeof(Discreet3DS::Chunk ) )
|
if ( chunkSize > (int) sizeof(Discreet3DS::Chunk ) )
|
||||||
ParseFaceChunk();
|
ParseFaceChunk();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,15 +65,11 @@ using namespace D3DS;
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** Importer class for 3D Studio r3 and r4 3DS files
|
/** Importer class for 3D Studio r3 and r4 3DS files
|
||||||
*/
|
*/
|
||||||
class Discreet3DSImporter : public BaseImporter
|
class Discreet3DSImporter : public BaseImporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Discreet3DSImporter();
|
Discreet3DSImporter();
|
||||||
~Discreet3DSImporter();
|
~Discreet3DSImporter();
|
||||||
|
|
||||||
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.
|
||||||
* See BaseImporter::CanRead() for details.
|
* See BaseImporter::CanRead() for details.
|
||||||
|
|
|
@ -9,6 +9,9 @@ For details, see http://sourceforge.net/projects/libb64
|
||||||
|
|
||||||
const int CHARS_PER_LINE = 72;
|
const int CHARS_PER_LINE = 72;
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4244)
|
||||||
|
|
||||||
void base64_init_encodestate(base64_encodestate* state_in)
|
void base64_init_encodestate(base64_encodestate* state_in)
|
||||||
{
|
{
|
||||||
state_in->step = step_A;
|
state_in->step = step_A;
|
||||||
|
@ -107,3 +110,4 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
||||||
return (int)(codechar - code_out);
|
return (int)(codechar - code_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
|
@ -206,7 +206,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
||||||
inflateInit2(&zstream, 16+MAX_WBITS);
|
inflateInit2(&zstream, 16+MAX_WBITS);
|
||||||
|
|
||||||
zstream.next_in = reinterpret_cast<Bytef*>( reader->GetPtr() );
|
zstream.next_in = reinterpret_cast<Bytef*>( reader->GetPtr() );
|
||||||
zstream.avail_in = reader->GetRemainingSize();
|
zstream.avail_in = (uInt) reader->GetRemainingSize();
|
||||||
|
|
||||||
size_t total = 0l;
|
size_t total = 0l;
|
||||||
|
|
||||||
|
|
|
@ -886,7 +886,7 @@ SET( Extra_SRCS
|
||||||
SOURCE_GROUP( Extra FILES ${Extra_SRCS})
|
SOURCE_GROUP( Extra FILES ${Extra_SRCS})
|
||||||
|
|
||||||
# irrXML
|
# irrXML
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(irrXML)
|
hunter_add_package(irrXML)
|
||||||
find_package(irrXML CONFIG REQUIRED)
|
find_package(irrXML CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
@ -894,7 +894,7 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# utf8
|
# utf8
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(utf8)
|
hunter_add_package(utf8)
|
||||||
find_package(utf8 CONFIG REQUIRED)
|
find_package(utf8 CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
@ -902,7 +902,7 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# polyclipping
|
# polyclipping
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(polyclipping)
|
hunter_add_package(polyclipping)
|
||||||
find_package(polyclipping CONFIG REQUIRED)
|
find_package(polyclipping CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
@ -914,7 +914,7 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# poly2tri
|
# poly2tri
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(poly2tri)
|
hunter_add_package(poly2tri)
|
||||||
find_package(poly2tri CONFIG REQUIRED)
|
find_package(poly2tri CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
@ -935,7 +935,7 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# minizip/unzip
|
# minizip/unzip
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(minizip)
|
hunter_add_package(minizip)
|
||||||
find_package(minizip CONFIG REQUIRED)
|
find_package(minizip CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
@ -950,7 +950,7 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# zip (https://github.com/kuba--/zip)
|
# zip (https://github.com/kuba--/zip)
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(zip)
|
hunter_add_package(zip)
|
||||||
find_package(zip CONFIG REQUIRED)
|
find_package(zip CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
@ -971,7 +971,7 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# openddlparser
|
# openddlparser
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(openddlparser)
|
hunter_add_package(openddlparser)
|
||||||
find_package(openddlparser CONFIG REQUIRED)
|
find_package(openddlparser CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
@ -994,7 +994,7 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Open3DGC
|
# Open3DGC
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
# Nothing to do, not available in Hunter yet.
|
# Nothing to do, not available in Hunter yet.
|
||||||
ELSE()
|
ELSE()
|
||||||
SET ( open3dgc_SRCS
|
SET ( open3dgc_SRCS
|
||||||
|
@ -1035,7 +1035,7 @@ ENDIF()
|
||||||
# RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
|
# RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
|
||||||
# has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
|
# has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
|
||||||
FIND_PACKAGE(RT QUIET)
|
FIND_PACKAGE(RT QUIET)
|
||||||
IF (NOT HUNTER_ENABLED AND (RT_FOUND OR MSVC))
|
IF (NOT ASSIMP_HUNTER_ENABLED AND (RT_FOUND OR MSVC))
|
||||||
SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 )
|
SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 )
|
||||||
ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 )
|
ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 )
|
||||||
ELSE ()
|
ELSE ()
|
||||||
|
@ -1045,7 +1045,7 @@ ELSE ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
# RapidJSON
|
# RapidJSON
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
hunter_add_package(RapidJSON)
|
hunter_add_package(RapidJSON)
|
||||||
find_package(RapidJSON CONFIG REQUIRED)
|
find_package(RapidJSON CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
@ -1068,7 +1068,7 @@ if ( MSVC )
|
||||||
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
IF(NOT HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
if (UNZIP_FOUND)
|
if (UNZIP_FOUND)
|
||||||
SET (unzip_compile_SRCS "")
|
SET (unzip_compile_SRCS "")
|
||||||
else ()
|
else ()
|
||||||
|
@ -1118,7 +1118,7 @@ SET( assimp_src
|
||||||
)
|
)
|
||||||
ADD_DEFINITIONS( -DOPENDDLPARSER_BUILD )
|
ADD_DEFINITIONS( -DOPENDDLPARSER_BUILD )
|
||||||
|
|
||||||
IF(NOT HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${IRRXML_INCLUDE_DIR}
|
${IRRXML_INCLUDE_DIR}
|
||||||
../contrib/openddlparser/include
|
../contrib/openddlparser/include
|
||||||
|
@ -1139,7 +1139,7 @@ TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
TARGET_LINK_LIBRARIES(assimp
|
TARGET_LINK_LIBRARIES(assimp
|
||||||
PUBLIC
|
PUBLIC
|
||||||
polyclipping::polyclipping
|
polyclipping::polyclipping
|
||||||
|
@ -1212,7 +1212,7 @@ SET_TARGET_PROPERTIES( assimp PROPERTIES
|
||||||
)
|
)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
if (BUILD_FRAMEWORK)
|
if (ASSIMP_BUILD_FRAMEWORK)
|
||||||
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
||||||
FRAMEWORK TRUE
|
FRAMEWORK TRUE
|
||||||
FRAMEWORK_VERSION C
|
FRAMEWORK_VERSION C
|
||||||
|
@ -1232,7 +1232,7 @@ ENDIF()
|
||||||
|
|
||||||
# Build against external unzip, or add ../contrib/unzip so
|
# Build against external unzip, or add ../contrib/unzip so
|
||||||
# assimp can #include "unzip.h"
|
# assimp can #include "unzip.h"
|
||||||
IF(NOT HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
if (UNZIP_FOUND)
|
if (UNZIP_FOUND)
|
||||||
INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS})
|
||||||
TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES})
|
TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES})
|
||||||
|
@ -1246,7 +1246,7 @@ IF (RT_FOUND AND ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC)
|
||||||
TARGET_LINK_LIBRARIES(assimp ${RT_LIBRARY})
|
TARGET_LINK_LIBRARIES(assimp ${RT_LIBRARY})
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF(HUNTER_ENABLED)
|
IF(ASSIMP_HUNTER_ENABLED)
|
||||||
INSTALL( TARGETS assimp
|
INSTALL( TARGETS assimp
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||||
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||||
|
|
|
@ -178,7 +178,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
||||||
*ot++ = *buffer++;
|
*ot++ = *buffer++;
|
||||||
|
|
||||||
*ot = '\0';
|
*ot = '\0';
|
||||||
nda->mNodeName.length = (ai_uint32)(ot-nda->mNodeName.data);
|
nda->mNodeName.length = static_cast<ai_uint32>(ot-nda->mNodeName.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
|
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -655,7 +655,8 @@ bool FBXConverter::NeedsComplexTransformationChain(const Model &model) {
|
||||||
for (size_t i = 0; i < TransformationComp_MAXIMUM; ++i) {
|
for (size_t i = 0; i < TransformationComp_MAXIMUM; ++i) {
|
||||||
const TransformationComp comp = static_cast<TransformationComp>(i);
|
const TransformationComp comp = static_cast<TransformationComp>(i);
|
||||||
|
|
||||||
if (comp == TransformationComp_Rotation || comp == TransformationComp_Scaling || comp == TransformationComp_Translation) {
|
if (comp == TransformationComp_Rotation || comp == TransformationComp_Scaling || comp == TransformationComp_Translation ||
|
||||||
|
comp == TransformationComp_PreRotation || comp == TransformationComp_PostRotation) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,9 +857,10 @@ bool FBXConverter::GenerateTransformationNodeChain(const Model &model, const std
|
||||||
|
|
||||||
// name passed to the method is already unique
|
// name passed to the method is already unique
|
||||||
nd->mName.Set(name);
|
nd->mName.Set(name);
|
||||||
|
// for (const auto &transform : chain) {
|
||||||
for (const auto &transform : chain) {
|
// skip inverse chain for no preservePivots
|
||||||
nd->mTransformation = nd->mTransformation * transform;
|
for (unsigned int i = TransformationComp_Translation; i < TransformationComp_MAXIMUM; i++) {
|
||||||
|
nd->mTransformation = nd->mTransformation * chain[i];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2738,15 +2740,12 @@ void FBXConverter::GenerateNodeAnimations(std::vector<aiNodeAnim *> &node_anims,
|
||||||
// be invoked _later_ (animations come first). If this node has only rotation,
|
// be invoked _later_ (animations come first). If this node has only rotation,
|
||||||
// scaling and translation _and_ there are no animated other components either,
|
// scaling and translation _and_ there are no animated other components either,
|
||||||
// we can use a single node and also a single node animation channel.
|
// we can use a single node and also a single node animation channel.
|
||||||
if (!has_complex && !NeedsComplexTransformationChain(target)) {
|
if( !has_complex && !NeedsComplexTransformationChain(target)) {
|
||||||
|
aiNodeAnim* const nd = GenerateSimpleNodeAnim(fixed_name, target, chain,
|
||||||
aiNodeAnim *const nd = GenerateSimpleNodeAnim(fixed_name, target, chain,
|
|
||||||
node_property_map.end(),
|
node_property_map.end(),
|
||||||
layer_map,
|
|
||||||
start, stop,
|
start, stop,
|
||||||
max_time,
|
max_time,
|
||||||
min_time,
|
min_time
|
||||||
true // input is TRS order, assimp is SRT
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ai_assert(nd);
|
ai_assert(nd);
|
||||||
|
@ -3020,133 +3019,121 @@ aiNodeAnim *FBXConverter::GenerateTranslationNodeAnim(const std::string &name,
|
||||||
return na.release();
|
return na.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
aiNodeAnim *FBXConverter::GenerateSimpleNodeAnim(const std::string &name,
|
aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
|
||||||
const Model &target,
|
const Model& target,
|
||||||
NodeMap::const_iterator chain[TransformationComp_MAXIMUM],
|
NodeMap::const_iterator chain[TransformationComp_MAXIMUM],
|
||||||
NodeMap::const_iterator iter_end,
|
NodeMap::const_iterator iterEnd,
|
||||||
const LayerMap &layer_map,
|
|
||||||
int64_t start, int64_t stop,
|
int64_t start, int64_t stop,
|
||||||
double &max_time,
|
double& maxTime,
|
||||||
double &min_time,
|
double& minTime)
|
||||||
bool reverse_order)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::unique_ptr<aiNodeAnim> na(new aiNodeAnim());
|
std::unique_ptr<aiNodeAnim> na(new aiNodeAnim());
|
||||||
na->mNodeName.Set(name);
|
na->mNodeName.Set(name);
|
||||||
|
|
||||||
const PropertyTable &props = target.Props();
|
const PropertyTable &props = target.Props();
|
||||||
|
|
||||||
// need to convert from TRS order to SRT?
|
// collect unique times and keyframe lists
|
||||||
if (reverse_order) {
|
KeyFrameListList keyframeLists[TransformationComp_MAXIMUM];
|
||||||
|
KeyTimeList keytimes;
|
||||||
|
|
||||||
aiVector3D def_scale = PropertyGet(props, "Lcl Scaling", aiVector3D(1.f, 1.f, 1.f));
|
for (size_t i = 0; i < TransformationComp_MAXIMUM; ++i) {
|
||||||
aiVector3D def_translate = PropertyGet(props, "Lcl Translation", aiVector3D(0.f, 0.f, 0.f));
|
if (chain[i] == iterEnd)
|
||||||
aiVector3D def_rot = PropertyGet(props, "Lcl Rotation", aiVector3D(0.f, 0.f, 0.f));
|
continue;
|
||||||
|
|
||||||
KeyFrameListList scaling;
|
keyframeLists[i] = GetKeyframeList((*chain[i]).second, start, stop);
|
||||||
KeyFrameListList translation;
|
|
||||||
KeyFrameListList rotation;
|
|
||||||
|
|
||||||
if (chain[TransformationComp_Scaling] != iter_end) {
|
for (KeyFrameListList::const_iterator it = keyframeLists[i].begin(); it != keyframeLists[i].end(); ++it) {
|
||||||
scaling = GetKeyframeList((*chain[TransformationComp_Scaling]).second, start, stop);
|
const KeyTimeList& times = *std::get<0>(*it);
|
||||||
|
keytimes.insert(keytimes.end(), times.begin(), times.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chain[TransformationComp_Translation] != iter_end) {
|
// remove duplicates
|
||||||
translation = GetKeyframeList((*chain[TransformationComp_Translation]).second, start, stop);
|
std::sort(keytimes.begin(), keytimes.end());
|
||||||
|
|
||||||
|
auto last = std::unique(keytimes.begin(), keytimes.end());
|
||||||
|
keytimes.erase(last, keytimes.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chain[TransformationComp_Rotation] != iter_end) {
|
const Model::RotOrder rotOrder = target.RotationOrder();
|
||||||
rotation = GetKeyframeList((*chain[TransformationComp_Rotation]).second, start, stop);
|
const size_t keyCount = keytimes.size();
|
||||||
|
|
||||||
|
aiVector3D defTranslate = PropertyGet(props, "Lcl Translation", aiVector3D(0.f, 0.f, 0.f));
|
||||||
|
aiVector3D defRotation = PropertyGet(props, "Lcl Rotation", aiVector3D(0.f, 0.f, 0.f));
|
||||||
|
aiVector3D defScale = PropertyGet(props, "Lcl Scaling", aiVector3D(1.f, 1.f, 1.f));
|
||||||
|
aiQuaternion defQuat = EulerToQuaternion(defRotation, rotOrder);
|
||||||
|
|
||||||
|
aiVectorKey* outTranslations = new aiVectorKey[keyCount];
|
||||||
|
aiQuatKey* outRotations = new aiQuatKey[keyCount];
|
||||||
|
aiVectorKey* outScales = new aiVectorKey[keyCount];
|
||||||
|
|
||||||
|
if (keyframeLists[TransformationComp_Translation].size() > 0) {
|
||||||
|
InterpolateKeys(outTranslations, keytimes, keyframeLists[TransformationComp_Translation], defTranslate, maxTime, minTime);
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < keyCount; ++i) {
|
||||||
|
outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
|
||||||
|
outTranslations[i].mValue = defTranslate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyFrameListList joined;
|
if (keyframeLists[TransformationComp_Rotation].size() > 0) {
|
||||||
joined.insert(joined.end(), scaling.begin(), scaling.end());
|
InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder);
|
||||||
joined.insert(joined.end(), translation.begin(), translation.end());
|
} else {
|
||||||
joined.insert(joined.end(), rotation.begin(), rotation.end());
|
for (size_t i = 0; i < keyCount; ++i) {
|
||||||
|
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
|
||||||
const KeyTimeList × = GetKeyTimeList(joined);
|
outRotations[i].mValue = defQuat;
|
||||||
|
}
|
||||||
aiQuatKey *out_quat = new aiQuatKey[times.size()];
|
|
||||||
aiVectorKey *out_scale = new aiVectorKey[times.size()];
|
|
||||||
aiVectorKey *out_translation = new aiVectorKey[times.size()];
|
|
||||||
|
|
||||||
if (times.size()) {
|
|
||||||
ConvertTransformOrder_TRStoSRT(out_quat, out_scale, out_translation,
|
|
||||||
scaling,
|
|
||||||
translation,
|
|
||||||
rotation,
|
|
||||||
times,
|
|
||||||
max_time,
|
|
||||||
min_time,
|
|
||||||
target.RotationOrder(),
|
|
||||||
def_scale,
|
|
||||||
def_translate,
|
|
||||||
def_rot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX remove duplicates / redundant keys which this operation did
|
if (keyframeLists[TransformationComp_Scaling].size() > 0) {
|
||||||
// likely produce if not all three channels were equally dense.
|
InterpolateKeys(outScales, keytimes, keyframeLists[TransformationComp_Scaling], defScale, maxTime, minTime);
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < keyCount; ++i) {
|
||||||
|
outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
|
||||||
|
outScales[i].mValue = defScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
na->mNumScalingKeys = static_cast<unsigned int>(times.size());
|
bool ok = false;
|
||||||
|
const float zero_epsilon = 1e-6f;
|
||||||
|
|
||||||
|
const aiVector3D& preRotation = PropertyGet<aiVector3D>(props, "PreRotation", ok);
|
||||||
|
if (ok && preRotation.SquareLength() > zero_epsilon) {
|
||||||
|
const aiQuaternion preQuat = EulerToQuaternion(preRotation, Model::RotOrder_EulerXYZ);
|
||||||
|
for (size_t i = 0; i < keyCount; ++i) {
|
||||||
|
outRotations[i].mValue = preQuat * outRotations[i].mValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const aiVector3D& postRotation = PropertyGet<aiVector3D>(props, "PostRotation", ok);
|
||||||
|
if (ok && postRotation.SquareLength() > zero_epsilon) {
|
||||||
|
const aiQuaternion postQuat = EulerToQuaternion(postRotation, Model::RotOrder_EulerXYZ);
|
||||||
|
for (size_t i = 0; i < keyCount; ++i) {
|
||||||
|
outRotations[i].mValue = outRotations[i].mValue * postQuat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert TRS to SRT
|
||||||
|
for (size_t i = 0; i < keyCount; ++i) {
|
||||||
|
aiQuaternion& r = outRotations[i].mValue;
|
||||||
|
aiVector3D& s = outScales[i].mValue;
|
||||||
|
aiVector3D& t = outTranslations[i].mValue;
|
||||||
|
|
||||||
|
aiMatrix4x4 mat, temp;
|
||||||
|
aiMatrix4x4::Translation(t, mat);
|
||||||
|
mat *= aiMatrix4x4(r.GetMatrix());
|
||||||
|
mat *= aiMatrix4x4::Scaling(s, temp);
|
||||||
|
|
||||||
|
mat.Decompose(s, r, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
na->mNumScalingKeys = static_cast<unsigned int>(keyCount);
|
||||||
na->mNumRotationKeys = na->mNumScalingKeys;
|
na->mNumRotationKeys = na->mNumScalingKeys;
|
||||||
na->mNumPositionKeys = na->mNumScalingKeys;
|
na->mNumPositionKeys = na->mNumScalingKeys;
|
||||||
|
|
||||||
na->mScalingKeys = out_scale;
|
na->mScalingKeys = outScales;
|
||||||
na->mRotationKeys = out_quat;
|
na->mRotationKeys = outRotations;
|
||||||
na->mPositionKeys = out_translation;
|
na->mPositionKeys = outTranslations;
|
||||||
} else {
|
|
||||||
|
|
||||||
// if a particular transformation is not given, grab it from
|
|
||||||
// the corresponding node to meet the semantics of aiNodeAnim,
|
|
||||||
// which requires all of rotation, scaling and translation
|
|
||||||
// to be set.
|
|
||||||
if (chain[TransformationComp_Scaling] != iter_end) {
|
|
||||||
ConvertScaleKeys(na.get(), (*chain[TransformationComp_Scaling]).second,
|
|
||||||
layer_map,
|
|
||||||
start, stop,
|
|
||||||
max_time,
|
|
||||||
min_time);
|
|
||||||
} else {
|
|
||||||
na->mScalingKeys = new aiVectorKey[1];
|
|
||||||
na->mNumScalingKeys = 1;
|
|
||||||
|
|
||||||
na->mScalingKeys[0].mTime = 0.;
|
|
||||||
na->mScalingKeys[0].mValue = PropertyGet(props, "Lcl Scaling",
|
|
||||||
aiVector3D(1.f, 1.f, 1.f));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chain[TransformationComp_Rotation] != iter_end) {
|
|
||||||
ConvertRotationKeys(na.get(), (*chain[TransformationComp_Rotation]).second,
|
|
||||||
layer_map,
|
|
||||||
start, stop,
|
|
||||||
max_time,
|
|
||||||
min_time,
|
|
||||||
target.RotationOrder());
|
|
||||||
} else {
|
|
||||||
na->mRotationKeys = new aiQuatKey[1];
|
|
||||||
na->mNumRotationKeys = 1;
|
|
||||||
|
|
||||||
na->mRotationKeys[0].mTime = 0.;
|
|
||||||
na->mRotationKeys[0].mValue = EulerToQuaternion(
|
|
||||||
PropertyGet(props, "Lcl Rotation", aiVector3D(0.f, 0.f, 0.f)),
|
|
||||||
target.RotationOrder());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chain[TransformationComp_Translation] != iter_end) {
|
|
||||||
ConvertTranslationKeys(na.get(), (*chain[TransformationComp_Translation]).second,
|
|
||||||
layer_map,
|
|
||||||
start, stop,
|
|
||||||
max_time,
|
|
||||||
min_time);
|
|
||||||
} else {
|
|
||||||
na->mPositionKeys = new aiVectorKey[1];
|
|
||||||
na->mNumPositionKeys = 1;
|
|
||||||
|
|
||||||
na->mPositionKeys[0].mTime = 0.;
|
|
||||||
na->mPositionKeys[0].mValue = PropertyGet(props, "Lcl Translation",
|
|
||||||
aiVector3D(0.f, 0.f, 0.f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return na.release();
|
return na.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3327,10 +3314,7 @@ void FBXConverter::InterpolateKeys(aiQuatKey *valOut, const KeyTimeList &keys, c
|
||||||
// take shortest path by checking the inner product
|
// take shortest path by checking the inner product
|
||||||
// http://www.3dkingdoms.com/weekly/weekly.php?a=36
|
// http://www.3dkingdoms.com/weekly/weekly.php?a=36
|
||||||
if (quat.x * lastq.x + quat.y * lastq.y + quat.z * lastq.z + quat.w * lastq.w < 0) {
|
if (quat.x * lastq.x + quat.y * lastq.y + quat.z * lastq.z + quat.w * lastq.w < 0) {
|
||||||
quat.x = -quat.x;
|
quat.Conjugate();
|
||||||
quat.y = -quat.y;
|
|
||||||
quat.z = -quat.z;
|
|
||||||
quat.w = -quat.w;
|
|
||||||
}
|
}
|
||||||
lastq = quat;
|
lastq = quat;
|
||||||
|
|
||||||
|
@ -3338,60 +3322,6 @@ void FBXConverter::InterpolateKeys(aiQuatKey *valOut, const KeyTimeList &keys, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBXConverter::ConvertTransformOrder_TRStoSRT(aiQuatKey *out_quat, aiVectorKey *out_scale,
|
|
||||||
aiVectorKey *out_translation,
|
|
||||||
const KeyFrameListList &scaling,
|
|
||||||
const KeyFrameListList &translation,
|
|
||||||
const KeyFrameListList &rotation,
|
|
||||||
const KeyTimeList ×,
|
|
||||||
double &maxTime,
|
|
||||||
double &minTime,
|
|
||||||
Model::RotOrder order,
|
|
||||||
const aiVector3D &def_scale,
|
|
||||||
const aiVector3D &def_translate,
|
|
||||||
const aiVector3D &def_rotation) {
|
|
||||||
if (rotation.size()) {
|
|
||||||
InterpolateKeys(out_quat, times, rotation, def_rotation, maxTime, minTime, order);
|
|
||||||
} else {
|
|
||||||
for (size_t i = 0; i < times.size(); ++i) {
|
|
||||||
out_quat[i].mTime = CONVERT_FBX_TIME(times[i]) * anim_fps;
|
|
||||||
out_quat[i].mValue = EulerToQuaternion(def_rotation, order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scaling.size()) {
|
|
||||||
InterpolateKeys(out_scale, times, scaling, def_scale, maxTime, minTime);
|
|
||||||
} else {
|
|
||||||
for (size_t i = 0; i < times.size(); ++i) {
|
|
||||||
out_scale[i].mTime = CONVERT_FBX_TIME(times[i]) * anim_fps;
|
|
||||||
out_scale[i].mValue = def_scale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (translation.size()) {
|
|
||||||
InterpolateKeys(out_translation, times, translation, def_translate, maxTime, minTime);
|
|
||||||
} else {
|
|
||||||
for (size_t i = 0; i < times.size(); ++i) {
|
|
||||||
out_translation[i].mTime = CONVERT_FBX_TIME(times[i]) * anim_fps;
|
|
||||||
out_translation[i].mValue = def_translate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t count = times.size();
|
|
||||||
for (size_t i = 0; i < count; ++i) {
|
|
||||||
aiQuaternion &r = out_quat[i].mValue;
|
|
||||||
aiVector3D &s = out_scale[i].mValue;
|
|
||||||
aiVector3D &t = out_translation[i].mValue;
|
|
||||||
|
|
||||||
aiMatrix4x4 mat, temp;
|
|
||||||
aiMatrix4x4::Translation(t, mat);
|
|
||||||
mat *= aiMatrix4x4(r.GetMatrix());
|
|
||||||
mat *= aiMatrix4x4::Scaling(s, temp);
|
|
||||||
|
|
||||||
mat.Decompose(s, r, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
aiQuaternion FBXConverter::EulerToQuaternion(const aiVector3D &rot, Model::RotOrder order) {
|
aiQuaternion FBXConverter::EulerToQuaternion(const aiVector3D &rot, Model::RotOrder order) {
|
||||||
aiMatrix4x4 m;
|
aiMatrix4x4 m;
|
||||||
GetRotationMatrix(order, rot, m);
|
GetRotationMatrix(order, rot, m);
|
||||||
|
|
|
@ -349,12 +349,10 @@ private:
|
||||||
aiNodeAnim* GenerateSimpleNodeAnim(const std::string& name,
|
aiNodeAnim* GenerateSimpleNodeAnim(const std::string& name,
|
||||||
const Model& target,
|
const Model& target,
|
||||||
NodeMap::const_iterator chain[TransformationComp_MAXIMUM],
|
NodeMap::const_iterator chain[TransformationComp_MAXIMUM],
|
||||||
NodeMap::const_iterator iter_end,
|
NodeMap::const_iterator iterEnd,
|
||||||
const LayerMap& layer_map,
|
|
||||||
int64_t start, int64_t stop,
|
int64_t start, int64_t stop,
|
||||||
double& max_time,
|
double& maxTime,
|
||||||
double& min_time,
|
double& minTime);
|
||||||
bool reverse_order = false);
|
|
||||||
|
|
||||||
// key (time), value, mapto (component index)
|
// key (time), value, mapto (component index)
|
||||||
typedef std::tuple<std::shared_ptr<KeyTimeList>, std::shared_ptr<KeyValueList>, unsigned int > KeyFrameList;
|
typedef std::tuple<std::shared_ptr<KeyTimeList>, std::shared_ptr<KeyValueList>, unsigned int > KeyFrameList;
|
||||||
|
@ -379,20 +377,6 @@ private:
|
||||||
double& minTime,
|
double& minTime,
|
||||||
Model::RotOrder order);
|
Model::RotOrder order);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertTransformOrder_TRStoSRT(aiQuatKey* out_quat, aiVectorKey* out_scale,
|
|
||||||
aiVectorKey* out_translation,
|
|
||||||
const KeyFrameListList& scaling,
|
|
||||||
const KeyFrameListList& translation,
|
|
||||||
const KeyFrameListList& rotation,
|
|
||||||
const KeyTimeList& times,
|
|
||||||
double& maxTime,
|
|
||||||
double& minTime,
|
|
||||||
Model::RotOrder order,
|
|
||||||
const aiVector3D& def_scale,
|
|
||||||
const aiVector3D& def_translate,
|
|
||||||
const aiVector3D& def_rotation);
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// euler xyz -> quat
|
// euler xyz -> quat
|
||||||
aiQuaternion EulerToQuaternion(const aiVector3D& rot, Model::RotOrder order);
|
aiQuaternion EulerToQuaternion(const aiVector3D& rot, Model::RotOrder order);
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -50,27 +49,25 @@ namespace Assimp {
|
||||||
namespace FBX {
|
namespace FBX {
|
||||||
|
|
||||||
/** FBX import settings, parts of which are publicly accessible via their corresponding AI_CONFIG constants */
|
/** FBX import settings, parts of which are publicly accessible via their corresponding AI_CONFIG constants */
|
||||||
struct ImportSettings
|
struct ImportSettings {
|
||||||
{
|
ImportSettings() :
|
||||||
ImportSettings()
|
strictMode(true),
|
||||||
: strictMode(true)
|
readAllLayers(true),
|
||||||
, readAllLayers(true)
|
readAllMaterials(false),
|
||||||
, readAllMaterials(false)
|
readMaterials(true),
|
||||||
, readMaterials(true)
|
readTextures(true),
|
||||||
, readTextures(true)
|
readCameras(true),
|
||||||
, readCameras(true)
|
readLights(true),
|
||||||
, readLights(true)
|
readAnimations(true),
|
||||||
, readAnimations(true)
|
readWeights(true),
|
||||||
, readWeights(true)
|
preservePivots(true),
|
||||||
, preservePivots(true)
|
optimizeEmptyAnimationCurves(true),
|
||||||
, optimizeEmptyAnimationCurves(true)
|
useLegacyEmbeddedTextureNaming(false),
|
||||||
, useLegacyEmbeddedTextureNaming(false)
|
removeEmptyBones(true),
|
||||||
, removeEmptyBones( true )
|
convertToMeters(false) {
|
||||||
, convertToMeters( false ) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** enable strict mode:
|
/** enable strict mode:
|
||||||
* - only accept fbx 2012, 2013 files
|
* - only accept fbx 2012, 2013 files
|
||||||
* - on the slightest error, give up.
|
* - on the slightest error, give up.
|
||||||
|
@ -94,7 +91,6 @@ struct ImportSettings
|
||||||
* This bit is ignored unless readMaterials=true*/
|
* This bit is ignored unless readMaterials=true*/
|
||||||
bool readAllMaterials;
|
bool readAllMaterials;
|
||||||
|
|
||||||
|
|
||||||
/** import materials (true) or skip them and assign a default
|
/** import materials (true) or skip them and assign a default
|
||||||
* material. The default value is true.*/
|
* material. The default value is true.*/
|
||||||
bool readMaterials;
|
bool readMaterials;
|
||||||
|
@ -156,9 +152,7 @@ struct ImportSettings
|
||||||
bool convertToMeters;
|
bool convertToMeters;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace FBX
|
||||||
} // !FBX
|
} // namespace Assimp
|
||||||
} // !Assimp
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -55,41 +54,40 @@ namespace Assimp {
|
||||||
|
|
||||||
// TinyFormatter.h
|
// TinyFormatter.h
|
||||||
namespace Formatter {
|
namespace Formatter {
|
||||||
template <typename T,typename TR, typename A> class basic_formatter;
|
|
||||||
typedef class basic_formatter< char, std::char_traits<char>, std::allocator<char> > format;
|
template <typename T, typename TR, typename A>
|
||||||
}
|
class basic_formatter;
|
||||||
|
|
||||||
|
typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format;
|
||||||
|
|
||||||
|
} // namespace Formatter
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
/** Load the Autodesk FBX file format.
|
/// Loads the Autodesk FBX file format.
|
||||||
|
///
|
||||||
See http://en.wikipedia.org/wiki/FBX
|
/// See http://en.wikipedia.org/wiki/FBX
|
||||||
*/
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter>
|
class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FBXImporter();
|
FBXImporter();
|
||||||
virtual ~FBXImporter();
|
virtual ~FBXImporter();
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
bool CanRead( const std::string& pFile,
|
bool CanRead(const std::string &pFile,
|
||||||
IOSystem* pIOHandler,
|
IOSystem *pIOHandler,
|
||||||
bool checkSig
|
bool checkSig) const;
|
||||||
) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// --------------------
|
||||||
|
const aiImporterDesc *GetInfo() const;
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
const aiImporterDesc* GetInfo () const;
|
void SetupProperties(const Importer *pImp);
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
void SetupProperties(const Importer* pImp);
|
void InternReadFile(const std::string &pFile,
|
||||||
|
aiScene *pScene,
|
||||||
// --------------------
|
IOSystem *pIOHandler);
|
||||||
void InternReadFile( const std::string& pFile,
|
|
||||||
aiScene* pScene,
|
|
||||||
IOSystem* pIOHandler
|
|
||||||
);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FBX::ImportSettings settings;
|
FBX::ImportSettings settings;
|
||||||
|
@ -97,4 +95,3 @@ private:
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
#endif // !INCLUDED_AI_FBX_IMPORTER_H
|
#endif // !INCLUDED_AI_FBX_IMPORTER_H
|
||||||
|
|
||||||
|
|
|
@ -1483,6 +1483,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
delete root;
|
delete root;
|
||||||
|
delete reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER
|
||||||
|
|
|
@ -292,8 +292,8 @@ void ExportSceneM3D(
|
||||||
// Prototyped and registered in Exporter.cpp
|
// Prototyped and registered in Exporter.cpp
|
||||||
void ExportSceneM3DA(
|
void ExportSceneM3DA(
|
||||||
const char *,
|
const char *,
|
||||||
IOSystem*,
|
IOSystem *,
|
||||||
const aiScene*,
|
const aiScene *,
|
||||||
const ExportProperties *
|
const ExportProperties *
|
||||||
|
|
||||||
) {
|
) {
|
||||||
|
@ -312,7 +312,9 @@ void ExportSceneM3DA(
|
||||||
M3DExporter::M3DExporter(const aiScene *pScene, const ExportProperties *pProperties) :
|
M3DExporter::M3DExporter(const aiScene *pScene, const ExportProperties *pProperties) :
|
||||||
mScene(pScene),
|
mScene(pScene),
|
||||||
mProperties(pProperties),
|
mProperties(pProperties),
|
||||||
outfile() {}
|
outfile() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void M3DExporter::doExport(
|
void M3DExporter::doExport(
|
||||||
|
@ -352,6 +354,9 @@ void M3DExporter::doExport(
|
||||||
// explicitly release file pointer,
|
// explicitly release file pointer,
|
||||||
// so we don't have to rely on class destruction.
|
// so we don't have to rely on class destruction.
|
||||||
outfile.reset();
|
outfile.reset();
|
||||||
|
|
||||||
|
M3D_FREE(m3d->name);
|
||||||
|
m3d->name = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -50,15 +50,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifdef ASSIMP_USE_M3D_READFILECB
|
#ifdef ASSIMP_USE_M3D_READFILECB
|
||||||
|
|
||||||
# if (__cplusplus >= 201103L) || !defined(_MSC_VER) || (_MSC_VER >= 1900) // C++11 and MSVC 2015 onwards
|
#if (__cplusplus >= 201103L) || !defined(_MSC_VER) || (_MSC_VER >= 1900) // C++11 and MSVC 2015 onwards
|
||||||
# define threadlocal thread_local
|
#define threadlocal thread_local
|
||||||
# else
|
#else
|
||||||
# if defined(_MSC_VER) && (_MSC_VER >= 1800) // there's an alternative for MSVC 2013
|
#if defined(_MSC_VER) && (_MSC_VER >= 1800) // there's an alternative for MSVC 2013
|
||||||
# define threadlocal __declspec(thread)
|
#define threadlocal __declspec(thread)
|
||||||
# else
|
#else
|
||||||
# define threadlocal
|
#define threadlocal
|
||||||
# endif
|
#endif
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
@ -121,8 +121,9 @@ M3DWrapper::~M3DWrapper() {
|
||||||
|
|
||||||
void M3DWrapper::reset() {
|
void M3DWrapper::reset() {
|
||||||
ClearSave();
|
ClearSave();
|
||||||
if (m3d_)
|
if (m3d_) {
|
||||||
m3d_free(m3d_);
|
m3d_free(m3d_);
|
||||||
|
}
|
||||||
m3d_ = nullptr;
|
m3d_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5440,13 +5440,13 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
out += 2;
|
out += 2;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
*((float *)out) = vrtx[i].data.x;
|
memcpy(out, &vrtx[i].data.x, sizeof(float));
|
||||||
out += 4;
|
out += 4;
|
||||||
*((float *)out) = vrtx[i].data.y;
|
memcpy(out, &vrtx[i].data.y, sizeof(float));
|
||||||
out += 4;
|
out += 4;
|
||||||
*((float *)out) = vrtx[i].data.z;
|
memcpy(out, &vrtx[i].data.z, sizeof(float));
|
||||||
out += 4;
|
out += 4;
|
||||||
*((float *)out) = vrtx[i].data.w;
|
memcpy(out, &vrtx[i].data.w, sizeof(float));
|
||||||
out += 4;
|
out += 4;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
@ -5474,9 +5474,11 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
}
|
}
|
||||||
out = _m3d_addidx(out, sk_s, vrtx[i].data.skinid);
|
out = _m3d_addidx(out, sk_s, vrtx[i].data.skinid);
|
||||||
}
|
}
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
|
memcpy(length, &v, sizeof(uint32_t));
|
||||||
|
//*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
out = NULL;
|
out = NULL;
|
||||||
len += *length;
|
len += v;
|
||||||
}
|
}
|
||||||
/* bones chunk */
|
/* bones chunk */
|
||||||
if (model->numbone && model->bone && !(flags & M3D_EXP_NOBONE)) {
|
if (model->numbone && model->bone && !(flags & M3D_EXP_NOBONE)) {
|
||||||
|
@ -5660,8 +5662,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
out = _m3d_addidx(out, vi_s, vrtxidx[face[i].data.normal[j]]);
|
out = _m3d_addidx(out, vi_s, vrtxidx[face[i].data.normal[j]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
len += *length;
|
memcpy(length, &v, sizeof(uint32_t));
|
||||||
|
len += v;
|
||||||
out = NULL;
|
out = NULL;
|
||||||
}
|
}
|
||||||
/* mathematical shapes face */
|
/* mathematical shapes face */
|
||||||
|
@ -5721,8 +5724,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
len += *length;
|
memcpy( length, &v, sizeof(uint32_t));
|
||||||
|
len += v;
|
||||||
out = NULL;
|
out = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5765,8 +5769,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->label[l].text));
|
out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->label[l].text));
|
||||||
}
|
}
|
||||||
if (length) {
|
if (length) {
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
len += *length;
|
memcpy( length, &v, sizeof(uint32_t));
|
||||||
|
len += v;
|
||||||
}
|
}
|
||||||
out = NULL;
|
out = NULL;
|
||||||
sn = sl = NULL;
|
sn = sl = NULL;
|
||||||
|
@ -5796,8 +5801,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
out = _m3d_addidx(out, vi_s, vrtxidx[a->frame[i].transform[k].ori]);
|
out = _m3d_addidx(out, vi_s, vrtxidx[a->frame[i].transform[k].ori]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
len += *length;
|
memcpy( length, &v, sizeof(uint32_t));
|
||||||
|
len += v;
|
||||||
out = NULL;
|
out = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,7 +503,7 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput,
|
||||||
pcNew->mData = new char[pSizeInBytes];
|
pcNew->mData = new char[pSizeInBytes];
|
||||||
memcpy (pcNew->mData,pInput,pSizeInBytes);
|
memcpy (pcNew->mData,pInput,pSizeInBytes);
|
||||||
|
|
||||||
pcNew->mKey.length = (ai_uint32)::strlen(pKey);
|
pcNew->mKey.length = static_cast<ai_uint32>( ::strlen(pKey) );
|
||||||
ai_assert ( MAXLEN > pcNew->mKey.length);
|
ai_assert ( MAXLEN > pcNew->mKey.length);
|
||||||
strcpy( pcNew->mKey.data, pKey );
|
strcpy( pcNew->mKey.data, pKey );
|
||||||
|
|
||||||
|
|
|
@ -617,7 +617,7 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model
|
||||||
// We'll leave it up to the user to figure out which extension the file has.
|
// We'll leave it up to the user to figure out which extension the file has.
|
||||||
aiString name;
|
aiString name;
|
||||||
strncpy( name.data, pTexture->strName, sizeof name.data );
|
strncpy( name.data, pTexture->strName, sizeof name.data );
|
||||||
name.length = (ai_uint32)strlen( name.data );
|
name.length = static_cast<ai_uint32>(strlen( name.data ));
|
||||||
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
|
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,7 +616,7 @@ void SMDImporter::CreateOutputMaterials() {
|
||||||
if (aszTextures[iMat].length())
|
if (aszTextures[iMat].length())
|
||||||
{
|
{
|
||||||
::strncpy(szName.data, aszTextures[iMat].c_str(),MAXLEN-1);
|
::strncpy(szName.data, aszTextures[iMat].c_str(),MAXLEN-1);
|
||||||
szName.length = (ai_uint32)aszTextures[iMat].length();
|
szName.length = static_cast<ai_uint32>( aszTextures[iMat].length() );
|
||||||
pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -43,17 +41,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Implementation of the Terragen importer class */
|
/** @file Implementation of the Terragen importer class */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
|
||||||
|
|
||||||
#include "TerragenLoader.h"
|
#include "TerragenLoader.h"
|
||||||
#include <assimp/StreamReader.h>
|
#include <assimp/StreamReader.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/importerdesc.h>
|
||||||
#include <assimp/IOSystem.hpp>
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -72,78 +68,72 @@ static const aiImporterDesc desc = {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
TerragenImporter::TerragenImporter()
|
TerragenImporter::TerragenImporter() :
|
||||||
: configComputeUVs (false)
|
configComputeUVs(false) {}
|
||||||
{}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
TerragenImporter::~TerragenImporter()
|
TerragenImporter::~TerragenImporter() {}
|
||||||
{}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool TerragenImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
|
||||||
{
|
|
||||||
// check file extension
|
// check file extension
|
||||||
std::string extension = GetExtension(pFile);
|
std::string extension = GetExtension(pFile);
|
||||||
|
|
||||||
if( extension == "ter")
|
if (extension == "ter")
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if( !extension.length() || checkSig) {
|
if (!extension.length() || checkSig) {
|
||||||
/* If CanRead() is called in order to check whether we
|
/* If CanRead() is called in order to check whether we
|
||||||
* support a specific file extension in general pIOHandler
|
* support a specific file extension in general pIOHandler
|
||||||
* might be NULL and it's our duty to return true here.
|
* might be NULL and it's our duty to return true here.
|
||||||
*/
|
*/
|
||||||
if (!pIOHandler)return true;
|
if (!pIOHandler) return true;
|
||||||
const char* tokens[] = {"terragen"};
|
const char *tokens[] = { "terragen" };
|
||||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Build a string of all file extensions supported
|
// Build a string of all file extensions supported
|
||||||
const aiImporterDesc* TerragenImporter::GetInfo () const
|
const aiImporterDesc *TerragenImporter::GetInfo() const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup import properties
|
// Setup import properties
|
||||||
void TerragenImporter::SetupProperties(const Importer* pImp)
|
void TerragenImporter::SetupProperties(const Importer *pImp) {
|
||||||
{
|
|
||||||
// AI_CONFIG_IMPORT_TER_MAKE_UVS
|
// AI_CONFIG_IMPORT_TER_MAKE_UVS
|
||||||
configComputeUVs = ( 0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS,0) );
|
configComputeUVs = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void TerragenImporter::InternReadFile( const std::string& pFile,
|
void TerragenImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
{
|
IOStream *file = pIOHandler->Open(pFile, "rb");
|
||||||
IOStream* file = pIOHandler->Open( pFile, "rb");
|
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if( file == NULL)
|
if (file == NULL)
|
||||||
throw DeadlyImportError( "Failed to open TERRAGEN TERRAIN file " + pFile + ".");
|
throw DeadlyImportError("Failed to open TERRAGEN TERRAIN file " + pFile + ".");
|
||||||
|
|
||||||
// Construct a stream reader to read all data in the correct endianness
|
// Construct a stream reader to read all data in the correct endianness
|
||||||
StreamReaderLE reader(file);
|
StreamReaderLE reader(file);
|
||||||
if(reader.GetRemainingSize() < 16)
|
if (reader.GetRemainingSize() < 16)
|
||||||
throw DeadlyImportError( "TER: file is too small" );
|
throw DeadlyImportError("TER: file is too small");
|
||||||
|
|
||||||
// Check for the existence of the two magic strings 'TERRAGEN' and 'TERRAIN '
|
// Check for the existence of the two magic strings 'TERRAGEN' and 'TERRAIN '
|
||||||
if (::strncmp((const char*)reader.GetPtr(),AI_TERR_BASE_STRING,8))
|
if (::strncmp((const char *)reader.GetPtr(), AI_TERR_BASE_STRING, 8))
|
||||||
throw DeadlyImportError( "TER: Magic string \'TERRAGEN\' not found" );
|
throw DeadlyImportError("TER: Magic string \'TERRAGEN\' not found");
|
||||||
|
|
||||||
if (::strncmp((const char*)reader.GetPtr()+8,AI_TERR_TERRAIN_STRING,8))
|
if (::strncmp((const char *)reader.GetPtr() + 8, AI_TERR_TERRAIN_STRING, 8))
|
||||||
throw DeadlyImportError( "TER: Magic string \'TERRAIN\' not found" );
|
throw DeadlyImportError("TER: Magic string \'TERRAIN\' not found");
|
||||||
|
|
||||||
unsigned int x = 0,y = 0,mode = 0;
|
unsigned int x = 0, y = 0, mode = 0;
|
||||||
|
|
||||||
aiNode* root = pScene->mRootNode = new aiNode();
|
aiNode *root = pScene->mRootNode = new aiNode();
|
||||||
root->mName.Set("<TERRAGEN.TERRAIN>");
|
root->mName.Set("<TERRAGEN.TERRAIN>");
|
||||||
|
|
||||||
// Default scaling is 30
|
// Default scaling is 30
|
||||||
|
@ -151,104 +141,98 @@ void TerragenImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// Now read all chunks until we're finished or an EOF marker is encountered
|
// Now read all chunks until we're finished or an EOF marker is encountered
|
||||||
reader.IncPtr(16);
|
reader.IncPtr(16);
|
||||||
while (reader.GetRemainingSize() >= 4)
|
while (reader.GetRemainingSize() >= 4) {
|
||||||
{
|
const char *head = (const char *)reader.GetPtr();
|
||||||
const char* head = (const char*)reader.GetPtr();
|
|
||||||
reader.IncPtr(4);
|
reader.IncPtr(4);
|
||||||
|
|
||||||
// EOF, break in every case
|
// EOF, break in every case
|
||||||
if (!::strncmp(head,AI_TERR_EOF_STRING,4))
|
if (!::strncmp(head, AI_TERR_EOF_STRING, 4))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Number of x-data points
|
// Number of x-data points
|
||||||
if (!::strncmp(head,AI_TERR_CHUNK_XPTS,4))
|
if (!::strncmp(head, AI_TERR_CHUNK_XPTS, 4)) {
|
||||||
{
|
|
||||||
x = (uint16_t)reader.GetI2();
|
x = (uint16_t)reader.GetI2();
|
||||||
}
|
}
|
||||||
// Number of y-data points
|
// Number of y-data points
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_YPTS,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_YPTS, 4)) {
|
||||||
{
|
|
||||||
y = (uint16_t)reader.GetI2();
|
y = (uint16_t)reader.GetI2();
|
||||||
}
|
}
|
||||||
// Squared terrains width-1.
|
// Squared terrains width-1.
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_SIZE,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_SIZE, 4)) {
|
||||||
{
|
x = y = (uint16_t)reader.GetI2() + 1;
|
||||||
x = y = (uint16_t)reader.GetI2()+1;
|
|
||||||
}
|
}
|
||||||
// terrain scaling
|
// terrain scaling
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_SCAL,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_SCAL, 4)) {
|
||||||
{
|
|
||||||
root->mTransformation.a1 = reader.GetF4();
|
root->mTransformation.a1 = reader.GetF4();
|
||||||
root->mTransformation.b2 = reader.GetF4();
|
root->mTransformation.b2 = reader.GetF4();
|
||||||
root->mTransformation.c3 = reader.GetF4();
|
root->mTransformation.c3 = reader.GetF4();
|
||||||
}
|
}
|
||||||
// mapping == 1: earth radius
|
// mapping == 1: earth radius
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_CRAD,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_CRAD, 4)) {
|
||||||
{
|
|
||||||
reader.GetF4();
|
reader.GetF4();
|
||||||
}
|
}
|
||||||
// mapping mode
|
// mapping mode
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_CRVM,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_CRVM, 4)) {
|
||||||
{
|
|
||||||
mode = reader.GetI1();
|
mode = reader.GetI1();
|
||||||
if (0 != mode)
|
if (0 != mode)
|
||||||
ASSIMP_LOG_ERROR("TER: Unsupported mapping mode, a flat terrain is returned");
|
ASSIMP_LOG_ERROR("TER: Unsupported mapping mode, a flat terrain is returned");
|
||||||
}
|
}
|
||||||
// actual terrain data
|
// actual terrain data
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_ALTW,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_ALTW, 4)) {
|
||||||
{
|
|
||||||
float hscale = (float)reader.GetI2() / 65536;
|
float hscale = (float)reader.GetI2() / 65536;
|
||||||
float bheight = (float)reader.GetI2();
|
float bheight = (float)reader.GetI2();
|
||||||
|
|
||||||
if (!hscale)hscale = 1;
|
if (!hscale) hscale = 1;
|
||||||
|
|
||||||
// Ensure we have enough data
|
// Ensure we have enough data
|
||||||
if (reader.GetRemainingSize() < x*y*2)
|
if (reader.GetRemainingSize() < x * y * 2)
|
||||||
throw DeadlyImportError("TER: ALTW chunk is too small");
|
throw DeadlyImportError("TER: ALTW chunk is too small");
|
||||||
|
|
||||||
if (x <= 1 || y <= 1)
|
if (x <= 1 || y <= 1)
|
||||||
throw DeadlyImportError("TER: Invalid terrain size");
|
throw DeadlyImportError("TER: Invalid terrain size");
|
||||||
|
|
||||||
// Allocate the output mesh
|
// Allocate the output mesh
|
||||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes = 1];
|
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes = 1];
|
||||||
aiMesh* m = pScene->mMeshes[0] = new aiMesh();
|
aiMesh *m = pScene->mMeshes[0] = new aiMesh();
|
||||||
|
|
||||||
// We return quads
|
// We return quads
|
||||||
aiFace* f = m->mFaces = new aiFace[m->mNumFaces = (x-1)*(y-1)];
|
aiFace *f = m->mFaces = new aiFace[m->mNumFaces = (x - 1) * (y - 1)];
|
||||||
aiVector3D* pv = m->mVertices = new aiVector3D[m->mNumVertices = m->mNumFaces*4];
|
aiVector3D *pv = m->mVertices = new aiVector3D[m->mNumVertices = m->mNumFaces * 4];
|
||||||
|
|
||||||
aiVector3D *uv( NULL );
|
aiVector3D *uv(NULL);
|
||||||
float step_y( 0.0f ), step_x( 0.0f );
|
float step_y(0.0f), step_x(0.0f);
|
||||||
if (configComputeUVs) {
|
if (configComputeUVs) {
|
||||||
uv = m->mTextureCoords[0] = new aiVector3D[m->mNumVertices];
|
uv = m->mTextureCoords[0] = new aiVector3D[m->mNumVertices];
|
||||||
step_y = 1.f/y;
|
step_y = 1.f / y;
|
||||||
step_x = 1.f/x;
|
step_x = 1.f / x;
|
||||||
}
|
}
|
||||||
const int16_t* data = (const int16_t*)reader.GetPtr();
|
const int16_t *data = (const int16_t *)reader.GetPtr();
|
||||||
|
|
||||||
for (unsigned int yy = 0, t = 0; yy < y-1;++yy) {
|
for (unsigned int yy = 0, t = 0; yy < y - 1; ++yy) {
|
||||||
for (unsigned int xx = 0; xx < x-1;++xx,++f) {
|
for (unsigned int xx = 0; xx < x - 1; ++xx, ++f) {
|
||||||
|
|
||||||
// make verts
|
// make verts
|
||||||
const float fy = (float)yy, fx = (float)xx;
|
const float fy = (float)yy, fx = (float)xx;
|
||||||
unsigned tmp,tmp2;
|
unsigned tmp, tmp2;
|
||||||
*pv++ = aiVector3D(fx,fy, (float)data[(tmp2=x*yy) + xx] * hscale + bheight);
|
*pv++ = aiVector3D(fx, fy, (float)data[(tmp2 = x * yy) + xx] * hscale + bheight);
|
||||||
*pv++ = aiVector3D(fx,fy+1, (float)data[(tmp=x*(yy+1)) + xx] * hscale + bheight);
|
*pv++ = aiVector3D(fx, fy + 1, (float)data[(tmp = x * (yy + 1)) + xx] * hscale + bheight);
|
||||||
*pv++ = aiVector3D(fx+1,fy+1,(float)data[tmp + xx+1] * hscale + bheight);
|
*pv++ = aiVector3D(fx + 1, fy + 1, (float)data[tmp + xx + 1] * hscale + bheight);
|
||||||
*pv++ = aiVector3D(fx+1,fy, (float)data[tmp2 + xx+1] * hscale + bheight);
|
*pv++ = aiVector3D(fx + 1, fy, (float)data[tmp2 + xx + 1] * hscale + bheight);
|
||||||
|
|
||||||
// also make texture coordinates, if necessary
|
// also make texture coordinates, if necessary
|
||||||
if (configComputeUVs) {
|
if (configComputeUVs) {
|
||||||
*uv++ = aiVector3D( step_x*xx, step_y*yy, 0.f );
|
*uv++ = aiVector3D(step_x * xx, step_y * yy, 0.f);
|
||||||
*uv++ = aiVector3D( step_x*xx, step_y*(yy+1), 0.f );
|
*uv++ = aiVector3D(step_x * xx, step_y * (yy + 1), 0.f);
|
||||||
*uv++ = aiVector3D( step_x*(xx+1), step_y*(yy+1), 0.f );
|
*uv++ = aiVector3D(step_x * (xx + 1), step_y * (yy + 1), 0.f);
|
||||||
*uv++ = aiVector3D( step_x*(xx+1), step_y*yy, 0.f );
|
*uv++ = aiVector3D(step_x * (xx + 1), step_y * yy, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make indices
|
// make indices
|
||||||
f->mIndices = new unsigned int[f->mNumIndices = 4];
|
f->mIndices = new unsigned int[f->mNumIndices = 4];
|
||||||
for (unsigned int i = 0; i < 4;++i)
|
for (unsigned int i = 0; i < 4; ++i) {
|
||||||
f->mIndices[i] = t++;
|
f->mIndices[i] = t;
|
||||||
|
t++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -69,33 +68,28 @@ namespace Assimp {
|
||||||
* The loader is basing on the information found here:
|
* The loader is basing on the information found here:
|
||||||
* http://www.planetside.co.uk/terragen/dev/tgterrain.html#chunks
|
* http://www.planetside.co.uk/terragen/dev/tgterrain.html#chunks
|
||||||
*/
|
*/
|
||||||
class TerragenImporter : public BaseImporter
|
class TerragenImporter : public BaseImporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
TerragenImporter();
|
TerragenImporter();
|
||||||
~TerragenImporter();
|
~TerragenImporter();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||||
bool checkSig) const;
|
bool checkSig) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
const aiImporterDesc *GetInfo() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
const aiImporterDesc* GetInfo () const;
|
void InternReadFile(const std::string &pFile, aiScene *pScene,
|
||||||
|
IOSystem *pIOHandler);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
void SetupProperties(const Importer *pImp);
|
||||||
IOSystem* pIOHandler);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
void SetupProperties(const Importer* pImp);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool configComputeUVs;
|
bool configComputeUVs;
|
||||||
|
|
||||||
}; //! class TerragenImporter
|
}; //! class TerragenImporter
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -48,26 +46,112 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* http://local.wasp.uwa.edu.au/~pbourke/dataformats/unreal/
|
* http://local.wasp.uwa.edu.au/~pbourke/dataformats/unreal/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3D_IMPORTER
|
||||||
|
|
||||||
#include "Unreal/UnrealLoader.h"
|
#include "Unreal/UnrealLoader.h"
|
||||||
#include "PostProcessing/ConvertToLHProcess.h"
|
#include "PostProcessing/ConvertToLHProcess.h"
|
||||||
|
|
||||||
#include <assimp/StreamReader.h>
|
|
||||||
#include <assimp/ParsingUtils.h>
|
#include <assimp/ParsingUtils.h>
|
||||||
|
#include <assimp/StreamReader.h>
|
||||||
#include <assimp/fast_atof.h>
|
#include <assimp/fast_atof.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/importerdesc.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/importerdesc.h>
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
namespace Unreal {
|
||||||
|
|
||||||
|
/*
|
||||||
|
0 = Normal one-sided
|
||||||
|
1 = Normal two-sided
|
||||||
|
2 = Translucent two-sided
|
||||||
|
3 = Masked two-sided
|
||||||
|
4 = Modulation blended two-sided
|
||||||
|
8 = Placeholder triangle for weapon positioning (invisible)
|
||||||
|
*/
|
||||||
|
enum MeshFlags {
|
||||||
|
MF_NORMAL_OS = 0,
|
||||||
|
MF_NORMAL_TS = 1,
|
||||||
|
MF_NORMAL_TRANS_TS = 2,
|
||||||
|
MF_NORMAL_MASKED_TS = 3,
|
||||||
|
MF_NORMAL_MOD_TS = 4,
|
||||||
|
MF_WEAPON_PLACEHOLDER = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
// a single triangle
|
||||||
|
struct Triangle {
|
||||||
|
uint16_t mVertex[3]; // Vertex indices
|
||||||
|
char mType; // James' Mesh Type
|
||||||
|
char mColor; // Color for flat and Gourand Shaded
|
||||||
|
unsigned char mTex[3][2]; // Texture UV coordinates
|
||||||
|
unsigned char mTextureNum; // Source texture offset
|
||||||
|
char mFlags; // Unreal Mesh Flags (unused)
|
||||||
|
unsigned int matIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
// temporary representation for a material
|
||||||
|
struct TempMat {
|
||||||
|
TempMat() :
|
||||||
|
type(MF_NORMAL_OS), tex(), numFaces(0) {}
|
||||||
|
|
||||||
|
explicit TempMat(const Triangle &in) :
|
||||||
|
type((Unreal::MeshFlags)in.mType), tex(in.mTextureNum), numFaces(0) {}
|
||||||
|
|
||||||
|
// type of mesh
|
||||||
|
Unreal::MeshFlags type;
|
||||||
|
|
||||||
|
// index of texture
|
||||||
|
unsigned int tex;
|
||||||
|
|
||||||
|
// number of faces using us
|
||||||
|
unsigned int numFaces;
|
||||||
|
|
||||||
|
// for std::find
|
||||||
|
bool operator==(const TempMat &o) {
|
||||||
|
return (tex == o.tex && type == o.type);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Vertex {
|
||||||
|
int32_t X : 11;
|
||||||
|
int32_t Y : 11;
|
||||||
|
int32_t Z : 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
// UNREAL vertex compression
|
||||||
|
inline void CompressVertex(const aiVector3D &v, uint32_t &out) {
|
||||||
|
union {
|
||||||
|
Vertex n;
|
||||||
|
int32_t t;
|
||||||
|
};
|
||||||
|
t = 0;
|
||||||
|
n.X = (int32_t)v.x;
|
||||||
|
n.Y = (int32_t)v.y;
|
||||||
|
n.Z = (int32_t)v.z;
|
||||||
|
::memcpy(&out, &t, sizeof(int32_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
// UNREAL vertex decompression
|
||||||
|
inline void DecompressVertex(aiVector3D &v, int32_t in) {
|
||||||
|
union {
|
||||||
|
Vertex n;
|
||||||
|
int32_t i;
|
||||||
|
};
|
||||||
|
i = in;
|
||||||
|
|
||||||
|
v.x = (float)n.X;
|
||||||
|
v.y = (float)n.Y;
|
||||||
|
v.z = (float)n.Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace Unreal
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static const aiImporterDesc desc = {
|
||||||
"Unreal Mesh Importer",
|
"Unreal Mesh Importer",
|
||||||
"",
|
"",
|
||||||
|
@ -81,60 +165,52 @@ static const aiImporterDesc desc = {
|
||||||
"3d uc"
|
"3d uc"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
UnrealImporter::UnrealImporter()
|
UnrealImporter::UnrealImporter() :
|
||||||
: configFrameID (0)
|
mConfigFrameID(0), mConfigHandleFlags(true) {}
|
||||||
, configHandleFlags (true)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
UnrealImporter::~UnrealImporter()
|
UnrealImporter::~UnrealImporter() {}
|
||||||
{}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool UnrealImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const
|
bool UnrealImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
|
||||||
{
|
return SimpleExtensionCheck(pFile, "3d", "uc");
|
||||||
return SimpleExtensionCheck(pFile,"3d","uc");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Build a string of all file extensions supported
|
// Build a string of all file extensions supported
|
||||||
const aiImporterDesc* UnrealImporter::GetInfo () const
|
const aiImporterDesc *UnrealImporter::GetInfo() const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup configuration properties for the loader
|
// Setup configuration properties for the loader
|
||||||
void UnrealImporter::SetupProperties(const Importer* pImp)
|
void UnrealImporter::SetupProperties(const Importer *pImp) {
|
||||||
{
|
|
||||||
// The
|
// The
|
||||||
// AI_CONFIG_IMPORT_UNREAL_KEYFRAME option overrides the
|
// AI_CONFIG_IMPORT_UNREAL_KEYFRAME option overrides the
|
||||||
// AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
|
// AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
|
||||||
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_KEYFRAME,-1);
|
mConfigFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_KEYFRAME, -1);
|
||||||
if(static_cast<unsigned int>(-1) == configFrameID) {
|
if (static_cast<unsigned int>(-1) == mConfigFrameID) {
|
||||||
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
|
mConfigFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS, default is true
|
// AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS, default is true
|
||||||
configHandleFlags = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS,1));
|
mConfigHandleFlags = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void UnrealImporter::InternReadFile( const std::string& pFile,
|
void UnrealImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
{
|
|
||||||
// For any of the 3 files being passed get the three correct paths
|
// For any of the 3 files being passed get the three correct paths
|
||||||
// First of all, determine file extension
|
// First of all, determine file extension
|
||||||
std::string::size_type pos = pFile.find_last_of('.');
|
std::string::size_type pos = pFile.find_last_of('.');
|
||||||
std::string extension = GetExtension(pFile);
|
std::string extension = GetExtension(pFile);
|
||||||
|
|
||||||
std::string d_path,a_path,uc_path;
|
std::string d_path, a_path, uc_path;
|
||||||
if (extension == "3d") {
|
if (extension == "3d") {
|
||||||
// jjjj_d.3d
|
// jjjj_d.3d
|
||||||
// jjjj_a.3d
|
// jjjj_a.3d
|
||||||
|
@ -142,18 +218,17 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
if (std::string::npos == pos) {
|
if (std::string::npos == pos) {
|
||||||
throw DeadlyImportError("UNREAL: Unexpected naming scheme");
|
throw DeadlyImportError("UNREAL: Unexpected naming scheme");
|
||||||
}
|
}
|
||||||
extension = pFile.substr(0,pos);
|
extension = pFile.substr(0, pos);
|
||||||
}
|
} else {
|
||||||
else {
|
extension = pFile.substr(0, pos);
|
||||||
extension = pFile.substr(0,pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// build proper paths
|
// build proper paths
|
||||||
d_path = extension+"_d.3d";
|
d_path = extension + "_d.3d";
|
||||||
a_path = extension+"_a.3d";
|
a_path = extension + "_a.3d";
|
||||||
uc_path = extension+".uc";
|
uc_path = extension + ".uc";
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F( "UNREAL: data file is ", d_path);
|
ASSIMP_LOG_DEBUG_F("UNREAL: data file is ", d_path);
|
||||||
ASSIMP_LOG_DEBUG_F("UNREAL: aniv file is ", a_path);
|
ASSIMP_LOG_DEBUG_F("UNREAL: aniv file is ", a_path);
|
||||||
ASSIMP_LOG_DEBUG_F("UNREAL: uc file is ", uc_path);
|
ASSIMP_LOG_DEBUG_F("UNREAL: uc file is ", uc_path);
|
||||||
|
|
||||||
|
@ -174,8 +249,8 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// collect triangles
|
// collect triangles
|
||||||
std::vector<Unreal::Triangle> triangles(numTris);
|
std::vector<Unreal::Triangle> triangles(numTris);
|
||||||
for (auto & tri : triangles) {
|
for (auto &tri : triangles) {
|
||||||
for (unsigned int i = 0; i < 3;++i) {
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
|
|
||||||
tri.mVertex[i] = d_reader.GetI2();
|
tri.mVertex[i] = d_reader.GetI2();
|
||||||
if (tri.mVertex[i] >= numTris) {
|
if (tri.mVertex[i] >= numTris) {
|
||||||
|
@ -186,7 +261,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
tri.mType = d_reader.GetI1();
|
tri.mType = d_reader.GetI1();
|
||||||
|
|
||||||
// handle mesh flagss?
|
// handle mesh flagss?
|
||||||
if (configHandleFlags)
|
if (mConfigHandleFlags)
|
||||||
tri.mType = Unreal::MF_NORMAL_OS;
|
tri.mType = Unreal::MF_NORMAL_OS;
|
||||||
else {
|
else {
|
||||||
// ignore MOD and MASKED for the moment, treat them as two-sided
|
// ignore MOD and MASKED for the moment, treat them as two-sided
|
||||||
|
@ -195,12 +270,12 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
d_reader.IncPtr(1);
|
d_reader.IncPtr(1);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 3;++i)
|
for (unsigned int i = 0; i < 3; ++i)
|
||||||
for (unsigned int i2 = 0; i2 < 2;++i2)
|
for (unsigned int i2 = 0; i2 < 2; ++i2)
|
||||||
tri.mTex[i][i2] = d_reader.GetI1();
|
tri.mTex[i][i2] = d_reader.GetI1();
|
||||||
|
|
||||||
tri.mTextureNum = d_reader.GetI1();
|
tri.mTextureNum = d_reader.GetI1();
|
||||||
maxTexIdx = std::max(maxTexIdx,(unsigned int)tri.mTextureNum);
|
maxTexIdx = std::max(maxTexIdx, (unsigned int)tri.mTextureNum);
|
||||||
d_reader.IncPtr(1);
|
d_reader.IncPtr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,63 +286,64 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// read number of frames
|
// read number of frames
|
||||||
const uint32_t numFrames = a_reader.GetI2();
|
const uint32_t numFrames = a_reader.GetI2();
|
||||||
if (configFrameID >= numFrames) {
|
if (mConfigFrameID >= numFrames) {
|
||||||
throw DeadlyImportError("UNREAL: The requested frame does not exist");
|
throw DeadlyImportError("UNREAL: The requested frame does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t st = a_reader.GetI2();
|
uint32_t st = a_reader.GetI2();
|
||||||
if (st != numVert*4u)
|
if (st != numVert * 4u)
|
||||||
throw DeadlyImportError("UNREAL: Unexpected aniv file length");
|
throw DeadlyImportError("UNREAL: Unexpected aniv file length");
|
||||||
|
|
||||||
// skip to our frame
|
// skip to our frame
|
||||||
a_reader.IncPtr(configFrameID *numVert*4);
|
a_reader.IncPtr(mConfigFrameID * numVert * 4);
|
||||||
|
|
||||||
// collect vertices
|
// collect vertices
|
||||||
std::vector<aiVector3D> vertices(numVert);
|
std::vector<aiVector3D> vertices(numVert);
|
||||||
for (auto &vertex : vertices) {
|
for (auto &vertex : vertices) {
|
||||||
int32_t val = a_reader.GetI4();
|
int32_t val = a_reader.GetI4();
|
||||||
Unreal::DecompressVertex(vertex ,val);
|
Unreal::DecompressVertex(vertex, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// list of textures.
|
// list of textures.
|
||||||
std::vector< std::pair<unsigned int, std::string> > textures;
|
std::vector<std::pair<unsigned int, std::string>> textures;
|
||||||
|
|
||||||
// allocate the output scene
|
// allocate the output scene
|
||||||
aiNode* nd = pScene->mRootNode = new aiNode();
|
aiNode *nd = pScene->mRootNode = new aiNode();
|
||||||
nd->mName.Set("<UnrealRoot>");
|
nd->mName.Set("<UnrealRoot>");
|
||||||
|
|
||||||
// we can live without the uc file if necessary
|
// we can live without the uc file if necessary
|
||||||
std::unique_ptr<IOStream> pb (pIOHandler->Open(uc_path));
|
std::unique_ptr<IOStream> pb(pIOHandler->Open(uc_path));
|
||||||
if (pb.get()) {
|
if (pb.get()) {
|
||||||
|
|
||||||
std::vector<char> _data;
|
std::vector<char> _data;
|
||||||
TextFileToBuffer(pb.get(),_data);
|
TextFileToBuffer(pb.get(), _data);
|
||||||
const char* data = &_data[0];
|
const char *data = &_data[0];
|
||||||
|
|
||||||
std::vector< std::pair< std::string,std::string > > tempTextures;
|
std::vector<std::pair<std::string, std::string>> tempTextures;
|
||||||
|
|
||||||
// do a quick search in the UC file for some known, usually texture-related, tags
|
// do a quick search in the UC file for some known, usually texture-related, tags
|
||||||
for (;*data;++data) {
|
for (; *data; ++data) {
|
||||||
if (TokenMatchI(data,"#exec",5)) {
|
if (TokenMatchI(data, "#exec", 5)) {
|
||||||
SkipSpacesAndLineEnd(&data);
|
SkipSpacesAndLineEnd(&data);
|
||||||
|
|
||||||
// #exec TEXTURE IMPORT [...] NAME=jjjjj [...] FILE=jjjj.pcx [...]
|
// #exec TEXTURE IMPORT [...] NAME=jjjjj [...] FILE=jjjj.pcx [...]
|
||||||
if (TokenMatchI(data,"TEXTURE",7)) {
|
if (TokenMatchI(data, "TEXTURE", 7)) {
|
||||||
SkipSpacesAndLineEnd(&data);
|
SkipSpacesAndLineEnd(&data);
|
||||||
|
|
||||||
if (TokenMatchI(data,"IMPORT",6)) {
|
if (TokenMatchI(data, "IMPORT", 6)) {
|
||||||
tempTextures.push_back(std::pair< std::string,std::string >());
|
tempTextures.push_back(std::pair<std::string, std::string>());
|
||||||
std::pair< std::string,std::string >& me = tempTextures.back();
|
std::pair<std::string, std::string> &me = tempTextures.back();
|
||||||
for (;!IsLineEnd(*data);++data) {
|
for (; !IsLineEnd(*data); ++data) {
|
||||||
if (!::ASSIMP_strincmp(data,"NAME=",5)) {
|
if (!::ASSIMP_strincmp(data, "NAME=", 5)) {
|
||||||
const char *d = data+=5;
|
const char *d = data += 5;
|
||||||
for (;!IsSpaceOrNewLine(*data);++data);
|
for (; !IsSpaceOrNewLine(*data); ++data)
|
||||||
me.first = std::string(d,(size_t)(data-d));
|
;
|
||||||
}
|
me.first = std::string(d, (size_t)(data - d));
|
||||||
else if (!::ASSIMP_strincmp(data,"FILE=",5)) {
|
} else if (!::ASSIMP_strincmp(data, "FILE=", 5)) {
|
||||||
const char *d = data+=5;
|
const char *d = data += 5;
|
||||||
for (;!IsSpaceOrNewLine(*data);++data);
|
for (; !IsSpaceOrNewLine(*data); ++data)
|
||||||
me.second = std::string(d,(size_t)(data-d));
|
;
|
||||||
|
me.second = std::string(d, (size_t)(data - d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!me.first.length() || !me.second.length())
|
if (!me.first.length() || !me.second.length())
|
||||||
|
@ -276,27 +352,27 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
// #exec MESHMAP SETTEXTURE MESHMAP=box NUM=1 TEXTURE=Jtex1
|
// #exec MESHMAP SETTEXTURE MESHMAP=box NUM=1 TEXTURE=Jtex1
|
||||||
// #exec MESHMAP SCALE MESHMAP=box X=0.1 Y=0.1 Z=0.2
|
// #exec MESHMAP SCALE MESHMAP=box X=0.1 Y=0.1 Z=0.2
|
||||||
else if (TokenMatchI(data,"MESHMAP",7)) {
|
else if (TokenMatchI(data, "MESHMAP", 7)) {
|
||||||
SkipSpacesAndLineEnd(&data);
|
SkipSpacesAndLineEnd(&data);
|
||||||
|
|
||||||
if (TokenMatchI(data,"SETTEXTURE",10)) {
|
if (TokenMatchI(data, "SETTEXTURE", 10)) {
|
||||||
|
|
||||||
textures.push_back(std::pair<unsigned int, std::string>());
|
textures.push_back(std::pair<unsigned int, std::string>());
|
||||||
std::pair<unsigned int, std::string>& me = textures.back();
|
std::pair<unsigned int, std::string> &me = textures.back();
|
||||||
|
|
||||||
for (;!IsLineEnd(*data);++data) {
|
for (; !IsLineEnd(*data); ++data) {
|
||||||
if (!::ASSIMP_strincmp(data,"NUM=",4)) {
|
if (!::ASSIMP_strincmp(data, "NUM=", 4)) {
|
||||||
data += 4;
|
data += 4;
|
||||||
me.first = strtoul10(data,&data);
|
me.first = strtoul10(data, &data);
|
||||||
}
|
} else if (!::ASSIMP_strincmp(data, "TEXTURE=", 8)) {
|
||||||
else if (!::ASSIMP_strincmp(data,"TEXTURE=",8)) {
|
|
||||||
data += 8;
|
data += 8;
|
||||||
const char *d = data;
|
const char *d = data;
|
||||||
for (;!IsSpaceOrNewLine(*data);++data);
|
for (; !IsSpaceOrNewLine(*data); ++data)
|
||||||
me.second = std::string(d,(size_t)(data-d));
|
;
|
||||||
|
me.second = std::string(d, (size_t)(data - d));
|
||||||
|
|
||||||
// try to find matching path names, doesn't care if we don't find them
|
// try to find matching path names, doesn't care if we don't find them
|
||||||
for (std::vector< std::pair< std::string,std::string > >::const_iterator it = tempTextures.begin();
|
for (std::vector<std::pair<std::string, std::string>>::const_iterator it = tempTextures.begin();
|
||||||
it != tempTextures.end(); ++it) {
|
it != tempTextures.end(); ++it) {
|
||||||
if ((*it).first == me.second) {
|
if ((*it).first == me.second) {
|
||||||
me.second = (*it).second;
|
me.second = (*it).second;
|
||||||
|
@ -305,36 +381,32 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (TokenMatchI(data, "SCALE", 5)) {
|
||||||
else if (TokenMatchI(data,"SCALE",5)) {
|
|
||||||
|
|
||||||
for (;!IsLineEnd(*data);++data) {
|
for (; !IsLineEnd(*data); ++data) {
|
||||||
if (data[0] == 'X' && data[1] == '=') {
|
if (data[0] == 'X' && data[1] == '=') {
|
||||||
data = fast_atoreal_move<float>(data+2,(float&)nd->mTransformation.a1);
|
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.a1);
|
||||||
}
|
} else if (data[0] == 'Y' && data[1] == '=') {
|
||||||
else if (data[0] == 'Y' && data[1] == '=') {
|
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.b2);
|
||||||
data = fast_atoreal_move<float>(data+2,(float&)nd->mTransformation.b2);
|
} else if (data[0] == 'Z' && data[1] == '=') {
|
||||||
}
|
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.c3);
|
||||||
else if (data[0] == 'Z' && data[1] == '=') {
|
|
||||||
data = fast_atoreal_move<float>(data+2,(float&)nd->mTransformation.c3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ASSIMP_LOG_ERROR("Unable to open .uc file");
|
ASSIMP_LOG_ERROR("Unable to open .uc file");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Unreal::TempMat> materials;
|
std::vector<Unreal::TempMat> materials;
|
||||||
materials.reserve(textures.size()*2+5);
|
materials.reserve(textures.size() * 2 + 5);
|
||||||
|
|
||||||
// find out how many output meshes and materials we'll have and build material indices
|
// find out how many output meshes and materials we'll have and build material indices
|
||||||
for (Unreal::Triangle &tri : triangles) {
|
for (Unreal::Triangle &tri : triangles) {
|
||||||
Unreal::TempMat mat(tri);
|
Unreal::TempMat mat(tri);
|
||||||
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);
|
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(), materials.end(), mat);
|
||||||
if (nt == materials.end()) {
|
if (nt == materials.end()) {
|
||||||
// add material
|
// add material
|
||||||
tri.matIndex = static_cast<unsigned int>(materials.size());
|
tri.matIndex = static_cast<unsigned int>(materials.size());
|
||||||
|
@ -342,9 +414,8 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
materials.push_back(mat);
|
materials.push_back(mat);
|
||||||
|
|
||||||
++pScene->mNumMeshes;
|
++pScene->mNumMeshes;
|
||||||
}
|
} else {
|
||||||
else {
|
tri.matIndex = static_cast<unsigned int>(nt - materials.begin());
|
||||||
tri.matIndex = static_cast<unsigned int>(nt-materials.begin());
|
|
||||||
++nt->numFaces;
|
++nt->numFaces;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,65 +425,65 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate meshes and bind them to the node graph
|
// allocate meshes and bind them to the node graph
|
||||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
|
||||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = pScene->mNumMeshes];
|
pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials = pScene->mNumMeshes];
|
||||||
|
|
||||||
nd->mNumMeshes = pScene->mNumMeshes;
|
nd->mNumMeshes = pScene->mNumMeshes;
|
||||||
nd->mMeshes = new unsigned int[nd->mNumMeshes];
|
nd->mMeshes = new unsigned int[nd->mNumMeshes];
|
||||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i) {
|
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
||||||
aiMesh* m = pScene->mMeshes[i] = new aiMesh();
|
aiMesh *m = pScene->mMeshes[i] = new aiMesh();
|
||||||
m->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
m->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||||
|
|
||||||
const unsigned int num = materials[i].numFaces;
|
const unsigned int num = materials[i].numFaces;
|
||||||
m->mFaces = new aiFace [num];
|
m->mFaces = new aiFace[num];
|
||||||
m->mVertices = new aiVector3D [num*3];
|
m->mVertices = new aiVector3D[num * 3];
|
||||||
m->mTextureCoords[0] = new aiVector3D [num*3];
|
m->mTextureCoords[0] = new aiVector3D[num * 3];
|
||||||
|
|
||||||
nd->mMeshes[i] = i;
|
nd->mMeshes[i] = i;
|
||||||
|
|
||||||
// create materials, too
|
// create materials, too
|
||||||
aiMaterial* mat = new aiMaterial();
|
aiMaterial *mat = new aiMaterial();
|
||||||
pScene->mMaterials[i] = mat;
|
pScene->mMaterials[i] = mat;
|
||||||
|
|
||||||
// all white by default - texture rulez
|
// all white by default - texture rulez
|
||||||
aiColor3D color(1.f,1.f,1.f);
|
aiColor3D color(1.f, 1.f, 1.f);
|
||||||
|
|
||||||
aiString s;
|
aiString s;
|
||||||
::ai_snprintf( s.data, MAXLEN, "mat%u_tx%u_",i,materials[i].tex );
|
::ai_snprintf(s.data, MAXLEN, "mat%u_tx%u_", i, materials[i].tex);
|
||||||
|
|
||||||
// set the two-sided flag
|
// set the two-sided flag
|
||||||
if (materials[i].type == Unreal::MF_NORMAL_TS) {
|
if (materials[i].type == Unreal::MF_NORMAL_TS) {
|
||||||
const int twosided = 1;
|
const int twosided = 1;
|
||||||
mat->AddProperty(&twosided,1,AI_MATKEY_TWOSIDED);
|
mat->AddProperty(&twosided, 1, AI_MATKEY_TWOSIDED);
|
||||||
::strcat(s.data,"ts_");
|
::strcat(s.data, "ts_");
|
||||||
}
|
} else
|
||||||
else ::strcat(s.data,"os_");
|
::strcat(s.data, "os_");
|
||||||
|
|
||||||
// make TRANS faces 90% opaque that RemRedundantMaterials won't catch us
|
// make TRANS faces 90% opaque that RemRedundantMaterials won't catch us
|
||||||
if (materials[i].type == Unreal::MF_NORMAL_TRANS_TS) {
|
if (materials[i].type == Unreal::MF_NORMAL_TRANS_TS) {
|
||||||
const float opac = 0.9f;
|
const float opac = 0.9f;
|
||||||
mat->AddProperty(&opac,1,AI_MATKEY_OPACITY);
|
mat->AddProperty(&opac, 1, AI_MATKEY_OPACITY);
|
||||||
::strcat(s.data,"tran_");
|
::strcat(s.data, "tran_");
|
||||||
}
|
} else
|
||||||
else ::strcat(s.data,"opaq_");
|
::strcat(s.data, "opaq_");
|
||||||
|
|
||||||
// a special name for the weapon attachment point
|
// a special name for the weapon attachment point
|
||||||
if (materials[i].type == Unreal::MF_WEAPON_PLACEHOLDER) {
|
if (materials[i].type == Unreal::MF_WEAPON_PLACEHOLDER) {
|
||||||
s.length = ::ai_snprintf( s.data, MAXLEN, "$WeaponTag$" );
|
s.length = ::ai_snprintf(s.data, MAXLEN, "$WeaponTag$");
|
||||||
color = aiColor3D(0.f,0.f,0.f);
|
color = aiColor3D(0.f, 0.f, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set color and name
|
// set color and name
|
||||||
mat->AddProperty(&color,1,AI_MATKEY_COLOR_DIFFUSE);
|
mat->AddProperty(&color, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||||
s.length = (ai_uint32)::strlen(s.data);
|
s.length = static_cast<ai_uint32>(::strlen(s.data));
|
||||||
mat->AddProperty(&s,AI_MATKEY_NAME);
|
mat->AddProperty(&s, AI_MATKEY_NAME);
|
||||||
|
|
||||||
// set texture, if any
|
// set texture, if any
|
||||||
const unsigned int tex = materials[i].tex;
|
const unsigned int tex = materials[i].tex;
|
||||||
for (std::vector< std::pair< unsigned int, std::string > >::const_iterator it = textures.begin();it != textures.end();++it) {
|
for (std::vector<std::pair<unsigned int, std::string>>::const_iterator it = textures.begin(); it != textures.end(); ++it) {
|
||||||
if ((*it).first == tex) {
|
if ((*it).first == tex) {
|
||||||
s.Set((*it).second);
|
s.Set((*it).second);
|
||||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
mat->AddProperty(&s, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,17 +492,17 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
// fill them.
|
// fill them.
|
||||||
for (const Unreal::Triangle &tri : triangles) {
|
for (const Unreal::Triangle &tri : triangles) {
|
||||||
Unreal::TempMat mat(tri);
|
Unreal::TempMat mat(tri);
|
||||||
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);
|
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(), materials.end(), mat);
|
||||||
|
|
||||||
aiMesh* mesh = pScene->mMeshes[nt-materials.begin()];
|
aiMesh *mesh = pScene->mMeshes[nt - materials.begin()];
|
||||||
aiFace& f = mesh->mFaces[mesh->mNumFaces++];
|
aiFace &f = mesh->mFaces[mesh->mNumFaces++];
|
||||||
f.mIndices = new unsigned int[f.mNumIndices = 3];
|
f.mIndices = new unsigned int[f.mNumIndices = 3];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 3;++i,mesh->mNumVertices++) {
|
for (unsigned int i = 0; i < 3; ++i, mesh->mNumVertices++) {
|
||||||
f.mIndices[i] = mesh->mNumVertices;
|
f.mIndices[i] = mesh->mNumVertices;
|
||||||
|
|
||||||
mesh->mVertices[mesh->mNumVertices] = vertices[ tri.mVertex[i] ];
|
mesh->mVertices[mesh->mNumVertices] = vertices[tri.mVertex[i]];
|
||||||
mesh->mTextureCoords[0][mesh->mNumVertices] = aiVector3D( tri.mTex[i][0] / 255.f, 1.f - tri.mTex[i][1] / 255.f, 0.f);
|
mesh->mTextureCoords[0][mesh->mNumVertices] = aiVector3D(tri.mTex[i][0] / 255.f, 1.f - tri.mTex[i][1] / 255.f, 0.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -47,161 +46,57 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define INCLUDED_AI_3D_LOADER_H
|
#define INCLUDED_AI_3D_LOADER_H
|
||||||
|
|
||||||
#include <assimp/BaseImporter.h>
|
#include <assimp/BaseImporter.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace Unreal {
|
|
||||||
|
|
||||||
/*
|
|
||||||
0 = Normal one-sided
|
|
||||||
1 = Normal two-sided
|
|
||||||
2 = Translucent two-sided
|
|
||||||
3 = Masked two-sided
|
|
||||||
4 = Modulation blended two-sided
|
|
||||||
8 = Placeholder triangle for weapon positioning (invisible)
|
|
||||||
*/
|
|
||||||
enum MeshFlags {
|
|
||||||
MF_NORMAL_OS = 0,
|
|
||||||
MF_NORMAL_TS = 1,
|
|
||||||
MF_NORMAL_TRANS_TS = 2,
|
|
||||||
MF_NORMAL_MASKED_TS = 3,
|
|
||||||
MF_NORMAL_MOD_TS = 4,
|
|
||||||
MF_WEAPON_PLACEHOLDER = 8
|
|
||||||
};
|
|
||||||
|
|
||||||
// a single triangle
|
|
||||||
struct Triangle {
|
|
||||||
uint16_t mVertex[3]; // Vertex indices
|
|
||||||
char mType; // James' Mesh Type
|
|
||||||
char mColor; // Color for flat and Gourand Shaded
|
|
||||||
unsigned char mTex[3][2]; // Texture UV coordinates
|
|
||||||
unsigned char mTextureNum; // Source texture offset
|
|
||||||
char mFlags; // Unreal Mesh Flags (unused)
|
|
||||||
|
|
||||||
unsigned int matIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
// temporary representation for a material
|
|
||||||
struct TempMat {
|
|
||||||
TempMat()
|
|
||||||
: type()
|
|
||||||
, tex()
|
|
||||||
, numFaces (0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
explicit TempMat(const Triangle& in)
|
|
||||||
: type ((Unreal::MeshFlags)in.mType)
|
|
||||||
, tex (in.mTextureNum)
|
|
||||||
, numFaces (0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// type of mesh
|
|
||||||
Unreal::MeshFlags type;
|
|
||||||
|
|
||||||
// index of texture
|
|
||||||
unsigned int tex;
|
|
||||||
|
|
||||||
// number of faces using us
|
|
||||||
unsigned int numFaces;
|
|
||||||
|
|
||||||
// for std::find
|
|
||||||
bool operator == (const TempMat& o ) {
|
|
||||||
return (tex == o.tex && type == o.type);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Vertex
|
|
||||||
{
|
|
||||||
int32_t X : 11;
|
|
||||||
int32_t Y : 11;
|
|
||||||
int32_t Z : 10;
|
|
||||||
};
|
|
||||||
|
|
||||||
// UNREAL vertex compression
|
|
||||||
inline void CompressVertex(const aiVector3D& v, uint32_t& out)
|
|
||||||
{
|
|
||||||
union {
|
|
||||||
Vertex n;
|
|
||||||
int32_t t;
|
|
||||||
};
|
|
||||||
n.X = (int32_t)v.x;
|
|
||||||
n.Y = (int32_t)v.y;
|
|
||||||
n.Z = (int32_t)v.z;
|
|
||||||
::memcpy( &out, &t, sizeof(int32_t));
|
|
||||||
//out = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
// UNREAL vertex decompression
|
|
||||||
inline void DecompressVertex(aiVector3D& v, int32_t in)
|
|
||||||
{
|
|
||||||
union {
|
|
||||||
Vertex n;
|
|
||||||
int32_t i;
|
|
||||||
};
|
|
||||||
i = in;
|
|
||||||
|
|
||||||
v.x = (float)n.X;
|
|
||||||
v.y = (float)n.Y;
|
|
||||||
v.z = (float)n.Z;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Unreal
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** @brief Importer class to load UNREAL files (*.3d)
|
/** @brief Importer class to load UNREAL files (*.3d)
|
||||||
*/
|
*/
|
||||||
class UnrealImporter : public BaseImporter
|
class UnrealImporter : public BaseImporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
UnrealImporter();
|
UnrealImporter();
|
||||||
~UnrealImporter();
|
~UnrealImporter();
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Returns whether we can handle the format of the given file
|
/** @brief Returns whether we can handle the format of the given file
|
||||||
*
|
*
|
||||||
* See BaseImporter::CanRead() for details.
|
* See BaseImporter::CanRead() for details.
|
||||||
**/
|
**/
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||||
bool checkSig) const;
|
bool checkSig) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Called by Importer::GetExtensionList()
|
/** @brief Called by Importer::GetExtensionList()
|
||||||
*
|
*
|
||||||
* See #BaseImporter::GetInfo for the details
|
* See #BaseImporter::GetInfo for the details
|
||||||
*/
|
*/
|
||||||
const aiImporterDesc* GetInfo () const;
|
const aiImporterDesc *GetInfo() const;
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Setup properties for the importer
|
/** @brief Setup properties for the importer
|
||||||
*
|
*
|
||||||
* See BaseImporter::SetupProperties() for details
|
* See BaseImporter::SetupProperties() for details
|
||||||
*/
|
*/
|
||||||
void SetupProperties(const Importer* pImp);
|
void SetupProperties(const Importer *pImp);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Imports the given file into the given scene structure.
|
/** @brief Imports the given file into the given scene structure.
|
||||||
*
|
*
|
||||||
* See BaseImporter::InternReadFile() for details
|
* See BaseImporter::InternReadFile() for details
|
||||||
*/
|
*/
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
void InternReadFile(const std::string &pFile, aiScene *pScene,
|
||||||
IOSystem* pIOHandler);
|
IOSystem *pIOHandler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! frame to be loaded
|
//! frame to be loaded
|
||||||
uint32_t configFrameID;
|
uint32_t mConfigFrameID;
|
||||||
|
|
||||||
//! process surface flags
|
//! process surface flags
|
||||||
bool configHandleFlags;
|
bool mConfigHandleFlags;
|
||||||
|
|
||||||
}; // !class UnrealImporter
|
}; // !class UnrealImporter
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
#endif // AI_UNREALIMPORTER_H_INC
|
#endif // AI_UNREALIMPORTER_H_INC
|
||||||
|
|
|
@ -176,7 +176,7 @@ void XGLImporter::InternReadFile( const std::string& pFile,
|
||||||
raw_reader->IncPtr(2);
|
raw_reader->IncPtr(2);
|
||||||
|
|
||||||
zstream.next_in = reinterpret_cast<Bytef*>( raw_reader->GetPtr() );
|
zstream.next_in = reinterpret_cast<Bytef*>( raw_reader->GetPtr() );
|
||||||
zstream.avail_in = raw_reader->GetRemainingSize();
|
zstream.avail_in = (uInt) raw_reader->GetRemainingSize();
|
||||||
|
|
||||||
size_t total = 0l;
|
size_t total = 0l;
|
||||||
|
|
||||||
|
|
|
@ -508,18 +508,23 @@ inline size_t Buffer::AppendData(uint8_t *data, size_t length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Buffer::Grow(size_t amount) {
|
inline void Buffer::Grow(size_t amount) {
|
||||||
if (amount <= 0) return;
|
if (amount <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Capacity is big enough
|
||||||
if (capacity >= byteLength + amount) {
|
if (capacity >= byteLength + amount) {
|
||||||
byteLength += amount;
|
byteLength += amount;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift operation is standard way to divide integer by 2, it doesn't cast it to float back and forth, also works for odd numbers,
|
// Just allocate data which we need
|
||||||
// originally it would look like: static_cast<size_t>(capacity * 1.5f)
|
capacity = byteLength + amount;
|
||||||
capacity = std::max(capacity + (capacity >> 1), byteLength + amount);
|
|
||||||
|
|
||||||
uint8_t *b = new uint8_t[capacity];
|
uint8_t *b = new uint8_t[capacity];
|
||||||
if (mData) memcpy(b, mData.get(), byteLength);
|
if (nullptr != mData) {
|
||||||
|
memcpy(b, mData.get(), byteLength);
|
||||||
|
}
|
||||||
mData.reset(b, std::default_delete<uint8_t[]>());
|
mData.reset(b, std::default_delete<uint8_t[]>());
|
||||||
byteLength += amount;
|
byteLength += amount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,7 +952,7 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
||||||
|
|
||||||
void glTF2Importer::ImportNodes(glTF2::Asset &r) {
|
void glTF2Importer::ImportNodes(glTF2::Asset &r) {
|
||||||
if (!r.scene) {
|
if (!r.scene) {
|
||||||
return;
|
throw DeadlyImportError("GLTF: No scene");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Ref<Node>> rootNodes = r.scene->nodes;
|
std::vector<Ref<Node>> rootNodes = r.scene->nodes;
|
||||||
|
@ -970,6 +970,8 @@ void glTF2Importer::ImportNodes(glTF2::Asset &r) {
|
||||||
root->mChildren[root->mNumChildren++] = node;
|
root->mChildren[root->mNumChildren++] = node;
|
||||||
}
|
}
|
||||||
mScene->mRootNode = root;
|
mScene->mRootNode = root;
|
||||||
|
} else {
|
||||||
|
mScene->mRootNode = new aiNode("ROOT");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Compile internal irrXML only if system is not requested
|
# Compile internal irrXML only if system is not requested
|
||||||
if( NOT SYSTEM_IRRXML )
|
if( NOT ASSIMP_SYSTEM_IRRXML )
|
||||||
add_subdirectory(irrXML)
|
add_subdirectory(irrXML)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -15,7 +15,11 @@ if ( MSVC )
|
||||||
endif ( MSVC )
|
endif ( MSVC )
|
||||||
|
|
||||||
IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
|
IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
|
||||||
|
IF(APPLE)
|
||||||
|
add_library(IrrXML STATIC ${IrrXML_SRCS})
|
||||||
|
ELSE()
|
||||||
add_library(IrrXML ${IrrXML_SRCS})
|
add_library(IrrXML ${IrrXML_SRCS})
|
||||||
|
ENDIF()
|
||||||
ELSE()
|
ELSE()
|
||||||
add_library(IrrXML STATIC ${IrrXML_SRCS})
|
add_library(IrrXML STATIC ${IrrXML_SRCS})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
|
@ -8,16 +8,7 @@
|
||||||
#include "irrXML.h"
|
#include "irrXML.h"
|
||||||
#include "irrString.h"
|
#include "irrString.h"
|
||||||
#include "irrArray.h"
|
#include "irrArray.h"
|
||||||
|
#include "fast_atof.h"
|
||||||
#include <cassert>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <cctype>
|
|
||||||
#include <cstdint>
|
|
||||||
//using namespace Assimp;
|
|
||||||
|
|
||||||
// For locale independent number conversion
|
|
||||||
#include <sstream>
|
|
||||||
#include <locale>
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define IRR_DEBUGPRINT(x) printf((x));
|
#define IRR_DEBUGPRINT(x) printf((x));
|
||||||
|
@ -37,14 +28,23 @@ template<class char_type, class superclass>
|
||||||
class CXMLReaderImpl : public IIrrXMLReader<char_type, superclass>
|
class CXMLReaderImpl : public IIrrXMLReader<char_type, superclass>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true)
|
CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true)
|
||||||
: TextData(0), P(0), TextBegin(0), TextSize(0), CurrentNodeType(EXN_NONE),
|
: TextData(0)
|
||||||
SourceFormat(ETF_ASCII), TargetFormat(ETF_ASCII)
|
, P(0)
|
||||||
{
|
, TextBegin(0)
|
||||||
if (!callback)
|
, TextSize(0)
|
||||||
|
, CurrentNodeType(EXN_NONE)
|
||||||
|
, SourceFormat(ETF_ASCII)
|
||||||
|
, TargetFormat(ETF_ASCII)
|
||||||
|
, NodeName ()
|
||||||
|
, EmptyString()
|
||||||
|
, IsEmptyElement(false)
|
||||||
|
, SpecialCharacters()
|
||||||
|
, Attributes() {
|
||||||
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
storeTargetFormat();
|
storeTargetFormat();
|
||||||
|
|
||||||
|
@ -168,8 +168,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
core::stringc c = attr->Value.c_str();
|
core::stringc c = attr->Value.c_str();
|
||||||
return static_cast<float>(atof(c.c_str()));
|
return core::fast_atof(c.c_str());
|
||||||
//return fast_atof(c.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,11 +180,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
core::stringc c = attrvalue;
|
core::stringc c = attrvalue;
|
||||||
std::istringstream sstr(c.c_str());
|
return core::fast_atof(c.c_str());
|
||||||
sstr.imbue(std::locale("C")); // Locale free number convert
|
|
||||||
float fNum;
|
|
||||||
sstr >> fNum;
|
|
||||||
return fNum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -228,7 +223,7 @@ private:
|
||||||
{
|
{
|
||||||
char_type* start = P;
|
char_type* start = P;
|
||||||
|
|
||||||
// move forward until '<' found
|
// more forward until '<' found
|
||||||
while(*P != L'<' && *P)
|
while(*P != L'<' && *P)
|
||||||
++P;
|
++P;
|
||||||
|
|
||||||
|
@ -438,10 +433,6 @@ private:
|
||||||
while(*P != L'>')
|
while(*P != L'>')
|
||||||
++P;
|
++P;
|
||||||
|
|
||||||
// remove trailing whitespace, if any
|
|
||||||
while( std::isspace( P[-1]))
|
|
||||||
--P;
|
|
||||||
|
|
||||||
NodeName = core::string<char_type>(pBeginClose, (int)(P - pBeginClose));
|
NodeName = core::string<char_type>(pBeginClose, (int)(P - pBeginClose));
|
||||||
++P;
|
++P;
|
||||||
}
|
}
|
||||||
|
@ -676,12 +667,8 @@ private:
|
||||||
|
|
||||||
TextData = new char_type[sizeWithoutHeader];
|
TextData = new char_type[sizeWithoutHeader];
|
||||||
|
|
||||||
// MSVC debugger complains here about loss of data ...
|
|
||||||
size_t numShift = sizeof( char_type) * 8;
|
|
||||||
assert(numShift < 64);
|
|
||||||
const src_char_type cc = (src_char_type)(((uint64_t(1u) << numShift) - 1));
|
|
||||||
for (int i=0; i<sizeWithoutHeader; ++i)
|
for (int i=0; i<sizeWithoutHeader; ++i)
|
||||||
TextData[i] = char_type( source[i] & cc);
|
TextData[i] = (char_type)source[i];
|
||||||
|
|
||||||
TextBegin = TextData;
|
TextBegin = TextData;
|
||||||
TextSize = sizeWithoutHeader;
|
TextSize = sizeWithoutHeader;
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||||
|
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||||
|
// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h
|
||||||
|
|
||||||
|
#ifndef __FAST_A_TO_F_H_INCLUDED__
|
||||||
|
#define __FAST_A_TO_F_H_INCLUDED__
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
namespace irr
|
||||||
|
{
|
||||||
|
namespace core
|
||||||
|
{
|
||||||
|
|
||||||
|
const float fast_atof_table[] = {
|
||||||
|
0.f,
|
||||||
|
0.1f,
|
||||||
|
0.01f,
|
||||||
|
0.001f,
|
||||||
|
0.0001f,
|
||||||
|
0.00001f,
|
||||||
|
0.000001f,
|
||||||
|
0.0000001f,
|
||||||
|
0.00000001f,
|
||||||
|
0.000000001f,
|
||||||
|
0.0000000001f,
|
||||||
|
0.00000000001f,
|
||||||
|
0.000000000001f,
|
||||||
|
0.0000000000001f,
|
||||||
|
0.00000000000001f,
|
||||||
|
0.000000000000001f
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Provides a fast function for converting a string into a float,
|
||||||
|
//! about 6 times faster than atof in win32.
|
||||||
|
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||||
|
inline char* fast_atof_move(char* c, float& out)
|
||||||
|
{
|
||||||
|
bool inv = false;
|
||||||
|
char *t;
|
||||||
|
float f;
|
||||||
|
|
||||||
|
if (*c=='-')
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
inv = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = (float)strtol(c, &t, 10);
|
||||||
|
|
||||||
|
c = t;
|
||||||
|
|
||||||
|
if (*c == '.')
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
|
||||||
|
float pl = (float)strtol(c, &t, 10);
|
||||||
|
pl *= fast_atof_table[t-c];
|
||||||
|
|
||||||
|
f += pl;
|
||||||
|
|
||||||
|
c = t;
|
||||||
|
|
||||||
|
if (*c == 'e')
|
||||||
|
{
|
||||||
|
++c;
|
||||||
|
float exp = (float)strtol(c, &t, 10);
|
||||||
|
f *= (float)pow(10.0f, exp);
|
||||||
|
c = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inv)
|
||||||
|
f *= -1.0f;
|
||||||
|
|
||||||
|
out = f;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Provides a fast function for converting a string into a float,
|
||||||
|
//! about 6 times faster than atof in win32.
|
||||||
|
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||||
|
inline const char* fast_atof_move_const(const char* c, float& out)
|
||||||
|
{
|
||||||
|
bool inv = false;
|
||||||
|
char *t;
|
||||||
|
float f;
|
||||||
|
|
||||||
|
if (*c=='-')
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
inv = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = (float)strtol(c, &t, 10);
|
||||||
|
|
||||||
|
c = t;
|
||||||
|
|
||||||
|
if (*c == '.')
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
|
||||||
|
float pl = (float)strtol(c, &t, 10);
|
||||||
|
pl *= fast_atof_table[t-c];
|
||||||
|
|
||||||
|
f += pl;
|
||||||
|
|
||||||
|
c = t;
|
||||||
|
|
||||||
|
if (*c == 'e')
|
||||||
|
{
|
||||||
|
++c;
|
||||||
|
f32 exp = (f32)strtol(c, &t, 10);
|
||||||
|
f *= (f32)powf(10.0f, exp);
|
||||||
|
c = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inv)
|
||||||
|
f *= -1.0f;
|
||||||
|
|
||||||
|
out = f;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline float fast_atof(const char* c)
|
||||||
|
{
|
||||||
|
float ret;
|
||||||
|
fast_atof_move_const(c, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace core
|
||||||
|
}// end namespace irr
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -21,6 +21,7 @@ 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)
|
||||||
|
|
|
@ -117,7 +117,7 @@ public:
|
||||||
//! Constructor for unicode and ascii strings
|
//! Constructor for unicode and ascii strings
|
||||||
template <class B>
|
template <class B>
|
||||||
string(const B* c)
|
string(const B* c)
|
||||||
: array(0),allocated(0), used(0)
|
: array(0), allocated(0), used(0)
|
||||||
{
|
{
|
||||||
*this = c;
|
*this = c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,13 +79,8 @@ typedef unsigned short wchar_t;
|
||||||
#endif // microsoft compiler
|
#endif // microsoft compiler
|
||||||
|
|
||||||
//! define a break macro for debugging only in Win32 mode.
|
//! define a break macro for debugging only in Win32 mode.
|
||||||
// WORKAROUND (assimp): remove __asm
|
#if !defined(_WIN64) && defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
||||||
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3}
|
||||||
#if defined(_M_IX86)
|
|
||||||
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) /*if (_CONDITION_) {_asm int 3}*/
|
|
||||||
#else
|
|
||||||
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
|
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,10 +91,8 @@ When you call unmanaged code that returns a bool type value of false from manage
|
||||||
the return value may appear as true. See
|
the return value may appear as true. See
|
||||||
http://support.microsoft.com/default.aspx?kbid=823071 for details.
|
http://support.microsoft.com/default.aspx?kbid=823071 for details.
|
||||||
Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/
|
Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/
|
||||||
|
#if !defined(_WIN64) && defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400)
|
||||||
// WORKAROUND (assimp): remove __asm
|
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX __asm mov eax,100
|
||||||
#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400)
|
|
||||||
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX /*__asm mov eax,100*/
|
|
||||||
#else
|
#else
|
||||||
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX
|
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX
|
||||||
#endif // _IRR_MANAGED_MARSHALLING_BUGFIX
|
#endif // _IRR_MANAGED_MARSHALLING_BUGFIX
|
||||||
|
|
|
@ -2,14 +2,10 @@
|
||||||
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||||
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
|
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
|
||||||
|
|
||||||
// Need to include Assimp, too. We're using Assimp's version of fast_atof
|
|
||||||
// so we need stdint.h. But no PCH.
|
|
||||||
|
|
||||||
|
|
||||||
#include "irrXML.h"
|
#include "irrXML.h"
|
||||||
#include "irrString.h"
|
#include "irrString.h"
|
||||||
#include "irrArray.h"
|
#include "irrArray.h"
|
||||||
//#include <assimp/fast_atof.h>
|
#include "fast_atof.h"
|
||||||
#include "CXMLReaderImpl.h"
|
#include "CXMLReaderImpl.h"
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
|
@ -18,7 +14,7 @@ namespace io
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Implementation of the file read callback for ordinary files
|
//! Implementation of the file read callback for ordinary files
|
||||||
class IRRXML_API CFileReadCallBack : public IFileReadCallBack
|
class CFileReadCallBack : public IFileReadCallBack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,6 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# define IRRXML_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
# define IRRXML_API __attribute__ ((visibility("default")))
|
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
/** \mainpage irrXML 1.2 API documentation
|
/** \mainpage irrXML 1.2 API documentation
|
||||||
<div align="center"><img src="logobig.png" ></div>
|
<div align="center"><img src="logobig.png" ></div>
|
||||||
|
|
||||||
|
@ -178,7 +172,7 @@ namespace io
|
||||||
ETF_UTF32_BE,
|
ETF_UTF32_BE,
|
||||||
|
|
||||||
//! UTF-32 format, little endian
|
//! UTF-32 format, little endian
|
||||||
ETF_UTF32_LE
|
ETF_UTF32_LE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,7 +209,7 @@ namespace io
|
||||||
two methods to read your data and give a pointer to an instance of
|
two methods to read your data and give a pointer to an instance of
|
||||||
your implementation when calling createIrrXMLReader(),
|
your implementation when calling createIrrXMLReader(),
|
||||||
createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
|
createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
|
||||||
class IRRXML_API IFileReadCallBack
|
class IFileReadCallBack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -415,7 +409,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReader* createIrrXMLReader(const char* filename);
|
IrrXMLReader* createIrrXMLReader(const char* filename);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
||||||
/** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
|
/** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
|
||||||
|
@ -427,7 +421,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReader* createIrrXMLReader(FILE* file);
|
IrrXMLReader* createIrrXMLReader(FILE* file);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
||||||
/** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
|
/** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
|
||||||
|
@ -440,7 +434,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback);
|
IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-16 xml parser.
|
//! Creates an instance of an UFT-16 xml parser.
|
||||||
/** This means that
|
/** This means that
|
||||||
|
@ -452,7 +446,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename);
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-16 xml parser.
|
//! Creates an instance of an UFT-16 xml parser.
|
||||||
/** This means that all character data will be returned in UTF-16. The file to read can
|
/** This means that all character data will be returned in UTF-16. The file to read can
|
||||||
|
@ -464,7 +458,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file);
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-16 xml parser.
|
//! Creates an instance of an UFT-16 xml parser.
|
||||||
/** This means that all character data will be returned in UTF-16. The file to read can
|
/** This means that all character data will be returned in UTF-16. The file to read can
|
||||||
|
@ -477,7 +471,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback);
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback);
|
||||||
|
|
||||||
|
|
||||||
//! Creates an instance of an UFT-32 xml parser.
|
//! Creates an instance of an UFT-32 xml parser.
|
||||||
|
@ -489,7 +483,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename);
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-32 xml parser.
|
//! Creates an instance of an UFT-32 xml parser.
|
||||||
/** This means that all character data will be returned in UTF-32. The file to read can
|
/** This means that all character data will be returned in UTF-32. The file to read can
|
||||||
|
@ -501,7 +495,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file);
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-32 xml parser.
|
//! Creates an instance of an UFT-32 xml parser.
|
||||||
/** This means that
|
/** This means that
|
||||||
|
@ -515,7 +509,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback);
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback);
|
||||||
|
|
||||||
|
|
||||||
/*! \file irrxml.h
|
/*! \file irrxml.h
|
||||||
|
|
|
@ -55,36 +55,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace Math {
|
namespace Math {
|
||||||
|
|
||||||
// TODO: use binary GCD for unsigned integers ....
|
/// @brief Will return the greatest common divisor.
|
||||||
template < typename IntegerType >
|
/// @param a [in] Value a.
|
||||||
inline
|
/// @param b [in] Value b.
|
||||||
IntegerType gcd( IntegerType a, IntegerType b ) {
|
/// @return The greatest common divisor.
|
||||||
|
template <typename IntegerType>
|
||||||
|
inline IntegerType gcd( IntegerType a, IntegerType b ) {
|
||||||
const IntegerType zero = (IntegerType)0;
|
const IntegerType zero = (IntegerType)0;
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
if ( a == zero )
|
if ( a == zero ) {
|
||||||
return b;
|
return b;
|
||||||
|
}
|
||||||
b %= a;
|
b %= a;
|
||||||
|
|
||||||
if ( b == zero )
|
if ( b == zero ) {
|
||||||
return a;
|
return a;
|
||||||
|
}
|
||||||
a %= b;
|
a %= b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will return the greatest common divisor.
|
||||||
|
/// @param a [in] Value a.
|
||||||
|
/// @param b [in] Value b.
|
||||||
|
/// @return The greatest common divisor.
|
||||||
template < typename IntegerType >
|
template < typename IntegerType >
|
||||||
inline
|
inline IntegerType lcm( IntegerType a, IntegerType b ) {
|
||||||
IntegerType lcm( IntegerType a, IntegerType b ) {
|
|
||||||
const IntegerType t = gcd (a,b);
|
const IntegerType t = gcd (a,b);
|
||||||
if (!t)
|
if (!t) {
|
||||||
return t;
|
return t;
|
||||||
|
}
|
||||||
return a / t * b;
|
return a / t * b;
|
||||||
}
|
}
|
||||||
|
/// @brief Will return the smallest epsilon-value for the requested type.
|
||||||
|
/// @return The numercical limit epsilon depending on its type.
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline T getEpsilon() {
|
||||||
T getEpsilon() {
|
|
||||||
return std::numeric_limits<T>::epsilon();
|
return std::numeric_limits<T>::epsilon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will return the constant PI for the requested type.
|
||||||
|
/// @return Pi
|
||||||
|
template<class T>
|
||||||
|
inline T PI() {
|
||||||
|
return static_cast<T>(3.14159265358979323846);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // namespace Math
|
||||||
|
} // namespace Assimp
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -49,13 +47,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_STREAMREADER_H_INCLUDED
|
#define AI_STREAMREADER_H_INCLUDED
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assimp/IOStream.hpp>
|
|
||||||
#include <assimp/Defines.h>
|
|
||||||
#include <assimp/ByteSwapper.h>
|
#include <assimp/ByteSwapper.h>
|
||||||
|
#include <assimp/Defines.h>
|
||||||
#include <assimp/Exceptional.h>
|
#include <assimp/Exceptional.h>
|
||||||
|
#include <assimp/IOStream.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -74,10 +72,8 @@ namespace Assimp {
|
||||||
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
||||||
class StreamReader {
|
class StreamReader {
|
||||||
public:
|
public:
|
||||||
// FIXME: use these data types throughout the whole library,
|
using diff = size_t;
|
||||||
// then change them to 64 bit values :-)
|
using pos = size_t;
|
||||||
using diff = int;
|
|
||||||
using pos = unsigned int;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Construction from a given stream with a well-defined endianness.
|
/** Construction from a given stream with a well-defined endianness.
|
||||||
|
@ -91,39 +87,44 @@ public:
|
||||||
* stream is in little endian byte order. Otherwise the
|
* stream is in little endian byte order. Otherwise the
|
||||||
* endianness information is contained in the @c SwapEndianess
|
* endianness information is contained in the @c SwapEndianess
|
||||||
* template parameter and this parameter is meaningless. */
|
* template parameter and this parameter is meaningless. */
|
||||||
StreamReader(std::shared_ptr<IOStream> stream, bool le = false)
|
StreamReader(std::shared_ptr<IOStream> stream, bool le = false) :
|
||||||
: stream(stream)
|
mStream(stream),
|
||||||
, le(le)
|
mBuffer(nullptr),
|
||||||
{
|
mCurrent(nullptr),
|
||||||
|
mEnd(nullptr),
|
||||||
|
mLimit(nullptr),
|
||||||
|
mLe(le) {
|
||||||
ai_assert(stream);
|
ai_assert(stream);
|
||||||
InternBegin();
|
InternBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
StreamReader(IOStream* stream, bool le = false)
|
StreamReader(IOStream *stream, bool le = false) :
|
||||||
: stream(std::shared_ptr<IOStream>(stream))
|
mStream(std::shared_ptr<IOStream>(stream)),
|
||||||
, le(le)
|
mBuffer(nullptr),
|
||||||
{
|
mCurrent(nullptr),
|
||||||
ai_assert(stream);
|
mEnd(nullptr),
|
||||||
|
mLimit(nullptr),
|
||||||
|
mLe(le) {
|
||||||
|
ai_assert(nullptr != stream);
|
||||||
InternBegin();
|
InternBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
~StreamReader() {
|
~StreamReader() {
|
||||||
delete[] buffer;
|
delete[] mBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated, use overloaded operator>> instead
|
// deprecated, use overloaded operator>> instead
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read a float from the stream */
|
/// Read a float from the stream.
|
||||||
float GetF4()
|
float GetF4() {
|
||||||
{
|
|
||||||
return Get<float>();
|
return Get<float>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read a double from the stream */
|
/// Read a double from the stream.
|
||||||
double GetF8() {
|
double GetF8() {
|
||||||
return Get<double>();
|
return Get<double>();
|
||||||
}
|
}
|
||||||
|
@ -159,50 +160,50 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read a unsigned 8 bit integer from the stream */
|
/// Read a unsigned 8 bit integer from the stream
|
||||||
uint8_t GetU1() {
|
uint8_t GetU1() {
|
||||||
return Get<uint8_t>();
|
return Get<uint8_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read an unsigned 32 bit integer from the stream */
|
/// Read an unsigned 32 bit integer from the stream
|
||||||
uint32_t GetU4() {
|
uint32_t GetU4() {
|
||||||
return Get<uint32_t>();
|
return Get<uint32_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read a unsigned 64 bit integer from the stream */
|
/// Read a unsigned 64 bit integer from the stream
|
||||||
uint64_t GetU8() {
|
uint64_t GetU8() {
|
||||||
return Get<uint64_t>();
|
return Get<uint64_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Get the remaining stream size (to the end of the stream) */
|
/// Get the remaining stream size (to the end of the stream)
|
||||||
unsigned int GetRemainingSize() const {
|
size_t GetRemainingSize() const {
|
||||||
return (unsigned int)(end - current);
|
return (unsigned int)(mEnd - mCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Get the remaining stream size (to the current read limit). The
|
/** Get the remaining stream size (to the current read limit). The
|
||||||
* return value is the remaining size of the stream if no custom
|
* return value is the remaining size of the stream if no custom
|
||||||
* read limit has been set. */
|
* read limit has been set. */
|
||||||
unsigned int GetRemainingSizeToLimit() const {
|
size_t GetRemainingSizeToLimit() const {
|
||||||
return (unsigned int)(limit - current);
|
return (unsigned int)(mLimit - mCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Increase the file pointer (relative seeking) */
|
/** Increase the file pointer (relative seeking) */
|
||||||
void IncPtr(intptr_t plus) {
|
void IncPtr(intptr_t plus) {
|
||||||
current += plus;
|
mCurrent += plus;
|
||||||
if (current > limit) {
|
if (mCurrent > mLimit) {
|
||||||
throw DeadlyImportError("End of file or read limit was reached");
|
throw DeadlyImportError("End of file or read limit was reached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Get the current file pointer */
|
/** Get the current file pointer */
|
||||||
int8_t* GetPtr() const {
|
int8_t *GetPtr() const {
|
||||||
return current;
|
return mCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -211,9 +212,9 @@ public:
|
||||||
* large chunks of data at once.
|
* large chunks of data at once.
|
||||||
* @param p The new pointer, which is validated against the size
|
* @param p The new pointer, which is validated against the size
|
||||||
* limit and buffer boundaries. */
|
* limit and buffer boundaries. */
|
||||||
void SetPtr(int8_t* p) {
|
void SetPtr(int8_t *p) {
|
||||||
current = p;
|
mCurrent = p;
|
||||||
if (current > limit || current < buffer) {
|
if (mCurrent > mLimit || mCurrent < mBuffer) {
|
||||||
throw DeadlyImportError("End of file or read limit was reached");
|
throw DeadlyImportError("End of file or read limit was reached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,21 +223,20 @@ public:
|
||||||
/** Copy n bytes to an external buffer
|
/** Copy n bytes to an external buffer
|
||||||
* @param out Destination for copying
|
* @param out Destination for copying
|
||||||
* @param bytes Number of bytes to copy */
|
* @param bytes Number of bytes to copy */
|
||||||
void CopyAndAdvance(void* out, size_t bytes) {
|
void CopyAndAdvance(void *out, size_t bytes) {
|
||||||
int8_t* ur = GetPtr();
|
int8_t *ur = GetPtr();
|
||||||
SetPtr(ur+bytes); // fire exception if eof
|
SetPtr(ur + bytes); // fire exception if eof
|
||||||
|
|
||||||
::memcpy(out,ur,bytes);
|
::memcpy(out, ur, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
/// @brief Get the current offset from the beginning of the file
|
||||||
/** Get the current offset from the beginning of the file */
|
|
||||||
int GetCurrentPos() const {
|
int GetCurrentPos() const {
|
||||||
return (unsigned int)(current - buffer);
|
return (unsigned int)(mCurrent - mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCurrentPos(size_t pos) {
|
void SetCurrentPos(size_t pos) {
|
||||||
SetPtr(buffer + pos);
|
SetPtr(mBuffer + pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -249,12 +249,12 @@ public:
|
||||||
unsigned int SetReadLimit(unsigned int _limit) {
|
unsigned int SetReadLimit(unsigned int _limit) {
|
||||||
unsigned int prev = GetReadLimit();
|
unsigned int prev = GetReadLimit();
|
||||||
if (UINT_MAX == _limit) {
|
if (UINT_MAX == _limit) {
|
||||||
limit = end;
|
mLimit = mEnd;
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
limit = buffer + _limit;
|
mLimit = mBuffer + _limit;
|
||||||
if (limit > end) {
|
if (mLimit > mEnd) {
|
||||||
throw DeadlyImportError("StreamReader: Invalid read limit");
|
throw DeadlyImportError("StreamReader: Invalid read limit");
|
||||||
}
|
}
|
||||||
return prev;
|
return prev;
|
||||||
|
@ -264,20 +264,20 @@ public:
|
||||||
/** Get the current read limit in bytes. Reading over this limit
|
/** Get the current read limit in bytes. Reading over this limit
|
||||||
* accidentally raises an exception. */
|
* accidentally raises an exception. */
|
||||||
unsigned int GetReadLimit() const {
|
unsigned int GetReadLimit() const {
|
||||||
return (unsigned int)(limit - buffer);
|
return (unsigned int)(mLimit - mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Skip to the read limit in bytes. Reading over this limit
|
/** Skip to the read limit in bytes. Reading over this limit
|
||||||
* accidentally raises an exception. */
|
* accidentally raises an exception. */
|
||||||
void SkipToReadLimit() {
|
void SkipToReadLimit() {
|
||||||
current = limit;
|
mCurrent = mLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** overload operator>> and allow chaining of >> ops. */
|
/** overload operator>> and allow chaining of >> ops. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
StreamReader& operator >> (T& f) {
|
StreamReader &operator>>(T &f) {
|
||||||
f = Get<T>();
|
f = Get<T>();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -286,14 +286,14 @@ public:
|
||||||
/** Generic read method. ByteSwap::Swap(T*) *must* be defined */
|
/** Generic read method. ByteSwap::Swap(T*) *must* be defined */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Get() {
|
T Get() {
|
||||||
if ( current + sizeof(T) > limit) {
|
if (mCurrent + sizeof(T) > mLimit) {
|
||||||
throw DeadlyImportError("End of file or stream limit was reached");
|
throw DeadlyImportError("End of file or stream limit was reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
T f;
|
T f;
|
||||||
::memcpy (&f, current, sizeof(T));
|
::memcpy(&f, mCurrent, sizeof(T));
|
||||||
Intern::Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
|
Intern::Getter<SwapEndianess, T, RuntimeSwitch>()(&f, mLe);
|
||||||
current += sizeof(T);
|
mCurrent += sizeof(T);
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -301,46 +301,44 @@ public:
|
||||||
private:
|
private:
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
void InternBegin() {
|
void InternBegin() {
|
||||||
if (!stream) {
|
if (nullptr == mStream) {
|
||||||
// in case someone wonders: StreamReader is frequently invoked with
|
|
||||||
// no prior validation whether the input stream is valid. Since
|
|
||||||
// no one bothers changing the error message, this message here
|
|
||||||
// is passed down to the caller and 'unable to open file'
|
|
||||||
// simply describes best what happened.
|
|
||||||
throw DeadlyImportError("StreamReader: Unable to open file");
|
throw DeadlyImportError("StreamReader: Unable to open file");
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t s = stream->FileSize() - stream->Tell();
|
const size_t filesize = mStream->FileSize() - mStream->Tell();
|
||||||
if (!s) {
|
if (0 == filesize) {
|
||||||
throw DeadlyImportError("StreamReader: File is empty or EOF is already reached");
|
throw DeadlyImportError("StreamReader: File is empty or EOF is already reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
current = buffer = new int8_t[s];
|
mCurrent = mBuffer = new int8_t[filesize];
|
||||||
const size_t read = stream->Read(current,1,s);
|
const size_t read = mStream->Read(mCurrent, 1, filesize);
|
||||||
// (read < s) can only happen if the stream was opened in text mode, in which case FileSize() is not reliable
|
// (read < s) can only happen if the stream was opened in text mode, in which case FileSize() is not reliable
|
||||||
ai_assert(read <= s);
|
ai_assert(read <= filesize);
|
||||||
end = limit = &buffer[read-1] + 1;
|
mEnd = mLimit = &mBuffer[read - 1] + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<IOStream> stream;
|
std::shared_ptr<IOStream> mStream;
|
||||||
int8_t *buffer, *current, *end, *limit;
|
int8_t *mBuffer;
|
||||||
bool le;
|
int8_t *mCurrent;
|
||||||
|
int8_t *mEnd;
|
||||||
|
int8_t *mLimit;
|
||||||
|
bool mLe;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
// `static` StreamReaders. Their byte order is fixed and they might be a little bit faster.
|
// `static` StreamReaders. Their byte order is fixed and they might be a little bit faster.
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
typedef StreamReader<true> StreamReaderLE;
|
typedef StreamReader<true> StreamReaderLE;
|
||||||
typedef StreamReader<false> StreamReaderBE;
|
typedef StreamReader<false> StreamReaderBE;
|
||||||
#else
|
#else
|
||||||
typedef StreamReader<true> StreamReaderBE;
|
typedef StreamReader<true> StreamReaderBE;
|
||||||
typedef StreamReader<false> StreamReaderLE;
|
typedef StreamReader<false> StreamReaderLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// `dynamic` StreamReader. The byte order of the input data is specified in the
|
// `dynamic` StreamReader. The byte order of the input data is specified in the
|
||||||
// c'tor. This involves runtime branching and might be a little bit slower.
|
// c'tor. This involves runtime branching and might be a little bit slower.
|
||||||
typedef StreamReader<true,true> StreamReaderAny;
|
typedef StreamReader<true, true> StreamReaderAny;
|
||||||
|
|
||||||
} // end namespace Assimp
|
} // end namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -562,6 +562,675 @@ ASSIMP_API size_t aiGetImportFormatCount(void);
|
||||||
* @return A description of that specific import format. NULL if pIndex is out of range.
|
* @return A description of that specific import format. NULL if pIndex is out of range.
|
||||||
*/
|
*/
|
||||||
ASSIMP_API const C_STRUCT aiImporterDesc* aiGetImportFormatDescription( size_t pIndex);
|
ASSIMP_API const C_STRUCT aiImporterDesc* aiGetImportFormatDescription( size_t pIndex);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if 2D vectors are equal.
|
||||||
|
* @param a First vector to compare
|
||||||
|
* @param b Second vector to compare
|
||||||
|
* @return 1 if the vectors are equal
|
||||||
|
* @return 0 if the vectors are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiVector2AreEqual(
|
||||||
|
const C_STRUCT aiVector2D* a,
|
||||||
|
const C_STRUCT aiVector2D* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if 2D vectors are equal using epsilon.
|
||||||
|
* @param a First vector to compare
|
||||||
|
* @param b Second vector to compare
|
||||||
|
* @param epsilon Epsilon
|
||||||
|
* @return 1 if the vectors are equal
|
||||||
|
* @return 0 if the vectors are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiVector2AreEqualEpsilon(
|
||||||
|
const C_STRUCT aiVector2D* a,
|
||||||
|
const C_STRUCT aiVector2D* b,
|
||||||
|
const float epsilon);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Add 2D vectors.
|
||||||
|
* @param dst First addend, receives result.
|
||||||
|
* @param src Vector to be added to 'dst'.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector2Add(
|
||||||
|
C_STRUCT aiVector2D* dst,
|
||||||
|
const C_STRUCT aiVector2D* src);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Subtract 2D vectors.
|
||||||
|
* @param dst Minuend, receives result.
|
||||||
|
* @param src Vector to be subtracted from 'dst'.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector2Subtract(
|
||||||
|
C_STRUCT aiVector2D* dst,
|
||||||
|
const C_STRUCT aiVector2D* src);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Multiply a 2D vector by a scalar.
|
||||||
|
* @param dst Vector to be scaled by \p s
|
||||||
|
* @param s Scale factor
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector2Scale(
|
||||||
|
C_STRUCT aiVector2D* dst,
|
||||||
|
const float s);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Multiply each component of a 2D vector with
|
||||||
|
* the components of another vector.
|
||||||
|
* @param dst First vector, receives result
|
||||||
|
* @param other Second vector
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector2SymMul(
|
||||||
|
C_STRUCT aiVector2D* dst,
|
||||||
|
const C_STRUCT aiVector2D* other);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Divide a 2D vector by a scalar.
|
||||||
|
* @param dst Vector to be divided by \p s
|
||||||
|
* @param s Scalar divisor
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector2DivideByScalar(
|
||||||
|
C_STRUCT aiVector2D* dst,
|
||||||
|
const float s);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Divide each component of a 2D vector by
|
||||||
|
* the components of another vector.
|
||||||
|
* @param dst Vector as the dividend
|
||||||
|
* @param v Vector as the divisor
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector2DivideByVector(
|
||||||
|
C_STRUCT aiVector2D* dst,
|
||||||
|
C_STRUCT aiVector2D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get the length of a 2D vector.
|
||||||
|
* @return v Vector to evaluate
|
||||||
|
*/
|
||||||
|
ASSIMP_API float aiVector2Length(
|
||||||
|
const C_STRUCT aiVector2D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get the squared length of a 2D vector.
|
||||||
|
* @return v Vector to evaluate
|
||||||
|
*/
|
||||||
|
ASSIMP_API float aiVector2SquareLength(
|
||||||
|
const C_STRUCT aiVector2D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Negate a 2D vector.
|
||||||
|
* @param dst Vector to be negated
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector2Negate(
|
||||||
|
C_STRUCT aiVector2D* dst);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get the dot product of 2D vectors.
|
||||||
|
* @param a First vector
|
||||||
|
* @param b Second vector
|
||||||
|
* @return The dot product of vectors
|
||||||
|
*/
|
||||||
|
ASSIMP_API float aiVector2DotProduct(
|
||||||
|
const C_STRUCT aiVector2D* a,
|
||||||
|
const C_STRUCT aiVector2D* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Normalize a 2D vector.
|
||||||
|
* @param v Vector to normalize
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector2Normalize(
|
||||||
|
C_STRUCT aiVector2D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if 3D vectors are equal.
|
||||||
|
* @param a First vector to compare
|
||||||
|
* @param b Second vector to compare
|
||||||
|
* @return 1 if the vectors are equal
|
||||||
|
* @return 0 if the vectors are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiVector3AreEqual(
|
||||||
|
const C_STRUCT aiVector3D* a,
|
||||||
|
const C_STRUCT aiVector3D* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if 3D vectors are equal using epsilon.
|
||||||
|
* @param a First vector to compare
|
||||||
|
* @param b Second vector to compare
|
||||||
|
* @param epsilon Epsilon
|
||||||
|
* @return 1 if the vectors are equal
|
||||||
|
* @return 0 if the vectors are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiVector3AreEqualEpsilon(
|
||||||
|
const C_STRUCT aiVector3D* a,
|
||||||
|
const C_STRUCT aiVector3D* b,
|
||||||
|
const float epsilon);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if vector \p a is less than vector \p b.
|
||||||
|
* @param a First vector to compare
|
||||||
|
* @param b Second vector to compare
|
||||||
|
* @param epsilon Epsilon
|
||||||
|
* @return 1 if \p a is less than \p b
|
||||||
|
* @return 0 if \p a is equal or greater than \p b
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiVector3LessThan(
|
||||||
|
const C_STRUCT aiVector3D* a,
|
||||||
|
const C_STRUCT aiVector3D* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Add 3D vectors.
|
||||||
|
* @param dst First addend, receives result.
|
||||||
|
* @param src Vector to be added to 'dst'.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3Add(
|
||||||
|
C_STRUCT aiVector3D* dst,
|
||||||
|
const C_STRUCT aiVector3D* src);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Subtract 3D vectors.
|
||||||
|
* @param dst Minuend, receives result.
|
||||||
|
* @param src Vector to be subtracted from 'dst'.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3Subtract(
|
||||||
|
C_STRUCT aiVector3D* dst,
|
||||||
|
const C_STRUCT aiVector3D* src);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Multiply a 3D vector by a scalar.
|
||||||
|
* @param dst Vector to be scaled by \p s
|
||||||
|
* @param s Scale factor
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3Scale(
|
||||||
|
C_STRUCT aiVector3D* dst,
|
||||||
|
const float s);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Multiply each component of a 3D vector with
|
||||||
|
* the components of another vector.
|
||||||
|
* @param dst First vector, receives result
|
||||||
|
* @param other Second vector
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3SymMul(
|
||||||
|
C_STRUCT aiVector3D* dst,
|
||||||
|
const C_STRUCT aiVector3D* other);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Divide a 3D vector by a scalar.
|
||||||
|
* @param dst Vector to be divided by \p s
|
||||||
|
* @param s Scalar divisor
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3DivideByScalar(
|
||||||
|
C_STRUCT aiVector3D* dst,
|
||||||
|
const float s);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Divide each component of a 3D vector by
|
||||||
|
* the components of another vector.
|
||||||
|
* @param dst Vector as the dividend
|
||||||
|
* @param v Vector as the divisor
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3DivideByVector(
|
||||||
|
C_STRUCT aiVector3D* dst,
|
||||||
|
C_STRUCT aiVector3D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get the length of a 3D vector.
|
||||||
|
* @return v Vector to evaluate
|
||||||
|
*/
|
||||||
|
ASSIMP_API float aiVector3Length(
|
||||||
|
const C_STRUCT aiVector3D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get the squared length of a 3D vector.
|
||||||
|
* @return v Vector to evaluate
|
||||||
|
*/
|
||||||
|
ASSIMP_API float aiVector3SquareLength(
|
||||||
|
const C_STRUCT aiVector3D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Negate a 3D vector.
|
||||||
|
* @param dst Vector to be negated
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3Negate(
|
||||||
|
C_STRUCT aiVector3D* dst);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get the dot product of 3D vectors.
|
||||||
|
* @param a First vector
|
||||||
|
* @param b Second vector
|
||||||
|
* @return The dot product of vectors
|
||||||
|
*/
|
||||||
|
ASSIMP_API float aiVector3DotProduct(
|
||||||
|
const C_STRUCT aiVector3D* a,
|
||||||
|
const C_STRUCT aiVector3D* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get cross product of 3D vectors.
|
||||||
|
* @param dst Vector to receive the result.
|
||||||
|
* @param a First vector
|
||||||
|
* @param b Second vector
|
||||||
|
* @return The dot product of vectors
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3CrossProduct(
|
||||||
|
C_STRUCT aiVector3D* dst,
|
||||||
|
const C_STRUCT aiVector3D* a,
|
||||||
|
const C_STRUCT aiVector3D* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Normalize a 3D vector.
|
||||||
|
* @param v Vector to normalize
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3Normalize(
|
||||||
|
C_STRUCT aiVector3D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check for division by zero and normalize a 3D vector.
|
||||||
|
* @param v Vector to normalize
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3NormalizeSafe(
|
||||||
|
C_STRUCT aiVector3D* v);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Rotate a 3D vector by a quaternion.
|
||||||
|
* @param v The vector to rotate by \p q
|
||||||
|
* @param q Quaternion to use to rotate \p v
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiVector3RotateByQuaternion(
|
||||||
|
C_STRUCT aiVector3D* v,
|
||||||
|
const C_STRUCT aiQuaternion* q);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Construct a 3x3 matrix from a 4x4 matrix.
|
||||||
|
* @param dst Receives the output matrix
|
||||||
|
* @param mat The 4x4 matrix to use
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix3FromMatrix4(
|
||||||
|
C_STRUCT aiMatrix3x3* dst,
|
||||||
|
const C_STRUCT aiMatrix4x4* mat);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Construct a 3x3 matrix from a quaternion.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param q The quaternion matrix to use
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix3FromQuaternion(
|
||||||
|
C_STRUCT aiMatrix3x3* mat,
|
||||||
|
const C_STRUCT aiQuaternion* q);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if 3x3 matrices are equal.
|
||||||
|
* @param a First matrix to compare
|
||||||
|
* @param b Second matrix to compare
|
||||||
|
* @return 1 if the matrices are equal
|
||||||
|
* @return 0 if the matrices are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiMatrix3AreEqual(
|
||||||
|
const C_STRUCT aiMatrix3x3* a,
|
||||||
|
const C_STRUCT aiMatrix3x3* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if 3x3 matrices are equal.
|
||||||
|
* @param a First matrix to compare
|
||||||
|
* @param b Second matrix to compare
|
||||||
|
* @param epsilon Epsilon
|
||||||
|
* @return 1 if the matrices are equal
|
||||||
|
* @return 0 if the matrices are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiMatrix3AreEqualEpsilon(
|
||||||
|
const C_STRUCT aiMatrix3x3* a,
|
||||||
|
const C_STRUCT aiMatrix3x3* b,
|
||||||
|
const float epsilon);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Invert a 3x3 matrix.
|
||||||
|
* @param mat Matrix to invert
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix3Inverse(
|
||||||
|
C_STRUCT aiMatrix3x3* mat);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get the determinant of a 3x3 matrix.
|
||||||
|
* @param mat Matrix to get the determinant from
|
||||||
|
*/
|
||||||
|
ASSIMP_API float aiMatrix3Determinant(
|
||||||
|
const C_STRUCT aiMatrix3x3* mat);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get a 3x3 rotation matrix around the Z axis.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param angle Rotation angle, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix3RotationZ(
|
||||||
|
C_STRUCT aiMatrix3x3* mat,
|
||||||
|
const float angle);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Returns a 3x3 rotation matrix for a rotation around an arbitrary axis.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param axis Rotation axis, should be a normalized vector
|
||||||
|
* @param angle Rotation angle, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix3FromRotationAroundAxis(
|
||||||
|
C_STRUCT aiMatrix3x3* mat,
|
||||||
|
const C_STRUCT aiVector3D* axis,
|
||||||
|
const float angle);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get a 3x3 translation matrix.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param translation The translation vector
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix3Translation(
|
||||||
|
C_STRUCT aiMatrix3x3* mat,
|
||||||
|
const C_STRUCT aiVector2D* translation);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Create a 3x3 matrix that rotates one vector to another vector.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param from Vector to rotate from
|
||||||
|
* @param to Vector to rotate to
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix3FromTo(
|
||||||
|
C_STRUCT aiMatrix3x3* mat,
|
||||||
|
const C_STRUCT aiVector3D* from,
|
||||||
|
const C_STRUCT aiVector3D* to);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Construct a 4x4 matrix from a 3x3 matrix.
|
||||||
|
* @param dst Receives the output matrix
|
||||||
|
* @param mat The 3x3 matrix to use
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4FromMatrix3(
|
||||||
|
C_STRUCT aiMatrix4x4* dst,
|
||||||
|
const C_STRUCT aiMatrix3x3* mat);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Construct a 4x4 matrix from scaling, rotation and position.
|
||||||
|
* @param mat Receives the output matrix.
|
||||||
|
* @param scaling The scaling for the x,y,z axes
|
||||||
|
* @param rotation The rotation as a hamilton quaternion
|
||||||
|
* @param position The position for the x,y,z axes
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4FromScalingQuaternionPosition(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
const C_STRUCT aiVector3D* scaling,
|
||||||
|
const C_STRUCT aiQuaternion* rotation,
|
||||||
|
const C_STRUCT aiVector3D* position);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Add 4x4 matrices.
|
||||||
|
* @param dst First addend, receives result.
|
||||||
|
* @param src Matrix to be added to 'dst'.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4Add(
|
||||||
|
C_STRUCT aiMatrix4x4* dst,
|
||||||
|
const C_STRUCT aiMatrix4x4* src);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if 4x4 matrices are equal.
|
||||||
|
* @param a First matrix to compare
|
||||||
|
* @param b Second matrix to compare
|
||||||
|
* @return 1 if the matrices are equal
|
||||||
|
* @return 0 if the matrices are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiMatrix4AreEqual(
|
||||||
|
const C_STRUCT aiMatrix4x4* a,
|
||||||
|
const C_STRUCT aiMatrix4x4* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if 4x4 matrices are equal.
|
||||||
|
* @param a First matrix to compare
|
||||||
|
* @param b Second matrix to compare
|
||||||
|
* @param epsilon Epsilon
|
||||||
|
* @return 1 if the matrices are equal
|
||||||
|
* @return 0 if the matrices are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiMatrix4AreEqualEpsilon(
|
||||||
|
const C_STRUCT aiMatrix4x4* a,
|
||||||
|
const C_STRUCT aiMatrix4x4* b,
|
||||||
|
const float epsilon);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Invert a 4x4 matrix.
|
||||||
|
* @param result Matrix to invert
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4Inverse(
|
||||||
|
C_STRUCT aiMatrix4x4* mat);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get the determinant of a 4x4 matrix.
|
||||||
|
* @param mat Matrix to get the determinant from
|
||||||
|
* @return The determinant of the matrix
|
||||||
|
*/
|
||||||
|
ASSIMP_API float aiMatrix4Determinant(
|
||||||
|
const C_STRUCT aiMatrix4x4* mat);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Returns true of the matrix is the identity matrix.
|
||||||
|
* @param mat Matrix to get the determinant from
|
||||||
|
* @return 1 if \p mat is an identity matrix.
|
||||||
|
* @return 0 if \p mat is not an identity matrix.
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiMatrix4IsIdentity(
|
||||||
|
const C_STRUCT aiMatrix4x4* mat);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Decompose a transformation matrix into its scaling,
|
||||||
|
* rotational as euler angles, and translational components.
|
||||||
|
*
|
||||||
|
* @param mat Matrix to decompose
|
||||||
|
* @param scaling Receives the output scaling for the x,y,z axes
|
||||||
|
* @param rotation Receives the output rotation as a Euler angles
|
||||||
|
* @param position Receives the output position for the x,y,z axes
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4DecomposeIntoScalingEulerAnglesPosition(
|
||||||
|
const C_STRUCT aiMatrix4x4* mat,
|
||||||
|
C_STRUCT aiVector3D* scaling,
|
||||||
|
C_STRUCT aiVector3D* rotation,
|
||||||
|
C_STRUCT aiVector3D* position);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Decompose a transformation matrix into its scaling,
|
||||||
|
* rotational split into an axis and rotational angle,
|
||||||
|
* and it's translational components.
|
||||||
|
*
|
||||||
|
* @param mat Matrix to decompose
|
||||||
|
* @param rotation Receives the rotational component
|
||||||
|
* @param axis Receives the output rotation axis
|
||||||
|
* @param angle Receives the output rotation angle
|
||||||
|
* @param position Receives the output position for the x,y,z axes.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4DecomposeIntoScalingAxisAnglePosition(
|
||||||
|
const C_STRUCT aiMatrix4x4* mat,
|
||||||
|
C_STRUCT aiVector3D* scaling,
|
||||||
|
C_STRUCT aiVector3D* axis,
|
||||||
|
float* angle,
|
||||||
|
C_STRUCT aiVector3D* position);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Decompose a transformation matrix into its rotational and
|
||||||
|
* translational components.
|
||||||
|
*
|
||||||
|
* @param mat Matrix to decompose
|
||||||
|
* @param rotation Receives the rotational component
|
||||||
|
* @param position Receives the translational component.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4DecomposeNoScaling(
|
||||||
|
const C_STRUCT aiMatrix4x4* mat,
|
||||||
|
C_STRUCT aiQuaternion* rotation,
|
||||||
|
C_STRUCT aiVector3D* position);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Creates a 4x4 matrix from a set of euler angles.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param x Rotation angle for the x-axis, in radians
|
||||||
|
* @param y Rotation angle for the y-axis, in radians
|
||||||
|
* @param z Rotation angle for the z-axis, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4FromEulerAngles(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
float x, float y, float z);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get a 4x4 rotation matrix around the X axis.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param angle Rotation angle, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4RotationX(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
const float angle);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get a 4x4 rotation matrix around the Y axis.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param angle Rotation angle, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4RotationY(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
const float angle);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get a 4x4 rotation matrix around the Z axis.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param angle Rotation angle, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4RotationZ(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
const float angle);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Returns a 4x4 rotation matrix for a rotation around an arbitrary axis.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param axis Rotation axis, should be a normalized vector
|
||||||
|
* @param angle Rotation angle, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4FromRotationAroundAxis(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
const C_STRUCT aiVector3D* axis,
|
||||||
|
const float angle);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get a 4x4 translation matrix.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param translation The translation vector
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4Translation(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
const C_STRUCT aiVector3D* translation);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Get a 4x4 scaling matrix.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param scaling The scaling vector
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4Scaling(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
const C_STRUCT aiVector3D* scaling);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Create a 4x4 matrix that rotates one vector to another vector.
|
||||||
|
* @param mat Receives the output matrix
|
||||||
|
* @param from Vector to rotate from
|
||||||
|
* @param to Vector to rotate to
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiMatrix4FromTo(
|
||||||
|
C_STRUCT aiMatrix4x4* mat,
|
||||||
|
const C_STRUCT aiVector3D* from,
|
||||||
|
const C_STRUCT aiVector3D* to);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Create a Quaternion from euler angles.
|
||||||
|
* @param q Receives the output quaternion
|
||||||
|
* @param x Rotation angle for the x-axis, in radians
|
||||||
|
* @param y Rotation angle for the y-axis, in radians
|
||||||
|
* @param z Rotation angle for the z-axis, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiQuaternionFromEulerAngles(
|
||||||
|
C_STRUCT aiQuaternion* q,
|
||||||
|
float x, float y, float z);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Create a Quaternion from an axis angle pair.
|
||||||
|
* @param q Receives the output quaternion
|
||||||
|
* @param axis The orientation axis
|
||||||
|
* @param angle The rotation angle, in radians
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiQuaternionFromAxisAngle(
|
||||||
|
C_STRUCT aiQuaternion* q,
|
||||||
|
const C_STRUCT aiVector3D* axis,
|
||||||
|
const float angle);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Create a Quaternion from a normalized quaternion stored
|
||||||
|
* in a 3D vector.
|
||||||
|
* @param q Receives the output quaternion
|
||||||
|
* @param normalized The vector that stores the quaternion
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiQuaternionFromNormalizedQuaternion(
|
||||||
|
C_STRUCT aiQuaternion* q,
|
||||||
|
const C_STRUCT aiVector3D* normalized);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if quaternions are equal.
|
||||||
|
* @param a First quaternion to compare
|
||||||
|
* @param b Second quaternion to compare
|
||||||
|
* @return 1 if the quaternions are equal
|
||||||
|
* @return 0 if the quaternions are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiQuaternionAreEqual(
|
||||||
|
const C_STRUCT aiQuaternion* a,
|
||||||
|
const C_STRUCT aiQuaternion* b);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Check if quaternions are equal using epsilon.
|
||||||
|
* @param a First quaternion to compare
|
||||||
|
* @param b Second quaternion to compare
|
||||||
|
* @param epsilon Epsilon
|
||||||
|
* @return 1 if the quaternions are equal
|
||||||
|
* @return 0 if the quaternions are not equal
|
||||||
|
*/
|
||||||
|
ASSIMP_API int aiQuaternionAreEqualEpsilon(
|
||||||
|
const C_STRUCT aiQuaternion* a,
|
||||||
|
const C_STRUCT aiQuaternion* b,
|
||||||
|
const float epsilon);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Normalize a quaternion.
|
||||||
|
* @param q Quaternion to normalize
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiQuaternionNormalize(
|
||||||
|
C_STRUCT aiQuaternion* q);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Compute quaternion conjugate.
|
||||||
|
* @param q Quaternion to compute conjugate,
|
||||||
|
* receives the output quaternion
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiQuaternionConjugate(
|
||||||
|
C_STRUCT aiQuaternion* q);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Multiply quaternions.
|
||||||
|
* @param dst First quaternion, receives the output quaternion
|
||||||
|
* @param q Second quaternion
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiQuaternionMultiply(
|
||||||
|
C_STRUCT aiQuaternion* dst,
|
||||||
|
const C_STRUCT aiQuaternion* q);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------
|
||||||
|
/** Performs a spherical interpolation between two quaternions.
|
||||||
|
* @param dst Receives the quaternion resulting from the interpolation.
|
||||||
|
* @param start Quaternion when factor == 0
|
||||||
|
* @param end Quaternion when factor == 1
|
||||||
|
* @param factor Interpolation factor between 0 and 1
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiQuaternionInterpolate(
|
||||||
|
C_STRUCT aiQuaternion* dst,
|
||||||
|
const C_STRUCT aiQuaternion* start,
|
||||||
|
const C_STRUCT aiQuaternion* end,
|
||||||
|
const float factor);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -49,20 +47,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_METADATA_H_INC
|
#define AI_METADATA_H_INC
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER <= 1500)
|
#if defined(_MSC_VER) && (_MSC_VER <= 1500)
|
||||||
# include "Compiler/pstdint.h"
|
#include "Compiler/pstdint.h"
|
||||||
#else
|
#else
|
||||||
# include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Enum used to distinguish data types
|
* Enum used to distinguish data types
|
||||||
*/
|
*/
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
typedef enum aiMetadataType {
|
typedef enum aiMetadataType {
|
||||||
AI_BOOL = 0,
|
AI_BOOL = 0,
|
||||||
AI_INT32 = 1,
|
AI_INT32 = 1,
|
||||||
|
@ -84,10 +82,10 @@ typedef enum aiMetadataType {
|
||||||
*
|
*
|
||||||
* The type field uniquely identifies the underlying type of the data field
|
* The type field uniquely identifies the underlying type of the data field
|
||||||
*/
|
*/
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
struct aiMetadataEntry {
|
struct aiMetadataEntry {
|
||||||
aiMetadataType mType;
|
aiMetadataType mType;
|
||||||
void* mData;
|
void *mData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -98,15 +96,29 @@ struct aiMetadataEntry {
|
||||||
/**
|
/**
|
||||||
* Helper functions to get the aiType enum entry for a type
|
* Helper functions to get the aiType enum entry for a type
|
||||||
*/
|
*/
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
|
|
||||||
inline aiMetadataType GetAiType( bool ) { return AI_BOOL; }
|
inline aiMetadataType GetAiType(bool) {
|
||||||
inline aiMetadataType GetAiType( int32_t ) { return AI_INT32; }
|
return AI_BOOL;
|
||||||
inline aiMetadataType GetAiType( uint64_t ) { return AI_UINT64; }
|
}
|
||||||
inline aiMetadataType GetAiType( float ) { return AI_FLOAT; }
|
inline aiMetadataType GetAiType(int32_t) {
|
||||||
inline aiMetadataType GetAiType( double ) { return AI_DOUBLE; }
|
return AI_INT32;
|
||||||
inline aiMetadataType GetAiType( const aiString & ) { return AI_AISTRING; }
|
}
|
||||||
inline aiMetadataType GetAiType( const aiVector3D & ) { return AI_AIVECTOR3D; }
|
inline aiMetadataType GetAiType(uint64_t) {
|
||||||
|
return AI_UINT64;
|
||||||
|
}
|
||||||
|
inline aiMetadataType GetAiType(float) {
|
||||||
|
return AI_FLOAT;
|
||||||
|
}
|
||||||
|
inline aiMetadataType GetAiType(double) {
|
||||||
|
return AI_DOUBLE;
|
||||||
|
}
|
||||||
|
inline aiMetadataType GetAiType(const aiString &) {
|
||||||
|
return AI_AISTRING;
|
||||||
|
}
|
||||||
|
inline aiMetadataType GetAiType(const aiVector3D &) {
|
||||||
|
return AI_AIVECTOR3D;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
@ -116,17 +128,17 @@ inline aiMetadataType GetAiType( const aiVector3D & ) { return AI_AIVECTOR3D; }
|
||||||
*
|
*
|
||||||
* Metadata is a key-value store using string keys and values.
|
* Metadata is a key-value store using string keys and values.
|
||||||
*/
|
*/
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
struct aiMetadata {
|
struct aiMetadata {
|
||||||
/** Length of the mKeys and mValues arrays, respectively */
|
/** Length of the mKeys and mValues arrays, respectively */
|
||||||
unsigned int mNumProperties;
|
unsigned int mNumProperties;
|
||||||
|
|
||||||
/** Arrays of keys, may not be NULL. Entries in this array may not be NULL as well. */
|
/** Arrays of keys, may not be NULL. Entries in this array may not be NULL as well. */
|
||||||
C_STRUCT aiString* mKeys;
|
C_STRUCT aiString *mKeys;
|
||||||
|
|
||||||
/** Arrays of values, may not be NULL. Entries in this array may be NULL if the
|
/** Arrays of values, may not be NULL. Entries in this array may be NULL if the
|
||||||
* corresponding property key has no assigned value. */
|
* corresponding property key has no assigned value. */
|
||||||
C_STRUCT aiMetadataEntry* mValues;
|
C_STRUCT aiMetadataEntry *mValues;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
@ -134,71 +146,62 @@ 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() AI_NO_EXCEPT
|
aiMetadata() AI_NO_EXCEPT
|
||||||
: mNumProperties(0)
|
: mNumProperties(0),
|
||||||
, mKeys(nullptr)
|
mKeys(nullptr),
|
||||||
, mValues(nullptr) {
|
mValues(nullptr) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMetadata( const aiMetadata &rhs )
|
aiMetadata(const aiMetadata &rhs) :
|
||||||
: mNumProperties( rhs.mNumProperties )
|
mNumProperties(rhs.mNumProperties), mKeys(nullptr), mValues(nullptr) {
|
||||||
, mKeys( nullptr )
|
mKeys = new aiString[mNumProperties];
|
||||||
, mValues( nullptr ) {
|
for (size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i) {
|
||||||
mKeys = new aiString[ mNumProperties ];
|
mKeys[i] = rhs.mKeys[i];
|
||||||
for ( size_t i = 0; i < static_cast<size_t>( mNumProperties ); ++i ) {
|
|
||||||
mKeys[ i ] = rhs.mKeys[ i ];
|
|
||||||
}
|
}
|
||||||
mValues = new aiMetadataEntry[ mNumProperties ];
|
mValues = new aiMetadataEntry[mNumProperties];
|
||||||
for ( size_t i = 0; i < static_cast<size_t>(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:
|
||||||
mValues[ i ].mData = new bool;
|
mValues[i].mData = new bool;
|
||||||
::memcpy( mValues[ i ].mData, rhs.mValues[ i ].mData, sizeof(bool) );
|
::memcpy(mValues[i].mData, rhs.mValues[i].mData, sizeof(bool));
|
||||||
break;
|
break;
|
||||||
case AI_INT32: {
|
case AI_INT32: {
|
||||||
int32_t v;
|
int32_t v;
|
||||||
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( int32_t ) );
|
::memcpy(&v, rhs.mValues[i].mData, sizeof(int32_t));
|
||||||
mValues[ i ].mData = new int32_t( v );
|
mValues[i].mData = new int32_t(v);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case AI_UINT64: {
|
case AI_UINT64: {
|
||||||
uint64_t v;
|
uint64_t v;
|
||||||
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( uint64_t ) );
|
::memcpy(&v, rhs.mValues[i].mData, sizeof(uint64_t));
|
||||||
mValues[ i ].mData = new uint64_t( v );
|
mValues[i].mData = new uint64_t(v);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case AI_FLOAT: {
|
case AI_FLOAT: {
|
||||||
float v;
|
float v;
|
||||||
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( float ) );
|
::memcpy(&v, rhs.mValues[i].mData, sizeof(float));
|
||||||
mValues[ i ].mData = new float( v );
|
mValues[i].mData = new float(v);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case AI_DOUBLE: {
|
case AI_DOUBLE: {
|
||||||
double v;
|
double v;
|
||||||
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( double ) );
|
::memcpy(&v, rhs.mValues[i].mData, sizeof(double));
|
||||||
mValues[ i ].mData = new double( v );
|
mValues[i].mData = new double(v);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case AI_AISTRING: {
|
case AI_AISTRING: {
|
||||||
aiString v;
|
aiString v;
|
||||||
rhs.Get<aiString>( mKeys[ i ], v );
|
rhs.Get<aiString>(mKeys[i], v);
|
||||||
mValues[ i ].mData = new aiString( v );
|
mValues[i].mData = new aiString(v);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case AI_AIVECTOR3D: {
|
case AI_AIVECTOR3D: {
|
||||||
aiVector3D v;
|
aiVector3D v;
|
||||||
rhs.Get<aiVector3D>( mKeys[ i ], v );
|
rhs.Get<aiVector3D>(mKeys[i], v);
|
||||||
mValues[ i ].mData = new aiVector3D( v );
|
mValues[i].mData = new aiVector3D(v);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
case FORCE_32BIT:
|
case FORCE_32BIT:
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,33 +209,33 @@ struct aiMetadata {
|
||||||
* @brief The destructor.
|
* @brief The destructor.
|
||||||
*/
|
*/
|
||||||
~aiMetadata() {
|
~aiMetadata() {
|
||||||
delete [] mKeys;
|
delete[] mKeys;
|
||||||
mKeys = nullptr;
|
mKeys = nullptr;
|
||||||
if (mValues) {
|
if (mValues) {
|
||||||
// Delete each metadata entry
|
// Delete each metadata entry
|
||||||
for (unsigned i=0; i<mNumProperties; ++i) {
|
for (unsigned i = 0; i < mNumProperties; ++i) {
|
||||||
void* data = mValues[i].mData;
|
void *data = mValues[i].mData;
|
||||||
switch (mValues[i].mType) {
|
switch (mValues[i].mType) {
|
||||||
case AI_BOOL:
|
case AI_BOOL:
|
||||||
delete static_cast< bool* >( data );
|
delete static_cast<bool *>(data);
|
||||||
break;
|
break;
|
||||||
case AI_INT32:
|
case AI_INT32:
|
||||||
delete static_cast< int32_t* >( data );
|
delete static_cast<int32_t *>(data);
|
||||||
break;
|
break;
|
||||||
case AI_UINT64:
|
case AI_UINT64:
|
||||||
delete static_cast< uint64_t* >( data );
|
delete static_cast<uint64_t *>(data);
|
||||||
break;
|
break;
|
||||||
case AI_FLOAT:
|
case AI_FLOAT:
|
||||||
delete static_cast< float* >( data );
|
delete static_cast<float *>(data);
|
||||||
break;
|
break;
|
||||||
case AI_DOUBLE:
|
case AI_DOUBLE:
|
||||||
delete static_cast< double* >( data );
|
delete static_cast<double *>(data);
|
||||||
break;
|
break;
|
||||||
case AI_AISTRING:
|
case AI_AISTRING:
|
||||||
delete static_cast< aiString* >( data );
|
delete static_cast<aiString *>(data);
|
||||||
break;
|
break;
|
||||||
case AI_AIVECTOR3D:
|
case AI_AIVECTOR3D:
|
||||||
delete static_cast< aiVector3D* >( data );
|
delete static_cast<aiVector3D *>(data);
|
||||||
break;
|
break;
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
case FORCE_32BIT:
|
case FORCE_32BIT:
|
||||||
|
@ -243,7 +246,7 @@ struct aiMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the metadata array
|
// Delete the metadata array
|
||||||
delete [] mValues;
|
delete[] mValues;
|
||||||
mValues = nullptr;
|
mValues = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,16 +255,15 @@ struct aiMetadata {
|
||||||
* @brief Allocates property fields + keys.
|
* @brief Allocates property fields + keys.
|
||||||
* @param numProperties Number of requested properties.
|
* @param numProperties Number of requested properties.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline aiMetadata *Alloc(unsigned int numProperties) {
|
||||||
aiMetadata *Alloc( unsigned int numProperties ) {
|
if (0 == numProperties) {
|
||||||
if ( 0 == numProperties ) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMetadata *data = new aiMetadata;
|
aiMetadata *data = new aiMetadata;
|
||||||
data->mNumProperties = numProperties;
|
data->mNumProperties = numProperties;
|
||||||
data->mKeys = new aiString[ data->mNumProperties ]();
|
data->mKeys = new aiString[data->mNumProperties]();
|
||||||
data->mValues = new aiMetadataEntry[ data->mNumProperties ]();
|
data->mValues = new aiMetadataEntry[data->mNumProperties]();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -269,19 +271,16 @@ struct aiMetadata {
|
||||||
/**
|
/**
|
||||||
* @brief Deallocates property fields + keys.
|
* @brief Deallocates property fields + keys.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline void Dealloc(aiMetadata *metadata) {
|
||||||
void Dealloc( aiMetadata *metadata ) {
|
|
||||||
delete metadata;
|
delete metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline
|
inline void Add(const std::string &key, const T &value) {
|
||||||
void Add(const std::string& key, const T& value) {
|
aiString *new_keys = new aiString[mNumProperties + 1];
|
||||||
aiString* new_keys = new aiString[mNumProperties + 1];
|
aiMetadataEntry *new_values = new aiMetadataEntry[mNumProperties + 1];
|
||||||
aiMetadataEntry* new_values = new aiMetadataEntry[mNumProperties + 1];
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < mNumProperties; ++i)
|
for (unsigned int i = 0; i < mNumProperties; ++i) {
|
||||||
{
|
|
||||||
new_keys[i] = mKeys[i];
|
new_keys[i] = mKeys[i];
|
||||||
new_values[i] = mValues[i];
|
new_values[i] = mValues[i];
|
||||||
}
|
}
|
||||||
|
@ -297,16 +296,15 @@ struct aiMetadata {
|
||||||
Set(mNumProperties - 1, key, value);
|
Set(mNumProperties - 1, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline
|
inline bool Set(unsigned index, const std::string &key, const T &value) {
|
||||||
bool Set( unsigned index, const std::string& key, const T& value ) {
|
|
||||||
// In range assertion
|
// In range assertion
|
||||||
if ( index >= mNumProperties ) {
|
if (index >= mNumProperties) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that we have a valid key.
|
// Ensure that we have a valid key.
|
||||||
if ( key.empty() ) {
|
if (key.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,42 +319,57 @@ struct aiMetadata {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline
|
inline bool Set( const std::string &key, const T &value ) {
|
||||||
bool Get( unsigned index, T& value ) const {
|
if (key.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool result = false;
|
||||||
|
for (unsigned int i = 0; i < mNumProperties; ++i) {
|
||||||
|
if (key == mKeys[i].C_Str()) {
|
||||||
|
Set(i, key, value);
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline bool Get(unsigned index, T &value) const {
|
||||||
// In range assertion
|
// In range assertion
|
||||||
if ( index >= mNumProperties ) {
|
if (index >= mNumProperties) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return false if the output data type does
|
// Return false if the output data type does
|
||||||
// not match the found value's data type
|
// not match the found value's data type
|
||||||
if ( GetAiType( value ) != mValues[ index ].mType ) {
|
if (GetAiType(value) != mValues[index].mType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, output the found value and
|
// Otherwise, output the found value and
|
||||||
// return true
|
// return true
|
||||||
value = *static_cast<T*>(mValues[index].mData);
|
value = *static_cast<T *>(mValues[index].mData);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline
|
inline bool Get(const aiString &key, T &value) const {
|
||||||
bool Get( const aiString& key, T& value ) const {
|
|
||||||
// Search for the given key
|
// Search for the given key
|
||||||
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
|
for (unsigned int i = 0; i < mNumProperties; ++i) {
|
||||||
if ( mKeys[ i ] == key ) {
|
if (mKeys[i] == key) {
|
||||||
return Get( i, value );
|
return Get(i, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline
|
inline bool Get(const std::string &key, T &value) const {
|
||||||
bool Get( const std::string& key, T& value ) const {
|
|
||||||
return Get(aiString(key), value);
|
return Get(aiString(key), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,9 +378,8 @@ struct aiMetadata {
|
||||||
/// \param [out] pKey - pointer to the key value.
|
/// \param [out] pKey - pointer to the key value.
|
||||||
/// \param [out] pEntry - pointer to the entry: type and value.
|
/// \param [out] pEntry - pointer to the entry: type and value.
|
||||||
/// \return false - if pIndex is out of range, else - true.
|
/// \return false - if pIndex is out of range, else - true.
|
||||||
inline
|
inline bool Get(size_t index, const aiString *&key, const aiMetadataEntry *&entry) const {
|
||||||
bool Get(size_t index, const aiString*& key, const aiMetadataEntry*& entry) const {
|
if (index >= mNumProperties) {
|
||||||
if ( index >= mNumProperties ) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,15 +391,14 @@ struct aiMetadata {
|
||||||
|
|
||||||
/// Check whether there is a metadata entry for the given key.
|
/// Check whether there is a metadata entry for the given key.
|
||||||
/// \param [in] Key - the key value value to check for.
|
/// \param [in] Key - the key value value to check for.
|
||||||
inline
|
inline bool HasKey(const char *key) {
|
||||||
bool HasKey(const char* key) {
|
if (nullptr == key) {
|
||||||
if ( nullptr == key ) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for the given key
|
// Search for the given key
|
||||||
for (unsigned int i = 0; i < mNumProperties; ++i) {
|
for (unsigned int i = 0; i < mNumProperties; ++i) {
|
||||||
if ( 0 == strncmp(mKeys[i].C_Str(), key, mKeys[i].length ) ) {
|
if (0 == strncmp(mKeys[i].C_Str(), key, mKeys[i].length)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,7 +406,6 @@ struct aiMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AI_METADATA_H_INC
|
#endif // AI_METADATA_H_INC
|
||||||
|
|
|
@ -99,7 +99,7 @@ public:
|
||||||
aiQuaterniont& Conjugate ();
|
aiQuaterniont& Conjugate ();
|
||||||
|
|
||||||
/** Rotate a point by this quaternion */
|
/** Rotate a point by this quaternion */
|
||||||
aiVector3t<TReal> Rotate (const aiVector3t<TReal>& in);
|
aiVector3t<TReal> Rotate (const aiVector3t<TReal>& in) const;
|
||||||
|
|
||||||
/** Multiply two quaternions */
|
/** Multiply two quaternions */
|
||||||
aiQuaterniont operator* (const aiQuaterniont& two) const;
|
aiQuaterniont operator* (const aiQuaterniont& two) const;
|
||||||
|
|
|
@ -277,7 +277,7 @@ inline aiQuaterniont<TReal>& aiQuaterniont<TReal>::Conjugate ()
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
template<typename TReal>
|
template<typename TReal>
|
||||||
inline aiVector3t<TReal> aiQuaterniont<TReal>::Rotate (const aiVector3t<TReal>& v)
|
inline aiVector3t<TReal> aiQuaterniont<TReal>::Rotate (const aiVector3t<TReal>& v) const
|
||||||
{
|
{
|
||||||
aiQuaterniont q2(0.f,v.x,v.y,v.z), q = *this, qinv = q;
|
aiQuaterniont q2(0.f,v.x,v.y,v.z), q = *this, qinv = q;
|
||||||
qinv.Conjugate();
|
qinv.Conjugate();
|
||||||
|
|
|
@ -278,7 +278,7 @@ void do_motion (void)
|
||||||
static int frames = 0;
|
static int frames = 0;
|
||||||
|
|
||||||
int time = glutGet(GLUT_ELAPSED_TIME);
|
int time = glutGet(GLUT_ELAPSED_TIME);
|
||||||
angle += (float)((time-prev_time)*0.01);
|
angle += static_cast<float>((time-prev_time)*0.01);
|
||||||
prev_time = time;
|
prev_time = time;
|
||||||
|
|
||||||
frames += 1;
|
frames += 1;
|
||||||
|
|
|
@ -31,40 +31,40 @@ struct Texture {
|
||||||
|
|
||||||
class Mesh {
|
class Mesh {
|
||||||
public:
|
public:
|
||||||
std::vector<VERTEX> vertices;
|
std::vector<VERTEX> vertices_;
|
||||||
std::vector<UINT> indices;
|
std::vector<UINT> indices_;
|
||||||
std::vector<Texture> textures;
|
std::vector<Texture> textures_;
|
||||||
ID3D11Device *dev;
|
ID3D11Device *dev_;
|
||||||
|
|
||||||
Mesh(ID3D11Device *dev, const std::vector<VERTEX>& vertices, const std::vector<UINT>& indices, const std::vector<Texture>& textures) :
|
Mesh(ID3D11Device *dev, const std::vector<VERTEX>& vertices, const std::vector<UINT>& indices, const std::vector<Texture>& textures) :
|
||||||
vertices(vertices),
|
vertices_(vertices),
|
||||||
indices(indices),
|
indices_(indices),
|
||||||
textures(textures),
|
textures_(textures),
|
||||||
dev(dev),
|
dev_(dev),
|
||||||
VertexBuffer(nullptr),
|
VertexBuffer_(nullptr),
|
||||||
IndexBuffer(nullptr) {
|
IndexBuffer_(nullptr) {
|
||||||
this->setupMesh(this->dev);
|
this->setupMesh(this->dev_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw(ID3D11DeviceContext *devcon) {
|
void Draw(ID3D11DeviceContext *devcon) {
|
||||||
UINT stride = sizeof(VERTEX);
|
UINT stride = sizeof(VERTEX);
|
||||||
UINT offset = 0;
|
UINT offset = 0;
|
||||||
|
|
||||||
devcon->IASetVertexBuffers(0, 1, &VertexBuffer, &stride, &offset);
|
devcon->IASetVertexBuffers(0, 1, &VertexBuffer_, &stride, &offset);
|
||||||
devcon->IASetIndexBuffer(IndexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
devcon->IASetIndexBuffer(IndexBuffer_, DXGI_FORMAT_R32_UINT, 0);
|
||||||
|
|
||||||
devcon->PSSetShaderResources(0, 1, &textures[0].texture);
|
devcon->PSSetShaderResources(0, 1, &textures_[0].texture);
|
||||||
|
|
||||||
devcon->DrawIndexed(static_cast<UINT>(indices.size()), 0, 0);
|
devcon->DrawIndexed(static_cast<UINT>(indices_.size()), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close() {
|
void Close() {
|
||||||
SafeRelease(VertexBuffer);
|
SafeRelease(VertexBuffer_);
|
||||||
SafeRelease(IndexBuffer);
|
SafeRelease(IndexBuffer_);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
// Render data
|
// Render data
|
||||||
ID3D11Buffer *VertexBuffer, *IndexBuffer;
|
ID3D11Buffer *VertexBuffer_, *IndexBuffer_;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
// Initializes all the buffer objects/arrays
|
// Initializes all the buffer objects/arrays
|
||||||
|
@ -73,15 +73,15 @@ private:
|
||||||
|
|
||||||
D3D11_BUFFER_DESC vbd;
|
D3D11_BUFFER_DESC vbd;
|
||||||
vbd.Usage = D3D11_USAGE_IMMUTABLE;
|
vbd.Usage = D3D11_USAGE_IMMUTABLE;
|
||||||
vbd.ByteWidth = static_cast<UINT>(sizeof(VERTEX) * vertices.size());
|
vbd.ByteWidth = static_cast<UINT>(sizeof(VERTEX) * vertices_.size());
|
||||||
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||||
vbd.CPUAccessFlags = 0;
|
vbd.CPUAccessFlags = 0;
|
||||||
vbd.MiscFlags = 0;
|
vbd.MiscFlags = 0;
|
||||||
|
|
||||||
D3D11_SUBRESOURCE_DATA initData;
|
D3D11_SUBRESOURCE_DATA initData;
|
||||||
initData.pSysMem = &vertices[0];
|
initData.pSysMem = &vertices_[0];
|
||||||
|
|
||||||
hr = dev->CreateBuffer(&vbd, &initData, &VertexBuffer);
|
hr = dev->CreateBuffer(&vbd, &initData, &VertexBuffer_);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Close();
|
Close();
|
||||||
throw std::runtime_error("Failed to create vertex buffer.");
|
throw std::runtime_error("Failed to create vertex buffer.");
|
||||||
|
@ -89,14 +89,14 @@ private:
|
||||||
|
|
||||||
D3D11_BUFFER_DESC ibd;
|
D3D11_BUFFER_DESC ibd;
|
||||||
ibd.Usage = D3D11_USAGE_IMMUTABLE;
|
ibd.Usage = D3D11_USAGE_IMMUTABLE;
|
||||||
ibd.ByteWidth = static_cast<UINT>(sizeof(UINT) * indices.size());
|
ibd.ByteWidth = static_cast<UINT>(sizeof(UINT) * indices_.size());
|
||||||
ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||||
ibd.CPUAccessFlags = 0;
|
ibd.CPUAccessFlags = 0;
|
||||||
ibd.MiscFlags = 0;
|
ibd.MiscFlags = 0;
|
||||||
|
|
||||||
initData.pSysMem = &indices[0];
|
initData.pSysMem = &indices_[0];
|
||||||
|
|
||||||
hr = dev->CreateBuffer(&ibd, &initData, &IndexBuffer);
|
hr = dev->CreateBuffer(&ibd, &initData, &IndexBuffer_);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Close();
|
Close();
|
||||||
throw std::runtime_error("Failed to create index buffer.");
|
throw std::runtime_error("Failed to create index buffer.");
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "ModelLoader.h"
|
#include "ModelLoader.h"
|
||||||
|
|
||||||
ModelLoader::ModelLoader() :
|
ModelLoader::ModelLoader() :
|
||||||
dev(nullptr),
|
dev_(nullptr),
|
||||||
devcon(nullptr),
|
devcon_(nullptr),
|
||||||
meshes(),
|
meshes_(),
|
||||||
directory(),
|
directory_(),
|
||||||
textures_loaded(),
|
textures_loaded_(),
|
||||||
hwnd(nullptr) {
|
hwnd_(nullptr) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ bool ModelLoader::Load(HWND hwnd, ID3D11Device * dev, ID3D11DeviceContext * devc
|
||||||
if (pScene == NULL)
|
if (pScene == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this->directory = filename.substr(0, filename.find_last_of("/\\"));
|
this->directory_ = filename.substr(0, filename.find_last_of("/\\"));
|
||||||
|
|
||||||
this->dev = dev;
|
this->dev_ = dev;
|
||||||
this->devcon = devcon;
|
this->devcon_ = devcon;
|
||||||
this->hwnd = hwnd;
|
this->hwnd_ = hwnd;
|
||||||
|
|
||||||
processNode(pScene->mRootNode, pScene);
|
processNode(pScene->mRootNode, pScene);
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ bool ModelLoader::Load(HWND hwnd, ID3D11Device * dev, ID3D11DeviceContext * devc
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelLoader::Draw(ID3D11DeviceContext * devcon) {
|
void ModelLoader::Draw(ID3D11DeviceContext * devcon) {
|
||||||
for (int i = 0; i < meshes.size(); ++i ) {
|
for (size_t i = 0; i < meshes_.size(); ++i ) {
|
||||||
meshes[i].Draw(devcon);
|
meshes_[i].Draw(devcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ Mesh ModelLoader::processMesh(aiMesh * mesh, const aiScene * scene) {
|
||||||
textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());
|
textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Mesh(dev, vertices, indices, textures);
|
return Mesh(dev_, vertices, indices, textures);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Texture> ModelLoader::loadMaterialTextures(aiMaterial * mat, aiTextureType type, std::string typeName, const aiScene * scene) {
|
std::vector<Texture> ModelLoader::loadMaterialTextures(aiMaterial * mat, aiTextureType type, std::string typeName, const aiScene * scene) {
|
||||||
|
@ -98,9 +98,9 @@ std::vector<Texture> ModelLoader::loadMaterialTextures(aiMaterial * mat, aiTextu
|
||||||
mat->GetTexture(type, i, &str);
|
mat->GetTexture(type, i, &str);
|
||||||
// Check if texture was loaded before and if so, continue to next iteration: skip loading a new texture
|
// Check if texture was loaded before and if so, continue to next iteration: skip loading a new texture
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
for (UINT j = 0; j < textures_loaded.size(); j++) {
|
for (UINT j = 0; j < textures_loaded_.size(); j++) {
|
||||||
if (std::strcmp(textures_loaded[j].path.c_str(), str.C_Str()) == 0) {
|
if (std::strcmp(textures_loaded_[j].path.c_str(), str.C_Str()) == 0) {
|
||||||
textures.push_back(textures_loaded[j]);
|
textures.push_back(textures_loaded_[j]);
|
||||||
skip = true; // A texture with the same filepath has already been loaded, continue to next one. (optimization)
|
skip = true; // A texture with the same filepath has already been loaded, continue to next one. (optimization)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -113,34 +113,34 @@ std::vector<Texture> ModelLoader::loadMaterialTextures(aiMaterial * mat, aiTextu
|
||||||
texture.texture = getTextureFromModel(scene, textureindex);
|
texture.texture = getTextureFromModel(scene, textureindex);
|
||||||
} else {
|
} else {
|
||||||
std::string filename = std::string(str.C_Str());
|
std::string filename = std::string(str.C_Str());
|
||||||
filename = directory + '/' + filename;
|
filename = directory_ + '/' + filename;
|
||||||
std::wstring filenamews = std::wstring(filename.begin(), filename.end());
|
std::wstring filenamews = std::wstring(filename.begin(), filename.end());
|
||||||
hr = CreateWICTextureFromFile(dev, devcon, filenamews.c_str(), nullptr, &texture.texture);
|
hr = CreateWICTextureFromFile(dev_, devcon_, filenamews.c_str(), nullptr, &texture.texture);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
MessageBox(hwnd, "Texture couldn't be loaded", "Error!", MB_ICONERROR | MB_OK);
|
MessageBox(hwnd_, "Texture couldn't be loaded", "Error!", MB_ICONERROR | MB_OK);
|
||||||
}
|
}
|
||||||
texture.type = typeName;
|
texture.type = typeName;
|
||||||
texture.path = str.C_Str();
|
texture.path = str.C_Str();
|
||||||
textures.push_back(texture);
|
textures.push_back(texture);
|
||||||
this->textures_loaded.push_back(texture); // Store it as texture loaded for entire model, to ensure we won't unnecesery load duplicate textures.
|
this->textures_loaded_.push_back(texture); // Store it as texture loaded for entire model, to ensure we won't unnecesery load duplicate textures.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return textures;
|
return textures;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelLoader::Close() {
|
void ModelLoader::Close() {
|
||||||
for (auto& t : textures_loaded)
|
for (auto& t : textures_loaded_)
|
||||||
t.Release();
|
t.Release();
|
||||||
|
|
||||||
for (int i = 0; i < meshes.size(); i++) {
|
for (size_t i = 0; i < meshes_.size(); i++) {
|
||||||
meshes[i].Close();
|
meshes_[i].Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelLoader::processNode(aiNode * node, const aiScene * scene) {
|
void ModelLoader::processNode(aiNode * node, const aiScene * scene) {
|
||||||
for (UINT i = 0; i < node->mNumMeshes; i++) {
|
for (UINT i = 0; i < node->mNumMeshes; i++) {
|
||||||
aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
|
aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
|
||||||
meshes.push_back(this->processMesh(mesh, scene));
|
meshes_.push_back(this->processMesh(mesh, scene));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (UINT i = 0; i < node->mNumChildren; i++) {
|
for (UINT i = 0; i < node->mNumChildren; i++) {
|
||||||
|
@ -179,9 +179,9 @@ ID3D11ShaderResourceView * ModelLoader::getTextureFromModel(const aiScene * scen
|
||||||
|
|
||||||
int* size = reinterpret_cast<int*>(&scene->mTextures[textureindex]->mWidth);
|
int* size = reinterpret_cast<int*>(&scene->mTextures[textureindex]->mWidth);
|
||||||
|
|
||||||
hr = CreateWICTextureFromMemory(dev, devcon, reinterpret_cast<unsigned char*>(scene->mTextures[textureindex]->pcData), *size, nullptr, &texture);
|
hr = CreateWICTextureFromMemory(dev_, devcon_, reinterpret_cast<unsigned char*>(scene->mTextures[textureindex]->pcData), *size, nullptr, &texture);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
MessageBox(hwnd, "Texture couldn't be created from memory!", "Error!", MB_ICONERROR | MB_OK);
|
MessageBox(hwnd_, "Texture couldn't be created from memory!", "Error!", MB_ICONERROR | MB_OK);
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ public:
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
private:
|
private:
|
||||||
ID3D11Device *dev;
|
ID3D11Device *dev_;
|
||||||
ID3D11DeviceContext *devcon;
|
ID3D11DeviceContext *devcon_;
|
||||||
std::vector<Mesh> meshes;
|
std::vector<Mesh> meshes_;
|
||||||
std::string directory;
|
std::string directory_;
|
||||||
std::vector<Texture> textures_loaded;
|
std::vector<Texture> textures_loaded_;
|
||||||
HWND hwnd;
|
HWND hwnd_;
|
||||||
|
|
||||||
void processNode(aiNode* node, const aiScene* scene);
|
void processNode(aiNode* node, const aiScene* scene);
|
||||||
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
|
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
|
||||||
|
|
|
@ -56,7 +56,7 @@ const char g_szClassName[] = "directxWindowClass";
|
||||||
static std::string g_ModelPath;
|
static std::string g_ModelPath;
|
||||||
|
|
||||||
UINT width, height;
|
UINT width, height;
|
||||||
HWND hwnd = nullptr;
|
HWND g_hwnd = nullptr;
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// DirectX Variables
|
// DirectX Variables
|
||||||
|
@ -120,8 +120,8 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
|
||||||
LPWSTR lpCmdLine, int nCmdShow)
|
LPWSTR /*lpCmdLine*/, int nCmdShow)
|
||||||
{
|
{
|
||||||
int argc;
|
int argc;
|
||||||
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||||
|
@ -182,7 +182,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
RECT wr = { 0,0, SCREEN_WIDTH, SCREEN_HEIGHT };
|
RECT wr = { 0,0, SCREEN_WIDTH, SCREEN_HEIGHT };
|
||||||
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
|
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
|
|
||||||
hwnd = CreateWindowEx(
|
g_hwnd = CreateWindowEx(
|
||||||
WS_EX_CLIENTEDGE,
|
WS_EX_CLIENTEDGE,
|
||||||
g_szClassName,
|
g_szClassName,
|
||||||
" Simple Textured Directx11 Sample ",
|
" Simple Textured Directx11 Sample ",
|
||||||
|
@ -191,21 +191,21 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
NULL, NULL, hInstance, NULL
|
NULL, NULL, hInstance, NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hwnd == NULL)
|
if (g_hwnd == NULL)
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Window Creation Failed!", "Error!",
|
MessageBox(NULL, "Window Creation Failed!", "Error!",
|
||||||
MB_ICONEXCLAMATION | MB_OK);
|
MB_ICONEXCLAMATION | MB_OK);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(hwnd, nCmdShow);
|
ShowWindow(g_hwnd, nCmdShow);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(g_hwnd);
|
||||||
|
|
||||||
width = wr.right - wr.left;
|
width = wr.right - wr.left;
|
||||||
height = wr.bottom - wr.top;
|
height = wr.bottom - wr.top;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InitD3D(hInstance, hwnd);
|
InitD3D(hInstance, g_hwnd);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -225,17 +225,17 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
CleanD3D();
|
CleanD3D();
|
||||||
return static_cast<int>(msg.wParam);
|
return static_cast<int>(msg.wParam);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
MessageBox(hwnd, e.what(), TEXT("Error!"), MB_ICONERROR | MB_OK);
|
MessageBox(g_hwnd, e.what(), TEXT("Error!"), MB_ICONERROR | MB_OK);
|
||||||
CleanD3D();
|
CleanD3D();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
MessageBox(hwnd, TEXT("Caught an unknown exception."), TEXT("Error!"), MB_ICONERROR | MB_OK);
|
MessageBox(g_hwnd, TEXT("Caught an unknown exception."), TEXT("Error!"), MB_ICONERROR | MB_OK);
|
||||||
CleanD3D();
|
CleanD3D();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitD3D(HINSTANCE hinstance, HWND hWnd)
|
void InitD3D(HINSTANCE /*hinstance*/, HWND hWnd)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ void InitD3D(HINSTANCE hinstance, HWND hWnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note this tutorial doesn't handle full-screen swapchains so we block the ALT+ENTER shortcut
|
// Note this tutorial doesn't handle full-screen swapchains so we block the ALT+ENTER shortcut
|
||||||
dxgiFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);
|
dxgiFactory->MakeWindowAssociation(g_hwnd, DXGI_MWA_NO_ALT_ENTER);
|
||||||
|
|
||||||
dxgiFactory->Release();
|
dxgiFactory->Release();
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ void InitGraphics()
|
||||||
m_View = XMMatrixLookAtLH(Eye, At, Up);
|
m_View = XMMatrixLookAtLH(Eye, At, Up);
|
||||||
|
|
||||||
ourModel = new ModelLoader;
|
ourModel = new ModelLoader;
|
||||||
if (!ourModel->Load(hwnd, dev, devcon, g_ModelPath))
|
if (!ourModel->Load(g_hwnd, dev, devcon, g_ModelPath))
|
||||||
Throwanerror("Model couldn't be loaded");
|
Throwanerror("Model couldn't be loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ if ( MSVC )
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${Assimp_SOURCE_DIR}/include
|
|
||||||
${Assimp_SOURCE_DIR}/code
|
${Assimp_SOURCE_DIR}/code
|
||||||
${OPENGL_INCLUDE_DIR}
|
${OPENGL_INCLUDE_DIR}
|
||||||
${GLUT_INCLUDE_DIR}
|
${GLUT_INCLUDE_DIR}
|
||||||
|
@ -30,7 +29,6 @@ LINK_DIRECTORIES(
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE( assimp_simpletexturedogl WIN32
|
ADD_EXECUTABLE( assimp_simpletexturedogl WIN32
|
||||||
SimpleTexturedOpenGL/include/boost_includes.h
|
|
||||||
SimpleTexturedOpenGL/src/model_loading.cpp
|
SimpleTexturedOpenGL/src/model_loading.cpp
|
||||||
${SAMPLES_SHARED_CODE_DIR}/UTFConverter.cpp
|
${SAMPLES_SHARED_CODE_DIR}/UTFConverter.cpp
|
||||||
${SAMPLES_SHARED_CODE_DIR}/UTFConverter.h
|
${SAMPLES_SHARED_CODE_DIR}/UTFConverter.h
|
||||||
|
@ -47,3 +45,4 @@ SET_TARGET_PROPERTIES( assimp_simpletexturedogl PROPERTIES
|
||||||
INSTALL( TARGETS assimp_simpletexturedogl
|
INSTALL( TARGETS assimp_simpletexturedogl
|
||||||
DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev
|
DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
#include <boost/lexical_cast.hpp>
|
|
|
@ -18,8 +18,10 @@
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
|
#pragma warning(disable: 4100) // Disable warning 'unreferenced formal parameter'
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "contrib/stb_image/stb_image.h"
|
#include "contrib/stb_image/stb_image.h"
|
||||||
|
#pragma warning(default: 4100) // Enable warning 'unreferenced formal parameter'
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
@ -38,10 +40,10 @@
|
||||||
// The default hard-coded path. Can be overridden by supplying a path through the command line.
|
// The default hard-coded path. Can be overridden by supplying a path through the command line.
|
||||||
static std::string modelpath = "../../test/models/OBJ/spider.obj";
|
static std::string modelpath = "../../test/models/OBJ/spider.obj";
|
||||||
|
|
||||||
HGLRC hRC=NULL; // Permanent Rendering Context
|
HGLRC hRC=nullptr; // Permanent Rendering Context
|
||||||
HDC hDC=NULL; // Private GDI Device Context
|
HDC hDC=nullptr; // Private GDI Device Context
|
||||||
HWND hWnd=NULL; // Holds Window Handle
|
HWND g_hWnd=nullptr; // Holds Window Handle
|
||||||
HINSTANCE hInstance; // Holds The Instance Of The Application
|
HINSTANCE g_hInstance=nullptr; // Holds The Instance Of The Application
|
||||||
|
|
||||||
bool keys[256]; // Array used for Keyboard Routine;
|
bool keys[256]; // Array used for Keyboard Routine;
|
||||||
bool active=TRUE; // Window Active Flag Set To TRUE by Default
|
bool active=TRUE; // Window Active Flag Set To TRUE by Default
|
||||||
|
@ -64,7 +66,7 @@ GLfloat LightPosition[]= { 0.0f, 0.0f, 15.0f, 1.0f };
|
||||||
|
|
||||||
|
|
||||||
// the global Assimp scene object
|
// the global Assimp scene object
|
||||||
const aiScene* scene = NULL;
|
const aiScene* g_scene = nullptr;
|
||||||
GLuint scene_list = 0;
|
GLuint scene_list = 0;
|
||||||
aiVector3D scene_min, scene_max, scene_center;
|
aiVector3D scene_min, scene_max, scene_center;
|
||||||
|
|
||||||
|
@ -122,15 +124,15 @@ bool Import3DFromFile( const std::string& pFile)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox(NULL, UTFConverter("Couldn't open file: " + pFile).c_wstr() , TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(nullptr, UTFConverter("Couldn't open file: " + pFile).c_wstr() , TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||||
logInfo( importer.GetErrorString());
|
logInfo( importer.GetErrorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
scene = importer.ReadFile( pFile, aiProcessPreset_TargetRealtime_Quality);
|
g_scene = importer.ReadFile(pFile, aiProcessPreset_TargetRealtime_Quality);
|
||||||
|
|
||||||
// If the import failed, report it
|
// If the import failed, report it
|
||||||
if( !scene)
|
if(!g_scene)
|
||||||
{
|
{
|
||||||
logInfo( importer.GetErrorString());
|
logInfo( importer.GetErrorString());
|
||||||
return false;
|
return false;
|
||||||
|
@ -179,7 +181,7 @@ void freeTextureIds()
|
||||||
if (textureIds)
|
if (textureIds)
|
||||||
{
|
{
|
||||||
delete[] textureIds;
|
delete[] textureIds;
|
||||||
textureIds = NULL;
|
textureIds = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +217,7 @@ int LoadGLTextures(const aiScene* scene)
|
||||||
while (texFound == AI_SUCCESS)
|
while (texFound == AI_SUCCESS)
|
||||||
{
|
{
|
||||||
texFound = scene->mMaterials[m]->GetTexture(aiTextureType_DIFFUSE, texIndex, &path);
|
texFound = scene->mMaterials[m]->GetTexture(aiTextureType_DIFFUSE, texIndex, &path);
|
||||||
textureIdMap[path.data] = NULL; //fill map with textures, pointers still NULL yet
|
textureIdMap[path.data] = nullptr; //fill map with textures, pointers still NULL yet
|
||||||
texIndex++;
|
texIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +285,7 @@ int LoadGLTextures(const aiScene* scene)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Error occurred */
|
/* Error occurred */
|
||||||
MessageBox(NULL, UTFConverter("Couldn't load Image: " + fileloc).c_wstr(), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(nullptr, UTFConverter("Couldn't load Image: " + fileloc).c_wstr(), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Because we have already copied image data into texture data we can release memory used by image.
|
// Because we have already copied image data into texture data we can release memory used by image.
|
||||||
|
@ -299,7 +301,7 @@ int LoadGLTextures(const aiScene* scene)
|
||||||
// All Setup For OpenGL goes here
|
// All Setup For OpenGL goes here
|
||||||
int InitGL()
|
int InitGL()
|
||||||
{
|
{
|
||||||
if (!LoadGLTextures(scene))
|
if (!LoadGLTextures(g_scene))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -440,12 +442,12 @@ void recursive_render (const struct aiScene *sc, const struct aiNode* nd, float
|
||||||
// draw all meshes assigned to this node
|
// draw all meshes assigned to this node
|
||||||
for (; n < nd->mNumMeshes; ++n)
|
for (; n < nd->mNumMeshes; ++n)
|
||||||
{
|
{
|
||||||
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
|
const struct aiMesh* mesh = sc->mMeshes[nd->mMeshes[n]];
|
||||||
|
|
||||||
apply_material(sc->mMaterials[mesh->mMaterialIndex]);
|
apply_material(sc->mMaterials[mesh->mMaterialIndex]);
|
||||||
|
|
||||||
|
|
||||||
if(mesh->mNormals == NULL)
|
if(mesh->mNormals == nullptr)
|
||||||
{
|
{
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
@ -454,7 +456,7 @@ void recursive_render (const struct aiScene *sc, const struct aiNode* nd, float
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mesh->mColors[0] != NULL)
|
if(mesh->mColors[0] != nullptr)
|
||||||
{
|
{
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
}
|
}
|
||||||
|
@ -480,9 +482,9 @@ void recursive_render (const struct aiScene *sc, const struct aiNode* nd, float
|
||||||
for(i = 0; i < face->mNumIndices; i++) // go through all vertices in face
|
for(i = 0; i < face->mNumIndices; i++) // go through all vertices in face
|
||||||
{
|
{
|
||||||
int vertexIndex = face->mIndices[i]; // get group index for current index
|
int vertexIndex = face->mIndices[i]; // get group index for current index
|
||||||
if(mesh->mColors[0] != NULL)
|
if(mesh->mColors[0] != nullptr)
|
||||||
Color4f(&mesh->mColors[0][vertexIndex]);
|
Color4f(&mesh->mColors[0][vertexIndex]);
|
||||||
if(mesh->mNormals != NULL)
|
if(mesh->mNormals != nullptr)
|
||||||
|
|
||||||
if(mesh->HasTextureCoords(0)) //HasTextureCoords(texture_coordinates_set)
|
if(mesh->HasTextureCoords(0)) //HasTextureCoords(texture_coordinates_set)
|
||||||
{
|
{
|
||||||
|
@ -527,7 +529,7 @@ int DrawGLScene() //Here's where we do all the drawing
|
||||||
glRotatef(yrot, 0.0f, 1.0f, 0.0f);
|
glRotatef(yrot, 0.0f, 1.0f, 0.0f);
|
||||||
glRotatef(zrot, 0.0f, 0.0f, 1.0f);
|
glRotatef(zrot, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
drawAiScene(scene);
|
drawAiScene(g_scene);
|
||||||
|
|
||||||
//xrot+=0.3f;
|
//xrot+=0.3f;
|
||||||
yrot+=0.2f;
|
yrot+=0.2f;
|
||||||
|
@ -541,50 +543,50 @@ void KillGLWindow() // Properly Kill The Window
|
||||||
{
|
{
|
||||||
if (fullscreen) // Are We In Fullscreen Mode?
|
if (fullscreen) // Are We In Fullscreen Mode?
|
||||||
{
|
{
|
||||||
ChangeDisplaySettings(NULL, 0); // If So Switch Back To The Desktop
|
ChangeDisplaySettings(nullptr, 0); // If So Switch Back To The Desktop
|
||||||
ShowCursor(TRUE); // Show Mouse Pointer
|
ShowCursor(TRUE); // Show Mouse Pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hRC) // Do We Have A Rendering Context?
|
if (hRC) // Do We Have A Rendering Context?
|
||||||
{
|
{
|
||||||
if (!wglMakeCurrent(NULL, NULL)) // Are We Able To Release The DC And RC Contexts?
|
if (!wglMakeCurrent(nullptr, nullptr)) // Are We Able To Release The DC And RC Contexts?
|
||||||
{
|
{
|
||||||
MessageBox(NULL, TEXT("Release Of DC And RC Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Release Of DC And RC Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
|
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
|
||||||
{
|
{
|
||||||
MessageBox(NULL, TEXT("Release Rendering Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Release Rendering Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
hRC = NULL;
|
hRC = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hDC)
|
if (hDC)
|
||||||
{
|
{
|
||||||
if (!ReleaseDC(hWnd, hDC)) // Are We able to Release The DC?
|
if (!ReleaseDC(g_hWnd, hDC)) // Are We able to Release The DC?
|
||||||
MessageBox(NULL, TEXT("Release Device Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Release Device Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
hDC = NULL;
|
hDC = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hWnd)
|
if (g_hWnd)
|
||||||
{
|
{
|
||||||
if (!DestroyWindow(hWnd)) // Are We Able To Destroy The Window
|
if (!DestroyWindow(g_hWnd)) // Are We Able To Destroy The Window
|
||||||
MessageBox(NULL, TEXT("Could Not Release hWnd."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Could Not Release hWnd."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
hWnd = NULL;
|
g_hWnd = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hInstance)
|
if (g_hInstance)
|
||||||
{
|
{
|
||||||
if (!UnregisterClass(TEXT("OpenGL"), hInstance)) // Are We Able To Unregister Class
|
if (!UnregisterClass(TEXT("OpenGL"), g_hInstance)) // Are We Able To Unregister Class
|
||||||
MessageBox(NULL, TEXT("Could Not Unregister Class."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Could Not Unregister Class."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
hInstance = NULL;
|
g_hInstance = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLboolean abortGLInit(const char* abortMessage)
|
GLboolean abortGLInit(const char* abortMessage)
|
||||||
{
|
{
|
||||||
KillGLWindow(); // Reset Display
|
KillGLWindow(); // Reset Display
|
||||||
MessageBox(NULL, UTFConverter(abortMessage).c_wstr(), TEXT("ERROR"), MB_OK|MB_ICONEXCLAMATION);
|
MessageBox(nullptr, UTFConverter(abortMessage).c_wstr(), TEXT("ERROR"), MB_OK|MB_ICONEXCLAMATION);
|
||||||
return FALSE; // quit and return False
|
return FALSE; // quit and return False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,21 +604,21 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
|
|
||||||
fullscreen = fullscreenflag;
|
fullscreen = fullscreenflag;
|
||||||
|
|
||||||
hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
|
g_hInstance = GetModuleHandle(nullptr); // Grab An Instance For Our Window
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Move, And Own DC For Window
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Move, And Own DC For Window
|
||||||
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc handles Messages
|
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc handles Messages
|
||||||
wc.cbClsExtra = 0; // No Extra Window Data
|
wc.cbClsExtra = 0; // No Extra Window Data
|
||||||
wc.cbWndExtra = 0; // No Extra Window Data
|
wc.cbWndExtra = 0; // No Extra Window Data
|
||||||
wc.hInstance = hInstance;
|
wc.hInstance = g_hInstance;
|
||||||
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
|
wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO); // Load The Default Icon
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load the default arrow
|
wc.hCursor = LoadCursor(nullptr, IDC_ARROW); // Load the default arrow
|
||||||
wc.hbrBackground= NULL; // No Background required for OpenGL
|
wc.hbrBackground= nullptr; // No Background required for OpenGL
|
||||||
wc.lpszMenuName = NULL; // No Menu
|
wc.lpszMenuName = nullptr; // No Menu
|
||||||
wc.lpszClassName= TEXT("OpenGL"); // Class Name
|
wc.lpszClassName= TEXT("OpenGL"); // Class Name
|
||||||
|
|
||||||
if (!RegisterClass(&wc))
|
if (!RegisterClass(&wc))
|
||||||
{
|
{
|
||||||
MessageBox(NULL, TEXT("Failed to register the window class"), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(nullptr, TEXT("Failed to register the window class"), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||||
return FALSE; //exit and return false
|
return FALSE; //exit and return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,14 +636,14 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
|
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
// If The Mode Fails, Offer Two Options. Quit Or Run In A Window.
|
// If The Mode Fails, Offer Two Options. Quit Or Run In A Window.
|
||||||
if (MessageBox(NULL,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
if (MessageBox(nullptr,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
||||||
{
|
{
|
||||||
fullscreen = FALSE; // Select Windowed Mode (Fullscreen = FALSE)
|
fullscreen = FALSE; // Select Windowed Mode (Fullscreen = FALSE)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Popup Messagebox: Closing
|
//Popup Messagebox: Closing
|
||||||
MessageBox(NULL, TEXT("Program will close now."), TEXT("ERROR"), MB_OK|MB_ICONSTOP);
|
MessageBox(nullptr, TEXT("Program will close now."), TEXT("ERROR"), MB_OK|MB_ICONSTOP);
|
||||||
return FALSE; //exit, return false
|
return FALSE; //exit, return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -661,7 +663,7 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
|
|
||||||
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requestes Size
|
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requestes Size
|
||||||
|
|
||||||
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
|
if (nullptr == (g_hWnd=CreateWindowEx(dwExStyle, // Extended Style For The Window
|
||||||
TEXT("OpenGL"), // Class Name
|
TEXT("OpenGL"), // Class Name
|
||||||
UTFConverter(title).c_wstr(), // Window Title
|
UTFConverter(title).c_wstr(), // Window Title
|
||||||
WS_CLIPSIBLINGS | // Required Window Style
|
WS_CLIPSIBLINGS | // Required Window Style
|
||||||
|
@ -670,10 +672,10 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
0, 0, // Window Position
|
0, 0, // Window Position
|
||||||
WindowRect.right-WindowRect.left, // Calc adjusted Window Width
|
WindowRect.right-WindowRect.left, // Calc adjusted Window Width
|
||||||
WindowRect.bottom-WindowRect.top, // Calc adjustes Window Height
|
WindowRect.bottom-WindowRect.top, // Calc adjustes Window Height
|
||||||
NULL, // No Parent Window
|
nullptr, // No Parent Window
|
||||||
NULL, // No Menu
|
nullptr, // No Menu
|
||||||
hInstance, // Instance
|
g_hInstance, // Instance
|
||||||
NULL ))) // Don't pass anything To WM_CREATE
|
nullptr ))) // Don't pass anything To WM_CREATE
|
||||||
{
|
{
|
||||||
abortGLInit("Window Creation Error.");
|
abortGLInit("Window Creation Error.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -701,13 +703,13 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
0, 0, 0 // Layer Masks Ignored
|
0, 0, 0 // Layer Masks Ignored
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(hDC=GetDC(hWnd))) // Did we get the Device Context?
|
if (nullptr == (hDC=GetDC(g_hWnd))) // Did we get the Device Context?
|
||||||
{
|
{
|
||||||
abortGLInit("Can't Create A GL Device Context.");
|
abortGLInit("Can't Create A GL Device Context.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(PixelFormat=ChoosePixelFormat(hDC, &pfd))) // Did We Find a matching pixel Format?
|
if (0 == (PixelFormat=ChoosePixelFormat(hDC, &pfd))) // Did We Find a matching pixel Format?
|
||||||
{
|
{
|
||||||
abortGLInit("Can't Find Suitable PixelFormat");
|
abortGLInit("Can't Find Suitable PixelFormat");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -719,7 +721,7 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(hRC=wglCreateContext(hDC)))
|
if (nullptr == (hRC=wglCreateContext(hDC)))
|
||||||
{
|
{
|
||||||
abortGLInit("Can't Create A GL Rendering Context.");
|
abortGLInit("Can't Create A GL Rendering Context.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -733,9 +735,9 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
|
|
||||||
//// *** everything okay ***
|
//// *** everything okay ***
|
||||||
|
|
||||||
ShowWindow(hWnd, SW_SHOW); // Show The Window
|
ShowWindow(g_hWnd, SW_SHOW); // Show The Window
|
||||||
SetForegroundWindow(hWnd); // Slightly Higher Prio
|
SetForegroundWindow(g_hWnd); // Slightly Higher Prio
|
||||||
SetFocus(hWnd); // Sets Keyboard Focus To The Window
|
SetFocus(g_hWnd); // Sets Keyboard Focus To The Window
|
||||||
ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
|
ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
|
||||||
|
|
||||||
if (!InitGL())
|
if (!InitGL())
|
||||||
|
@ -753,7 +755,7 @@ void cleanup()
|
||||||
|
|
||||||
destroyAILogger();
|
destroyAILogger();
|
||||||
|
|
||||||
if (hWnd)
|
if (g_hWnd)
|
||||||
KillGLWindow();
|
KillGLWindow();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -818,12 +820,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, // Handles for this Window
|
||||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI WinMain( HINSTANCE hInstance, // The instance
|
int WINAPI WinMain( HINSTANCE /*hInstance*/, // The instance
|
||||||
HINSTANCE hPrevInstance, // Previous instance
|
HINSTANCE /*hPrevInstance*/, // Previous instance
|
||||||
LPSTR lpCmdLine, // Command Line Parameters
|
LPSTR /*lpCmdLine*/, // Command Line Parameters
|
||||||
int nShowCmd ) // Window Show State
|
int /*nShowCmd*/ ) // Window Show State
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg = {};
|
||||||
BOOL done=FALSE;
|
BOOL done=FALSE;
|
||||||
|
|
||||||
createAILogger();
|
createAILogger();
|
||||||
|
@ -832,7 +834,7 @@ int WINAPI WinMain( HINSTANCE hInstance, // The instance
|
||||||
// Check the command line for an override file path.
|
// Check the command line for an override file path.
|
||||||
int argc;
|
int argc;
|
||||||
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||||
if (argv != NULL && argc > 1)
|
if (argv != nullptr && argc > 1)
|
||||||
{
|
{
|
||||||
std::wstring modelpathW(argv[1]);
|
std::wstring modelpathW(argv[1]);
|
||||||
modelpath = UTFConverter(modelpathW).str();
|
modelpath = UTFConverter(modelpathW).str();
|
||||||
|
@ -846,7 +848,7 @@ int WINAPI WinMain( HINSTANCE hInstance, // The instance
|
||||||
|
|
||||||
logInfo("=============== Post Import ====================");
|
logInfo("=============== Post Import ====================");
|
||||||
|
|
||||||
if (MessageBox(NULL, TEXT("Would You Like To Run In Fullscreen Mode?"), TEXT("Start Fullscreen?"), MB_YESNO|MB_ICONEXCLAMATION)==IDNO)
|
if (MessageBox(nullptr, TEXT("Would You Like To Run In Fullscreen Mode?"), TEXT("Start Fullscreen?"), MB_YESNO|MB_ICONEXCLAMATION)==IDNO)
|
||||||
{
|
{
|
||||||
fullscreen=FALSE;
|
fullscreen=FALSE;
|
||||||
}
|
}
|
||||||
|
@ -859,7 +861,7 @@ int WINAPI WinMain( HINSTANCE hInstance, // The instance
|
||||||
|
|
||||||
while(!done) // Game Loop
|
while(!done) // Game Loop
|
||||||
{
|
{
|
||||||
if (PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
|
if (PeekMessage(&msg, nullptr, 0,0, PM_REMOVE))
|
||||||
{
|
{
|
||||||
if (msg.message==WM_QUIT)
|
if (msg.message==WM_QUIT)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,6 +61,14 @@ SET( COMMON
|
||||||
unit/utIssues.cpp
|
unit/utIssues.cpp
|
||||||
unit/utAnim.cpp
|
unit/utAnim.cpp
|
||||||
unit/AssimpAPITest.cpp
|
unit/AssimpAPITest.cpp
|
||||||
|
unit/AssimpAPITest_aiMatrix3x3.cpp
|
||||||
|
unit/AssimpAPITest_aiMatrix4x4.cpp
|
||||||
|
unit/AssimpAPITest_aiQuaternion.cpp
|
||||||
|
unit/AssimpAPITest_aiVector2D.cpp
|
||||||
|
unit/AssimpAPITest_aiVector3D.cpp
|
||||||
|
unit/MathTest.cpp
|
||||||
|
unit/MathTest.h
|
||||||
|
unit/RandomNumberGeneration.h
|
||||||
unit/utBatchLoader.cpp
|
unit/utBatchLoader.cpp
|
||||||
unit/utDefaultIOStream.cpp
|
unit/utDefaultIOStream.cpp
|
||||||
unit/utFastAtof.cpp
|
unit/utFastAtof.cpp
|
||||||
|
@ -76,10 +84,12 @@ SET( COMMON
|
||||||
unit/utProfiler.cpp
|
unit/utProfiler.cpp
|
||||||
unit/utSharedPPData.cpp
|
unit/utSharedPPData.cpp
|
||||||
unit/utStringUtils.cpp
|
unit/utStringUtils.cpp
|
||||||
|
unit/Common/uiScene.cpp
|
||||||
unit/Common/utLineSplitter.cpp
|
unit/Common/utLineSplitter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( IMPORTERS
|
SET( IMPORTERS
|
||||||
|
unit/ImportExport/Assxml/utAssxmlImportExport.cpp
|
||||||
unit/utLWSImportExport.cpp
|
unit/utLWSImportExport.cpp
|
||||||
unit/utLWOImportExport.cpp
|
unit/utLWOImportExport.cpp
|
||||||
unit/utSMDImportExport.cpp
|
unit/utSMDImportExport.cpp
|
||||||
|
@ -136,6 +146,9 @@ SET( IMPORTERS
|
||||||
unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp
|
unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp
|
||||||
unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp
|
unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp
|
||||||
unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
|
unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
|
||||||
|
#unit/ImportExport/IRR/utIrrImportExport.cpp
|
||||||
|
unit/ImportExport/RAW/utRAWImportExport.cpp
|
||||||
|
unit/ImportExport/Terragen/utTerragenImportExport.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( MATERIAL
|
SET( MATERIAL
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"asset": {
|
||||||
|
"version": "2.0"
|
||||||
|
},
|
||||||
|
"scene": 0
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"asset": {
|
||||||
|
"version": "2.0"
|
||||||
|
},
|
||||||
|
"scene": 0,
|
||||||
|
"scenes": [
|
||||||
|
{
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiMatrix3x3 : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiMatrix3x3();
|
||||||
|
}
|
||||||
|
|
||||||
|
aiMatrix3x3 result_c, result_cpp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiIdentityMatrix3Test) {
|
||||||
|
// Force a non-identity matrix.
|
||||||
|
result_c = aiMatrix3x3(0,0,0,0,0,0,0,0,0);
|
||||||
|
aiIdentityMatrix3(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromMatrix4Test) {
|
||||||
|
const auto m = random_mat4();
|
||||||
|
result_cpp = aiMatrix3x3(m);
|
||||||
|
aiMatrix3FromMatrix4(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromQuaternionTest) {
|
||||||
|
const auto q = random_quat();
|
||||||
|
result_cpp = q.GetMatrix();
|
||||||
|
aiMatrix3FromQuaternion(&result_c, &q);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3AreEqualTest) {
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiMatrix3AreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3AreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiMatrix3AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMultiplyMatrix3Test) {
|
||||||
|
const auto m = random_mat3();
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
result_cpp *= m;
|
||||||
|
aiMultiplyMatrix3(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiTransposeMatrix3Test) {
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
result_cpp.Transpose();
|
||||||
|
aiTransposeMatrix3(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3InverseTest) {
|
||||||
|
// Use a predetermined matrix to prevent arbitrary
|
||||||
|
// cases where it could have a null determinant.
|
||||||
|
result_c = result_cpp = aiMatrix3x3(
|
||||||
|
5, 2, 7,
|
||||||
|
4, 6, 9,
|
||||||
|
1, 8, 3);
|
||||||
|
result_cpp.Inverse();
|
||||||
|
aiMatrix3Inverse(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3DeterminantTest) {
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
EXPECT_EQ(result_cpp.Determinant(),
|
||||||
|
aiMatrix3Determinant(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3RotationZTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
aiMatrix3x3::RotationZ(angle, result_cpp);
|
||||||
|
aiMatrix3RotationZ(&result_c, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromRotationAroundAxisTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
const auto axis = random_unit_vec3();
|
||||||
|
aiMatrix3x3::Rotation(angle, axis, result_cpp);
|
||||||
|
aiMatrix3FromRotationAroundAxis(&result_c, &axis, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3TranslationTest) {
|
||||||
|
const auto axis = random_vec2();
|
||||||
|
aiMatrix3x3::Translation(axis, result_cpp);
|
||||||
|
aiMatrix3Translation(&result_c, &axis);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromToTest) {
|
||||||
|
// Use predetermined vectors to prevent running into division by zero.
|
||||||
|
const auto from = aiVector3D(1,2,1).Normalize(), to = aiVector3D(-1,1,1).Normalize();
|
||||||
|
aiMatrix3x3::FromToMatrix(from, to, result_cpp);
|
||||||
|
aiMatrix3FromTo(&result_c, &from, &to);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
|
@ -0,0 +1,259 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiMatrix4x4 : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiMatrix4x4();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generates a predetermined transformation matrix to use
|
||||||
|
for the aiDecompose functions to prevent running into
|
||||||
|
division by zero. */
|
||||||
|
aiMatrix4x4 get_predetermined_transformation_matrix_for_decomposition() const {
|
||||||
|
aiMatrix4x4 t, r;
|
||||||
|
aiMatrix4x4::Translation(aiVector3D(14,-25,-8), t);
|
||||||
|
aiMatrix4x4::Rotation(Math::PI<float>() / 4.0f, aiVector3D(1).Normalize(), r);
|
||||||
|
return t * r;
|
||||||
|
}
|
||||||
|
|
||||||
|
aiMatrix4x4 result_c, result_cpp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiIdentityMatrix4Test) {
|
||||||
|
// Force a non-identity matrix.
|
||||||
|
result_c = aiMatrix4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
|
||||||
|
aiIdentityMatrix4(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromMatrix3Test) {
|
||||||
|
aiMatrix3x3 m = random_mat3();
|
||||||
|
result_cpp = aiMatrix4x4(m);
|
||||||
|
aiMatrix4FromMatrix3(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromScalingQuaternionPositionTest) {
|
||||||
|
const aiVector3D s = random_vec3();
|
||||||
|
const aiQuaternion q = random_quat();
|
||||||
|
const aiVector3D t = random_vec3();
|
||||||
|
result_cpp = aiMatrix4x4(s, q, t);
|
||||||
|
aiMatrix4FromScalingQuaternionPosition(&result_c, &s, &q, &t);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AddTest) {
|
||||||
|
const aiMatrix4x4 temp = random_mat4();
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
result_cpp = result_cpp + temp;
|
||||||
|
aiMatrix4Add(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AreEqualTest) {
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiMatrix4AreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiMatrix4AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMultiplyMatrix4Test) {
|
||||||
|
const auto m = random_mat4();
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
result_cpp *= m;
|
||||||
|
aiMultiplyMatrix4(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiTransposeMatrix4Test) {
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
result_cpp.Transpose();
|
||||||
|
aiTransposeMatrix4(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4InverseTest) {
|
||||||
|
// Use a predetermined matrix to prevent arbitrary
|
||||||
|
// cases where it could have a null determinant.
|
||||||
|
result_c = result_cpp = aiMatrix4x4(
|
||||||
|
6, 10, 15, 3,
|
||||||
|
14, 2, 12, 8,
|
||||||
|
9, 13, 5, 16,
|
||||||
|
4, 7, 11, 1);
|
||||||
|
result_cpp.Inverse();
|
||||||
|
aiMatrix4Inverse(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DeterminantTest) {
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
EXPECT_EQ(result_cpp.Determinant(),
|
||||||
|
aiMatrix4Determinant(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4IsIdentityTest) {
|
||||||
|
EXPECT_EQ(result_cpp.IsIdentity(),
|
||||||
|
(bool)aiMatrix4IsIdentity(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiDecomposeMatrixTest) {
|
||||||
|
aiVector3D scaling_c, scaling_cpp,
|
||||||
|
position_c, position_cpp;
|
||||||
|
aiQuaternion rotation_c, rotation_cpp;
|
||||||
|
|
||||||
|
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
|
||||||
|
result_cpp.Decompose(scaling_cpp, rotation_cpp, position_cpp);
|
||||||
|
aiDecomposeMatrix(&result_c, &scaling_c, &rotation_c, &position_c);
|
||||||
|
EXPECT_EQ(scaling_cpp, scaling_c);
|
||||||
|
EXPECT_EQ(position_cpp, position_c);
|
||||||
|
EXPECT_EQ(rotation_cpp, rotation_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeIntoScalingEulerAnglesPositionTest) {
|
||||||
|
aiVector3D scaling_c, scaling_cpp,
|
||||||
|
rotation_c, rotation_cpp,
|
||||||
|
position_c, position_cpp;
|
||||||
|
|
||||||
|
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
|
||||||
|
result_cpp.Decompose(scaling_cpp, rotation_cpp, position_cpp);
|
||||||
|
aiMatrix4DecomposeIntoScalingEulerAnglesPosition(&result_c, &scaling_c, &rotation_c, &position_c);
|
||||||
|
EXPECT_EQ(scaling_cpp, scaling_c);
|
||||||
|
EXPECT_EQ(position_cpp, position_c);
|
||||||
|
EXPECT_EQ(rotation_cpp, rotation_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeIntoScalingAxisAnglePositionTest) {
|
||||||
|
aiVector3D scaling_c, scaling_cpp,
|
||||||
|
axis_c, axis_cpp,
|
||||||
|
position_c, position_cpp;
|
||||||
|
float angle_c, angle_cpp;
|
||||||
|
|
||||||
|
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
|
||||||
|
result_cpp.Decompose(scaling_cpp, axis_cpp, angle_cpp, position_cpp);
|
||||||
|
aiMatrix4DecomposeIntoScalingAxisAnglePosition(&result_c, &scaling_c, &axis_c, &angle_c, &position_c);
|
||||||
|
EXPECT_EQ(scaling_cpp, scaling_c);
|
||||||
|
EXPECT_EQ(axis_cpp, axis_c);
|
||||||
|
EXPECT_EQ(angle_cpp, angle_c);
|
||||||
|
EXPECT_EQ(position_cpp, position_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeNoScalingTest) {
|
||||||
|
aiVector3D position_c, position_cpp;
|
||||||
|
aiQuaternion rotation_c, rotation_cpp;
|
||||||
|
|
||||||
|
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
|
||||||
|
result_cpp.DecomposeNoScaling(rotation_cpp, position_cpp);
|
||||||
|
aiMatrix4DecomposeNoScaling(&result_c, &rotation_c, &position_c);
|
||||||
|
EXPECT_EQ(position_cpp, position_c);
|
||||||
|
EXPECT_EQ(rotation_cpp, rotation_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromEulerAnglesTest) {
|
||||||
|
const float x(RandPI.next()),
|
||||||
|
y(RandPI.next()),
|
||||||
|
z(RandPI.next());
|
||||||
|
result_cpp.FromEulerAnglesXYZ(x, y, z);
|
||||||
|
aiMatrix4FromEulerAngles(&result_c, x, y, z);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationXTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
aiMatrix4x4::RotationX(angle, result_cpp);
|
||||||
|
aiMatrix4RotationX(&result_c, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationYTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
aiMatrix4x4::RotationY(angle, result_cpp);
|
||||||
|
aiMatrix4RotationY(&result_c, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationZTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
aiMatrix4x4::RotationZ(angle, result_cpp);
|
||||||
|
aiMatrix4RotationZ(&result_c, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromRotationAroundAxisTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
const auto axis = random_unit_vec3();
|
||||||
|
aiMatrix4x4::Rotation(angle, axis, result_cpp);
|
||||||
|
aiMatrix4FromRotationAroundAxis(&result_c, &axis, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4TranslationTest) {
|
||||||
|
const auto axis = random_vec3();
|
||||||
|
aiMatrix4x4::Translation(axis, result_cpp);
|
||||||
|
aiMatrix4Translation(&result_c, &axis);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4ScalingTest) {
|
||||||
|
const auto scaling = random_vec3();
|
||||||
|
aiMatrix4x4::Scaling(scaling, result_cpp);
|
||||||
|
aiMatrix4Scaling(&result_c, &scaling);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromToTest) {
|
||||||
|
// Use predetermined vectors to prevent running into division by zero.
|
||||||
|
const auto from = aiVector3D(1,2,1).Normalize(), to = aiVector3D(-1,1,1).Normalize();
|
||||||
|
aiMatrix4x4::FromToMatrix(from, to, result_cpp);
|
||||||
|
aiMatrix4FromTo(&result_c, &from, &to);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiQuaternion : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiQuaternion();
|
||||||
|
}
|
||||||
|
|
||||||
|
aiQuaternion result_c, result_cpp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiCreateQuaternionFromMatrixTest) {
|
||||||
|
// Use a predetermined transformation matrix
|
||||||
|
// to prevent running into division by zero.
|
||||||
|
aiMatrix3x3 m, r;
|
||||||
|
aiMatrix3x3::Translation(aiVector2D(14,-25), m);
|
||||||
|
aiMatrix3x3::RotationZ(Math::PI<float>() / 4.0f, r);
|
||||||
|
m = m * r;
|
||||||
|
|
||||||
|
result_cpp = aiQuaternion(m);
|
||||||
|
aiCreateQuaternionFromMatrix(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromEulerAnglesTest) {
|
||||||
|
const float x(RandPI.next()),
|
||||||
|
y(RandPI.next()),
|
||||||
|
z(RandPI.next());
|
||||||
|
result_cpp = aiQuaternion(x, y, z);
|
||||||
|
aiQuaternionFromEulerAngles(&result_c, x, y, z);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromAxisAngleTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
const aiVector3D axis(random_unit_vec3());
|
||||||
|
result_cpp = aiQuaternion(axis, angle);
|
||||||
|
aiQuaternionFromAxisAngle(&result_c, &axis, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromNormalizedQuaternionTest) {
|
||||||
|
const auto qvec3 = random_unit_vec3();
|
||||||
|
result_cpp = aiQuaternion(qvec3);
|
||||||
|
aiQuaternionFromNormalizedQuaternion(&result_c, &qvec3);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionAreEqualTest) {
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiQuaternionAreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionAreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiQuaternionAreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionNormalizeTest) {
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
aiQuaternionNormalize(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.Normalize(), result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionConjugateTest) {
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
aiQuaternionConjugate(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.Conjugate(), result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionMultiplyTest) {
|
||||||
|
const aiQuaternion temp = random_quat();
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
result_cpp = result_cpp * temp;
|
||||||
|
aiQuaternionMultiply(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionInterpolateTest) {
|
||||||
|
// Use predetermined quaternions to prevent division by zero
|
||||||
|
// during slerp calculations.
|
||||||
|
const float INTERPOLATION(0.5f);
|
||||||
|
const auto q1 = aiQuaternion(aiVector3D(-1,1,1).Normalize(), Math::PI<float>() / 4.0f);
|
||||||
|
const auto q2 = aiQuaternion(aiVector3D(1,2,1).Normalize(), Math::PI<float>() / 2.0f);
|
||||||
|
aiQuaternion::Interpolate(result_cpp, q1, q2, INTERPOLATION);
|
||||||
|
aiQuaternionInterpolate(&result_c, &q1, &q2, INTERPOLATION);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiVector2D : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiVector2D();
|
||||||
|
temp = random_vec2(); // Generates a random 2D vector != null vector.
|
||||||
|
}
|
||||||
|
|
||||||
|
aiVector2D result_c, result_cpp, temp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2AreEqualTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiVector2AreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2AreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiVector2AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2AddTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp += temp;
|
||||||
|
aiVector2Add(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2SubtractTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp -= temp;
|
||||||
|
aiVector2Subtract(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2ScaleTest) {
|
||||||
|
const float FACTOR = RandNonZero.next();
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp *= FACTOR;
|
||||||
|
aiVector2Scale(&result_c, FACTOR);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2SymMulTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp = result_cpp.SymMul(temp);
|
||||||
|
aiVector2SymMul(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2DivideByScalarTest) {
|
||||||
|
const float DIVISOR = RandNonZero.next();
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp /= DIVISOR;
|
||||||
|
aiVector2DivideByScalar(&result_c, DIVISOR);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2DivideByVectorTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp = result_cpp / temp;
|
||||||
|
aiVector2DivideByVector(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2LengthTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp.Length(), aiVector2Length(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2SquareLengthTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp.SquareLength(), aiVector2SquareLength(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2NegateTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
aiVector2Negate(&result_c);
|
||||||
|
EXPECT_EQ(-result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2DotProductTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp * result_c,
|
||||||
|
aiVector2DotProduct(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2NormalizeTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
aiVector2Normalize(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.Normalize(), result_c);
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiVector3D : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiVector3D();
|
||||||
|
temp = random_vec3(); // Generates a random 3D vector != null vector.
|
||||||
|
}
|
||||||
|
|
||||||
|
aiVector3D result_c, result_cpp, temp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3AreEqualTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiVector3AreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3AreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiVector3AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3LessThanTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp < temp,
|
||||||
|
(bool)aiVector3LessThan(&result_c, &temp));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3AddTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp += temp;
|
||||||
|
aiVector3Add(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3SubtractTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp -= temp;
|
||||||
|
aiVector3Subtract(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3ScaleTest) {
|
||||||
|
const float FACTOR = RandNonZero.next();
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp *= FACTOR;
|
||||||
|
aiVector3Scale(&result_c, FACTOR);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3SymMulTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp = result_cpp.SymMul(temp);
|
||||||
|
aiVector3SymMul(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3DivideByScalarTest) {
|
||||||
|
const float DIVISOR = RandNonZero.next();
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp /= DIVISOR;
|
||||||
|
aiVector3DivideByScalar(&result_c, DIVISOR);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3DivideByVectorTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp = result_cpp / temp;
|
||||||
|
aiVector3DivideByVector(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3LengthTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp.Length(), aiVector3Length(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3SquareLengthTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp.SquareLength(), aiVector3SquareLength(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3NegateTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
aiVector3Negate(&result_c);
|
||||||
|
EXPECT_EQ(-result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3DotProductTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp * result_c,
|
||||||
|
aiVector3DotProduct(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3CrossProductTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp = result_cpp ^ temp;
|
||||||
|
aiVector3CrossProduct(&result_c, &result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3NormalizeTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
aiVector3Normalize(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.Normalize(), result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3NormalizeSafeTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
aiVector3NormalizeSafe(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.NormalizeSafe(), result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3RotateByQuaternionTest) {
|
||||||
|
aiVector3D v_c, v_cpp;
|
||||||
|
v_c = v_cpp = random_vec3();
|
||||||
|
const auto q = random_quat();
|
||||||
|
aiVector3RotateByQuaternion(&v_c, &q);
|
||||||
|
EXPECT_EQ(q.Rotate(v_cpp), v_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiTransformVecByMatrix3Test) {
|
||||||
|
const auto m = random_mat3();
|
||||||
|
aiVector3D v_c, v_cpp;
|
||||||
|
v_c = v_cpp = random_vec3();
|
||||||
|
v_cpp *= m;
|
||||||
|
aiTransformVecByMatrix3(&v_c, &m);
|
||||||
|
EXPECT_EQ(v_cpp, v_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiTransformVecByMatrix4Test) {
|
||||||
|
const auto m = random_mat4();
|
||||||
|
aiVector3D v_c, v_cpp;
|
||||||
|
v_c = v_cpp = random_vec3();
|
||||||
|
v_cpp *= m;
|
||||||
|
aiTransformVecByMatrix4(&v_c, &m);
|
||||||
|
EXPECT_EQ(v_cpp, v_c);
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utScene : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
aiScene *scene;
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
scene = new aiScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
delete scene;
|
||||||
|
scene = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utScene, findNodeTest) {
|
||||||
|
scene->mRootNode = new aiNode();
|
||||||
|
scene->mRootNode->mName.Set("test");
|
||||||
|
aiNode *child = new aiNode;
|
||||||
|
child->mName.Set("child");
|
||||||
|
scene->mRootNode->addChildren(1, &child);
|
||||||
|
aiNode *found = scene->mRootNode->FindNode("child");
|
||||||
|
EXPECT_EQ(child, found);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utScene, sceneHasContentTest) {
|
||||||
|
EXPECT_FALSE(scene->HasAnimations());
|
||||||
|
EXPECT_FALSE(scene->HasMaterials());
|
||||||
|
EXPECT_FALSE(scene->HasMeshes());
|
||||||
|
EXPECT_FALSE(scene->HasCameras());
|
||||||
|
EXPECT_FALSE(scene->HasLights());
|
||||||
|
EXPECT_FALSE(scene->HasTextures());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utScene, getShortFilenameTest) {
|
||||||
|
std::string long_filename1 = "foo_bar/name";
|
||||||
|
const char *name1 = scene->GetShortFilename(long_filename1.c_str());
|
||||||
|
EXPECT_NE(nullptr, name1);
|
||||||
|
|
||||||
|
std::string long_filename2 = "foo_bar\\name";
|
||||||
|
const char *name2 = scene->GetShortFilename(long_filename2.c_str());
|
||||||
|
EXPECT_NE(nullptr, name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utScene, getEmbeddedTextureTest) {
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2019, 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 "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utAssxmlImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
bool importerTest() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
bool exporterTest() override {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
|
||||||
|
EXPECT_NE(scene, nullptr );
|
||||||
|
|
||||||
|
::Assimp::Exporter exporter;
|
||||||
|
return AI_SUCCESS == exporter.Export(scene, "assxml", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.assxml");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
|
TEST_F(utAssxmlImportExport, exportAssxmlTest) {
|
||||||
|
EXPECT_TRUE(exporterTest());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utIrrImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/IRR/box.irr", aiProcess_ValidateDataStructure);
|
||||||
|
return nullptr != scene;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utIrrImportExport, importSimpleIrrTest) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utIrrImportExport, importSGIrrTest) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/IRR/dawfInCellar_SameHierarchy.irr", aiProcess_ValidateDataStructure);
|
||||||
|
EXPECT_NE( nullptr,scene);
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utRAWImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/RAW/Wuson.raw", aiProcess_ValidateDataStructure);
|
||||||
|
#ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
|
||||||
|
return nullptr != scene;
|
||||||
|
#else
|
||||||
|
return nullptr == scene;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utRAWImportExport, importSimpleRAWTest) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
class utTerragenImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
/*Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/TER/RealisticTerrain.ter", aiProcess_ValidateDataStructure);
|
||||||
|
return nullptr != scene;*/
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utTerragenImportExport, importX3DFromFileTest) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
|
@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
// Initialize epsilon value.
|
||||||
|
const float AssimpMathTest::Epsilon = Math::getEpsilon<float>();
|
||||||
|
|
||||||
|
// Initialize with an interval of [1,100].
|
||||||
|
RandomUniformFloatGenerator AssimpMathTest::RandNonZero(1.0f, 100.0f);
|
||||||
|
|
||||||
|
// Initialize with an interval of [-PI,PI] inclusively.
|
||||||
|
RandomUniformFloatGenerator AssimpMathTest::RandPI(-Math::PI<float>(), Math::PI<float>());
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ASSIMP_MATH_TEST_H
|
||||||
|
#define ASSIMP_MATH_TEST_H
|
||||||
|
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include <assimp/types.h>
|
||||||
|
#include "RandomNumberGeneration.h"
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
/** Custom test class providing several math related utilities. */
|
||||||
|
class AssimpMathTest : public ::testing::Test {
|
||||||
|
public:
|
||||||
|
/** Return a random non-null 2D vector. */
|
||||||
|
inline static aiVector2D random_vec2() {
|
||||||
|
return aiVector2D(RandNonZero.next(), RandNonZero.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random non-null 3D vector. */
|
||||||
|
inline static aiVector3D random_vec3() {
|
||||||
|
return aiVector3D(RandNonZero.next(), RandNonZero.next(),RandNonZero.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random unit 3D vector. */
|
||||||
|
inline static aiVector3D random_unit_vec3() {
|
||||||
|
return random_vec3().NormalizeSafe();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a quaternion with random orientation and
|
||||||
|
* rotation angle around axis. */
|
||||||
|
inline static aiQuaternion random_quat() {
|
||||||
|
return aiQuaternion(random_unit_vec3(), RandPI.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random non-null 3x3 matrix. */
|
||||||
|
inline static aiMatrix3x3 random_mat3() {
|
||||||
|
return aiMatrix3x3(
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random non-null 4x4 matrix. */
|
||||||
|
inline static aiMatrix4x4 random_mat4() {
|
||||||
|
return aiMatrix4x4(
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Epsilon value to use in tests. */
|
||||||
|
static const float Epsilon;
|
||||||
|
|
||||||
|
/** Random number generators. */
|
||||||
|
static RandomUniformFloatGenerator RandNonZero, RandPI;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ASSIMP_MATH_TEST_H
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ASSIMP_RANDOM_NUMBER_GENERATION_H
|
||||||
|
#define ASSIMP_RANDOM_NUMBER_GENERATION_H
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
/** Helper class to use for generating pseudo-random
|
||||||
|
* real numbers, with a uniform distribution. */
|
||||||
|
template<typename T>
|
||||||
|
class RandomUniformRealGenerator {
|
||||||
|
public:
|
||||||
|
RandomUniformRealGenerator() :
|
||||||
|
dist_(),
|
||||||
|
rd_(),
|
||||||
|
re_(rd_()) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
RandomUniformRealGenerator(T min, T max) :
|
||||||
|
dist_(min, max),
|
||||||
|
rd_(),
|
||||||
|
re_(rd_()) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
inline T next() {
|
||||||
|
return dist_(re_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::uniform_real_distribution<T> dist_;
|
||||||
|
std::random_device rd_;
|
||||||
|
std::default_random_engine re_;
|
||||||
|
};
|
||||||
|
|
||||||
|
using RandomUniformFloatGenerator = RandomUniformRealGenerator<float>;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ASSIMP_RANDOM_NUMBER_GENERATION_H
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
|
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/commonMetaData.h>
|
#include <assimp/commonMetaData.h>
|
||||||
|
@ -214,6 +213,10 @@ TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
|
||||||
double factor(0.0);
|
double factor(0.0);
|
||||||
scene->mMetaData->Get("UnitScaleFactor", factor);
|
scene->mMetaData->Get("UnitScaleFactor", factor);
|
||||||
EXPECT_DOUBLE_EQ(500.0, factor);
|
EXPECT_DOUBLE_EQ(500.0, factor);
|
||||||
|
|
||||||
|
scene->mMetaData->Set("UnitScaleFactor", factor * 2);
|
||||||
|
scene->mMetaData->Get("UnitScaleFactor", factor);
|
||||||
|
EXPECT_DOUBLE_EQ(1000.0, factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
|
TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
|
||||||
|
|
|
@ -41,9 +41,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ using namespace Assimp;
|
||||||
|
|
||||||
class utM3DImportExport : public AbstractImportExportBase {
|
class utM3DImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
bool importerTest() override {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
|
||||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||||
|
@ -60,8 +61,24 @@ public:
|
||||||
return nullptr == scene;
|
return nullptr == scene;
|
||||||
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
|
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
bool exporterTest() override {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
|
||||||
|
Exporter exporter;
|
||||||
|
aiReturn ret = exporter.Export(scene, "m3d", ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals_out.m3d");
|
||||||
|
return ret == AI_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(utM3DImportExport, importM3DFromFileTest) {
|
TEST_F(utM3DImportExport, importM3DFromFileTest) {
|
||||||
EXPECT_TRUE(importerTest());
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
TEST_F(utM3DImportExport, exportM3DFromFileTest) {
|
||||||
|
EXPECT_TRUE(exporterTest());
|
||||||
|
}
|
||||||
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "MMD/MMDImporter.h"
|
#include "MMD/MMDImporter.h"
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
|
@ -490,3 +490,16 @@ TEST_F(utglTF2ImportExport, texcoords) {
|
||||||
EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_UNKNOWN, 0), &uvIndex), aiReturn_SUCCESS);
|
EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_UNKNOWN, 0), &uvIndex), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ(uvIndex, 1);
|
EXPECT_EQ(uvIndex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(utglTF2ImportExport, norootnode_noscene) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/TestNoRootNode/NoScene.gltf", aiProcess_ValidateDataStructure);
|
||||||
|
ASSERT_EQ(scene, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utglTF2ImportExport, norootnode_scenewithoutnodes) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/TestNoRootNode/SceneWithoutNodes.gltf", aiProcess_ValidateDataStructure);
|
||||||
|
ASSERT_NE(scene, nullptr);
|
||||||
|
ASSERT_NE(scene->mRootNode, nullptr);
|
||||||
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ void CBackgroundPainter::SetColor (D3DCOLOR p_clrNew)
|
||||||
if (pcTexture)
|
if (pcTexture)
|
||||||
{
|
{
|
||||||
pcTexture->Release();
|
pcTexture->Release();
|
||||||
pcTexture = NULL;
|
pcTexture = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -135,7 +135,7 @@ void CBackgroundPainter::SetCubeMapBG (const char* p_szPath)
|
||||||
if (pcTexture)
|
if (pcTexture)
|
||||||
{
|
{
|
||||||
pcTexture->Release();
|
pcTexture->Release();
|
||||||
pcTexture = NULL;
|
pcTexture = nullptr;
|
||||||
if(TEXTURE_CUBE ==eMode)bHad = true;
|
if(TEXTURE_CUBE ==eMode)bHad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ void CBackgroundPainter::SetTextureBG (const char* p_szPath)
|
||||||
if (pcTexture)
|
if (pcTexture)
|
||||||
{
|
{
|
||||||
pcTexture->Release();
|
pcTexture->Release();
|
||||||
pcTexture = NULL;
|
pcTexture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
eMode = TEXTURE_2D;
|
eMode = TEXTURE_2D;
|
||||||
|
@ -223,12 +223,12 @@ void CBackgroundPainter::OnPreRender()
|
||||||
// the color buffer )
|
// the color buffer )
|
||||||
if (g_sOptions.eDrawMode == RenderOptions::WIREFRAME)
|
if (g_sOptions.eDrawMode == RenderOptions::WIREFRAME)
|
||||||
{
|
{
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,
|
g_piDevice->Clear(0,nullptr,D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,
|
||||||
D3DCOLOR_ARGB(0xff,100,100,100),1.0f,0);
|
D3DCOLOR_ARGB(0xff,100,100,100),1.0f,0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
g_piDevice->Clear(0,nullptr,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TEXTURE_2D == eMode)
|
if (TEXTURE_2D == eMode)
|
||||||
|
@ -293,7 +293,7 @@ void CBackgroundPainter::OnPreRender()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// clear both the render target and the z-buffer
|
// clear both the render target and the z-buffer
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
g_piDevice->Clear(0,nullptr,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
||||||
clrColor,1.0f,0);
|
clrColor,1.0f,0);
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -342,12 +342,12 @@ void CBackgroundPainter::ReleaseNativeResource()
|
||||||
if ( piSkyBoxEffect)
|
if ( piSkyBoxEffect)
|
||||||
{
|
{
|
||||||
piSkyBoxEffect->Release();
|
piSkyBoxEffect->Release();
|
||||||
piSkyBoxEffect = NULL;
|
piSkyBoxEffect = nullptr;
|
||||||
}
|
}
|
||||||
if (pcTexture)
|
if (pcTexture)
|
||||||
{
|
{
|
||||||
pcTexture->Release();
|
pcTexture->Release();
|
||||||
pcTexture = NULL;
|
pcTexture = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -377,8 +377,8 @@ void CBackgroundPainter::RecreateNativeResource()
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
0,
|
0,
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
(IDirect3DCubeTexture9**)&pcTexture)))
|
(IDirect3DCubeTexture9**)&pcTexture)))
|
||||||
{
|
{
|
||||||
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
||||||
|
@ -411,8 +411,8 @@ void CBackgroundPainter::RecreateNativeResource()
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
0,
|
0,
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
(IDirect3DTexture9**)&pcTexture)))
|
(IDirect3DTexture9**)&pcTexture)))
|
||||||
{
|
{
|
||||||
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
||||||
|
@ -433,15 +433,15 @@ void CBackgroundPainter::RecreateNativeResource()
|
||||||
}
|
}
|
||||||
if (!piSkyBoxEffect)
|
if (!piSkyBoxEffect)
|
||||||
{
|
{
|
||||||
ID3DXBuffer* piBuffer = NULL;
|
ID3DXBuffer* piBuffer = nullptr;
|
||||||
if(FAILED( D3DXCreateEffect(
|
if(FAILED( D3DXCreateEffect(
|
||||||
g_piDevice,
|
g_piDevice,
|
||||||
g_szSkyboxShader.c_str(),
|
g_szSkyboxShader.c_str(),
|
||||||
(UINT)g_szSkyboxShader.length(),
|
(UINT)g_szSkyboxShader.length(),
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
AI_SHADER_COMPILE_FLAGS,
|
AI_SHADER_COMPILE_FLAGS,
|
||||||
NULL,
|
nullptr,
|
||||||
&piSkyBoxEffect,&piBuffer)))
|
&piSkyBoxEffect,&piBuffer)))
|
||||||
{
|
{
|
||||||
// failed to compile the shader
|
// failed to compile the shader
|
||||||
|
|
|
@ -158,8 +158,8 @@ int CDisplay::AddNodeToDisplayList(
|
||||||
aiNode* pcNode,
|
aiNode* pcNode,
|
||||||
HTREEITEM hRoot)
|
HTREEITEM hRoot)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pcNode);
|
ai_assert(nullptr != pcNode);
|
||||||
ai_assert(NULL != hRoot);
|
ai_assert(nullptr != hRoot);
|
||||||
|
|
||||||
char chTemp[MAXLEN];
|
char chTemp[MAXLEN];
|
||||||
|
|
||||||
|
@ -269,13 +269,13 @@ int CDisplay::AddMeshToDisplayList(unsigned int iIndex, HTREEITEM hRoot)
|
||||||
// Replace the currently selected texture by another one
|
// Replace the currently selected texture by another one
|
||||||
int CDisplay::ReplaceCurrentTexture(const char* szPath)
|
int CDisplay::ReplaceCurrentTexture(const char* szPath)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != szPath);
|
ai_assert(nullptr != szPath);
|
||||||
|
|
||||||
// well ... try to load it
|
// well ... try to load it
|
||||||
IDirect3DTexture9* piTexture = NULL;
|
IDirect3DTexture9* piTexture = nullptr;
|
||||||
aiString szString;
|
aiString szString;
|
||||||
strcpy(szString.data,szPath);
|
strcpy(szString.data,szPath);
|
||||||
szString.length = strlen(szPath);
|
szString.length = static_cast<ai_uint32>(strlen(szPath));
|
||||||
CMaterialManager::Instance().LoadTexture(&piTexture,&szString);
|
CMaterialManager::Instance().LoadTexture(&piTexture,&szString);
|
||||||
|
|
||||||
if (!piTexture) {
|
if (!piTexture) {
|
||||||
|
@ -301,8 +301,8 @@ int CDisplay::ReplaceCurrentTexture(const char* szPath)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
AssetHelper::MeshHelper* pcMesh = g_pcAsset->apcMeshes[i];
|
AssetHelper::MeshHelper* pcMesh = g_pcAsset->apcMeshes[i];
|
||||||
IDirect3DTexture9** tex = NULL;
|
IDirect3DTexture9** tex = nullptr;
|
||||||
const char* tex_string = NULL;
|
const char* tex_string = nullptr;
|
||||||
|
|
||||||
switch (this->m_pcCurrentTexture->iType)
|
switch (this->m_pcCurrentTexture->iType)
|
||||||
{
|
{
|
||||||
|
@ -378,7 +378,7 @@ int CDisplay::AddTextureToDisplayList(unsigned int iType,
|
||||||
aiTextureOp eTextureOp /*= aiTextureOp_Multiply*/,
|
aiTextureOp eTextureOp /*= aiTextureOp_Multiply*/,
|
||||||
unsigned int iMesh /*= 0*/)
|
unsigned int iMesh /*= 0*/)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != szPath);
|
ai_assert(nullptr != szPath);
|
||||||
|
|
||||||
char chTemp[512];
|
char chTemp[512];
|
||||||
char chTempEmb[256];
|
char chTempEmb[256];
|
||||||
|
@ -388,8 +388,8 @@ int CDisplay::AddTextureToDisplayList(unsigned int iType,
|
||||||
{
|
{
|
||||||
if ('*' == *szPath->data)
|
if ('*' == *szPath->data)
|
||||||
{
|
{
|
||||||
int iIndex = atoi(szPath->data+1);
|
int iIndex2 = atoi(szPath->data+1);
|
||||||
ai_snprintf(chTempEmb,256,"Embedded #%i",iIndex);
|
ai_snprintf(chTempEmb,256,"Embedded #%i",iIndex2);
|
||||||
sz = chTempEmb;
|
sz = chTempEmb;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -436,15 +436,15 @@ int CDisplay::AddTextureToDisplayList(unsigned int iType,
|
||||||
szType = "Lightmap";
|
szType = "Lightmap";
|
||||||
break;
|
break;
|
||||||
case aiTextureType_DISPLACEMENT:
|
case aiTextureType_DISPLACEMENT:
|
||||||
piTexture = NULL;
|
piTexture = nullptr;
|
||||||
szType = "Displacement";
|
szType = "Displacement";
|
||||||
break;
|
break;
|
||||||
case aiTextureType_REFLECTION:
|
case aiTextureType_REFLECTION:
|
||||||
piTexture = NULL;
|
piTexture = nullptr;
|
||||||
szType = "Reflection";
|
szType = "Reflection";
|
||||||
break;
|
break;
|
||||||
case aiTextureType_UNKNOWN:
|
case aiTextureType_UNKNOWN:
|
||||||
piTexture = NULL;
|
piTexture = nullptr;
|
||||||
szType = "Unknown";
|
szType = "Unknown";
|
||||||
break;
|
break;
|
||||||
default: // opacity + opacity | mask
|
default: // opacity + opacity | mask
|
||||||
|
@ -521,7 +521,7 @@ int CDisplay::AddTextureToDisplayList(unsigned int iType,
|
||||||
int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
||||||
unsigned int iIndex)
|
unsigned int iIndex)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != hRoot);
|
ai_assert(nullptr != hRoot);
|
||||||
|
|
||||||
aiMaterial* pcMat = g_pcAsset->pcScene->mMaterials[iIndex];
|
aiMaterial* pcMat = g_pcAsset->pcScene->mMaterials[iIndex];
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (AI_SUCCESS != aiGetMaterialTexture(pcMat,(aiTextureType)i,iNum,
|
if (AI_SUCCESS != aiGetMaterialTexture(pcMat,(aiTextureType)i,iNum,
|
||||||
&szPath,NULL, &iUV,&fBlend,&eOp))
|
&szPath,nullptr, &iUV,&fBlend,&eOp))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -658,23 +658,23 @@ int CDisplay::LoadImageList(void)
|
||||||
|
|
||||||
// Load the bitmaps and add them to the image lists.
|
// Load the bitmaps and add them to the image lists.
|
||||||
HBITMAP hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BFX));
|
HBITMAP hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BFX));
|
||||||
m_aiImageList[AI_VIEW_IMGLIST_MATERIAL] = ImageList_Add(hIml, hBmp, NULL);
|
m_aiImageList[AI_VIEW_IMGLIST_MATERIAL] = ImageList_Add(hIml, hBmp, nullptr);
|
||||||
DeleteObject(hBmp);
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BNODE));
|
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BNODE));
|
||||||
m_aiImageList[AI_VIEW_IMGLIST_NODE] = ImageList_Add(hIml, hBmp, NULL);
|
m_aiImageList[AI_VIEW_IMGLIST_NODE] = ImageList_Add(hIml, hBmp, nullptr);
|
||||||
DeleteObject(hBmp);
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BTX));
|
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BTX));
|
||||||
m_aiImageList[AI_VIEW_IMGLIST_TEXTURE] = ImageList_Add(hIml, hBmp, NULL);
|
m_aiImageList[AI_VIEW_IMGLIST_TEXTURE] = ImageList_Add(hIml, hBmp, nullptr);
|
||||||
DeleteObject(hBmp);
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BTXI));
|
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BTXI));
|
||||||
m_aiImageList[AI_VIEW_IMGLIST_TEXTURE_INVALID] = ImageList_Add(hIml, hBmp, NULL);
|
m_aiImageList[AI_VIEW_IMGLIST_TEXTURE_INVALID] = ImageList_Add(hIml, hBmp, nullptr);
|
||||||
DeleteObject(hBmp);
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BROOT));
|
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BROOT));
|
||||||
m_aiImageList[AI_VIEW_IMGLIST_MODEL] = ImageList_Add(hIml, hBmp, NULL);
|
m_aiImageList[AI_VIEW_IMGLIST_MODEL] = ImageList_Add(hIml, hBmp, nullptr);
|
||||||
DeleteObject(hBmp);
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
// Associate the image list with the tree.
|
// Associate the image list with the tree.
|
||||||
|
@ -778,7 +778,7 @@ int CDisplay::OnRender()
|
||||||
|
|
||||||
// present the back-buffer
|
// present the back-buffer
|
||||||
g_piDevice->EndScene();
|
g_piDevice->EndScene();
|
||||||
g_piDevice->Present(NULL,NULL,NULL,NULL);
|
g_piDevice->Present(nullptr,nullptr,nullptr,nullptr);
|
||||||
|
|
||||||
// don't remove this, problems on some older machines (AMD timing bug)
|
// don't remove this, problems on some older machines (AMD timing bug)
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
|
@ -788,9 +788,9 @@ int CDisplay::OnRender()
|
||||||
// Update UI
|
// Update UI
|
||||||
void UpdateColorFieldsInUI()
|
void UpdateColorFieldsInUI()
|
||||||
{
|
{
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR1),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR1),nullptr,TRUE);
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR2),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR2),nullptr,TRUE);
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR3),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR3),nullptr,TRUE);
|
||||||
|
|
||||||
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR1));
|
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR1));
|
||||||
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR2));
|
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR2));
|
||||||
|
@ -859,7 +859,7 @@ int CDisplay::Reset(void)
|
||||||
m_asNodes.clear();
|
m_asNodes.clear();
|
||||||
m_asMeshes.clear();
|
m_asMeshes.clear();
|
||||||
|
|
||||||
m_hRoot = NULL;
|
m_hRoot = nullptr;
|
||||||
|
|
||||||
return OnSetupNormalView();
|
return OnSetupNormalView();
|
||||||
}
|
}
|
||||||
|
@ -896,9 +896,9 @@ int CDisplay::OnSetupNormalView()
|
||||||
SetViewMode(VIEWMODE_FULL);
|
SetViewMode(VIEWMODE_FULL);
|
||||||
|
|
||||||
// for debugging
|
// for debugging
|
||||||
m_pcCurrentMaterial = NULL;
|
m_pcCurrentMaterial = nullptr;
|
||||||
m_pcCurrentTexture = NULL;
|
m_pcCurrentTexture = nullptr;
|
||||||
m_pcCurrentNode = NULL;
|
m_pcCurrentNode = nullptr;
|
||||||
|
|
||||||
// redraw the color fields in the UI --- their purpose has possibly changed
|
// redraw the color fields in the UI --- their purpose has possibly changed
|
||||||
UpdateColorFieldsInUI();
|
UpdateColorFieldsInUI();
|
||||||
|
@ -908,7 +908,7 @@ int CDisplay::OnSetupNormalView()
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CDisplay::OnSetupNodeView(NodeInfo* pcNew)
|
int CDisplay::OnSetupNodeView(NodeInfo* pcNew)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pcNew);
|
ai_assert(nullptr != pcNew);
|
||||||
|
|
||||||
if (m_pcCurrentNode == pcNew)return 2;
|
if (m_pcCurrentNode == pcNew)return 2;
|
||||||
|
|
||||||
|
@ -955,7 +955,7 @@ int CDisplay::OnSetupNodeView(NodeInfo* pcNew)
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CDisplay::OnSetupMaterialView(MaterialInfo* pcNew)
|
int CDisplay::OnSetupMaterialView(MaterialInfo* pcNew)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pcNew);
|
ai_assert(nullptr != pcNew);
|
||||||
|
|
||||||
if (m_pcCurrentMaterial == pcNew)return 2;
|
if (m_pcCurrentMaterial == pcNew)return 2;
|
||||||
|
|
||||||
|
@ -973,7 +973,7 @@ int CDisplay::OnSetupMaterialView(MaterialInfo* pcNew)
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CDisplay::OnSetupTextureView(TextureInfo* pcNew)
|
int CDisplay::OnSetupTextureView(TextureInfo* pcNew)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pcNew);
|
ai_assert(nullptr != pcNew);
|
||||||
|
|
||||||
if (this->m_pcCurrentTexture == pcNew)return 2;
|
if (this->m_pcCurrentTexture == pcNew)return 2;
|
||||||
|
|
||||||
|
@ -1099,7 +1099,7 @@ int CDisplay::OnSetup(HTREEITEM p_hTreeItem)
|
||||||
MaterialInfo* pcNew3;
|
MaterialInfo* pcNew3;
|
||||||
};
|
};
|
||||||
|
|
||||||
pcNew = NULL;
|
pcNew = nullptr;
|
||||||
for (std::vector<TextureInfo>::iterator i = m_asTextures.begin();i != m_asTextures.end();++i){
|
for (std::vector<TextureInfo>::iterator i = m_asTextures.begin();i != m_asTextures.end();++i){
|
||||||
if (p_hTreeItem == (*i).hTreeItem) {
|
if (p_hTreeItem == (*i).hTreeItem) {
|
||||||
pcNew = &(*i);
|
pcNew = &(*i);
|
||||||
|
@ -1136,12 +1136,12 @@ int CDisplay::OnSetup(HTREEITEM p_hTreeItem)
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CDisplay::ShowTreeViewContextMenu(HTREEITEM hItem)
|
int CDisplay::ShowTreeViewContextMenu(HTREEITEM hItem)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != hItem);
|
ai_assert(nullptr != hItem);
|
||||||
|
|
||||||
HMENU hDisplay = NULL;
|
HMENU hDisplay = nullptr;
|
||||||
|
|
||||||
// search in our list for the item
|
// search in our list for the item
|
||||||
TextureInfo* pcNew = NULL;
|
TextureInfo* pcNew = nullptr;
|
||||||
for (std::vector<TextureInfo>::iterator
|
for (std::vector<TextureInfo>::iterator
|
||||||
i = m_asTextures.begin();
|
i = m_asTextures.begin();
|
||||||
i != m_asTextures.end();++i)
|
i != m_asTextures.end();++i)
|
||||||
|
@ -1158,7 +1158,7 @@ int CDisplay::ShowTreeViewContextMenu(HTREEITEM hItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
// search in the material list for the item
|
// search in the material list for the item
|
||||||
MaterialInfo* pcNew2 = NULL;
|
MaterialInfo* pcNew2 = nullptr;
|
||||||
for (std::vector<MaterialInfo>::iterator
|
for (std::vector<MaterialInfo>::iterator
|
||||||
i = m_asMaterials.begin();
|
i = m_asMaterials.begin();
|
||||||
i != m_asMaterials.end();++i)
|
i != m_asMaterials.end();++i)
|
||||||
|
@ -1173,7 +1173,7 @@ int CDisplay::ShowTreeViewContextMenu(HTREEITEM hItem)
|
||||||
HMENU hMenu = LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_MATPOPUP));
|
HMENU hMenu = LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_MATPOPUP));
|
||||||
hDisplay = GetSubMenu(hMenu,0);
|
hDisplay = GetSubMenu(hMenu,0);
|
||||||
}
|
}
|
||||||
if (NULL != hDisplay)
|
if (nullptr != hDisplay)
|
||||||
{
|
{
|
||||||
// select this entry (this should all OnSetup())
|
// select this entry (this should all OnSetup())
|
||||||
TreeView_Select(GetDlgItem(g_hDlg,IDC_TREE1),hItem,TVGN_CARET);
|
TreeView_Select(GetDlgItem(g_hDlg,IDC_TREE1),hItem,TVGN_CARET);
|
||||||
|
@ -1185,7 +1185,7 @@ int CDisplay::ShowTreeViewContextMenu(HTREEITEM hItem)
|
||||||
POINT sPoint;
|
POINT sPoint;
|
||||||
GetCursorPos(&sPoint);
|
GetCursorPos(&sPoint);
|
||||||
TrackPopupMenu(hDisplay, TPM_LEFTALIGN, sPoint.x, sPoint.y, 0,
|
TrackPopupMenu(hDisplay, TPM_LEFTALIGN, sPoint.x, sPoint.y, 0,
|
||||||
g_hDlg,NULL);
|
g_hDlg,nullptr);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1260,8 +1260,8 @@ int CDisplay::HandleTreeViewPopup(WPARAM wParam,LPARAM lParam)
|
||||||
clamp<unsigned char>(clrOld.g * 255.0f),
|
clamp<unsigned char>(clrOld.g * 255.0f),
|
||||||
clamp<unsigned char>(clrOld.b * 255.0f));
|
clamp<unsigned char>(clrOld.b * 255.0f));
|
||||||
clr.lpCustColors = g_aclCustomColors;
|
clr.lpCustColors = g_aclCustomColors;
|
||||||
clr.lpfnHook = NULL;
|
clr.lpfnHook = nullptr;
|
||||||
clr.lpTemplateName = NULL;
|
clr.lpTemplateName = nullptr;
|
||||||
clr.lCustData = 0;
|
clr.lCustData = 0;
|
||||||
|
|
||||||
ChooseColor(&clr);
|
ChooseColor(&clr);
|
||||||
|
@ -1308,7 +1308,7 @@ int CALLBACK TreeViewCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
|
int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM /*lParam*/)
|
||||||
{
|
{
|
||||||
char szFileName[MAX_PATH];
|
char szFileName[MAX_PATH];
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
|
@ -1318,7 +1318,7 @@ int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
|
||||||
case ID_HEY_REPLACE:
|
case ID_HEY_REPLACE:
|
||||||
{
|
{
|
||||||
// get a path to a new texture
|
// get a path to a new texture
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"ReplaceTextureSrc",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"ReplaceTextureSrc",nullptr,nullptr,
|
||||||
(BYTE*)szFileName,&dwTemp))
|
(BYTE*)szFileName,&dwTemp))
|
||||||
{
|
{
|
||||||
// Key was not found. Use C:
|
// Key was not found. Use C:
|
||||||
|
@ -1335,13 +1335,13 @@ int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
|
||||||
}
|
}
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(nullptr),
|
||||||
"Textures\0*.png;*.dds;*.tga;*.bmp;*.tif;*.ppm;*.ppx;*.jpg;*.jpeg;*.exr\0*.*\0",
|
"Textures\0*.png;*.dds;*.tga;*.bmp;*.tif;*.ppm;*.ppx;*.jpg;*.jpeg;*.exr\0*.*\0",
|
||||||
NULL, 0, 1,
|
nullptr, 0, 1,
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, nullptr, 0, nullptr,
|
||||||
"Replace this texture",
|
"Replace this texture",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
0, 1, ".jpg", 0, NULL, NULL
|
0, 1, ".jpg", 0, nullptr, nullptr
|
||||||
};
|
};
|
||||||
if(GetOpenFileName(&sFilename1) == 0) return 0;
|
if(GetOpenFileName(&sFilename1) == 0) return 0;
|
||||||
|
|
||||||
|
@ -1353,7 +1353,7 @@ int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
|
||||||
|
|
||||||
case ID_HEY_EXPORT:
|
case ID_HEY_EXPORT:
|
||||||
{
|
{
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"TextureExportDest",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"TextureExportDest",nullptr,nullptr,
|
||||||
(BYTE*)szFileName,&dwTemp))
|
(BYTE*)szFileName,&dwTemp))
|
||||||
{
|
{
|
||||||
// Key was not found. Use C:
|
// Key was not found. Use C:
|
||||||
|
@ -1370,12 +1370,12 @@ int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
|
||||||
}
|
}
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(nullptr),
|
||||||
"Textures\0*.png;*.dds;*.bmp;*.tif;*.pfm;*.jpg;*.jpeg;*.hdr\0*.*\0", NULL, 0, 1,
|
"Textures\0*.png;*.dds;*.bmp;*.tif;*.pfm;*.jpg;*.jpeg;*.hdr\0*.*\0", nullptr, 0, 1,
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, nullptr, 0, nullptr,
|
||||||
"Export texture to file",
|
"Export texture to file",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
0, 1, ".png", 0, NULL, NULL
|
0, 1, ".png", 0, nullptr, nullptr
|
||||||
};
|
};
|
||||||
if(GetSaveFileName(&sFilename1) == 0) return 0;
|
if(GetSaveFileName(&sFilename1) == 0) return 0;
|
||||||
|
|
||||||
|
@ -1397,9 +1397,9 @@ int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a pointer to the first surface of the current texture
|
// get a pointer to the first surface of the current texture
|
||||||
IDirect3DSurface9* pi = NULL;
|
IDirect3DSurface9* pi = nullptr;
|
||||||
(*this->m_pcCurrentTexture->piTexture)->GetSurfaceLevel(0,&pi);
|
(*this->m_pcCurrentTexture->piTexture)->GetSurfaceLevel(0,&pi);
|
||||||
if(!pi || FAILED(D3DXSaveSurfaceToFile(szFileName,eFormat,pi,NULL,NULL)))
|
if(!pi || FAILED(D3DXSaveSurfaceToFile(szFileName,eFormat,pi,nullptr,nullptr)))
|
||||||
{
|
{
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to export texture",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to export texture",
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
|
@ -1495,7 +1495,7 @@ int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
|
||||||
// Setup stereo view
|
// Setup stereo view
|
||||||
int CDisplay::SetupStereoView()
|
int CDisplay::SetupStereoView()
|
||||||
{
|
{
|
||||||
if (NULL != g_pcAsset && NULL != g_pcAsset->pcScene->mRootNode)
|
if (nullptr != g_pcAsset && nullptr != g_pcAsset->pcScene->mRootNode)
|
||||||
{
|
{
|
||||||
// enable the RED, GREEN and ALPHA channels
|
// enable the RED, GREEN and ALPHA channels
|
||||||
g_piDevice->SetRenderState(D3DRS_COLORWRITEENABLE,
|
g_piDevice->SetRenderState(D3DRS_COLORWRITEENABLE,
|
||||||
|
@ -1513,7 +1513,7 @@ int CDisplay::SetupStereoView()
|
||||||
int CDisplay::RenderStereoView(const aiMatrix4x4& m)
|
int CDisplay::RenderStereoView(const aiMatrix4x4& m)
|
||||||
{
|
{
|
||||||
// and rerender the scene
|
// and rerender the scene
|
||||||
if (NULL != g_pcAsset && NULL != g_pcAsset->pcScene->mRootNode)
|
if (nullptr != g_pcAsset && nullptr != g_pcAsset->pcScene->mRootNode)
|
||||||
{
|
{
|
||||||
// enable the BLUE, GREEN and ALPHA channels
|
// enable the BLUE, GREEN and ALPHA channels
|
||||||
g_piDevice->SetRenderState(D3DRS_COLORWRITEENABLE,
|
g_piDevice->SetRenderState(D3DRS_COLORWRITEENABLE,
|
||||||
|
@ -1522,7 +1522,7 @@ int CDisplay::RenderStereoView(const aiMatrix4x4& m)
|
||||||
D3DCOLORWRITEENABLE_BLUE);
|
D3DCOLORWRITEENABLE_BLUE);
|
||||||
|
|
||||||
// clear the z-buffer
|
// clear the z-buffer
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
g_piDevice->Clear(0,nullptr,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
||||||
|
|
||||||
// move the camera a little bit to the right
|
// move the camera a little bit to the right
|
||||||
g_sCamera.vPos += g_sCamera.vRight * 0.06f;
|
g_sCamera.vPos += g_sCamera.vRight * 0.06f;
|
||||||
|
@ -1751,7 +1751,7 @@ int CDisplay::RenderFullScene()
|
||||||
|
|
||||||
// draw all opaque objects in the scene
|
// draw all opaque objects in the scene
|
||||||
aiMatrix4x4 m;
|
aiMatrix4x4 m;
|
||||||
if (NULL != g_pcAsset && NULL != g_pcAsset->pcScene->mRootNode)
|
if (nullptr != g_pcAsset && nullptr != g_pcAsset->pcScene->mRootNode)
|
||||||
{
|
{
|
||||||
HandleInput();
|
HandleInput();
|
||||||
m = g_mWorld * g_mWorldRotate;
|
m = g_mWorld * g_mWorldRotate;
|
||||||
|
@ -1766,7 +1766,7 @@ int CDisplay::RenderFullScene()
|
||||||
CBackgroundPainter::Instance().OnPostRender();
|
CBackgroundPainter::Instance().OnPostRender();
|
||||||
|
|
||||||
// draw all non-opaque objects in the scene
|
// draw all non-opaque objects in the scene
|
||||||
if (NULL != g_pcAsset && NULL != g_pcAsset->pcScene->mRootNode)
|
if (nullptr != g_pcAsset && nullptr != g_pcAsset->pcScene->mRootNode)
|
||||||
{
|
{
|
||||||
// disable the z-buffer
|
// disable the z-buffer
|
||||||
if (!g_sOptions.bNoAlphaBlending) {
|
if (!g_sOptions.bNoAlphaBlending) {
|
||||||
|
@ -1784,7 +1784,7 @@ int CDisplay::RenderFullScene()
|
||||||
RenderStereoView(m);
|
RenderStereoView(m);
|
||||||
|
|
||||||
// render the skeleton if necessary
|
// render the skeleton if necessary
|
||||||
if (g_sOptions.bSkeleton && NULL != g_pcAsset && NULL != g_pcAsset->pcScene->mRootNode) {
|
if (g_sOptions.bSkeleton && nullptr != g_pcAsset && nullptr != g_pcAsset->pcScene->mRootNode) {
|
||||||
// disable the z-buffer
|
// disable the z-buffer
|
||||||
g_piDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
g_piDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||||
|
|
||||||
|
@ -1795,11 +1795,11 @@ int CDisplay::RenderFullScene()
|
||||||
g_piDevice->SetVertexDeclaration( gDefaultVertexDecl);
|
g_piDevice->SetVertexDeclaration( gDefaultVertexDecl);
|
||||||
// this is very similar to the code in SetupMaterial()
|
// this is very similar to the code in SetupMaterial()
|
||||||
ID3DXEffect* piEnd = g_piNormalsEffect;
|
ID3DXEffect* piEnd = g_piNormalsEffect;
|
||||||
aiMatrix4x4 pcProj = m * mViewProjection;
|
aiMatrix4x4 pcProj2 = m * mViewProjection;
|
||||||
|
|
||||||
D3DXVECTOR4 vVector(1.f,0.f,0.f,1.f);
|
D3DXVECTOR4 vVector(1.f,0.f,0.f,1.f);
|
||||||
piEnd->SetVector("OUTPUT_COLOR",&vVector);
|
piEnd->SetVector("OUTPUT_COLOR",&vVector);
|
||||||
piEnd->SetMatrix("WorldViewProjection", (const D3DXMATRIX*)&pcProj);
|
piEnd->SetMatrix("WorldViewProjection", (const D3DXMATRIX*)&pcProj2);
|
||||||
|
|
||||||
UINT dwPasses = 0;
|
UINT dwPasses = 0;
|
||||||
piEnd->Begin(&dwPasses,0);
|
piEnd->Begin(&dwPasses,0);
|
||||||
|
@ -2098,14 +2098,14 @@ int CDisplay::RenderPatternBG()
|
||||||
{
|
{
|
||||||
// seems we have not yet compiled this shader.
|
// seems we have not yet compiled this shader.
|
||||||
// and NOW is the best time to do that ...
|
// and NOW is the best time to do that ...
|
||||||
ID3DXBuffer* piBuffer = NULL;
|
ID3DXBuffer* piBuffer = nullptr;
|
||||||
if(FAILED( D3DXCreateEffect(g_piDevice,
|
if(FAILED( D3DXCreateEffect(g_piDevice,
|
||||||
g_szCheckerBackgroundShader.c_str(),
|
g_szCheckerBackgroundShader.c_str(),
|
||||||
(UINT)g_szCheckerBackgroundShader.length(),
|
(UINT)g_szCheckerBackgroundShader.length(),
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
D3DXSHADER_USE_LEGACY_D3DX9_31_DLL,
|
D3DXSHADER_USE_LEGACY_D3DX9_31_DLL,
|
||||||
NULL,
|
nullptr,
|
||||||
&g_piPatternEffect,&piBuffer)))
|
&g_piPatternEffect,&piBuffer)))
|
||||||
{
|
{
|
||||||
if( piBuffer)
|
if( piBuffer)
|
||||||
|
@ -2118,7 +2118,7 @@ int CDisplay::RenderPatternBG()
|
||||||
if( piBuffer)
|
if( piBuffer)
|
||||||
{
|
{
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
piBuffer = NULL;
|
piBuffer = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2126,14 +2126,14 @@ int CDisplay::RenderPatternBG()
|
||||||
// clear the color buffer in magenta
|
// clear the color buffer in magenta
|
||||||
// (hopefully this is ugly enough that every ps_2_0 cards owner
|
// (hopefully this is ugly enough that every ps_2_0 cards owner
|
||||||
// runs to the next shop to buy himself a new card ...)
|
// runs to the next shop to buy himself a new card ...)
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
g_piDevice->Clear(0,nullptr,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0xFF), 1.0f,0 );
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0xFF), 1.0f,0 );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the depth buffer only
|
// clear the depth buffer only
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,
|
g_piDevice->Clear(0,nullptr,D3DCLEAR_ZBUFFER,
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0xFF), 1.0f,0 );
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0xFF), 1.0f,0 );
|
||||||
|
|
||||||
// setup the colors to be used ...
|
// setup the colors to be used ...
|
||||||
|
|
|
@ -53,8 +53,8 @@ INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM ) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
// load the help file ...
|
// load the help file ...
|
||||||
HRSRC res = FindResource(NULL,MAKEINTRESOURCE(IDR_TEXT1),"TEXT");
|
HRSRC res = FindResource(nullptr,MAKEINTRESOURCE(IDR_TEXT1),"TEXT");
|
||||||
HGLOBAL hg = LoadResource(NULL,res);
|
HGLOBAL hg = LoadResource(nullptr,res);
|
||||||
void* pData = LockResource(hg);
|
void* pData = LockResource(hg);
|
||||||
|
|
||||||
SETTEXTEX sInfo;
|
SETTEXTEX sInfo;
|
||||||
|
|
|
@ -117,29 +117,29 @@ void CLogDisplay::OnRender() {
|
||||||
sCopy.top = sWndRect.top+1;
|
sCopy.top = sWndRect.top+1;
|
||||||
sCopy.bottom = sWndRect.bottom+1;
|
sCopy.bottom = sWndRect.bottom+1;
|
||||||
sCopy.right = sWndRect.right+1;
|
sCopy.right = sWndRect.right+1;
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(nullptr,szText ,
|
||||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||||
sCopy.left = sWndRect.left+1;
|
sCopy.left = sWndRect.left+1;
|
||||||
sCopy.top = sWndRect.top+1;
|
sCopy.top = sWndRect.top+1;
|
||||||
sCopy.bottom = sWndRect.bottom-1;
|
sCopy.bottom = sWndRect.bottom-1;
|
||||||
sCopy.right = sWndRect.right-1;
|
sCopy.right = sWndRect.right-1;
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(nullptr,szText ,
|
||||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||||
sCopy.left = sWndRect.left-1;
|
sCopy.left = sWndRect.left-1;
|
||||||
sCopy.top = sWndRect.top-1;
|
sCopy.top = sWndRect.top-1;
|
||||||
sCopy.bottom = sWndRect.bottom+1;
|
sCopy.bottom = sWndRect.bottom+1;
|
||||||
sCopy.right = sWndRect.right+1;
|
sCopy.right = sWndRect.right+1;
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(nullptr,szText ,
|
||||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||||
sCopy.left = sWndRect.left-1;
|
sCopy.left = sWndRect.left-1;
|
||||||
sCopy.top = sWndRect.top-1;
|
sCopy.top = sWndRect.top-1;
|
||||||
sCopy.bottom = sWndRect.bottom-1;
|
sCopy.bottom = sWndRect.bottom-1;
|
||||||
sCopy.right = sWndRect.right-1;
|
sCopy.right = sWndRect.right-1;
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(nullptr,szText ,
|
||||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||||
|
|
||||||
// text
|
// text
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(nullptr,szText ,
|
||||||
-1,&sWndRect,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF));
|
-1,&sWndRect,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ void CLogDisplay::OnRender() {
|
||||||
sCopy.top = sRect.top+1;
|
sCopy.top = sRect.top+1;
|
||||||
sCopy.bottom = sRect.bottom+1;
|
sCopy.bottom = sRect.bottom+1;
|
||||||
sCopy.right = sRect.right+1;
|
sCopy.right = sRect.right+1;
|
||||||
this->piFont->DrawText(NULL,szText,
|
this->piFont->DrawText(nullptr,szText,
|
||||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ void CLogDisplay::OnRender() {
|
||||||
sCopy.top = sRect.top-1;
|
sCopy.top = sRect.top-1;
|
||||||
sCopy.bottom = sRect.bottom-1;
|
sCopy.bottom = sRect.bottom-1;
|
||||||
sCopy.right = sRect.right-1;
|
sCopy.right = sRect.right-1;
|
||||||
this->piFont->DrawText(NULL,szText,
|
this->piFont->DrawText(nullptr,szText,
|
||||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ void CLogDisplay::OnRender() {
|
||||||
sCopy.top = sRect.top-1;
|
sCopy.top = sRect.top-1;
|
||||||
sCopy.bottom = sRect.bottom+1;
|
sCopy.bottom = sRect.bottom+1;
|
||||||
sCopy.right = sRect.right+1;
|
sCopy.right = sRect.right+1;
|
||||||
this->piFont->DrawText(NULL,szText,
|
this->piFont->DrawText(nullptr,szText,
|
||||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||||
|
|
||||||
|
@ -200,12 +200,12 @@ void CLogDisplay::OnRender() {
|
||||||
sCopy.top = sRect.top+1;
|
sCopy.top = sRect.top+1;
|
||||||
sCopy.bottom = sRect.bottom-1;
|
sCopy.bottom = sRect.bottom-1;
|
||||||
sCopy.right = sRect.right-1;
|
sCopy.right = sRect.right-1;
|
||||||
this->piFont->DrawText(NULL,szText,
|
this->piFont->DrawText(nullptr,szText,
|
||||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||||
|
|
||||||
// draw the text itself
|
// draw the text itself
|
||||||
int iPX = this->piFont->DrawText(NULL,szText,
|
int iPX = this->piFont->DrawText(nullptr,szText,
|
||||||
-1,&sRect,DT_RIGHT | DT_TOP,clrColor);
|
-1,&sRect,DT_RIGHT | DT_TOP,clrColor);
|
||||||
|
|
||||||
sRect.top += iPX;
|
sRect.top += iPX;
|
||||||
|
|
|
@ -70,7 +70,7 @@ static const char* AI_VIEW_RTF_LOG_HEADER =
|
||||||
// Message procedure for the log window
|
// Message procedure for the log window
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam)
|
WPARAM /*wParam*/,LPARAM lParam)
|
||||||
{
|
{
|
||||||
(void)lParam;
|
(void)lParam;
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
|
@ -86,7 +86,7 @@ INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
int x = LOWORD(lParam);
|
int x = LOWORD(lParam);
|
||||||
int y = HIWORD(lParam);
|
int y = HIWORD(lParam);
|
||||||
|
|
||||||
SetWindowPos(GetDlgItem(hwndDlg,IDC_EDIT1),NULL,0,0,
|
SetWindowPos(GetDlgItem(hwndDlg,IDC_EDIT1),nullptr,0,0,
|
||||||
x-10,y-12,SWP_NOMOVE|SWP_NOZORDER);
|
x-10,y-12,SWP_NOMOVE|SWP_NOZORDER);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -103,7 +103,7 @@ INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogWindow::Init () {
|
void CLogWindow::Init () {
|
||||||
this->hwnd = ::CreateDialog(g_hInstance,MAKEINTRESOURCE(IDD_LOGVIEW),
|
this->hwnd = ::CreateDialog(g_hInstance,MAKEINTRESOURCE(IDD_LOGVIEW),
|
||||||
NULL,&LogDialogProc);
|
nullptr,&LogDialogProc);
|
||||||
|
|
||||||
if (!this->hwnd) {
|
if (!this->hwnd) {
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create logger window",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create logger window",
|
||||||
|
@ -156,7 +156,7 @@ void CLogWindow::Save() {
|
||||||
char szFileName[MAX_PATH];
|
char szFileName[MAX_PATH];
|
||||||
|
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LogDestination",NULL,NULL,(BYTE*)szFileName,&dwTemp)) {
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LogDestination",nullptr,nullptr,(BYTE*)szFileName,&dwTemp)) {
|
||||||
// Key was not found. Use C:
|
// Key was not found. Use C:
|
||||||
strcpy(szFileName,"");
|
strcpy(szFileName,"");
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,12 +169,12 @@ void CLogWindow::Save() {
|
||||||
}
|
}
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(nullptr),
|
||||||
"Log files\0*.txt", NULL, 0, 1,
|
"Log files\0*.txt", nullptr, 0, 1,
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, nullptr, 0, nullptr,
|
||||||
"Save log to file",
|
"Save log to file",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
0, 1, ".txt", 0, NULL, NULL
|
0, 1, ".txt", 0, nullptr, nullptr
|
||||||
};
|
};
|
||||||
if(GetSaveFileName(&sFilename1) == 0) return;
|
if(GetSaveFileName(&sFilename1) == 0) return;
|
||||||
|
|
||||||
|
|
|
@ -210,15 +210,15 @@ int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut)
|
||||||
D3DFMT_A8R8G8B8,
|
D3DFMT_A8R8G8B8,
|
||||||
D3DPOOL_MANAGED,
|
D3DPOOL_MANAGED,
|
||||||
p_ppiOut,
|
p_ppiOut,
|
||||||
NULL)))
|
nullptr)))
|
||||||
{
|
{
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create default texture",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create default texture",
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
|
|
||||||
*p_ppiOut = NULL;
|
*p_ppiOut = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
D3DXFillTexture(*p_ppiOut,&FillFunc,NULL);
|
D3DXFillTexture(*p_ppiOut,&FillFunc,nullptr);
|
||||||
sDefaultTexture = *p_ppiOut;
|
sDefaultTexture = *p_ppiOut;
|
||||||
sDefaultTexture->AddRef();
|
sDefaultTexture->AddRef();
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
|
||||||
size_t iLen2 = iLen+1;
|
size_t iLen2 = iLen+1;
|
||||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
||||||
memcpy(p_szString->data,szTempB,iLen2);
|
memcpy(p_szString->data,szTempB,iLen2);
|
||||||
p_szString->length = iLen;
|
p_szString->length = static_cast<ai_uint32>(iLen);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
|
||||||
size_t iLen2 = iLen+1;
|
size_t iLen2 = iLen+1;
|
||||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
||||||
memcpy(p_szString->data,szTempB,iLen2);
|
memcpy(p_szString->data,szTempB,iLen2);
|
||||||
p_szString->length = iLen;
|
p_szString->length = static_cast<ai_uint32>(iLen);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CMaterialManager::FindValidPath(aiString* p_szString)
|
int CMaterialManager::FindValidPath(aiString* p_szString)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != p_szString);
|
ai_assert(nullptr != p_szString);
|
||||||
aiString pcpy = *p_szString;
|
aiString pcpy = *p_szString;
|
||||||
if ('*' == p_szString->data[0]) {
|
if ('*' == p_szString->data[0]) {
|
||||||
// '*' as first character indicates an embedded file
|
// '*' as first character indicates an embedded file
|
||||||
|
@ -389,10 +389,10 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
|
||||||
if( !q ) q=strrchr( tmp2,'\\' );
|
if( !q ) q=strrchr( tmp2,'\\' );
|
||||||
if( q ){
|
if( q ){
|
||||||
strcpy( q+1,p+1 );
|
strcpy( q+1,p+1 );
|
||||||
if((pFile=fopen( tmp2,"r" ))){
|
if((pFile=fopen( tmp2,"r" )) != nullptr){
|
||||||
fclose( pFile );
|
fclose( pFile );
|
||||||
strcpy(p_szString->data,tmp2);
|
strcpy(p_szString->data,tmp2);
|
||||||
p_szString->length = strlen(tmp2);
|
p_szString->length = static_cast<ai_uint32>(strlen(tmp2));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,23 +402,22 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
|
||||||
}
|
}
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
// copy the result string back to the aiString
|
// copy the result string back to the aiStr
|
||||||
const size_t iLen = strlen(szTemp);
|
const size_t len = strlen(szTemp);
|
||||||
size_t iLen2 = iLen+1;
|
size_t len2 = len+1;
|
||||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
len2 = len2 > MAXLEN ? MAXLEN : len2;
|
||||||
memcpy(p_szString->data,szTemp,iLen2);
|
memcpy(p_szString->data, szTemp, len2);
|
||||||
p_szString->length = iLen;
|
p_szString->length = static_cast<ai_uint32>(len);
|
||||||
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CMaterialManager::LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath)
|
int CMaterialManager::LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != p_ppiOut);
|
ai_assert(nullptr != p_ppiOut);
|
||||||
ai_assert(NULL != szPath);
|
ai_assert(nullptr != szPath);
|
||||||
|
|
||||||
*p_ppiOut = NULL;
|
*p_ppiOut = nullptr;
|
||||||
|
|
||||||
const std::string s = szPath->data;
|
const std::string s = szPath->data;
|
||||||
TextureCache::iterator ff;
|
TextureCache::iterator ff;
|
||||||
|
@ -453,7 +452,7 @@ int CMaterialManager::LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath)
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
0,
|
0,
|
||||||
&info,
|
&info,
|
||||||
NULL,
|
nullptr,
|
||||||
p_ppiOut)))
|
p_ppiOut)))
|
||||||
{
|
{
|
||||||
std::string sz = "[ERROR] Unable to load embedded texture (#1): ";
|
std::string sz = "[ERROR] Unable to load embedded texture (#1): ";
|
||||||
|
@ -470,7 +469,7 @@ int CMaterialManager::LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath)
|
||||||
if(FAILED(g_piDevice->CreateTexture(
|
if(FAILED(g_piDevice->CreateTexture(
|
||||||
g_pcAsset->pcScene->mTextures[iIndex]->mWidth,
|
g_pcAsset->pcScene->mTextures[iIndex]->mWidth,
|
||||||
g_pcAsset->pcScene->mTextures[iIndex]->mHeight,
|
g_pcAsset->pcScene->mTextures[iIndex]->mHeight,
|
||||||
0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,p_ppiOut,NULL)))
|
0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,p_ppiOut,nullptr)))
|
||||||
{
|
{
|
||||||
std::string sz = "[ERROR] Unable to load embedded texture (#2): ";
|
std::string sz = "[ERROR] Unable to load embedded texture (#2): ";
|
||||||
sz.append(szPath->data);
|
sz.append(szPath->data);
|
||||||
|
@ -482,7 +481,7 @@ int CMaterialManager::LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath)
|
||||||
|
|
||||||
// now copy the data to it ... (assume non pow2 to be supported)
|
// now copy the data to it ... (assume non pow2 to be supported)
|
||||||
D3DLOCKED_RECT sLock;
|
D3DLOCKED_RECT sLock;
|
||||||
(*p_ppiOut)->LockRect(0,&sLock,NULL,0);
|
(*p_ppiOut)->LockRect(0,&sLock,nullptr,0);
|
||||||
|
|
||||||
const aiTexel* pcData = g_pcAsset->pcScene->mTextures[iIndex]->pcData;
|
const aiTexel* pcData = g_pcAsset->pcScene->mTextures[iIndex]->pcData;
|
||||||
|
|
||||||
|
@ -524,8 +523,8 @@ int CMaterialManager::LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath)
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
0,
|
0,
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
p_ppiOut)))
|
p_ppiOut)))
|
||||||
{
|
{
|
||||||
// error ... use the default texture instead
|
// error ... use the default texture instead
|
||||||
|
@ -550,44 +549,44 @@ void CMaterialManager::DeleteMaterial(AssetHelper::MeshHelper* pcIn)
|
||||||
if (pcIn->piDiffuseTexture)
|
if (pcIn->piDiffuseTexture)
|
||||||
{
|
{
|
||||||
pcIn->piDiffuseTexture->Release();
|
pcIn->piDiffuseTexture->Release();
|
||||||
pcIn->piDiffuseTexture = NULL;
|
pcIn->piDiffuseTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (pcIn->piSpecularTexture)
|
if (pcIn->piSpecularTexture)
|
||||||
{
|
{
|
||||||
pcIn->piSpecularTexture->Release();
|
pcIn->piSpecularTexture->Release();
|
||||||
pcIn->piSpecularTexture = NULL;
|
pcIn->piSpecularTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (pcIn->piEmissiveTexture)
|
if (pcIn->piEmissiveTexture)
|
||||||
{
|
{
|
||||||
pcIn->piEmissiveTexture->Release();
|
pcIn->piEmissiveTexture->Release();
|
||||||
pcIn->piEmissiveTexture = NULL;
|
pcIn->piEmissiveTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (pcIn->piAmbientTexture)
|
if (pcIn->piAmbientTexture)
|
||||||
{
|
{
|
||||||
pcIn->piAmbientTexture->Release();
|
pcIn->piAmbientTexture->Release();
|
||||||
pcIn->piAmbientTexture = NULL;
|
pcIn->piAmbientTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (pcIn->piOpacityTexture)
|
if (pcIn->piOpacityTexture)
|
||||||
{
|
{
|
||||||
pcIn->piOpacityTexture->Release();
|
pcIn->piOpacityTexture->Release();
|
||||||
pcIn->piOpacityTexture = NULL;
|
pcIn->piOpacityTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (pcIn->piNormalTexture)
|
if (pcIn->piNormalTexture)
|
||||||
{
|
{
|
||||||
pcIn->piNormalTexture->Release();
|
pcIn->piNormalTexture->Release();
|
||||||
pcIn->piNormalTexture = NULL;
|
pcIn->piNormalTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (pcIn->piShininessTexture)
|
if (pcIn->piShininessTexture)
|
||||||
{
|
{
|
||||||
pcIn->piShininessTexture->Release();
|
pcIn->piShininessTexture->Release();
|
||||||
pcIn->piShininessTexture = NULL;
|
pcIn->piShininessTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (pcIn->piLightmapTexture)
|
if (pcIn->piLightmapTexture)
|
||||||
{
|
{
|
||||||
pcIn->piLightmapTexture->Release();
|
pcIn->piLightmapTexture->Release();
|
||||||
pcIn->piLightmapTexture = NULL;
|
pcIn->piLightmapTexture = nullptr;
|
||||||
}
|
}
|
||||||
pcIn->piEffect = NULL;
|
pcIn->piEffect = nullptr;
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CMaterialManager::HMtoNMIfNecessary(
|
void CMaterialManager::HMtoNMIfNecessary(
|
||||||
|
@ -595,8 +594,8 @@ void CMaterialManager::HMtoNMIfNecessary(
|
||||||
IDirect3DTexture9** piTextureOut,
|
IDirect3DTexture9** piTextureOut,
|
||||||
bool bWasOriginallyHM)
|
bool bWasOriginallyHM)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != piTexture);
|
ai_assert(nullptr != piTexture);
|
||||||
ai_assert(NULL != piTextureOut);
|
ai_assert(nullptr != piTextureOut);
|
||||||
|
|
||||||
bool bMustConvert = false;
|
bool bMustConvert = false;
|
||||||
uintptr_t iElement = 3;
|
uintptr_t iElement = 3;
|
||||||
|
@ -617,7 +616,7 @@ void CMaterialManager::HMtoNMIfNecessary(
|
||||||
D3DLOCKED_RECT sRect;
|
D3DLOCKED_RECT sRect;
|
||||||
D3DSURFACE_DESC sDesc;
|
D3DSURFACE_DESC sDesc;
|
||||||
piTexture->GetLevelDesc(0,&sDesc);
|
piTexture->GetLevelDesc(0,&sDesc);
|
||||||
if (FAILED(piTexture->LockRect(0,&sRect,NULL,D3DLOCK_READONLY)))
|
if (FAILED(piTexture->LockRect(0,&sRect,nullptr,D3DLOCK_READONLY)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -627,7 +626,7 @@ void CMaterialManager::HMtoNMIfNecessary(
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct {unsigned char b,g,r,a;};
|
struct {unsigned char b,g,r,a;} data;
|
||||||
char _array[4];
|
char _array[4];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -646,7 +645,7 @@ void CMaterialManager::HMtoNMIfNecessary(
|
||||||
{
|
{
|
||||||
for (unsigned int x = 0; x < sDesc.Width;++x)
|
for (unsigned int x = 0; x < sDesc.Width;++x)
|
||||||
{
|
{
|
||||||
if (pcPointer->b != pcPointer->r || pcPointer->b != pcPointer->g)
|
if (pcPointer->data.b != pcPointer->data.r || pcPointer->data.b != pcPointer->data.g)
|
||||||
{
|
{
|
||||||
bIsEqual = false;
|
bIsEqual = false;
|
||||||
break;
|
break;
|
||||||
|
@ -705,9 +704,9 @@ void CMaterialManager::HMtoNMIfNecessary(
|
||||||
aiColor3D clrColorLine;
|
aiColor3D clrColorLine;
|
||||||
for (unsigned int x = 0; x < sDesc.Width;++x)
|
for (unsigned int x = 0; x < sDesc.Width;++x)
|
||||||
{
|
{
|
||||||
clrColorLine.r += pcPointer->r;
|
clrColorLine.r += pcPointer->data.r;
|
||||||
clrColorLine.g += pcPointer->g;
|
clrColorLine.g += pcPointer->data.g;
|
||||||
clrColorLine.b += pcPointer->b;
|
clrColorLine.b += pcPointer->data.b;
|
||||||
pcPointer++;
|
pcPointer++;
|
||||||
}
|
}
|
||||||
clrColor.r += clrColorLine.r /= (float)sDesc.Width;
|
clrColor.r += clrColorLine.r /= (float)sDesc.Width;
|
||||||
|
@ -739,17 +738,17 @@ void CMaterialManager::HMtoNMIfNecessary(
|
||||||
// need to convert it NOW
|
// need to convert it NOW
|
||||||
if (bMustConvert)
|
if (bMustConvert)
|
||||||
{
|
{
|
||||||
D3DSURFACE_DESC sDesc;
|
D3DSURFACE_DESC sDesc2;
|
||||||
piTexture->GetLevelDesc(0, &sDesc);
|
piTexture->GetLevelDesc(0, &sDesc2);
|
||||||
|
|
||||||
IDirect3DTexture9* piTempTexture;
|
IDirect3DTexture9* piTempTexture;
|
||||||
if(FAILED(g_piDevice->CreateTexture(
|
if(FAILED(g_piDevice->CreateTexture(
|
||||||
sDesc.Width,
|
sDesc2.Width,
|
||||||
sDesc.Height,
|
sDesc2.Height,
|
||||||
piTexture->GetLevelCount(),
|
piTexture->GetLevelCount(),
|
||||||
sDesc.Usage,
|
sDesc2.Usage,
|
||||||
sDesc.Format,
|
sDesc2.Format,
|
||||||
sDesc.Pool, &piTempTexture, NULL)))
|
sDesc2.Pool, &piTempTexture, nullptr)))
|
||||||
{
|
{
|
||||||
CLogDisplay::Instance().AddEntry(
|
CLogDisplay::Instance().AddEntry(
|
||||||
"[ERROR] Unable to create normal map texture",
|
"[ERROR] Unable to create normal map texture",
|
||||||
|
@ -764,7 +763,7 @@ void CMaterialManager::HMtoNMIfNecessary(
|
||||||
else /*if (0 == iElement)*/dwFlags = D3DX_CHANNEL_BLUE;
|
else /*if (0 == iElement)*/dwFlags = D3DX_CHANNEL_BLUE;
|
||||||
|
|
||||||
if(FAILED(D3DXComputeNormalMap(piTempTexture,
|
if(FAILED(D3DXComputeNormalMap(piTempTexture,
|
||||||
piTexture,NULL,0,dwFlags,1.0f)))
|
piTexture,nullptr,0,dwFlags,1.0f)))
|
||||||
{
|
{
|
||||||
CLogDisplay::Instance().AddEntry(
|
CLogDisplay::Instance().AddEntry(
|
||||||
"[ERROR] Unable to compute normal map from height map",
|
"[ERROR] Unable to compute normal map from height map",
|
||||||
|
@ -780,12 +779,12 @@ void CMaterialManager::HMtoNMIfNecessary(
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
bool CMaterialManager::HasAlphaPixels(IDirect3DTexture9* piTexture)
|
bool CMaterialManager::HasAlphaPixels(IDirect3DTexture9* piTexture)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != piTexture);
|
ai_assert(nullptr != piTexture);
|
||||||
|
|
||||||
D3DLOCKED_RECT sRect;
|
D3DLOCKED_RECT sRect;
|
||||||
D3DSURFACE_DESC sDesc;
|
D3DSURFACE_DESC sDesc;
|
||||||
piTexture->GetLevelDesc(0,&sDesc);
|
piTexture->GetLevelDesc(0,&sDesc);
|
||||||
if (FAILED(piTexture->LockRect(0,&sRect,NULL,D3DLOCK_READONLY)))
|
if (FAILED(piTexture->LockRect(0,&sRect,nullptr,D3DLOCK_READONLY)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -823,8 +822,8 @@ bool CMaterialManager::HasAlphaPixels(IDirect3DTexture9* piTexture)
|
||||||
int CMaterialManager::CreateMaterial(
|
int CMaterialManager::CreateMaterial(
|
||||||
AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource)
|
AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pcMesh);
|
ai_assert(nullptr != pcMesh);
|
||||||
ai_assert(NULL != pcSource);
|
ai_assert(nullptr != pcSource);
|
||||||
|
|
||||||
ID3DXBuffer* piBuffer;
|
ID3DXBuffer* piBuffer;
|
||||||
|
|
||||||
|
@ -1060,29 +1059,29 @@ int CMaterialManager::CreateMaterial(
|
||||||
}
|
}
|
||||||
AssetHelper::MeshHelper* pc = g_pcAsset->apcMeshes[i];
|
AssetHelper::MeshHelper* pc = g_pcAsset->apcMeshes[i];
|
||||||
|
|
||||||
if ((pcMesh->piDiffuseTexture != NULL ? true : false) !=
|
if ((pcMesh->piDiffuseTexture != nullptr ? true : false) !=
|
||||||
(pc->piDiffuseTexture != NULL ? true : false))
|
(pc->piDiffuseTexture != nullptr ? true : false))
|
||||||
continue;
|
continue;
|
||||||
if ((pcMesh->piSpecularTexture != NULL ? true : false) !=
|
if ((pcMesh->piSpecularTexture != nullptr ? true : false) !=
|
||||||
(pc->piSpecularTexture != NULL ? true : false))
|
(pc->piSpecularTexture != nullptr ? true : false))
|
||||||
continue;
|
continue;
|
||||||
if ((pcMesh->piAmbientTexture != NULL ? true : false) !=
|
if ((pcMesh->piAmbientTexture != nullptr ? true : false) !=
|
||||||
(pc->piAmbientTexture != NULL ? true : false))
|
(pc->piAmbientTexture != nullptr ? true : false))
|
||||||
continue;
|
continue;
|
||||||
if ((pcMesh->piEmissiveTexture != NULL ? true : false) !=
|
if ((pcMesh->piEmissiveTexture != nullptr ? true : false) !=
|
||||||
(pc->piEmissiveTexture != NULL ? true : false))
|
(pc->piEmissiveTexture != nullptr ? true : false))
|
||||||
continue;
|
continue;
|
||||||
if ((pcMesh->piNormalTexture != NULL ? true : false) !=
|
if ((pcMesh->piNormalTexture != nullptr ? true : false) !=
|
||||||
(pc->piNormalTexture != NULL ? true : false))
|
(pc->piNormalTexture != nullptr ? true : false))
|
||||||
continue;
|
continue;
|
||||||
if ((pcMesh->piOpacityTexture != NULL ? true : false) !=
|
if ((pcMesh->piOpacityTexture != nullptr ? true : false) !=
|
||||||
(pc->piOpacityTexture != NULL ? true : false))
|
(pc->piOpacityTexture != nullptr ? true : false))
|
||||||
continue;
|
continue;
|
||||||
if ((pcMesh->piShininessTexture != NULL ? true : false) !=
|
if ((pcMesh->piShininessTexture != nullptr ? true : false) !=
|
||||||
(pc->piShininessTexture != NULL ? true : false))
|
(pc->piShininessTexture != nullptr ? true : false))
|
||||||
continue;
|
continue;
|
||||||
if ((pcMesh->piLightmapTexture != NULL ? true : false) !=
|
if ((pcMesh->piLightmapTexture != nullptr ? true : false) !=
|
||||||
(pc->piLightmapTexture != NULL ? true : false))
|
(pc->piLightmapTexture != nullptr ? true : false))
|
||||||
continue;
|
continue;
|
||||||
if ((pcMesh->eShadingMode != aiShadingMode_Gouraud ? true : false) !=
|
if ((pcMesh->eShadingMode != aiShadingMode_Gouraud ? true : false) !=
|
||||||
(pc->eShadingMode != aiShadingMode_Gouraud ? true : false))
|
(pc->eShadingMode != aiShadingMode_Gouraud ? true : false))
|
||||||
|
@ -1239,13 +1238,13 @@ int CMaterialManager::CreateMaterial(
|
||||||
sMacro[iCurrent].Definition = "1";
|
sMacro[iCurrent].Definition = "1";
|
||||||
++iCurrent;
|
++iCurrent;
|
||||||
}
|
}
|
||||||
sMacro[iCurrent].Name = NULL;
|
sMacro[iCurrent].Name = nullptr;
|
||||||
sMacro[iCurrent].Definition = NULL;
|
sMacro[iCurrent].Definition = nullptr;
|
||||||
|
|
||||||
// compile the shader
|
// compile the shader
|
||||||
if(FAILED( D3DXCreateEffect(g_piDevice,
|
if(FAILED( D3DXCreateEffect(g_piDevice,
|
||||||
g_szMaterialShader.c_str(),(UINT)g_szMaterialShader.length(),
|
g_szMaterialShader.c_str(),(UINT)g_szMaterialShader.length(),
|
||||||
(const D3DXMACRO*)sMacro,NULL,0,NULL,&pcMesh->piEffect,&piBuffer)))
|
(const D3DXMACRO*)sMacro,nullptr,0,nullptr,&pcMesh->piEffect,&piBuffer)))
|
||||||
{
|
{
|
||||||
// failed to compile the shader
|
// failed to compile the shader
|
||||||
if( piBuffer)
|
if( piBuffer)
|
||||||
|
@ -1333,7 +1332,7 @@ int CMaterialManager::SetupMaterial (
|
||||||
const aiMatrix4x4& pcCam,
|
const aiMatrix4x4& pcCam,
|
||||||
const aiVector3D& vPos)
|
const aiVector3D& vPos)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pcMesh);
|
ai_assert(nullptr != pcMesh);
|
||||||
if (!pcMesh->piEffect)return 0;
|
if (!pcMesh->piEffect)return 0;
|
||||||
|
|
||||||
ID3DXEffect* piEnd = pcMesh->piEffect;
|
ID3DXEffect* piEnd = pcMesh->piEffect;
|
||||||
|
@ -1476,7 +1475,7 @@ int CMaterialManager::SetupMaterial (
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CMaterialManager::EndMaterial (AssetHelper::MeshHelper* pcMesh)
|
int CMaterialManager::EndMaterial (AssetHelper::MeshHelper* pcMesh)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pcMesh);
|
ai_assert(nullptr != pcMesh);
|
||||||
if (!pcMesh->piEffect)return 0;
|
if (!pcMesh->piEffect)return 0;
|
||||||
|
|
||||||
// end the effect
|
// end the effect
|
||||||
|
@ -1490,4 +1489,5 @@ int CMaterialManager::EndMaterial (AssetHelper::MeshHelper* pcMesh)
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}; // end namespace AssimpView
|
|
||||||
|
} // end namespace AssimpView
|
||||||
|
|
|
@ -60,13 +60,13 @@ using namespace Assimp;
|
||||||
COLORREF g_aclCustomColors[16] = {0};
|
COLORREF g_aclCustomColors[16] = {0};
|
||||||
|
|
||||||
// Global registry key
|
// Global registry key
|
||||||
HKEY g_hRegistry = NULL;
|
HKEY g_hRegistry = nullptr;
|
||||||
|
|
||||||
// list of previous files (always 5)
|
// list of previous files (always 5)
|
||||||
std::vector<std::string> g_aPreviousFiles;
|
std::vector<std::string> g_aPreviousFiles;
|
||||||
|
|
||||||
// history menu item
|
// history menu item
|
||||||
HMENU g_hHistoryMenu = NULL;
|
HMENU g_hHistoryMenu = nullptr;
|
||||||
|
|
||||||
float g_fACMR = 3.0f;
|
float g_fACMR = 3.0f;
|
||||||
|
|
||||||
|
@ -89,10 +89,10 @@ void MakeFileAssociations() {
|
||||||
char szTemp2[MAX_PATH];
|
char szTemp2[MAX_PATH];
|
||||||
char szTemp[MAX_PATH + 10];
|
char szTemp[MAX_PATH + 10];
|
||||||
|
|
||||||
GetModuleFileName(NULL,szTemp2,MAX_PATH);
|
GetModuleFileName(nullptr,szTemp2,MAX_PATH);
|
||||||
sprintf(szTemp,"%s %%1",szTemp2);
|
sprintf(szTemp,"%s %%1",szTemp2);
|
||||||
|
|
||||||
HKEY hRegistry = NULL;
|
HKEY hRegistry = nullptr;
|
||||||
|
|
||||||
aiString list, tmp;
|
aiString list, tmp;
|
||||||
aiGetExtensionList(&list);
|
aiGetExtensionList(&list);
|
||||||
|
@ -104,15 +104,15 @@ void MakeFileAssociations() {
|
||||||
ai_assert(sz[0] == '*');
|
ai_assert(sz[0] == '*');
|
||||||
sprintf(buf,"Software\\Classes\\%s",sz+1);
|
sprintf(buf,"Software\\Classes\\%s",sz+1);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,buf,0,NULL,0,KEY_ALL_ACCESS, NULL, &hRegistry,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,buf,0,nullptr,0,KEY_ALL_ACCESS, nullptr, &hRegistry,nullptr);
|
||||||
RegSetValueEx(hRegistry,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
RegSetValueEx(hRegistry,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hRegistry);
|
RegCloseKey(hRegistry);
|
||||||
} while ((sz = strtok(NULL,";")));
|
} while ((sz = strtok(nullptr,";")) != nullptr);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",0,NULL,0,KEY_ALL_ACCESS, NULL, &hRegistry,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",0,nullptr,0,KEY_ALL_ACCESS, nullptr, &hRegistry,nullptr);
|
||||||
RegCloseKey(hRegistry);
|
RegCloseKey(hRegistry);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS\\shell\\open\\command",0,NULL,0,KEY_ALL_ACCESS, NULL, &hRegistry,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS\\shell\\open\\command",0,nullptr,0,KEY_ALL_ACCESS, nullptr, &hRegistry,nullptr);
|
||||||
RegSetValueEx(hRegistry,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
RegSetValueEx(hRegistry,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
||||||
RegCloseKey(hRegistry);
|
RegCloseKey(hRegistry);
|
||||||
|
|
||||||
|
@ -157,9 +157,9 @@ void HandleCommandLine(char* p_szCommand) {
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void LoadLightColors() {
|
void LoadLightColors() {
|
||||||
DWORD dwTemp = 4;
|
DWORD dwTemp = 4;
|
||||||
RegQueryValueEx(g_hRegistry,"LightColor0",NULL,NULL, (BYTE*)&g_avLightColors[0],&dwTemp);
|
RegQueryValueEx(g_hRegistry,"LightColor0",nullptr,nullptr, (BYTE*)&g_avLightColors[0],&dwTemp);
|
||||||
RegQueryValueEx(g_hRegistry,"LightColor1",NULL,NULL, (BYTE*)&g_avLightColors[1],&dwTemp);
|
RegQueryValueEx(g_hRegistry,"LightColor1",nullptr,nullptr, (BYTE*)&g_avLightColors[1],&dwTemp);
|
||||||
RegQueryValueEx(g_hRegistry,"LightColor2",NULL,NULL, (BYTE*)&g_avLightColors[2],&dwTemp);
|
RegQueryValueEx(g_hRegistry,"LightColor2",nullptr,nullptr, (BYTE*)&g_avLightColors[2],&dwTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -190,10 +190,10 @@ void SaveCheckerPatternColors() {
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void LoadCheckerPatternColors() {
|
void LoadCheckerPatternColors() {
|
||||||
DWORD dwTemp = sizeof(D3DXVECTOR3);
|
DWORD dwTemp = sizeof(D3DXVECTOR3);
|
||||||
RegQueryValueEx(g_hRegistry,"CheckerPattern0",NULL,NULL,
|
RegQueryValueEx(g_hRegistry,"CheckerPattern0",nullptr,nullptr,
|
||||||
(BYTE*) /* jep, this is evil */ CDisplay::Instance().GetFirstCheckerColor(),&dwTemp);
|
(BYTE*) /* jep, this is evil */ CDisplay::Instance().GetFirstCheckerColor(),&dwTemp);
|
||||||
|
|
||||||
RegQueryValueEx(g_hRegistry,"CheckerPattern1",NULL,NULL,
|
RegQueryValueEx(g_hRegistry,"CheckerPattern1",nullptr,nullptr,
|
||||||
(BYTE*) /* jep, this is evil */ CDisplay::Instance().GetSecondCheckerColor(),&dwTemp);
|
(BYTE*) /* jep, this is evil */ CDisplay::Instance().GetSecondCheckerColor(),&dwTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,13 +372,13 @@ void ToggleUIState() {
|
||||||
sRect2.top -= sRect.top;
|
sRect2.top -= sRect.top;
|
||||||
|
|
||||||
if (BST_UNCHECKED == IsDlgButtonChecked(g_hDlg,IDC_BLUBB)) {
|
if (BST_UNCHECKED == IsDlgButtonChecked(g_hDlg,IDC_BLUBB)) {
|
||||||
SetWindowPos(g_hDlg,NULL,0,0,sRect.right-214,sRect.bottom,
|
SetWindowPos(g_hDlg,nullptr,0,0,sRect.right-214,sRect.bottom,
|
||||||
SWP_NOMOVE | SWP_NOZORDER);
|
SWP_NOMOVE | SWP_NOZORDER);
|
||||||
|
|
||||||
SetWindowText(GetDlgItem(g_hDlg,IDC_BLUBB),">>");
|
SetWindowText(GetDlgItem(g_hDlg,IDC_BLUBB),">>");
|
||||||
storeRegKey(false, "MultiSampling");
|
storeRegKey(false, "MultiSampling");
|
||||||
} else {
|
} else {
|
||||||
SetWindowPos(g_hDlg,NULL,0,0,sRect.right+214,sRect.bottom,
|
SetWindowPos(g_hDlg,nullptr,0,0,sRect.right+214,sRect.bottom,
|
||||||
SWP_NOMOVE | SWP_NOZORDER);
|
SWP_NOMOVE | SWP_NOZORDER);
|
||||||
|
|
||||||
storeRegKey(true, "LastUIState");
|
storeRegKey(true, "LastUIState");
|
||||||
|
@ -394,7 +394,7 @@ void LoadBGTexture() {
|
||||||
char szFileName[MAX_PATH];
|
char szFileName[MAX_PATH];
|
||||||
|
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"TextureSrc",NULL,NULL, (BYTE*)szFileName,&dwTemp)) {
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"TextureSrc",nullptr,nullptr, (BYTE*)szFileName,&dwTemp)) {
|
||||||
// Key was not found. Use C:
|
// Key was not found. Use C:
|
||||||
strcpy(szFileName,"");
|
strcpy(szFileName,"");
|
||||||
} else {
|
} else {
|
||||||
|
@ -407,13 +407,13 @@ void LoadBGTexture() {
|
||||||
}
|
}
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(nullptr),
|
||||||
"Textures\0*.png;*.dds;*.tga;*.bmp;*.tif;*.ppm;*.ppx;*.jpg;*.jpeg;*.exr\0*.*\0",
|
"Textures\0*.png;*.dds;*.tga;*.bmp;*.tif;*.ppm;*.ppx;*.jpg;*.jpeg;*.exr\0*.*\0",
|
||||||
NULL, 0, 1,
|
nullptr, 0, 1,
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, nullptr, 0, nullptr,
|
||||||
"Open texture as background",
|
"Open texture as background",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
0, 1, ".jpg", 0, NULL, NULL
|
0, 1, ".jpg", 0, nullptr, nullptr
|
||||||
};
|
};
|
||||||
if(GetOpenFileName(&sFilename1) == 0) return;
|
if(GetOpenFileName(&sFilename1) == 0) return;
|
||||||
|
|
||||||
|
@ -448,8 +448,8 @@ void DisplayColorDialog(D3DCOLOR* pclrResult) {
|
||||||
clr.Flags = CC_RGBINIT | CC_FULLOPEN;
|
clr.Flags = CC_RGBINIT | CC_FULLOPEN;
|
||||||
clr.rgbResult = RGB((*pclrResult >> 16) & 0xff,(*pclrResult >> 8) & 0xff,*pclrResult & 0xff);
|
clr.rgbResult = RGB((*pclrResult >> 16) & 0xff,(*pclrResult >> 8) & 0xff,*pclrResult & 0xff);
|
||||||
clr.lpCustColors = g_aclCustomColors;
|
clr.lpCustColors = g_aclCustomColors;
|
||||||
clr.lpfnHook = NULL;
|
clr.lpfnHook = nullptr;
|
||||||
clr.lpTemplateName = NULL;
|
clr.lpTemplateName = nullptr;
|
||||||
clr.lCustData = 0;
|
clr.lCustData = 0;
|
||||||
|
|
||||||
ChooseColor(&clr);
|
ChooseColor(&clr);
|
||||||
|
@ -472,8 +472,8 @@ void DisplayColorDialog(D3DXVECTOR4* pclrResult) {
|
||||||
clamp<unsigned char>(pclrResult->y * 255.0f),
|
clamp<unsigned char>(pclrResult->y * 255.0f),
|
||||||
clamp<unsigned char>(pclrResult->z * 255.0f));
|
clamp<unsigned char>(pclrResult->z * 255.0f));
|
||||||
clr.lpCustColors = g_aclCustomColors;
|
clr.lpCustColors = g_aclCustomColors;
|
||||||
clr.lpfnHook = NULL;
|
clr.lpfnHook = nullptr;
|
||||||
clr.lpTemplateName = NULL;
|
clr.lpTemplateName = nullptr;
|
||||||
clr.lCustData = 0;
|
clr.lCustData = 0;
|
||||||
|
|
||||||
ChooseColor(&clr);
|
ChooseColor(&clr);
|
||||||
|
@ -504,7 +504,7 @@ void LoadSkybox() {
|
||||||
char szFileName[MAX_PATH];
|
char szFileName[MAX_PATH];
|
||||||
|
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"SkyBoxSrc",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"SkyBoxSrc",nullptr,nullptr,
|
||||||
(BYTE*)szFileName,&dwTemp))
|
(BYTE*)szFileName,&dwTemp))
|
||||||
{
|
{
|
||||||
// Key was not found. Use C:
|
// Key was not found. Use C:
|
||||||
|
@ -521,12 +521,12 @@ void LoadSkybox() {
|
||||||
}
|
}
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(nullptr),
|
||||||
"Skyboxes\0*.dds\0*.*\0", NULL, 0, 1,
|
"Skyboxes\0*.dds\0*.*\0", nullptr, 0, 1,
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, nullptr, 0, nullptr,
|
||||||
"Open skybox as background",
|
"Open skybox as background",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
0, 1, ".dds", 0, NULL, NULL
|
0, 1, ".dds", 0, nullptr, nullptr
|
||||||
};
|
};
|
||||||
if(GetOpenFileName(&sFilename1) == 0) return;
|
if(GetOpenFileName(&sFilename1) == 0) return;
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ void SaveScreenshot() {
|
||||||
char szFileName[MAX_PATH];
|
char szFileName[MAX_PATH];
|
||||||
|
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"ScreenShot",NULL,NULL, (BYTE*)szFileName,&dwTemp)) {
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"ScreenShot",nullptr,nullptr, (BYTE*)szFileName,&dwTemp)) {
|
||||||
// Key was not found. Use C:
|
// Key was not found. Use C:
|
||||||
strcpy(szFileName,"");
|
strcpy(szFileName,"");
|
||||||
} else {
|
} else {
|
||||||
|
@ -568,21 +568,21 @@ void SaveScreenshot() {
|
||||||
}
|
}
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(nullptr),
|
||||||
"PNG Images\0*.png", NULL, 0, 1,
|
"PNG Images\0*.png", nullptr, 0, 1,
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, nullptr, 0, nullptr,
|
||||||
"Save Screenshot to file",
|
"Save Screenshot to file",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
0, 1, ".png", 0, NULL, NULL
|
0, 1, ".png", 0, nullptr, nullptr
|
||||||
};
|
};
|
||||||
if(GetSaveFileName(&sFilename1) == 0) return;
|
if(GetSaveFileName(&sFilename1) == 0) return;
|
||||||
|
|
||||||
// Now store the file in the registry
|
// Now store the file in the registry
|
||||||
RegSetValueExA(g_hRegistry,"ScreenShot",0,REG_SZ,(const BYTE*)szFileName,MAX_PATH);
|
RegSetValueExA(g_hRegistry,"ScreenShot",0,REG_SZ,(const BYTE*)szFileName,MAX_PATH);
|
||||||
|
|
||||||
IDirect3DSurface9* pi = NULL;
|
IDirect3DSurface9* pi = nullptr;
|
||||||
g_piDevice->GetRenderTarget(0,&pi);
|
g_piDevice->GetRenderTarget(0,&pi);
|
||||||
if(!pi || FAILED(D3DXSaveSurfaceToFile(szFileName,D3DXIFF_PNG,pi,NULL,NULL))) {
|
if(!pi || FAILED(D3DXSaveSurfaceToFile(szFileName,D3DXIFF_PNG,pi,nullptr,nullptr))) {
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to save screenshot",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to save screenshot",
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
} else {
|
} else {
|
||||||
|
@ -751,7 +751,7 @@ void LoadHistory() {
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
|
|
||||||
szFileName[0] ='\0';
|
szFileName[0] ='\0';
|
||||||
if(ERROR_SUCCESS == RegQueryValueEx(g_hRegistry,szName,NULL,NULL,
|
if(ERROR_SUCCESS == RegQueryValueEx(g_hRegistry,szName,nullptr,nullptr,
|
||||||
(BYTE*)szFileName,&dwTemp)) {
|
(BYTE*)szFileName,&dwTemp)) {
|
||||||
g_aPreviousFiles[i] = std::string(szFileName);
|
g_aPreviousFiles[i] = std::string(szFileName);
|
||||||
}
|
}
|
||||||
|
@ -826,7 +826,7 @@ void OpenAsset() {
|
||||||
char szFileName[MAX_PATH];
|
char szFileName[MAX_PATH];
|
||||||
|
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"CurrentApp",NULL,NULL, (BYTE*)szFileName,&dwTemp)) {
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"CurrentApp",nullptr,nullptr, (BYTE*)szFileName,&dwTemp)) {
|
||||||
// Key was not found. Use C:
|
// Key was not found. Use C:
|
||||||
strcpy(szFileName,"");
|
strcpy(szFileName,"");
|
||||||
} else {
|
} else {
|
||||||
|
@ -856,15 +856,15 @@ void OpenAsset() {
|
||||||
ZeroMemory(&sFilename1, sizeof(sFilename1));
|
ZeroMemory(&sFilename1, sizeof(sFilename1));
|
||||||
sFilename1.lStructSize = sizeof(sFilename1);
|
sFilename1.lStructSize = sizeof(sFilename1);
|
||||||
sFilename1.hwndOwner = g_hDlg;
|
sFilename1.hwndOwner = g_hDlg;
|
||||||
sFilename1.hInstance = GetModuleHandle(NULL);
|
sFilename1.hInstance = GetModuleHandle(nullptr);
|
||||||
sFilename1.lpstrFile = szFileName;
|
sFilename1.lpstrFile = szFileName;
|
||||||
sFilename1.lpstrFile[0] = '\0';
|
sFilename1.lpstrFile[0] = '\0';
|
||||||
sFilename1.nMaxFile = sizeof(szList);
|
sFilename1.nMaxFile = sizeof(szList);
|
||||||
sFilename1.lpstrFilter = szList;
|
sFilename1.lpstrFilter = szList;
|
||||||
sFilename1.nFilterIndex = 1;
|
sFilename1.nFilterIndex = 1;
|
||||||
sFilename1.lpstrFileTitle = NULL;
|
sFilename1.lpstrFileTitle = nullptr;
|
||||||
sFilename1.nMaxFileTitle = 0;
|
sFilename1.nMaxFileTitle = 0;
|
||||||
sFilename1.lpstrInitialDir = NULL;
|
sFilename1.lpstrInitialDir = nullptr;
|
||||||
sFilename1.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
|
sFilename1.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
|
||||||
if (GetOpenFileName(&sFilename1) == 0) {
|
if (GetOpenFileName(&sFilename1) == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -942,7 +942,7 @@ void DoExport(size_t formatId) {
|
||||||
|
|
||||||
char szFileName[MAX_PATH*2];
|
char szFileName[MAX_PATH*2];
|
||||||
DWORD dwTemp = sizeof(szFileName);
|
DWORD dwTemp = sizeof(szFileName);
|
||||||
if(ERROR_SUCCESS == RegQueryValueEx(g_hRegistry,"ModelExportDest",NULL,NULL,(BYTE*)szFileName, &dwTemp)) {
|
if(ERROR_SUCCESS == RegQueryValueEx(g_hRegistry,"ModelExportDest",nullptr,nullptr,(BYTE*)szFileName, &dwTemp)) {
|
||||||
ai_assert(strlen(szFileName) <= MAX_PATH);
|
ai_assert(strlen(szFileName) <= MAX_PATH);
|
||||||
|
|
||||||
// invent a nice default file name
|
// invent a nice default file name
|
||||||
|
@ -975,12 +975,12 @@ void DoExport(size_t formatId) {
|
||||||
const std::string ext = "."+std::string(e->fileExtension);
|
const std::string ext = "."+std::string(e->fileExtension);
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(nullptr),
|
||||||
desc, NULL, 0, 1,
|
desc, nullptr, 0, 1,
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, nullptr, 0, nullptr,
|
||||||
"Export asset",
|
"Export asset",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
0, 1, ext.c_str(), 0, NULL, NULL
|
0, 1, ext.c_str(), 0, nullptr, nullptr
|
||||||
};
|
};
|
||||||
if(::GetSaveFileName(&sFilename1) == 0) {
|
if(::GetSaveFileName(&sFilename1) == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -1036,9 +1036,9 @@ void InitUI() {
|
||||||
|
|
||||||
// store the key in a global variable for later use
|
// store the key in a global variable for later use
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\ASSIMP\\Viewer",
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\ASSIMP\\Viewer",
|
||||||
0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
|
0,nullptr,0,KEY_ALL_ACCESS, nullptr, &g_hRegistry,nullptr);
|
||||||
|
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LastUIState",NULL,NULL, (BYTE*)&dwValue,&dwTemp)) {
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LastUIState",nullptr,nullptr, (BYTE*)&dwValue,&dwTemp)) {
|
||||||
dwValue = 1;
|
dwValue = 1;
|
||||||
}
|
}
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
|
@ -1054,7 +1054,7 @@ void InitUI() {
|
||||||
sRect2.left -= sRect.left;
|
sRect2.left -= sRect.left;
|
||||||
sRect2.top -= sRect.top;
|
sRect2.top -= sRect.top;
|
||||||
|
|
||||||
SetWindowPos(g_hDlg,NULL,0,0,sRect.right-214,sRect.bottom,
|
SetWindowPos(g_hDlg,nullptr,0,0,sRect.right-214,sRect.bottom,
|
||||||
SWP_NOMOVE | SWP_NOZORDER);
|
SWP_NOMOVE | SWP_NOZORDER);
|
||||||
SetWindowText(GetDlgItem(g_hDlg,IDC_BLUBB),">>");
|
SetWindowText(GetDlgItem(g_hDlg,IDC_BLUBB),">>");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1062,7 +1062,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutoRotate
|
// AutoRotate
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"AutoRotate",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"AutoRotate",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
g_sOptions.bRotate = false;
|
g_sOptions.bRotate = false;
|
||||||
|
@ -1073,7 +1073,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MultipleLights
|
// MultipleLights
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"MultipleLights",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"MultipleLights",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
g_sOptions.b3Lights = false;
|
g_sOptions.b3Lights = false;
|
||||||
|
@ -1084,7 +1084,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Light rotate
|
// Light rotate
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LightRotate",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LightRotate",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
g_sOptions.bLightRotate = false;
|
g_sOptions.bLightRotate = false;
|
||||||
|
@ -1095,7 +1095,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoSpecular
|
// NoSpecular
|
||||||
if (ERROR_SUCCESS != RegQueryValueEx(g_hRegistry, "NoSpecular", NULL, NULL, (BYTE*)&dwValue, &dwTemp)) {
|
if (ERROR_SUCCESS != RegQueryValueEx(g_hRegistry, "NoSpecular", nullptr, nullptr, (BYTE*)&dwValue, &dwTemp)) {
|
||||||
dwValue = 0;
|
dwValue = 0;
|
||||||
}
|
}
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
|
@ -1107,7 +1107,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LowQuality
|
// LowQuality
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LowQuality",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LowQuality",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
g_sOptions.bLowQuality = false;
|
g_sOptions.bLowQuality = false;
|
||||||
|
@ -1118,7 +1118,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LowQuality
|
// LowQuality
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"NoTransparency",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"NoTransparency",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
g_sOptions.bNoAlphaBlending = false;
|
g_sOptions.bNoAlphaBlending = false;
|
||||||
|
@ -1129,7 +1129,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisplayNormals
|
// DisplayNormals
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"RenderNormals",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"RenderNormals",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
g_sOptions.bRenderNormals = false;
|
g_sOptions.bRenderNormals = false;
|
||||||
|
@ -1140,7 +1140,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoMaterials
|
// NoMaterials
|
||||||
if (ERROR_SUCCESS != RegQueryValueEx(g_hRegistry, "RenderMats", NULL, NULL,
|
if (ERROR_SUCCESS != RegQueryValueEx(g_hRegistry, "RenderMats", nullptr, nullptr,
|
||||||
(BYTE*)&dwValue, &dwTemp)) {
|
(BYTE*)&dwValue, &dwTemp)) {
|
||||||
dwValue = 1;
|
dwValue = 1;
|
||||||
}
|
}
|
||||||
|
@ -1153,7 +1153,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MultiSampling
|
// MultiSampling
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"MultiSampling",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"MultiSampling",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 1;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 1;
|
||||||
if (0 == dwValue)
|
if (0 == dwValue)
|
||||||
{
|
{
|
||||||
|
@ -1165,7 +1165,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FPS Mode
|
// FPS Mode
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"FPSView",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"FPSView",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
||||||
if (0 == dwValue) {
|
if (0 == dwValue) {
|
||||||
g_bFPSView = false;
|
g_bFPSView = false;
|
||||||
|
@ -1176,7 +1176,7 @@ void InitUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WireFrame
|
// WireFrame
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"Wireframe",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"Wireframe",nullptr,nullptr,
|
||||||
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
(BYTE*)&dwValue,&dwTemp))dwValue = 0;
|
||||||
if (0 == dwValue)
|
if (0 == dwValue)
|
||||||
{
|
{
|
||||||
|
@ -1189,7 +1189,7 @@ void InitUI() {
|
||||||
CheckDlgButton(g_hDlg,IDC_TOGGLEWIRE,BST_CHECKED);
|
CheckDlgButton(g_hDlg,IDC_TOGGLEWIRE,BST_CHECKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"PostProcessing",NULL,NULL,(BYTE*)&dwValue,&dwTemp))
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"PostProcessing",nullptr,nullptr,(BYTE*)&dwValue,&dwTemp))
|
||||||
ppsteps = ppstepsdefault;
|
ppsteps = ppstepsdefault;
|
||||||
else ppsteps = dwValue;
|
else ppsteps = dwValue;
|
||||||
|
|
||||||
|
@ -1458,7 +1458,7 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam
|
||||||
if (bDraw)
|
if (bDraw)
|
||||||
{
|
{
|
||||||
SetBkColor(pcStruct->hDC,RGB(0,0,0));
|
SetBkColor(pcStruct->hDC,RGB(0,0,0));
|
||||||
MoveToEx(pcStruct->hDC,0,0,NULL);
|
MoveToEx(pcStruct->hDC,0,0,nullptr);
|
||||||
LineTo(pcStruct->hDC,sRect.right-1,0);
|
LineTo(pcStruct->hDC,sRect.right-1,0);
|
||||||
LineTo(pcStruct->hDC,sRect.right-1,sRect.bottom-1);
|
LineTo(pcStruct->hDC,sRect.right-1,sRect.bottom-1);
|
||||||
LineTo(pcStruct->hDC,0,sRect.bottom-1);
|
LineTo(pcStruct->hDC,0,sRect.bottom-1);
|
||||||
|
@ -1534,7 +1534,7 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam
|
||||||
g_eClick = EClickPos_Outside;
|
g_eClick = EClickPos_Outside;
|
||||||
if (xPos2 >= fHalfX && xPos2 < fHalfX + (int)sDesc.Width &&
|
if (xPos2 >= fHalfX && xPos2 < fHalfX + (int)sDesc.Width &&
|
||||||
yPos2 >= fHalfY && yPos2 < fHalfY + (int)sDesc.Height &&
|
yPos2 >= fHalfY && yPos2 < fHalfY + (int)sDesc.Height &&
|
||||||
NULL != g_szImageMask)
|
nullptr != g_szImageMask)
|
||||||
{
|
{
|
||||||
// inside the texture. Lookup the grayscale value from it
|
// inside the texture. Lookup the grayscale value from it
|
||||||
xPos2 -= fHalfX;
|
xPos2 -= fHalfX;
|
||||||
|
@ -1710,13 +1710,13 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam
|
||||||
} else if (ID_TOOLS_LOGWINDOW == LOWORD(wParam)) {
|
} else if (ID_TOOLS_LOGWINDOW == LOWORD(wParam)) {
|
||||||
CLogWindow::Instance().Show();
|
CLogWindow::Instance().Show();
|
||||||
} else if (ID__WEBSITE == LOWORD(wParam)) {
|
} else if (ID__WEBSITE == LOWORD(wParam)) {
|
||||||
ShellExecute(NULL,"open","http://assimp.sourceforge.net","","",SW_SHOW);
|
ShellExecute(nullptr,"open","http://assimp.sourceforge.net","","",SW_SHOW);
|
||||||
} else if (ID__WEBSITESF == LOWORD(wParam)) {
|
} else if (ID__WEBSITESF == LOWORD(wParam)) {
|
||||||
ShellExecute(NULL,"open","https://sourceforge.net/projects/assimp","","",SW_SHOW);
|
ShellExecute(nullptr,"open","https://sourceforge.net/projects/assimp","","",SW_SHOW);
|
||||||
} else if (ID_REPORTBUG == LOWORD(wParam)) {
|
} else if (ID_REPORTBUG == LOWORD(wParam)) {
|
||||||
ShellExecute(NULL,"open","https://sourceforge.net/tracker/?func=add&group_id=226462&atid=1067632","","",SW_SHOW);
|
ShellExecute(nullptr,"open","https://sourceforge.net/tracker/?func=add&group_id=226462&atid=1067632","","",SW_SHOW);
|
||||||
} else if (ID_FR == LOWORD(wParam)) {
|
} else if (ID_FR == LOWORD(wParam)) {
|
||||||
ShellExecute(NULL,"open","https://sourceforge.net/forum/forum.php?forum_id=817653","","",SW_SHOW);
|
ShellExecute(nullptr,"open","https://sourceforge.net/forum/forum.php?forum_id=817653","","",SW_SHOW);
|
||||||
} else if (ID_TOOLS_CLEARLOG == LOWORD(wParam)) {
|
} else if (ID_TOOLS_CLEARLOG == LOWORD(wParam)) {
|
||||||
CLogWindow::Instance().Clear();
|
CLogWindow::Instance().Clear();
|
||||||
} else if (ID_TOOLS_SAVELOGTOFILE == LOWORD(wParam)) {
|
} else if (ID_TOOLS_SAVELOGTOFILE == LOWORD(wParam)) {
|
||||||
|
@ -1838,7 +1838,7 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam
|
||||||
}
|
}
|
||||||
else if (ID_IMPORTSETTINGS_OPENPOST == LOWORD(wParam))
|
else if (ID_IMPORTSETTINGS_OPENPOST == LOWORD(wParam))
|
||||||
{
|
{
|
||||||
ShellExecute(NULL,"open","http://assimp.sourceforge.net/lib_html/ai_post_process_8h.html","","",SW_SHOW);
|
ShellExecute(nullptr,"open","http://assimp.sourceforge.net/lib_html/ai_post_process_8h.html","","",SW_SHOW);
|
||||||
}
|
}
|
||||||
else if (ID_TOOLS_ORIGINALNORMALS == LOWORD(wParam))
|
else if (ID_TOOLS_ORIGINALNORMALS == LOWORD(wParam))
|
||||||
{
|
{
|
||||||
|
@ -1922,7 +1922,7 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam
|
||||||
DisplayColorDialog(&g_avLightColors[0]);
|
DisplayColorDialog(&g_avLightColors[0]);
|
||||||
SaveLightColors();
|
SaveLightColors();
|
||||||
}
|
}
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR1),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR1),nullptr,TRUE);
|
||||||
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR1));
|
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR1));
|
||||||
}
|
}
|
||||||
else if (IDC_LCOLOR2 == LOWORD(wParam))
|
else if (IDC_LCOLOR2 == LOWORD(wParam))
|
||||||
|
@ -1939,13 +1939,13 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam
|
||||||
DisplayColorDialog(&g_avLightColors[1]);
|
DisplayColorDialog(&g_avLightColors[1]);
|
||||||
SaveLightColors();
|
SaveLightColors();
|
||||||
}
|
}
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR2),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR2),nullptr,TRUE);
|
||||||
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR2));
|
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR2));
|
||||||
}
|
}
|
||||||
else if (IDC_LCOLOR3 == LOWORD(wParam))
|
else if (IDC_LCOLOR3 == LOWORD(wParam))
|
||||||
{
|
{
|
||||||
DisplayColorDialog(&g_avLightColors[2]);
|
DisplayColorDialog(&g_avLightColors[2]);
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR3),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR3),nullptr,TRUE);
|
||||||
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR3));
|
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR3));
|
||||||
SaveLightColors();
|
SaveLightColors();
|
||||||
}
|
}
|
||||||
|
@ -1966,11 +1966,11 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam
|
||||||
SaveLightColors();
|
SaveLightColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR1),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR1),nullptr,TRUE);
|
||||||
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR1));
|
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR1));
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR2),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR2),nullptr,TRUE);
|
||||||
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR2));
|
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR2));
|
||||||
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR3),NULL,TRUE);
|
InvalidateRect(GetDlgItem(g_hDlg,IDC_LCOLOR3),nullptr,TRUE);
|
||||||
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR3));
|
UpdateWindow(GetDlgItem(g_hDlg,IDC_LCOLOR3));
|
||||||
}
|
}
|
||||||
else if (IDC_NOSPECULAR == LOWORD(wParam))
|
else if (IDC_NOSPECULAR == LOWORD(wParam))
|
||||||
|
@ -2076,7 +2076,7 @@ INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
SendDlgItemMessage(hwndDlg,IDC_PROGRESS,PBM_SETRANGE,0,
|
SendDlgItemMessage(hwndDlg,IDC_PROGRESS,PBM_SETRANGE,0,
|
||||||
MAKELPARAM(0,500));
|
MAKELPARAM(0,500));
|
||||||
|
|
||||||
SetTimer(hwndDlg,0,40,NULL);
|
SetTimer(hwndDlg,0,40,nullptr);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
|
@ -2090,7 +2090,7 @@ INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
#if 0
|
#if 0
|
||||||
g_bLoadingCanceled = true;
|
g_bLoadingCanceled = true;
|
||||||
TerminateThread(g_hThreadHandle,5);
|
TerminateThread(g_hThreadHandle,5);
|
||||||
g_pcAsset = NULL;
|
g_pcAsset = nullptr;
|
||||||
|
|
||||||
EndDialog(hwndDlg,0);
|
EndDialog(hwndDlg,0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2167,14 +2167,14 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
// initialize the IDirect3D9 interface
|
// initialize the IDirect3D9 interface
|
||||||
g_hInstance = hInstance;
|
g_hInstance = hInstance;
|
||||||
if (0 == InitD3D()) {
|
if (0 == InitD3D()) {
|
||||||
MessageBox(NULL,"Failed to initialize Direct3D 9",
|
MessageBox(nullptr,"Failed to initialize Direct3D 9",
|
||||||
"ASSIMP ModelViewer",MB_OK);
|
"ASSIMP ModelViewer",MB_OK);
|
||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the main dialog
|
// create the main dialog
|
||||||
HWND hDlg = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOGMAIN),
|
HWND hDlg = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOGMAIN),
|
||||||
NULL,&MessageProc);
|
nullptr,&MessageProc);
|
||||||
|
|
||||||
// ensure we get high priority
|
// ensure we get high priority
|
||||||
::SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);
|
::SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);
|
||||||
|
@ -2187,8 +2187,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
Assimp::DefaultLogger::Debugging | Assimp::DefaultLogger::Info |
|
Assimp::DefaultLogger::Debugging | Assimp::DefaultLogger::Info |
|
||||||
Assimp::DefaultLogger::Err | Assimp::DefaultLogger::Warn);
|
Assimp::DefaultLogger::Err | Assimp::DefaultLogger::Warn);
|
||||||
|
|
||||||
if (NULL == hDlg) {
|
if (nullptr == hDlg) {
|
||||||
MessageBox(NULL,"Failed to create dialog from resource",
|
MessageBox(nullptr,"Failed to create dialog from resource",
|
||||||
"ASSIMP ModelViewer",MB_OK);
|
"ASSIMP ModelViewer",MB_OK);
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
@ -2202,7 +2202,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
// create the D3D device object
|
// create the D3D device object
|
||||||
if (0 == CreateDevice(g_sOptions.bMultiSample,false,true)) {
|
if (0 == CreateDevice(g_sOptions.bMultiSample,false,true)) {
|
||||||
MessageBox(NULL,"Failed to initialize Direct3D 9 (2)",
|
MessageBox(nullptr,"Failed to initialize Direct3D 9 (2)",
|
||||||
"ASSIMP ModelViewer",MB_OK);
|
"ASSIMP ModelViewer",MB_OK);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
@ -2222,18 +2222,18 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
};
|
};
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,
|
RegCreateKeyEx(HKEY_CURRENT_USER,
|
||||||
"Software\\ASSIMP\\Viewer",0,NULL,0,KEY_ALL_ACCESS, NULL, &hRegistry,NULL);
|
"Software\\ASSIMP\\Viewer",0,nullptr,0,KEY_ALL_ACCESS, nullptr, &hRegistry,nullptr);
|
||||||
if(ERROR_SUCCESS == RegQueryValueEx(hRegistry,"LastSkyBoxSrc",NULL,NULL,
|
if(ERROR_SUCCESS == RegQueryValueEx(hRegistry,"LastSkyBoxSrc",nullptr,nullptr,
|
||||||
(BYTE*)szFileName,&dwTemp) && '\0' != szFileName[0])
|
(BYTE*)szFileName,&dwTemp) && '\0' != szFileName[0])
|
||||||
{
|
{
|
||||||
CBackgroundPainter::Instance().SetCubeMapBG(szFileName);
|
CBackgroundPainter::Instance().SetCubeMapBG(szFileName);
|
||||||
}
|
}
|
||||||
else if(ERROR_SUCCESS == RegQueryValueEx(hRegistry,"LastTextureSrc",NULL,NULL,
|
else if(ERROR_SUCCESS == RegQueryValueEx(hRegistry,"LastTextureSrc",nullptr,nullptr,
|
||||||
(BYTE*)szFileName,&dwTemp) && '\0' != szFileName[0])
|
(BYTE*)szFileName,&dwTemp) && '\0' != szFileName[0])
|
||||||
{
|
{
|
||||||
CBackgroundPainter::Instance().SetTextureBG(szFileName);
|
CBackgroundPainter::Instance().SetTextureBG(szFileName);
|
||||||
}
|
}
|
||||||
else if(ERROR_SUCCESS == RegQueryValueEx(hRegistry,"Color",NULL,NULL,
|
else if(ERROR_SUCCESS == RegQueryValueEx(hRegistry,"Color",nullptr,nullptr,
|
||||||
(BYTE*)&clrColor,&dwTemp))
|
(BYTE*)&clrColor,&dwTemp))
|
||||||
{
|
{
|
||||||
CBackgroundPainter::Instance().SetColor(clrColor);
|
CBackgroundPainter::Instance().SetColor(clrColor);
|
||||||
|
@ -2251,7 +2251,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
double g_dLastTime = 0;
|
double g_dLastTime = 0;
|
||||||
while( uMsg.message != WM_QUIT )
|
while( uMsg.message != WM_QUIT )
|
||||||
{
|
{
|
||||||
if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
|
if( PeekMessage( &uMsg, nullptr, 0, 0, PM_REMOVE ) )
|
||||||
{
|
{
|
||||||
TranslateMessage( &uMsg );
|
TranslateMessage( &uMsg );
|
||||||
DispatchMessage( &uMsg );
|
DispatchMessage( &uMsg );
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue