Merge pull request #1 from assimp/master

Pull from master 12-17-2015
pull/725/head
John Carlson 2015-12-17 09:53:56 -05:00
commit 0ebab2ef23
667 changed files with 205851 additions and 183655 deletions

22
.editorconfig 100644
View File

@ -0,0 +1,22 @@
# See <http://EditorConfig.org> for details
root = true
[CMakeLists.txt,*.cmake{,.in}]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 2
indent_style = space
[*.h.in]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = space
[*.txt]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

8
.gitattributes vendored 100644
View File

@ -0,0 +1,8 @@
# Declare files that will always have LF line endings on checkout.
*.cpp text eol=lf
*.h text eol=lf
*.c text eol=lf
*.hpp text eol=lf
*.txt text eol=lf
*.cmake text eol=lf
*.sh text eol=lf

13
.gitignore vendored
View File

@ -1,3 +1,4 @@
.idea
build build
.project .project
*.kdev4* *.kdev4*
@ -59,3 +60,15 @@ test/gtest/src/gtest-stamp/gtest-gitclone-lastrun.txt
Assimp.opensdf Assimp.opensdf
contrib/zlib/CTestTestfile.cmake contrib/zlib/CTestTestfile.cmake
ipch/assimp_viewer-44bbbcd1/assimp_viewerd-ccc45335.ipch ipch/assimp_viewer-44bbbcd1/assimp_viewerd-ccc45335.ipch
bin64/assimp-vc140-mt.dll
bin64/assimp-vc140-mtd.dll
lib64/assimp-vc140-mt.exp
lib64/assimp-vc140-mtd.exp
lib64/assimp-vc140-mtd.ilk
lib64/assimp-vc140-mtd.pdb
bin64/assimp-vc120-mt.dll
bin64/assimp-vc120-mtd.dll
lib64/assimp-vc120-mtd.pdb
lib64/assimp-vc120-mtd.ilk
lib64/assimp-vc120-mtd.exp
lib64/assimp-vc120-mt.exp

16
.travis.sh 100755
View File

@ -0,0 +1,16 @@
function generate()
{
cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -DBUILD_SHARED_LIBS=$SHARED_BUILD
}
if [ $ANDROID ]; then
ant -v -Dmy.dir=${TRAVIS_BUILD_DIR} -f ${TRAVIS_BUILD_DIR}/port/jassimp/build.xml ndk-jni
else
generate \
&& make \
&& sudo make install \
&& sudo ldconfig \
&& (cd test/unit; ../../bin/unit) \
&& (cd test/regression; chmod 755 run.py; ./run.py; \
chmod 755 result_checker.py; ./result_checker.py)
fi

View File

@ -28,18 +28,4 @@ install:
- if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi - if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi
script: script:
- if [ $ANDROID ]; then - . ./.travis.sh
ant -v -Dmy.dir=${TRAVIS_BUILD_DIR} -f ${TRAVIS_BUILD_DIR}/port/jassimp/build.xml ndk-jni ;
else
cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -DBUILD_SHARED_LIBS=$SHARED_BUILD ;
make ;
sudo make install ;
sudo ldconfig ;
cd test/unit ;
../../bin/unit ;
cd ../regression ;
chmod 755 run.py ;
./run.py ;
chmod 755 result_checker.py ;
./result_checker.py;
fi

View File

@ -10,30 +10,33 @@ endif(NOT BUILD_SHARED_LIBS)
# Define here the needed parameters # Define here the needed parameters
set (ASSIMP_VERSION_MAJOR 3) set (ASSIMP_VERSION_MAJOR 3)
set (ASSIMP_VERSION_MINOR 1) set (ASSIMP_VERSION_MINOR 2)
set (ASSIMP_VERSION_PATCH 1) # subversion revision? set (ASSIMP_VERSION_PATCH 0) # subversion revision?
set (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}) set (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH})
set (ASSIMP_SOVERSION 3) set (ASSIMP_SOVERSION 3)
set (PROJECT_VERSION "${ASSIMP_VERSION}") set (PROJECT_VERSION "${ASSIMP_VERSION}")
set(ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources") set(ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources")
# Needed for openddl_parser config, no use of c++11 at this moment
add_definitions( -DOPENDDL_NO_USE_CPP11 ) add_definitions( -DOPENDDL_NO_USE_CPP11 )
# 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
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
) )
# Get the latest abbreviated commit hash of the working branch # Get the latest abbreviated commit hash of the working branch
execute_process( execute_process(
COMMAND git log -1 --format=%h COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
) )
if(NOT GIT_COMMIT_HASH) if(NOT GIT_COMMIT_HASH)
@ -62,9 +65,11 @@ if( CMAKE_COMPILER_IS_MINGW )
endif() endif()
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW) if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW)
set(CMAKE_CXX_FLAGS "-fPIC") # this is a very important switch and some libraries seem now to have it.... if (BUILD_SHARED_LIBS AND CMAKE_SIZEOF_VOID_P EQUAL 8) # -fPIC is only required for shared libs on 64 bit
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
# hide all not-exported symbols # hide all not-exported symbols
set(CMAKE_CXX_FLAGS "-fvisibility=hidden -Wall" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall" )
elseif(MSVC) elseif(MSVC)
# enable multi-core compilation with MSVC # enable multi-core compilation with MSVC
add_definitions(/MP) add_definitions(/MP)
@ -93,7 +98,11 @@ SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE PATH
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH
"Path the tool executables are installed to." ) "Path the tool executables are installed to." )
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools") IF (CMAKE_BUILD_TYPE STREQUAL "Release")
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Debug Postfix for lib, samples and tools")
ELSE()
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfix for lib, samples and tools")
ENDIF()
# Only generate this target if no higher-level project already has # Only generate this target if no higher-level project already has
IF (NOT TARGET uninstall) IF (NOT TARGET uninstall)
@ -114,7 +123,9 @@ IF ( ASSIMP_ENABLE_BOOST_WORKAROUND )
MESSAGE( STATUS "Building a non-boost version of Assimp." ) MESSAGE( STATUS "Building a non-boost version of Assimp." )
ELSE ( ASSIMP_ENABLE_BOOST_WORKAROUND ) ELSE ( ASSIMP_ENABLE_BOOST_WORKAROUND )
SET( Boost_DETAILED_FAILURE_MSG ON ) SET( Boost_DETAILED_FAILURE_MSG ON )
SET( Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0" "1.48.0" "1.48" "1.49" "1.49.0" "1.50" "1.50.0" "1.51" "1.51.0" "1.52.0" "1.53.0" "1.54.0" "1.55" "1.55.0" "1.56" "1.56.0" "1.57" "1.57.0" "1.58" "1.58.0" ) IF ( NOT Boost_ADDITIONAL_VERSIONS )
SET( Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0" "1.48.0" "1.48" "1.49" "1.49.0" "1.50" "1.50.0" "1.51" "1.51.0" "1.52.0" "1.53.0" "1.54.0" "1.55" "1.55.0" "1.56" "1.56.0" "1.57" "1.57.0" "1.58" "1.58.0" "1.59" "1.59.0")
ENDIF ( NOT Boost_ADDITIONAL_VERSIONS )
FIND_PACKAGE( Boost ) FIND_PACKAGE( Boost )
IF ( NOT Boost_FOUND ) IF ( NOT Boost_FOUND )
MESSAGE( FATAL_ERROR MESSAGE( FATAL_ERROR
@ -132,6 +143,8 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${C
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT}) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
FIND_PACKAGE( DirectX )
option ( ASSIMP_NO_EXPORT option ( ASSIMP_NO_EXPORT
"Disable Assimp's export functionality." "Disable Assimp's export functionality."
OFF OFF
@ -241,9 +254,9 @@ option ( ASSIMP_BUILD_ASSIMP_TOOLS
ON ON
) )
IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
IF ( WIN32 ) IF ( WIN32 AND DirectX_FOUND )
ADD_SUBDIRECTORY( tools/assimp_view/ ) ADD_SUBDIRECTORY( tools/assimp_view/ )
ENDIF ( WIN32 ) ENDIF ( WIN32 AND DirectX_FOUND )
ADD_SUBDIRECTORY( tools/assimp_cmd/ ) ADD_SUBDIRECTORY( tools/assimp_cmd/ )
ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS ) ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS )
@ -327,3 +340,31 @@ if(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
include(CPack) include(CPack)
include(DebSourcePPA) include(DebSourcePPA)
endif() endif()
if(WIN32)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BIN_DIR "${PROJECT_SOURCE_DIR}/bin64/")
set(LIB_DIR "${PROJECT_SOURCE_DIR}/lib64/")
elseif()
set(BIN_DIR "${PROJECT_SOURCE_DIR}/bin32/")
set(LIB_DIR "${PROJECT_SOURCE_DIR}/lib32/")
endif()
if(MSVC12)
set(ASSIMP_MSVC_VERSION "vc120")
elseif(MSVC14)
set(ASSIMP_MSVC_VERSION "vc140")
endif(MSVC12)
if(MSVC12 OR MSVC14)
add_custom_target(UpdateAssimpLibsDebugSymbolsAndDLLs COMMENT "Copying Assimp Libraries ..." VERBATIM)
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
add_custom_command(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
endif(MSVC12 OR MSVC14)
endif (WIN32)

12
CodeConventions.md 100644
View File

@ -0,0 +1,12 @@
Open Asset Import Library Coding Conventions
==
If you want to participate as a developer in the **Open Asset Import Library** please read and respect the following coding conventions. This will ensure consistency throughout the codebase and help all the Open Asset Import Library users.
Spacing
==
* Use UNIX-style line endings (LF)
* Remove any trailing whitespace
* Expand tabs to 4 spaces

View File

@ -1,14 +0,0 @@
===============================================
The Asset-Importer-Library Coding conventions
===============================================
If you want to participate to the Asset-Importer_Library please have a look
onto these coding conventions and try to follow them. They are more or less
some kind of guide line to help others coming into the code and help all
the Asset-Importer-Library users.
Tab width
===========
The tab width shall be 4 spaces.

15
INSTALL
View File

@ -33,13 +33,12 @@ CMake is the preferred build system for Assimp. The minimum required version
is 2.6. If you don't have it yet, downloads for CMake can be found on is 2.6. If you don't have it yet, downloads for CMake can be found on
http://www.cmake.org/. http://www.cmake.org/.
Building Assimp with CMake is 'business as usual' if you've used CMake For Unix:
before. All steps can be done either on the command line / shell or
by using the CMake GUI tool, the choice is up to you.
First, invoke CMake to generate build files for a particular
toolchain (for standard GNU makefiles: cmake -G 'Unix Makefiles').
Afterwards, use the generated build files to perform the actual
build.
1. cmake CMakeLists.txt -G 'Unix Makefiles'
2. make
For Windows:
1. Open a command prompt
2. cmake CMakeLists.txt
2. Open your default IDE and build it

View File

@ -1,6 +1,6 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -7,9 +7,15 @@ APIs are provided for C and C++. There are various bindings to other languages (
Additionally, assimp features various __mesh post processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more. Additionally, assimp features various __mesh post processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more.
This is the development trunk containing the latest features and bugfixes. For productive use though, we recommend one of the stable releases available from [assimp.sf.net](http://assimp.sf.net) or from *nix package repositories. According to [Travis-CI] (https://travis-ci.org/), the current build status is: This is the development trunk containing the latest features and bugfixes. For productive use though, we recommend one of the stable releases available from [assimp.sf.net](http://assimp.sf.net) or from *nix package repositories.
The current build status is:
[![Build Status](https://travis-ci.org/assimp/assimp.png)](https://travis-ci.org/assimp/assimp) Linux [![Linux Build Status](https://travis-ci.org/assimp/assimp.png)](https://travis-ci.org/assimp/assimp)
Windows [![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp)
Coverity<a href="https://scan.coverity.com/projects/5607">
<img alt="Coverity Scan Build Status"
src="https://scan.coverity.com/projects/5607/badge.svg"/>
</a>
__[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.__ __[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.__
@ -36,6 +42,7 @@ __Importers__:
- STL - STL
- X - X
- OBJ - OBJ
- OpenGEX
- SMD - SMD
- LWO - LWO
- LXO - LXO
@ -54,6 +61,7 @@ __Importers__:
- Ogre XML - Ogre XML
- Q3D - Q3D
- ASSBIN (Assimp custom format) - ASSBIN (Assimp custom format)
- glTF
Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default): Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default):
@ -69,6 +77,7 @@ __Exporters__:
- 3DS - 3DS
- JSON (for WebGl, via https://github.com/acgessler/assimp2json) - JSON (for WebGl, via https://github.com/acgessler/assimp2json)
- ASSBIN - ASSBIN
- glTF
### Building ### ### Building ###
@ -106,6 +115,9 @@ If the docs don't solve your problem, ask on [StackOverflow](http://stackoverflo
For development discussions, there is also a (very low-volume) mailing list, _assimp-discussions_ For development discussions, there is also a (very low-volume) mailing list, _assimp-discussions_
[(subscribe here)]( https://lists.sourceforge.net/lists/listinfo/assimp-discussions) [(subscribe here)]( https://lists.sourceforge.net/lists/listinfo/assimp-discussions)
And we also have an IRC-channel at freenode: #assetimporterlib . You can easily join us via: [KiwiIRC/freenote](https://kiwiirc.com/client/irc.freenode.net), choose your nickname and type
> /join #assetimporterlib
### Contributing ### ### Contributing ###
Contributions to assimp are highly appreciated. The easiest way to get involved is to submit Contributions to assimp are highly appreciated. The easiest way to get involved is to submit
@ -119,3 +131,6 @@ An _informal_ summary is: do whatever you want, but include Assimp's license tex
and don't sue us if our code doesn't work. Note that, unlike LGPLed code, you may link statically to Assimp. and don't sue us if our code doesn't work. Note that, unlike LGPLed code, you may link statically to Assimp.
For the legal details, see the `LICENSE` file. For the legal details, see the `LICENSE` file.
### Why this name ###
Sorry, we're germans :-), no english native speakers ...

21
appveyor.yml 100644
View File

@ -0,0 +1,21 @@
# AppVeyor file
# http://www.appveyor.com/docs/appveyor-yml
# clone directory
clone_folder: c:\projects\assimp
# branches to build
branches:
# whitelist
only:
- master
platform: x64
configuration: Release
build:
build_script:
- cd c:\projects\assimp
- cmake CMakeLists.txt -G "Visual Studio 11"
- msbuild /m /p:Configuration=Release /p:Platform="Win32" Assimp.sln

View File

@ -29,8 +29,10 @@ if( MSVC )
set(MSVC_PREFIX "vc110") set(MSVC_PREFIX "vc110")
elseif( MSVC12 ) elseif( MSVC12 )
set(MSVC_PREFIX "vc120") set(MSVC_PREFIX "vc120")
elseif( MSVC14 )
set(MSVC_PREFIX "vc140")
else() else()
set(MSVC_PREFIX "vc130") set(MSVC_PREFIX "vc150")
endif() endif()
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" FORCE) set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" FORCE)
else() else()

View File

@ -30,7 +30,14 @@ endif()
set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gtest") set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gtest")
ExternalProject_Add(gtest # try to find git - if found, setup gtest
find_package(Git)
if(NOT GIT_FOUND)
set(AddGTest_FOUND false CACHE BOOL "Was gtest setup correctly?")
else(NOT GIT_FOUND)
set(AddGTest_FOUND true CACHE BOOL "Was gtest setup correctly?")
ExternalProject_Add(gtest
GIT_REPOSITORY https://chromium.googlesource.com/external/googletest GIT_REPOSITORY https://chromium.googlesource.com/external/googletest
TIMEOUT 10 TIMEOUT 10
PREFIX "${GTEST_PREFIX}" PREFIX "${GTEST_PREFIX}"
@ -40,25 +47,26 @@ ExternalProject_Add(gtest
LOG_BUILD ON LOG_BUILD ON
# Disable install # Disable install
INSTALL_COMMAND "" INSTALL_COMMAND ""
) )
set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}") set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}") set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GTEST_LOCATION "${GTEST_PREFIX}/src/gtest-build") set(GTEST_LOCATION "${GTEST_PREFIX}/src/gtest-build")
set(GTEST_DEBUG_LIBRARIES set(GTEST_DEBUG_LIBRARIES
"${GTEST_LOCATION}/${DEBUG_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}" "${GTEST_LOCATION}/${DEBUG_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}"
"${CMAKE_THREAD_LIBS_INIT}") "${CMAKE_THREAD_LIBS_INIT}")
SET(GTEST_RELEASE_LIBRARIES SET(GTEST_RELEASE_LIBRARIES
"${GTEST_LOCATION}/${RELEASE_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}" "${GTEST_LOCATION}/${RELEASE_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}"
"${CMAKE_THREAD_LIBS_INIT}") "${CMAKE_THREAD_LIBS_INIT}")
if(MSVC_VERSION EQUAL 1700) if(MSVC_VERSION EQUAL 1700)
add_definitions(-D_VARIADIC_MAX=10) add_definitions(-D_VARIADIC_MAX=10)
endif() endif()
ExternalProject_Get_Property(gtest source_dir) ExternalProject_Get_Property(gtest source_dir)
include_directories(${source_dir}/include) include_directories(${source_dir}/include)
include_directories(${source_dir}/gtest/include) include_directories(${source_dir}/gtest/include)
ExternalProject_Get_Property(gtest binary_dir) ExternalProject_Get_Property(gtest binary_dir)
link_directories(${binary_dir}) link_directories(${binary_dir})
endif(NOT GIT_FOUND)

View File

@ -35,6 +35,7 @@ if(WIN32) # The only platform it makes sense to check for DirectX SDK
"C:/Program Files (x86)/Microsoft DirectX SDK*" "C:/Program Files (x86)/Microsoft DirectX SDK*"
"C:/apps/Microsoft DirectX SDK*" "C:/apps/Microsoft DirectX SDK*"
"C:/Program Files/Microsoft DirectX SDK*" "C:/Program Files/Microsoft DirectX SDK*"
"C:/Program Files (x86)/Windows Kits/8.1"
"$ENV{ProgramFiles}/Microsoft DirectX SDK*" "$ENV{ProgramFiles}/Microsoft DirectX SDK*"
) )
create_search_paths(DirectX) create_search_paths(DirectX)

View File

@ -1,25 +1,81 @@
FIND_PATH( if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ASSIMP_ARCHITECTURE "64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ASSIMP_ARCHITECTURE "32")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(WIN32)
set(ASSIMP_ROOT_DIR CACHE PATH "ASSIMP root directory")
# Find path of each library
find_path(ASSIMP_INCLUDE_DIR
NAMES
assimp/anim.h
HINTS
${ASSIMP_ROOT_DIR}/include
)
if(MSVC12)
set(ASSIMP_MSVC_VERSION "vc120")
elseif(MSVC14)
set(ASSIMP_MSVC_VERSION "vc140")
endif(MSVC12)
if(MSVC12 OR MSVC14)
find_path(ASSIMP_LIBRARY_DIR
NAMES
assimp-${ASSIMP_MSVC_VERSION}-mt.lib
HINTS
${ASSIMP_ROOT_DIR}/lib${ASSIMP_ARCHITECTURE}
)
find_library(ASSIMP_LIBRARY_RELEASE assimp-${ASSIMP_MSVC_VERSION}-mt.lib PATHS ${ASSIMP_LIBRARY_DIR})
find_library(ASSIMP_LIBRARY_DEBUG assimp-${ASSIMP_MSVC_VERSION}-mtd.lib PATHS ${ASSIMP_LIBRARY_DIR})
set(ASSIMP_LIBRARY
optimized ${ASSIMP_LIBRARY_RELEASE}
debug ${ASSIMP_LIBRARY_DEBUG}
)
set(ASSIMP_LIBRARIES "ASSIMP_LIBRARY_RELEASE" "ASSIMP_LIBRARY_DEBUG")
FUNCTION(ASSIMP_COPY_BINARIES TargetDirectory)
ADD_CUSTOM_TARGET(AssimpCopyBinaries
COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${TargetDirectory}/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll
COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${TargetDirectory}/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll
COMMENT "Copying Assimp binaries to '${TargetDirectory}'"
VERBATIM)
ENDFUNCTION(ASSIMP_COPY_BINARIES)
endif()
else(WIN32)
find_path(
assimp_INCLUDE_DIRS assimp_INCLUDE_DIRS
NAMES postprocess.h scene.h version.h config.h cimport.h NAMES postprocess.h scene.h version.h config.h cimport.h
PATHS /usr/local/include/ PATHS /usr/local/include/
) )
FIND_LIBRARY( find_library(
assimp_LIBRARIES assimp_LIBRARIES
NAMES assimp NAMES assimp
PATHS /usr/local/lib/ PATHS /usr/local/lib/
) )
IF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES) if (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
SET(assimp_FOUND TRUE) SET(assimp_FOUND TRUE)
ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES) ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
IF (assimp_FOUND) if (assimp_FOUND)
IF (NOT assimp_FIND_QUIETLY) if (NOT assimp_FIND_QUIETLY)
MESSAGE(STATUS "Found asset importer library: ${assimp_LIBRARIES}") message(STATUS "Found asset importer library: ${assimp_LIBRARIES}")
ENDIF (NOT assimp_FIND_QUIETLY) endif (NOT assimp_FIND_QUIETLY)
ELSE (assimp_FOUND) else (assimp_FOUND)
IF (assimp_FIND_REQUIRED) if (assimp_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find asset importer library") message(FATAL_ERROR "Could not find asset importer library")
ENDIF (assimp_FIND_REQUIRED) endif (assimp_FIND_REQUIRED)
ENDIF (assimp_FOUND) endif (assimp_FOUND)
endif(WIN32)

View File

@ -0,0 +1,8 @@
# See <http://EditorConfig.org> for details
[*.{h,hpp,c,cpp}]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = space

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -757,7 +757,7 @@ void Discreet3DSImporter::GenerateNodeGraph(aiScene* pcOut)
pcNode->mNumMeshes = 1; pcNode->mNumMeshes = 1;
// Build a name for the node // Build a name for the node
pcNode->mName.length = sprintf(pcNode->mName.data,"3DSMesh_%i",i); pcNode->mName.length = sprintf(pcNode->mName.data,"3DSMesh_%u",i);
} }
// Build dummy nodes for all cameras // Build dummy nodes for all cameras

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -332,6 +332,7 @@ struct Texture
, mScaleV (1.0f) , mScaleV (1.0f)
, mRotation (0.0f) , mRotation (0.0f)
, mMapMode (aiTextureMapMode_Wrap) , mMapMode (aiTextureMapMode_Wrap)
, bPrivate()
, iUVSrc (0) , iUVSrc (0)
{ {
mTextureBlend = get_qnan(); mTextureBlend = get_qnan();
@ -484,11 +485,11 @@ struct aiFloatKey
struct Node struct Node
{ {
Node() Node()
: mParent()
: mHierarchyPos (0) , mInstanceNumber()
, mHierarchyPos (0)
, mHierarchyIndex (0) , mHierarchyIndex (0)
, mInstanceCount (1) , mInstanceCount (1)
{ {
static int iCnt = 0; static int iCnt = 0;

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -86,8 +86,8 @@ static const aiImporterDesc desc = {
int chunkSize = chunk.Size-sizeof(Discreet3DS::Chunk); \ int chunkSize = chunk.Size-sizeof(Discreet3DS::Chunk); \
if(chunkSize <= 0) \ if(chunkSize <= 0) \
continue; \ continue; \
const int oldReadLimit = stream->GetReadLimit(); \ const unsigned int oldReadLimit = stream->SetReadLimit( \
stream->SetReadLimit(stream->GetCurrentPos() + chunkSize); \ stream->GetCurrentPos() + chunkSize); \
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -103,6 +103,14 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
Discreet3DSImporter::Discreet3DSImporter() Discreet3DSImporter::Discreet3DSImporter()
: stream(),
mLastNodeIndex(),
mCurrentNode(),
mRootNode(),
mScene(),
mMasterScale(),
bHasBG(),
bIsPrj()
{} {}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -4,7 +4,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -89,6 +89,9 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// read a string (may be enclosed in double quotation marks). buffer must point to " // read a string (may be enclosed in double quotation marks). buffer must point to "
#define AI_AC_GET_STRING(out) \ #define AI_AC_GET_STRING(out) \
if (*buffer == '\0') { \
throw DeadlyImportError("AC3D: Unexpected EOF in string"); \
} \
++buffer; \ ++buffer; \
const char* sz = buffer; \ const char* sz = buffer; \
while ('\"' != *buffer) \ while ('\"' != *buffer) \
@ -129,6 +132,15 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
AC3DImporter::AC3DImporter() AC3DImporter::AC3DImporter()
: buffer(),
configSplitBFCull(),
configEvalSubdivision(),
mNumMeshes(),
mLights(),
lights(),
groups(),
polys(),
worlds()
{ {
// nothing to be done here // nothing to be done here
} }
@ -284,6 +296,9 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
SkipSpaces(&buffer); SkipSpaces(&buffer);
unsigned int t = strtoul10(buffer,&buffer); unsigned int t = strtoul10(buffer,&buffer);
if (t >= AI_MAX_ALLOC(aiVector3D)) {
throw DeadlyImportError("AC3D: Too many vertices, would run out of memory");
}
obj.vertices.reserve(t); obj.vertices.reserve(t);
for (unsigned int i = 0; i < t;++i) for (unsigned int i = 0; i < t;++i)
{ {
@ -337,8 +352,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
{ {
if(!GetNextLine()) if(!GetNextLine())
{ {
DefaultLogger::get()->error("AC3D: Unexpected EOF: surface is incomplete"); throw DeadlyImportError("AC3D: Unexpected EOF: surface is incomplete");
break;
} }
if (TokenMatch(buffer,"mat",3)) if (TokenMatch(buffer,"mat",3))
{ {
@ -573,9 +587,19 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
// allocate storage for vertices and normals // allocate storage for vertices and normals
mesh->mNumFaces = (*cit).first; mesh->mNumFaces = (*cit).first;
if (mesh->mNumFaces == 0) {
throw DeadlyImportError("AC3D: No faces");
} else if (mesh->mNumFaces > AI_MAX_ALLOC(aiFace)) {
throw DeadlyImportError("AC3D: Too many faces, would run out of memory");
}
aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces]; aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
mesh->mNumVertices = (*cit).second; mesh->mNumVertices = (*cit).second;
if (mesh->mNumVertices == 0) {
throw DeadlyImportError("AC3D: No vertices");
} else if (mesh->mNumVertices > AI_MAX_ALLOC(aiVector3D)) {
throw DeadlyImportError("AC3D: Too many vertices, would run out of memory");
}
aiVector3D* vertices = mesh->mVertices = new aiVector3D[mesh->mNumVertices]; aiVector3D* vertices = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
unsigned int cur = 0; unsigned int cur = 0;
@ -608,6 +632,9 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
face.mIndices[i] = cur++; face.mIndices[i] = cur++;
// copy vertex positions // copy vertex positions
if (static_cast<unsigned>(vertices - mesh->mVertices) >= mesh->mNumVertices) {
throw DeadlyImportError("AC3D: Invalid number of vertices");
}
*vertices = object.vertices[entry.first] + object.translation; *vertices = object.vertices[entry.first] + object.translation;
@ -639,6 +666,10 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
face.mIndices[1] = cur++; face.mIndices[1] = cur++;
// copy vertex positions // copy vertex positions
if (it2 == (*it).entries.end() ) {
throw DeadlyImportError("AC3D: Bad line");
}
ai_assert((*it2).first < object.vertices.size());
*vertices++ = object.vertices[(*it2).first]; *vertices++ = object.vertices[(*it2).first];
// copy texture coordinates // copy texture coordinates

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -130,6 +130,7 @@ public:
, surfaces() , surfaces()
, numRefs (0) , numRefs (0)
, subDiv (0) , subDiv (0)
, crease()
{} {}
// Type description // Type description

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -79,7 +79,11 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
ASEImporter::ASEImporter() ASEImporter::ASEImporter()
: noSkeletonMesh() : mParser(),
mBuffer(),
pcScene(),
configRecomputeNormals(),
noSkeletonMesh()
{} {}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -143,9 +143,9 @@ void Parser::LogWarning(const char* szWarn)
char szTemp[1024]; char szTemp[1024];
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400
sprintf_s(szTemp,"Line %i: %s",iLineNumber,szWarn); sprintf_s(szTemp,"Line %u: %s",iLineNumber,szWarn);
#else #else
snprintf(szTemp,1024,"Line %i: %s",iLineNumber,szWarn); snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn);
#endif #endif
// output the warning to the logger ... // output the warning to the logger ...
@ -159,9 +159,9 @@ void Parser::LogInfo(const char* szWarn)
char szTemp[1024]; char szTemp[1024];
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400
sprintf_s(szTemp,"Line %i: %s",iLineNumber,szWarn); sprintf_s(szTemp,"Line %u: %s",iLineNumber,szWarn);
#else #else
snprintf(szTemp,1024,"Line %i: %s",iLineNumber,szWarn); snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn);
#endif #endif
// output the information to the logger ... // output the information to the logger ...
@ -175,9 +175,9 @@ AI_WONT_RETURN void Parser::LogError(const char* szWarn)
char szTemp[1024]; char szTemp[1024];
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400
sprintf_s(szTemp,"Line %i: %s",iLineNumber,szWarn); sprintf_s(szTemp,"Line %u: %s",iLineNumber,szWarn);
#else #else
snprintf(szTemp,1024,"Line %i: %s",iLineNumber,szWarn); snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn);
#endif #endif
// throw an exception // throw an exception

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -138,7 +138,7 @@ struct Bone
} }
//! Construction from an existing name //! Construction from an existing name
Bone( const std::string& name) explicit Bone( const std::string& name)
: mName (name) : mName (name)
{} {}
@ -216,7 +216,7 @@ struct BaseNode
enum Type {Light, Camera, Mesh, Dummy} mType; enum Type {Light, Camera, Mesh, Dummy} mType;
//! Constructor. Creates a default name for the node //! Constructor. Creates a default name for the node
BaseNode(Type _mType) explicit BaseNode(Type _mType)
: mType (_mType) : mType (_mType)
, mProcessed (false) , mProcessed (false)
{ {

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -110,7 +110,7 @@ static boost::mutex gLogStreamMutex;
class LogToCallbackRedirector : public LogStream class LogToCallbackRedirector : public LogStream
{ {
public: public:
LogToCallbackRedirector(const aiLogStream& s) explicit LogToCallbackRedirector(const aiLogStream& s)
: stream (s) { : stream (s) {
ai_assert(NULL != s.callback); ai_assert(NULL != s.callback);
} }
@ -423,6 +423,21 @@ const char* aiGetErrorString()
return gLastErrorString.c_str(); return gLastErrorString.c_str();
} }
// -----------------------------------------------------------------------------------------------
// Return the description of a importer given its index
const aiImporterDesc* aiGetImportFormatDescription( size_t pIndex)
{
return Importer().GetImporterInfo(pIndex);
}
// -----------------------------------------------------------------------------------------------
// Return the number of importers
size_t aiGetImportFormatCount(void)
{
return Importer().GetImporterCount();
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns the error text of the last failed import process. // Returns the error text of the last failed import process.
aiBool aiIsExtensionSupported(const char* szExtension) aiBool aiIsExtensionSupported(const char* szExtension)

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -59,13 +59,38 @@ ASSIMP_API size_t aiGetExportFormatCount(void)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex) ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index)
{ {
// Note: this is valid as the index always pertains to a builtin exporter, // Note: this is valid as the index always pertains to a built-in exporter,
// for which the returned structure is guaranteed to be of static storage duration. // for which the returned structure is guaranteed to be of static storage duration.
return Exporter().GetExportFormatDescription(pIndex); Exporter exporter;
const aiExportFormatDesc* orig( exporter.GetExportFormatDescription( index ) );
if (NULL == orig) {
return NULL;
}
aiExportFormatDesc *desc = new aiExportFormatDesc;
desc->description = new char[ strlen( orig->description ) + 1 ];
::strncpy( (char*) desc->description, orig->description, strlen( orig->description ) );
desc->fileExtension = new char[ strlen( orig->fileExtension ) + 1 ];
::strncpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) );
desc->id = new char[ strlen( orig->id ) + 1 ];
::strncpy( ( char* ) desc->id, orig->id, strlen( orig->id ) );
return desc;
} }
// ------------------------------------------------------------------------------------------------
ASSIMP_API void aiReleaseExportFormatDescription( const aiExportFormatDesc *desc ) {
if (NULL == desc) {
return;
}
delete [] desc->description;
delete [] desc->fileExtension;
delete [] desc->id;
delete desc;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut)

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -239,8 +239,10 @@ unsigned B3DImporter::ChunkSize(){
template<class T> template<class T>
T *B3DImporter::to_array( const vector<T> &v ){ T *B3DImporter::to_array( const vector<T> &v ){
if( !v.size() ) return 0; if( v.empty() ) {
T *p=new T[v.size()]; return 0;
}
T *p=new T[ v.size() ];
for( size_t i=0;i<v.size();++i ){ for( size_t i=0;i<v.size();++i ){
p[i]=v[i]; p[i]=v[i];
} }

View File

@ -1,9 +1,8 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -4,7 +4,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -70,7 +70,10 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
BVHLoader::BVHLoader() BVHLoader::BVHLoader()
: noSkeletonMesh() : mLine(),
mAnimTickDuration(),
mAnimNumFrames(),
noSkeletonMesh()
{} {}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -4,7 +4,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -83,7 +83,7 @@ class BVHLoader : public BaseImporter
std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames
Node() { } Node() { }
Node( const aiNode* pNode) : mNode( pNode) { } explicit Node( const aiNode* pNode) : mNode( pNode) { }
}; };
public: public:

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -63,7 +63,7 @@ using namespace Assimp;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
BaseImporter::BaseImporter() BaseImporter::BaseImporter()
: progress() : m_progress()
{ {
// nothing to do here // nothing to do here
} }
@ -79,8 +79,8 @@ BaseImporter::~BaseImporter()
// Imports the given file and returns the imported data. // Imports the given file and returns the imported data.
aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler)
{ {
progress = pImp->GetProgressHandler(); m_progress = pImp->GetProgressHandler();
ai_assert(progress); ai_assert(m_progress);
// Gather configuration properties for this run // Gather configuration properties for this run
SetupProperties( pImp ); SetupProperties( pImp );
@ -98,8 +98,8 @@ aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile,
} catch( const std::exception& err ) { } catch( const std::exception& err ) {
// extract error description // extract error description
mErrorText = err.what(); m_ErrorText = err.what();
DefaultLogger::get()->error(mErrorText); DefaultLogger::get()->error(m_ErrorText);
return NULL; return NULL;
} }
@ -154,20 +154,26 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
// read 200 characters from the file // read 200 characters from the file
boost::scoped_array<char> _buffer (new char[searchBytes+1 /* for the '\0' */]); boost::scoped_array<char> _buffer (new char[searchBytes+1 /* for the '\0' */]);
char* buffer = _buffer.get(); char* buffer = _buffer.get();
if( NULL == buffer ) {
const unsigned int read = pStream->Read(buffer,1,searchBytes);
if (!read)
return false; return false;
}
for (unsigned int i = 0; i < read;++i) const size_t read = pStream->Read(buffer,1,searchBytes);
buffer[i] = ::tolower(buffer[i]); if( !read ) {
return false;
}
for( size_t i = 0; i < read; ++i ) {
buffer[ i ] = ::tolower( buffer[ i ] );
}
// It is not a proper handling of unicode files here ... // It is not a proper handling of unicode files here ...
// ehm ... but it works in most cases. // ehm ... but it works in most cases.
char* cur = buffer,*cur2 = buffer,*end = &buffer[read]; char* cur = buffer,*cur2 = buffer,*end = &buffer[read];
while (cur != end) { while (cur != end) {
if (*cur) if( *cur ) {
*cur2++ = *cur; *cur2++ = *cur;
}
++cur; ++cur;
} }
*cur2 = '\0'; *cur2 = '\0';
@ -177,8 +183,9 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
const char* r = strstr(buffer,tokens[i]); const char* r = strstr(buffer,tokens[i]);
if (!r) if( !r ) {
continue; continue;
}
// We got a match, either we don't care where it is, or it happens to // We got a match, either we don't care where it is, or it happens to
// be in the beginning of the file / line // be in the beginning of the file / line
if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') { if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') {
@ -187,6 +194,7 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
} }
} }
} }
return false; return false;
} }
@ -266,7 +274,7 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
for (unsigned int i = 0; i < num; ++i) { for (unsigned int i = 0; i < num; ++i) {
// also check against big endian versions of tokens with size 2,4 // also check against big endian versions of tokens with size 2,4
// that's just for convinience, the chance that we cause conflicts // that's just for convenience, the chance that we cause conflicts
// is quite low and it can save some lines and prevent nasty bugs // is quite low and it can save some lines and prevent nasty bugs
if (2 == size) { if (2 == size) {
uint16_t rev = *magic_u16; uint16_t rev = *magic_u16;
@ -392,11 +400,11 @@ void BaseImporter::ConvertToUTF8(std::vector<char>& data)
// Convert to UTF8 data to ISO-8859-1 // Convert to UTF8 data to ISO-8859-1
void BaseImporter::ConvertUTF8toISO8859_1(std::string& data) void BaseImporter::ConvertUTF8toISO8859_1(std::string& data)
{ {
unsigned int size = data.size(); size_t size = data.size();
unsigned int i = 0, j = 0; size_t i = 0, j = 0;
while(i < size) { while(i < size) {
if((unsigned char) data[i] < 0x80) { if ((unsigned char) data[i] < (size_t) 0x80) {
data[j] = data[i]; data[j] = data[i];
} else if(i < size - 1) { } else if(i < size - 1) {
if((unsigned char) data[i] == 0xC2) { if((unsigned char) data[i] == 0xC2) {
@ -427,22 +435,27 @@ void BaseImporter::ConvertUTF8toISO8859_1(std::string& data)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void BaseImporter::TextFileToBuffer(IOStream* stream, void BaseImporter::TextFileToBuffer(IOStream* stream,
std::vector<char>& data) std::vector<char>& data,
TextFileMode mode)
{ {
ai_assert(NULL != stream); ai_assert(NULL != stream);
const size_t fileSize = stream->FileSize(); const size_t fileSize = stream->FileSize();
if (mode == FORBID_EMPTY) {
if(!fileSize) { if(!fileSize) {
throw DeadlyImportError("File is empty"); throw DeadlyImportError("File is empty");
} }
}
data.reserve(fileSize+1); data.reserve(fileSize+1);
data.resize(fileSize); data.resize(fileSize);
if(fileSize > 0) {
if(fileSize != stream->Read( &data[0], 1, fileSize)) { if(fileSize != stream->Read( &data[0], 1, fileSize)) {
throw DeadlyImportError("File read error"); throw DeadlyImportError("File read error");
} }
ConvertToUTF8(data); ConvertToUTF8(data);
}
// append a binary zero to simplify string parsing // append a binary zero to simplify string parsing
data.push_back(0); data.push_back(0);
@ -603,7 +616,3 @@ void BatchLoader::LoadAll()
DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%"); DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%");
} }
} }

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -70,7 +70,7 @@ class IOStream;
template <typename T> template <typename T>
struct ScopeGuard struct ScopeGuard
{ {
ScopeGuard(T* obj) : obj(obj), mdismiss() {} explicit ScopeGuard(T* obj) : obj(obj), mdismiss() {}
~ScopeGuard () throw() { ~ScopeGuard () throw() {
if (!mdismiss) { if (!mdismiss) {
delete obj; delete obj;
@ -181,7 +181,7 @@ public:
* string if there was no error. * string if there was no error.
*/ */
const std::string& GetErrorText() const { const std::string& GetErrorText() const {
return mErrorText; return m_ErrorText;
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -347,6 +347,8 @@ public: // static utilities
static void ConvertUTF8toISO8859_1( static void ConvertUTF8toISO8859_1(
std::string& data); std::string& data);
enum TextFileMode { ALLOW_EMPTY, FORBID_EMPTY };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Utility for text file loaders which copies the contents of the /** Utility for text file loaders which copies the contents of the
* file into a memory buffer and converts it to our UTF8 * file into a memory buffer and converts it to our UTF8
@ -354,18 +356,41 @@ public: // static utilities
* @param stream Stream to read from. * @param stream Stream to read from.
* @param data Output buffer to be resized and filled with the * @param data Output buffer to be resized and filled with the
* converted text file data. The buffer is terminated with * converted text file data. The buffer is terminated with
* a binary 0. */ * a binary 0.
* @param mode Whether it is OK to load empty text files. */
static void TextFileToBuffer( static void TextFileToBuffer(
IOStream* stream, IOStream* stream,
std::vector<char>& data); std::vector<char>& data,
TextFileMode mode = FORBID_EMPTY);
// -------------------------------------------------------------------
/** Utility function to move a std::vector into a aiScene array
* @param vec The vector to be moved
* @param out The output pointer to the allocated array.
* @param numOut The output count of elements copied. */
template<typename T>
AI_FORCE_INLINE
static void CopyVector(
std::vector<T>& vec,
T*& out,
unsigned int& outLength)
{
outLength = vec.size();
if (outLength) {
out = new T[outLength];
std::swap_ranges(vec.begin(), vec.end(), out);
}
}
protected: protected:
/** Error description in case there was one. */ /** Error description in case there was one. */
std::string mErrorText; std::string m_ErrorText;
/** Currently set progress handler */ /** Currently set progress handler */
ProgressHandler* progress; ProgressHandler* m_progress;
}; };

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -74,7 +74,7 @@ public:
template <typename T> template <typename T>
struct THeapData : public Base struct THeapData : public Base
{ {
THeapData(T* in) explicit THeapData(T* in)
: data (in) : data (in)
{} {}
@ -89,7 +89,7 @@ public:
template <typename T> template <typename T>
struct TStaticData : public Base struct TStaticData : public Base
{ {
TStaticData(T in) explicit TStaticData(T in)
: data (in) : data (in)
{} {}

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -84,7 +84,12 @@ namespace Assimp {
template<typename T> template<typename T>
inline std::size_t Copy(uint8_t* data, T& field) { inline std::size_t Copy(uint8_t* data, T& field) {
#ifdef AI_BUILD_BIG_ENDIAN
T field_swapped=AI_BE(field);
std::memcpy(data, &field_swapped, sizeof(field)); return sizeof(field);
#else
std::memcpy(data, &AI_BE(field), sizeof(field)); return sizeof(field); std::memcpy(data, &AI_BE(field), sizeof(field)); return sizeof(field);
#endif
} }
void Bitmap::WriteHeader(Header& header, IOStream* file) { void Bitmap::WriteHeader(Header& header, IOStream* file) {

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -103,7 +103,7 @@ struct Image;
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
struct ID : ElemBase { struct ID : ElemBase {
char name[24] WARN; char name[1024] WARN;
short flag; short flag;
}; };

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -57,7 +57,7 @@ class CIOStreamWrapper : public IOStream
friend class CIOSystemWrapper; friend class CIOSystemWrapper;
public: public:
CIOStreamWrapper(aiFile* pFile) explicit CIOStreamWrapper(aiFile* pFile)
: mFile(pFile) : mFile(pFile)
{} {}
@ -110,7 +110,7 @@ private:
class CIOSystemWrapper : public IOSystem class CIOSystemWrapper : public IOSystem
{ {
public: public:
CIOSystemWrapper(aiFileIO* pFile) explicit CIOSystemWrapper(aiFileIO* pFile)
: mFileSystem(pFile) : mFileSystem(pFile)
{} {}

View File

@ -357,6 +357,8 @@ ADD_ASSIMP_IMPORTER(OGRE
) )
ADD_ASSIMP_IMPORTER(OPENGEX ADD_ASSIMP_IMPORTER(OPENGEX
OpenGEXExporter.cpp
OpenGEXExporter.h
OpenGEXImporter.cpp OpenGEXImporter.cpp
OpenGEXImporter.h OpenGEXImporter.h
OpenGEXStructs.h OpenGEXStructs.h
@ -528,6 +530,11 @@ ADD_ASSIMP_IMPORTER(RAW
RawLoader.h RawLoader.h
) )
ADD_ASSIMP_IMPORTER(SIB
SIBImporter.cpp
SIBImporter.h
)
ADD_ASSIMP_IMPORTER(SMD ADD_ASSIMP_IMPORTER(SMD
SMDLoader.cpp SMDLoader.cpp
SMDLoader.h SMDLoader.h
@ -560,6 +567,19 @@ ADD_ASSIMP_IMPORTER(X
XFileExporter.cpp XFileExporter.cpp
) )
ADD_ASSIMP_IMPORTER(GLTF
glTFAsset.h
glTFAsset.inl
glTFAssetWriter.h
glTFAssetWriter.inl
glTFImporter.cpp
glTFImporter.h
glTFExporter.h
glTFExporter.cpp
)
SET( Step_SRCS SET( Step_SRCS
StepExporter.h StepExporter.h
StepExporter.cpp StepExporter.cpp
@ -630,15 +650,20 @@ SOURCE_GROUP( unzip FILES ${unzip_SRCS})
SET ( openddl_parser_SRCS SET ( openddl_parser_SRCS
../contrib/openddlparser/code/OpenDDLParser.cpp ../contrib/openddlparser/code/OpenDDLParser.cpp
../contrib/openddlparser/code/DDLNode.cpp ../contrib/openddlparser/code/DDLNode.cpp
../contrib/openddlparser/code/OpenDDLCommon.cpp
../contrib/openddlparser/code/OpenDDLExport.cpp
../contrib/openddlparser/code/Value.cpp ../contrib/openddlparser/code/Value.cpp
../contrib/openddlparser/include/openddlparser/OpenDDLParser.h ../contrib/openddlparser/include/openddlparser/OpenDDLParser.h
../contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h ../contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h
../contrib/openddlparser/include/openddlparser/OpenDDLCommon.h ../contrib/openddlparser/include/openddlparser/OpenDDLCommon.h
../contrib/openddlparser/include/openddlparser/OpenDDLExport.h
../contrib/openddlparser/include/openddlparser/DDLNode.h ../contrib/openddlparser/include/openddlparser/DDLNode.h
../contrib/openddlparser/include/openddlparser/Value.h ../contrib/openddlparser/include/openddlparser/Value.h
) )
SOURCE_GROUP( openddl_parser FILES ${openddl_parser_SRCS}) SOURCE_GROUP( openddl_parser FILES ${openddl_parser_SRCS})
INCLUDE_DIRECTORIES( "../contrib/rapidjson/include" )
# VC2010 fixes # VC2010 fixes
if(MSVC10) if(MSVC10)
option( VC10_STDINT_FIX "Fix for VC10 Compiler regarding pstdint.h redefinition errors" OFF ) option( VC10_STDINT_FIX "Fix for VC10 Compiler regarding pstdint.h redefinition errors" OFF )
@ -731,8 +756,10 @@ if( MSVC )
set(MSVC_PREFIX "vc110") set(MSVC_PREFIX "vc110")
elseif( MSVC12 ) elseif( MSVC12 )
set(MSVC_PREFIX "vc120") set(MSVC_PREFIX "vc120")
elseif( MSVC14 )
set(MSVC_PREFIX "vc140")
else() else()
set(MSVC_PREFIX "vc130") set(MSVC_PREFIX "vc150")
endif() endif()
set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library") set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library")
endif() endif()
@ -764,7 +791,7 @@ INSTALL( TARGETS assimp
INSTALL( FILES ${PUBLIC_HEADERS} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}/assimp COMPONENT assimp-dev) INSTALL( FILES ${PUBLIC_HEADERS} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}/assimp COMPONENT assimp-dev)
INSTALL( FILES ${COMPILER_HEADERS} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}/assimp/Compiler COMPONENT assimp-dev) INSTALL( FILES ${COMPILER_HEADERS} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}/assimp/Compiler COMPONENT assimp-dev)
if (ASSIMP_ANDROID_JNIIOSYSTEM) if (ASSIMP_ANDROID_JNIIOSYSTEM)
INSTALL(FILES ${HEADER_PATH}/../${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/AndroidJNIIOSystem.h INSTALL(FILES ${HEADER_PATH}/${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/AndroidJNIIOSystem.h
DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}
COMPONENT assimp-dev) COMPONENT assimp-dev)
endif(ASSIMP_ANDROID_JNIIOSYSTEM) endif(ASSIMP_ANDROID_JNIIOSYSTEM)

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -167,8 +167,6 @@ void ColladaExporter::WriteHeader()
std::time_t date = std::time(NULL); std::time_t date = std::time(NULL);
std::strftime(date_str, date_nb_chars, "%Y-%m-%dT%H:%M:%S", std::localtime(&date)); std::strftime(date_str, date_nb_chars, "%Y-%m-%dT%H:%M:%S", std::localtime(&date));
std::string scene_name = mScene->mRootNode->mName.C_Str();
aiVector3D scaling; aiVector3D scaling;
aiQuaternion rotation; aiQuaternion rotation;
aiVector3D position; aiVector3D position;
@ -622,8 +620,6 @@ void ColladaExporter::WriteMaterials()
{ {
materials.resize( mScene->mNumMaterials); materials.resize( mScene->mNumMaterials);
std::set<std::string> material_names;
/// collect all materials from the scene /// collect all materials from the scene
size_t numTextures = 0; size_t numTextures = 0;
for( size_t a = 0; a < mScene->mNumMaterials; ++a ) for( size_t a = 0; a < mScene->mNumMaterials; ++a )
@ -1093,4 +1089,3 @@ void ColladaExporter::WriteNode(aiNode* pNode)
#endif #endif
#endif #endif

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -4,7 +4,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -333,8 +333,16 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll
out->mAttenuationLinear = srcLight->mAttLinear; out->mAttenuationLinear = srcLight->mAttLinear;
out->mAttenuationQuadratic = srcLight->mAttQuadratic; out->mAttenuationQuadratic = srcLight->mAttQuadratic;
// collada doesn't differenciate between these color types
out->mColorDiffuse = out->mColorSpecular = out->mColorAmbient = srcLight->mColor*srcLight->mIntensity; out->mColorDiffuse = out->mColorSpecular = out->mColorAmbient = srcLight->mColor*srcLight->mIntensity;
if (out->mType == aiLightSource_AMBIENT) {
out->mColorDiffuse = out->mColorSpecular = aiColor3D(0, 0, 0);
out->mColorAmbient = srcLight->mColor*srcLight->mIntensity;
}
else {
// collada doesn't differentiate between these color types
out->mColorDiffuse = out->mColorSpecular = srcLight->mColor*srcLight->mIntensity;
out->mColorAmbient = aiColor3D(0, 0, 0);
}
// convert falloff angle and falloff exponent in our representation, if given // convert falloff angle and falloff exponent in our representation, if given
if (out->mType == aiLightSource_SPOT) { if (out->mType == aiLightSource_SPOT) {
@ -919,7 +927,7 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructs the animations for the given source anim // Constructs the animations for the given source anim
void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string pPrefix) void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string &pPrefix)
{ {
std::string animName = pPrefix.empty() ? pSrcAnim->mName : pPrefix + "_" + pSrcAnim->mName; std::string animName = pPrefix.empty() ? pSrcAnim->mName : pPrefix + "_" + pSrcAnim->mName;

View File

@ -4,7 +4,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -155,7 +155,7 @@ protected:
* @param pSrcAnim the source animation to process * @param pSrcAnim the source animation to process
* @param pPrefix Prefix to the name in case of nested animations * @param pPrefix Prefix to the name in case of nested animations
*/ */
void StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string pPrefix); void StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pPrefix);
/** Constructs the animation for the given source anim */ /** Constructs the animation for the given source anim */
void CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName); void CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName);

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER #ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
#include <sstream> #include <sstream>
#include <stdarg.h>
#include "ColladaParser.h" #include "ColladaParser.h"
#include "fast_atof.h" #include "fast_atof.h"
#include "ParsingUtils.h" #include "ParsingUtils.h"
@ -63,25 +64,41 @@ using namespace Assimp::Collada;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile) ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile)
: mFileName( pFile) : mFileName( pFile )
, mReader( NULL )
, mDataLibrary()
, mAccessorLibrary()
, mMeshLibrary()
, mNodeLibrary()
, mImageLibrary()
, mEffectLibrary()
, mMaterialLibrary()
, mLightLibrary()
, mCameraLibrary()
, mControllerLibrary()
, mRootNode( NULL )
, mAnims()
, mUnitSize( 1.0f )
, mUpDirection( UP_Y )
, mFormat(FV_1_5_n ) // We assume the newest file format by default
{ {
mRootNode = NULL; // validate io-handler instance
mUnitSize = 1.0f; if ( NULL == pIOHandler ) {
mUpDirection = UP_Y; throw DeadlyImportError("IOSystem is NULL." );
}
// We assume the newest file format by default
mFormat = FV_1_5_n;
// open the file // open the file
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile)); boost::scoped_ptr<IOStream> file( pIOHandler->Open(pFile ) );
if( file.get() == NULL) if (file.get() == NULL) {
throw DeadlyImportError( "Failed to open file " + pFile + "."); throw DeadlyImportError( "Failed to open file " + pFile + "." );
}
// generate a XML reader for it // generate a XML reader for it
boost::scoped_ptr<CIrrXML_IOStreamReader> mIOWrapper( new CIrrXML_IOStreamReader( file.get())); boost::scoped_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));
mReader = irr::io::createIrrXMLReader( mIOWrapper.get()); mReader = irr::io::createIrrXMLReader( mIOWrapper.get());
if( !mReader) if (!mReader) {
ThrowException( "Collada: Unable to open file."); ThrowException("Collada: Unable to open file.");
}
// start reading // start reading
ReadContents(); ReadContents();
@ -831,7 +848,7 @@ void ColladaParser::ReadMaterialLibrary()
{ {
if( IsElement( "material")) if( IsElement( "material"))
{ {
// read ID. By now you propably know my opinion about this "specification" // read ID. By now you probably know my opinion about this "specification"
int attrID = GetAttribute( "id"); int attrID = GetAttribute( "id");
std::string id = mReader->getAttributeValue( attrID); std::string id = mReader->getAttributeValue( attrID);
@ -889,7 +906,7 @@ void ColladaParser::ReadLightLibrary()
if( mReader->getNodeType() == irr::io::EXN_ELEMENT) { if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
if( IsElement( "light")) if( IsElement( "light"))
{ {
// read ID. By now you propably know my opinion about this "specification" // read ID. By now you probably know my opinion about this "specification"
int attrID = GetAttribute( "id"); int attrID = GetAttribute( "id");
std::string id = mReader->getAttributeValue( attrID); std::string id = mReader->getAttributeValue( attrID);
@ -923,7 +940,7 @@ void ColladaParser::ReadCameraLibrary()
if( mReader->getNodeType() == irr::io::EXN_ELEMENT) { if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
if( IsElement( "camera")) if( IsElement( "camera"))
{ {
// read ID. By now you propably know my opinion about this "specification" // read ID. By now you probably know my opinion about this "specification"
int attrID = GetAttribute( "id"); int attrID = GetAttribute( "id");
std::string id = mReader->getAttributeValue( attrID); std::string id = mReader->getAttributeValue( attrID);
@ -1066,6 +1083,12 @@ void ColladaParser::ReadLight( Collada::Light& pLight)
pLight.mFalloffAngle = ReadFloatFromTextContent(); pLight.mFalloffAngle = ReadFloatFromTextContent();
TestClosing("hotspot_beam"); TestClosing("hotspot_beam");
} }
// OpenCOLLADA extensions
// -------------------------------------------------------
else if (IsElement("decay_falloff")) {
pLight.mOuterAngle = ReadFloatFromTextContent();
TestClosing("decay_falloff");
}
} }
else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
if( strcmp( mReader->getNodeName(), "light") == 0) if( strcmp( mReader->getNodeName(), "light") == 0)
@ -1502,7 +1525,7 @@ void ColladaParser::ReadEffectParam( Collada::EffectParam& pParam)
// don't care for remaining stuff // don't care for remaining stuff
SkipElement( "surface"); SkipElement( "surface");
} }
else if( IsElement( "sampler2D")) else if( IsElement( "sampler2D") && (FV_1_4_n == mFormat || FV_1_3_n == mFormat))
{ {
// surface ID is given inside <source> tags // surface ID is given inside <source> tags
TestOpening( "source"); TestOpening( "source");
@ -1513,6 +1536,19 @@ void ColladaParser::ReadEffectParam( Collada::EffectParam& pParam)
// don't care for remaining stuff // don't care for remaining stuff
SkipElement( "sampler2D"); SkipElement( "sampler2D");
}
else if( IsElement( "sampler2D"))
{
// surface ID is given inside <instance_image> tags
TestOpening( "instance_image");
int attrURL = GetAttribute("url");
const char* url = mReader->getAttributeValue( attrURL);
if( url[0] != '#')
ThrowException( "Unsupported URL format in instance_image");
url++;
pParam.mType = Param_Sampler;
pParam.mReference = url;
SkipElement( "sampler2D");
} else } else
{ {
// ignore unknown element // ignore unknown element
@ -1940,7 +1976,7 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
ai_assert( primType != Prim_Invalid); ai_assert( primType != Prim_Invalid);
// also a number of <input> elements, but in addition a <p> primitive collection and propably index counts for all primitives // also a number of <input> elements, but in addition a <p> primitive collection and probably index counts for all primitives
while( mReader->read()) while( mReader->read())
{ {
if( mReader->getNodeType() == irr::io::EXN_ELEMENT) if( mReader->getNodeType() == irr::io::EXN_ELEMENT)
@ -1998,7 +2034,8 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
} }
#ifdef ASSIMP_BUILD_DEBUG #ifdef ASSIMP_BUILD_DEBUG
if (primType != Prim_TriFans && primType != Prim_TriStrips) { if (primType != Prim_TriFans && primType != Prim_TriStrips &&
primType != Prim_Lines) { // this is ONLY to workaround a bug in SketchUp 15.3.331 where it writes the wrong 'count' when it writes out the 'lines'.
ai_assert(actualPrimitives == numPrimitives); ai_assert(actualPrimitives == numPrimitives);
} }
#endif #endif
@ -2108,9 +2145,15 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
} }
// complain if the index count doesn't fit // complain if the index count doesn't fit
if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) {
if (pPrimType == Prim_Lines) {
// HACK: We just fix this number since SketchUp 15.3.331 writes the wrong 'count' for 'lines'
ReportWarning( "Expected different index count in <p> element, %d instead of %d.", indices.size(), expectedPointCount * numOffsets);
pNumPrimitives = (indices.size() / numOffsets) / 2;
} else
ThrowException( "Expected different index count in <p> element."); ThrowException( "Expected different index count in <p> element.");
else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0)
} else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0)
ThrowException( "Expected different index count in <p> element."); ThrowException( "Expected different index count in <p> element.");
// find the data for all sources // find the data for all sources
@ -2712,6 +2755,21 @@ AI_WONT_RETURN void ColladaParser::ThrowException( const std::string& pError) co
{ {
throw DeadlyImportError( boost::str( boost::format( "Collada: %s - %s") % mFileName % pError)); throw DeadlyImportError( boost::str( boost::format( "Collada: %s - %s") % mFileName % pError));
} }
void ColladaParser::ReportWarning(const char* msg,...)
{
ai_assert(NULL != msg);
va_list args;
va_start(args,msg);
char szBuffer[3000];
const int iLen = vsprintf(szBuffer,msg,args);
ai_assert(iLen > 0);
va_end(args);
DefaultLogger::get()->warn("Validation warning: " + std::string(szBuffer,iLen));
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Skips all data until the end node of the current element // Skips all data until the end node of the current element

View File

@ -1,42 +1,42 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
with or without modification, are permitted provided that the with or without modification, are permitted provided that the
following conditions are met: following conditions are met:
* Redistributions of source code must retain the above * Redistributions of source code must retain the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer. following disclaimer.
* Redistributions in binary form must reproduce the above * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other following disclaimer in the documentation and/or other
materials provided with the distribution. materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its * Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products contributors may be used to endorse or promote products
derived from this software without specific prior derived from this software without specific prior
written permission of the assimp team. written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
/** @file ColladaParser.h /** @file ColladaParser.h
* @brief Defines the parser helper class for the collada loader * @brief Defines the parser helper class for the collada loader
@ -49,21 +49,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ColladaHelper.h" #include "ColladaHelper.h"
#include "../include/assimp/ai_assert.h" #include "../include/assimp/ai_assert.h"
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/scoped_ptr.hpp>
namespace Assimp namespace Assimp
{ {
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
/** Parser helper class for the Collada loader. /** Parser helper class for the Collada loader.
* *
* Does all the XML reading and builds internal data structures from it, * Does all the XML reading and builds internal data structures from it,
* but leaves the resolving of all the references to the loader. * but leaves the resolving of all the references to the loader.
*/ */
class ColladaParser class ColladaParser
{ {
friend class ColladaLoader; friend class ColladaLoader;
protected: protected:
/** Constructor from XML file */ /** Constructor from XML file */
ColladaParser( IOSystem* pIOHandler, const std::string& pFile); ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
@ -212,9 +213,10 @@ protected:
// Processes bind_vertex_input and bind elements // Processes bind_vertex_input and bind elements
void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl); void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl);
protected: protected:
/** Aborts the file reading with an exception */ /** Aborts the file reading with an exception */
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX; AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
void ReportWarning(const char* msg,...);
/** Skips all data until the end node of the current element */ /** Skips all data until the end node of the current element */
void SkipElement(); void SkipElement();
@ -263,7 +265,7 @@ protected:
template <typename Type> const Type& ResolveLibraryReference( template <typename Type> const Type& ResolveLibraryReference(
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const; const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
protected: protected:
/** Filename, for a verbose error message */ /** Filename, for a verbose error message */
std::string mFileName; std::string mFileName;
@ -326,26 +328,26 @@ protected:
/** Collada file format version */ /** Collada file format version */
Collada::FormatVersion mFormat; Collada::FormatVersion mFormat;
}; };
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Check for element match // Check for element match
inline bool ColladaParser::IsElement( const char* pName) const inline bool ColladaParser::IsElement( const char* pName) const
{ {
ai_assert( mReader->getNodeType() == irr::io::EXN_ELEMENT); ai_assert( mReader->getNodeType() == irr::io::EXN_ELEMENT);
return ::strcmp( mReader->getNodeName(), pName) == 0; return ::strcmp( mReader->getNodeName(), pName) == 0;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Finds the item in the given library by its reference, throws if not found // Finds the item in the given library by its reference, throws if not found
template <typename Type> template <typename Type>
const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const
{ {
typename std::map<std::string, Type>::const_iterator it = pLibrary.find( pURL); typename std::map<std::string, Type>::const_iterator it = pLibrary.find( pURL);
if( it == pLibrary.end()) if( it == pLibrary.end())
ThrowException( boost::str( boost::format( "Unable to resolve library reference \"%s\".") % pURL)); ThrowException( boost::str( boost::format( "Unable to resolve library reference \"%s\".") % pURL));
return it->second; return it->second;
} }
} // end of namespace Assimp } // end of namespace Assimp

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -412,7 +412,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene)
{ {
if (!DefaultLogger::isNullLogger()) if (!DefaultLogger::isNullLogger())
{ {
sprintf(buffer, "Found non-UV mapped texture (%s,%i). Mapping type: %s", sprintf(buffer, "Found non-UV mapped texture (%s,%u). Mapping type: %s",
TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex, TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex,
MappingTypeToString(mapping)); MappingTypeToString(mapping));

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -125,7 +125,7 @@ private:
// temporary structure to describe a mapping // temporary structure to describe a mapping
struct MappingInfo struct MappingInfo
{ {
MappingInfo(aiTextureMapping _type) explicit MappingInfo(aiTextureMapping _type)
: type (_type) : type (_type)
, axis (0.f,1.f,0.f) , axis (0.f,1.f,0.f)
, uv (0u) , uv (0u)

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -1,8 +1,8 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -147,7 +147,7 @@ void DeboneProcess::Execute( aiScene* pScene)
if(!DefaultLogger::isNullLogger()) { if(!DefaultLogger::isNullLogger()) {
char buffer[1024]; char buffer[1024];
::sprintf(buffer,"Removed %i bones. Input bones: %i. Output bones: %i",in-out,in,out); ::sprintf(buffer,"Removed %u bones. Input bones: %u. Output bones: %u",in-out,in,out);
DefaultLogger::get()->info(buffer); DefaultLogger::get()->info(buffer);
} }

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -135,8 +135,8 @@ inline void MakeAbsolutePath (const char* in, char* _out)
{ {
ai_assert(in && _out); ai_assert(in && _out);
char* ret; char* ret;
#ifdef _WIN32 #if defined( _MSC_VER ) || defined( __MINGW32__ )
ret = ::_fullpath(_out, in,PATHLIMIT); ret = ::_fullpath( _out, in, PATHLIMIT );
#else #else
// use realpath // use realpath
ret = realpath(in, _out); ret = realpath(in, _out);
@ -167,8 +167,8 @@ bool DefaultIOSystem::ComparePaths (const char* one, const char* second) const
return !ASSIMP_stricmp(temp1,temp2); return !ASSIMP_stricmp(temp1,temp2);
} }
// ------------------------------------------------------------------------------------------------
std::string DefaultIOSystem::fileName(std::string path) std::string DefaultIOSystem::fileName( const std::string &path )
{ {
std::string ret = path; std::string ret = path;
std::size_t last = ret.find_last_of("\\/"); std::size_t last = ret.find_last_of("\\/");
@ -176,8 +176,8 @@ std::string DefaultIOSystem::fileName(std::string path)
return ret; return ret;
} }
// ------------------------------------------------------------------------------------------------
std::string DefaultIOSystem::completeBaseName(std::string path) std::string DefaultIOSystem::completeBaseName( const std::string &path )
{ {
std::string ret = fileName(path); std::string ret = fileName(path);
std::size_t pos = ret.find_last_of('.'); std::size_t pos = ret.find_last_of('.');
@ -185,8 +185,8 @@ std::string DefaultIOSystem::completeBaseName(std::string path)
return ret; return ret;
} }
// ------------------------------------------------------------------------------------------------
std::string DefaultIOSystem::absolutePath(std::string path) std::string DefaultIOSystem::absolutePath( const std::string &path )
{ {
std::string ret = path; std::string ret = path;
std::size_t last = ret.find_last_of("\\/"); std::size_t last = ret.find_last_of("\\/");
@ -194,4 +194,6 @@ std::string DefaultIOSystem::absolutePath(std::string path)
return ret; return ret;
} }
// ------------------------------------------------------------------------------------------------
#undef PATHLIMIT #undef PATHLIMIT

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -80,17 +80,17 @@ public:
/** @brief get the file name of a full filepath /** @brief get the file name of a full filepath
* example: /tmp/archive.tar.gz -> archive.tar.gz * example: /tmp/archive.tar.gz -> archive.tar.gz
*/ */
static std::string fileName(std::string path); static std::string fileName( const std::string &path );
/** @brief get the complete base name of a full filepath /** @brief get the complete base name of a full filepath
* example: /tmp/archive.tar.gz -> archive.tar * example: /tmp/archive.tar.gz -> archive.tar
*/ */
static std::string completeBaseName(std::string path); static std::string completeBaseName( const std::string &path);
/** @brief get the path of a full filepath /** @brief get the path of a full filepath
* example: /tmp/archive.tar.gz -> /tmp/ * example: /tmp/archive.tar.gz -> /tmp/
*/ */
static std::string absolutePath(std::string path); static std::string absolutePath( const std::string &path);
}; };
} //!ns Assimp } //!ns Assimp

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -169,7 +169,6 @@ void Logger::debug(const char* message) {
// sometimes importers will include data from the input file // sometimes importers will include data from the input file
// (i.e. node names) in their messages. // (i.e. node names) in their messages.
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
ai_assert(false);
return; return;
} }
return OnDebug(message); return OnDebug(message);
@ -180,7 +179,6 @@ void Logger::info(const char* message) {
// SECURITY FIX: see above // SECURITY FIX: see above
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
ai_assert(false);
return; return;
} }
return OnInfo(message); return OnInfo(message);
@ -191,7 +189,6 @@ void Logger::warn(const char* message) {
// SECURITY FIX: see above // SECURITY FIX: see above
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
ai_assert(false);
return; return;
} }
return OnWarn(message); return OnWarn(message);
@ -202,7 +199,6 @@ void Logger::error(const char* message) {
// SECURITY FIX: see above // SECURITY FIX: see above
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
ai_assert(false);
return; return;
} }
return OnError(message); return OnError(message);
@ -258,7 +254,7 @@ void DefaultLogger::OnDebug( const char* message )
return; return;
char msg[MAX_LOG_MESSAGE_LENGTH + 16]; char msg[MAX_LOG_MESSAGE_LENGTH + 16];
::sprintf(msg,"Debug, T%i: %s", GetThreadID(), message ); ::sprintf(msg,"Debug, T%u: %s", GetThreadID(), message );
WriteToStreams( msg, Logger::Debugging ); WriteToStreams( msg, Logger::Debugging );
} }
@ -268,7 +264,7 @@ void DefaultLogger::OnDebug( const char* message )
void DefaultLogger::OnInfo( const char* message ) void DefaultLogger::OnInfo( const char* message )
{ {
char msg[MAX_LOG_MESSAGE_LENGTH + 16]; char msg[MAX_LOG_MESSAGE_LENGTH + 16];
::sprintf(msg,"Info, T%i: %s", GetThreadID(), message ); ::sprintf(msg,"Info, T%u: %s", GetThreadID(), message );
WriteToStreams( msg , Logger::Info ); WriteToStreams( msg , Logger::Info );
} }
@ -278,7 +274,7 @@ void DefaultLogger::OnInfo( const char* message )
void DefaultLogger::OnWarn( const char* message ) void DefaultLogger::OnWarn( const char* message )
{ {
char msg[MAX_LOG_MESSAGE_LENGTH + 16]; char msg[MAX_LOG_MESSAGE_LENGTH + 16];
::sprintf(msg,"Warn, T%i: %s", GetThreadID(), message ); ::sprintf(msg,"Warn, T%u: %s", GetThreadID(), message );
WriteToStreams( msg, Logger::Warn ); WriteToStreams( msg, Logger::Warn );
} }
@ -288,7 +284,7 @@ void DefaultLogger::OnWarn( const char* message )
void DefaultLogger::OnError( const char* message ) void DefaultLogger::OnError( const char* message )
{ {
char msg[MAX_LOG_MESSAGE_LENGTH + 16]; char msg[MAX_LOG_MESSAGE_LENGTH + 16];
::sprintf(msg,"Error, T%i: %s", GetThreadID(), message ); ::sprintf(msg,"Error, T%u: %s", GetThreadID(), message );
WriteToStreams( msg, Logger::Err ); WriteToStreams( msg, Logger::Err );
} }

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
@ -87,6 +87,8 @@ void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*, const ExportPro
void ExportScenePly(const char*,IOSystem*, const aiScene*, const ExportProperties*); void ExportScenePly(const char*,IOSystem*, const aiScene*, const ExportProperties*);
void ExportScenePlyBinary(const char*, IOSystem*, const aiScene*, const ExportProperties*); void ExportScenePlyBinary(const char*, IOSystem*, const aiScene*, const ExportProperties*);
void ExportScene3DS(const char*, IOSystem*, const aiScene*, const ExportProperties*); void ExportScene3DS(const char*, IOSystem*, const aiScene*, const ExportProperties*);
void ExportSceneGLTF(const char*, IOSystem*, const aiScene*, const ExportProperties*);
void ExportSceneGLB(const char*, IOSystem*, const aiScene*, const ExportProperties*);
void ExportSceneAssbin(const char*, IOSystem*, const aiScene*, const ExportProperties*); void ExportSceneAssbin(const char*, IOSystem*, const aiScene*, const ExportProperties*);
void ExportSceneAssxml(const char*, IOSystem*, const aiScene*, const ExportProperties*); void ExportSceneAssxml(const char*, IOSystem*, const aiScene*, const ExportProperties*);
@ -135,6 +137,13 @@ Exporter::ExportFormatEntry gExporters[] =
aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices), aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices),
#endif #endif
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
Exporter::ExportFormatEntry( "gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF,
aiProcess_JoinIdenticalVertices /*| aiProcess_SortByPType*/),
Exporter::ExportFormatEntry( "glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB,
aiProcess_JoinIdenticalVertices /*| aiProcess_SortByPType*/),
#endif
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER #ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
Exporter::ExportFormatEntry( "assbin", "Assimp Binary", "assbin" , &ExportSceneAssbin, 0), Exporter::ExportFormatEntry( "assbin", "Assimp Binary", "assbin" , &ExportSceneAssbin, 0),
#endif #endif

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXUtil.h" #include "FBXUtil.h"
#include "FBXProperties.h" #include "FBXProperties.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "StringComparison.h"
#include "../include/assimp/scene.h" #include "../include/assimp/scene.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/scoped_array.hpp> #include <boost/scoped_array.hpp>
@ -148,6 +149,7 @@ public:
std::for_each(animations.begin(),animations.end(),Util::delete_fun<aiAnimation>()); std::for_each(animations.begin(),animations.end(),Util::delete_fun<aiAnimation>());
std::for_each(lights.begin(),lights.end(),Util::delete_fun<aiLight>()); std::for_each(lights.begin(),lights.end(),Util::delete_fun<aiLight>());
std::for_each(cameras.begin(),cameras.end(),Util::delete_fun<aiCamera>()); std::for_each(cameras.begin(),cameras.end(),Util::delete_fun<aiCamera>());
std::for_each(textures.begin(),textures.end(),Util::delete_fun<aiTexture>());
} }
@ -1449,6 +1451,36 @@ private:
return static_cast<unsigned int>(materials.size() - 1); return static_cast<unsigned int>(materials.size() - 1);
} }
// ------------------------------------------------------------------------------------------------
// Video -> aiTexture
unsigned int ConvertVideo(const Video& video)
{
// generate empty output texture
aiTexture* out_tex = new aiTexture();
textures.push_back(out_tex);
// assuming the texture is compressed
out_tex->mWidth = static_cast<unsigned int>(video.ContentLength()); // total data size
out_tex->mHeight = 0; // fixed to 0
// steal the data from the Video to avoid an additional copy
out_tex->pcData = reinterpret_cast<aiTexel*>( const_cast<Video&>(video).RelinquishContent() );
// try to extract a hint from the file extension
const std::string& filename = video.FileName().empty() ? video.RelativeFilename() : video.FileName();
std::string ext = BaseImporter::GetExtension(filename);
if(ext == "jpeg") {
ext = "jpg";
}
if(ext.size() <= 3) {
memcpy(out_tex->achFormatHint, ext.c_str(), ext.size());
}
return static_cast<unsigned int>(textures.size() - 1);
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void TrySetTextureProperties(aiMaterial* out_mat, const TextureMap& textures, void TrySetTextureProperties(aiMaterial* out_mat, const TextureMap& textures,
@ -1466,6 +1498,24 @@ private:
aiString path; aiString path;
path.Set(tex->RelativeFilename()); path.Set(tex->RelativeFilename());
const Video* media = tex->Media();
if(media != 0 && media->ContentLength() > 0) {
unsigned int index;
VideoMap::const_iterator it = textures_converted.find(media);
if(it != textures_converted.end()) {
index = (*it).second;
}
else {
index = ConvertVideo(*media);
textures_converted[media] = index;
}
// setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture)
path.data[0] = '*';
path.length = 1 + ASSIMP_itoa10(path.data + 1, MAXLEN - 1, index);
}
out_mat->AddProperty(&path,_AI_MATKEY_TEXTURE_BASE,target,0); out_mat->AddProperty(&path,_AI_MATKEY_TEXTURE_BASE,target,0);
aiUVTransform uvTrafo; aiUVTransform uvTrafo;
@ -2496,8 +2546,9 @@ private:
// need to convert from TRS order to SRT? // need to convert from TRS order to SRT?
if(reverse_order) { if(reverse_order) {
aiVector3D def_scale, def_translate; aiVector3D def_scale = PropertyGet(props,"Lcl Scaling",aiVector3D(1.f,1.f,1.f));
aiQuaternion def_rot; aiVector3D def_translate = PropertyGet(props,"Lcl Translation",aiVector3D(0.f,0.f,0.f));
aiVector3D def_rot = PropertyGet(props,"Lcl Rotation",aiVector3D(0.f,0.f,0.f));
KeyFrameListList scaling; KeyFrameListList scaling;
KeyFrameListList translation; KeyFrameListList translation;
@ -2506,24 +2557,14 @@ private:
if(chain[TransformationComp_Scaling] != iter_end) { if(chain[TransformationComp_Scaling] != iter_end) {
scaling = GetKeyframeList((*chain[TransformationComp_Scaling]).second, start, stop); scaling = GetKeyframeList((*chain[TransformationComp_Scaling]).second, start, stop);
} }
else {
def_scale = PropertyGet(props,"Lcl Scaling",aiVector3D(1.f,1.f,1.f));
}
if(chain[TransformationComp_Translation] != iter_end) { if(chain[TransformationComp_Translation] != iter_end) {
translation = GetKeyframeList((*chain[TransformationComp_Translation]).second, start, stop); translation = GetKeyframeList((*chain[TransformationComp_Translation]).second, start, stop);
} }
else {
def_translate = PropertyGet(props,"Lcl Translation",aiVector3D(0.f,0.f,0.f));
}
if(chain[TransformationComp_Rotation] != iter_end) { if(chain[TransformationComp_Rotation] != iter_end) {
rotation = GetKeyframeList((*chain[TransformationComp_Rotation]).second, start, stop); rotation = GetKeyframeList((*chain[TransformationComp_Rotation]).second, start, stop);
} }
else {
def_rot = EulerToQuaternion(PropertyGet(props,"Lcl Rotation",aiVector3D(0.f,0.f,0.f)),
target.RotationOrder());
}
KeyFrameListList joined; KeyFrameListList joined;
joined.insert(joined.end(), scaling.begin(), scaling.end()); joined.insert(joined.end(), scaling.begin(), scaling.end());
@ -2740,7 +2781,7 @@ private:
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void InterpolateKeys(aiVectorKey* valOut,const KeyTimeList& keys, const KeyFrameListList& inputs, void InterpolateKeys(aiVectorKey* valOut,const KeyTimeList& keys, const KeyFrameListList& inputs,
const bool geom, const aiVector3D& def_value,
double& max_time, double& max_time,
double& min_time) double& min_time)
@ -2754,10 +2795,7 @@ private:
next_pos.resize(inputs.size(),0); next_pos.resize(inputs.size(),0);
BOOST_FOREACH(KeyTimeList::value_type time, keys) { BOOST_FOREACH(KeyTimeList::value_type time, keys) {
float result[3] = {0.0f, 0.0f, 0.0f}; float result[3] = {def_value.x, def_value.y, def_value.z};
if(geom) {
result[0] = result[1] = result[2] = 1.0f;
}
for (size_t i = 0; i < count; ++i) { for (size_t i = 0; i < count; ++i) {
const KeyFrameList& kfl = inputs[i]; const KeyFrameList& kfl = inputs[i];
@ -2782,12 +2820,7 @@ private:
const double factor = timeB == timeA ? 0. : static_cast<double>((time - timeA) / (timeB - timeA)); const double factor = timeB == timeA ? 0. : static_cast<double>((time - timeA) / (timeB - timeA));
const float interpValue = static_cast<float>(valueA + (valueB - valueA) * factor); const float interpValue = static_cast<float>(valueA + (valueB - valueA) * factor);
if(geom) { result[kfl.get<2>()] = interpValue;
result[kfl.get<2>()] *= interpValue;
}
else {
result[kfl.get<2>()] += interpValue;
}
} }
// magic value to convert fbx times to seconds // magic value to convert fbx times to seconds
@ -2807,7 +2840,7 @@ private:
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void InterpolateKeys(aiQuatKey* valOut,const KeyTimeList& keys, const KeyFrameListList& inputs, void InterpolateKeys(aiQuatKey* valOut,const KeyTimeList& keys, const KeyFrameListList& inputs,
const bool geom, const aiVector3D& def_value,
double& maxTime, double& maxTime,
double& minTime, double& minTime,
Model::RotOrder order) Model::RotOrder order)
@ -2816,7 +2849,7 @@ private:
ai_assert(valOut); ai_assert(valOut);
boost::scoped_array<aiVectorKey> temp(new aiVectorKey[keys.size()]); boost::scoped_array<aiVectorKey> temp(new aiVectorKey[keys.size()]);
InterpolateKeys(temp.get(),keys,inputs,geom,maxTime, minTime); InterpolateKeys(temp.get(), keys, inputs, def_value, maxTime, minTime);
aiMatrix4x4 m; aiMatrix4x4 m;
@ -2858,20 +2891,20 @@ private:
Model::RotOrder order, Model::RotOrder order,
const aiVector3D& def_scale, const aiVector3D& def_scale,
const aiVector3D& def_translate, const aiVector3D& def_translate,
const aiQuaternion& def_rotation) const aiVector3D& def_rotation)
{ {
if (rotation.size()) { if (rotation.size()) {
InterpolateKeys(out_quat, times, rotation, false, maxTime, minTime, order); InterpolateKeys(out_quat, times, rotation, def_rotation, maxTime, minTime, order);
} }
else { else {
for (size_t i = 0; i < times.size(); ++i) { for (size_t i = 0; i < times.size(); ++i) {
out_quat[i].mTime = CONVERT_FBX_TIME(times[i]) * anim_fps; out_quat[i].mTime = CONVERT_FBX_TIME(times[i]) * anim_fps;
out_quat[i].mValue = def_rotation; out_quat[i].mValue = EulerToQuaternion(def_rotation, order);
} }
} }
if (scaling.size()) { if (scaling.size()) {
InterpolateKeys(out_scale, times, scaling, true, maxTime, minTime); InterpolateKeys(out_scale, times, scaling, def_scale, maxTime, minTime);
} }
else { else {
for (size_t i = 0; i < times.size(); ++i) { for (size_t i = 0; i < times.size(); ++i) {
@ -2881,7 +2914,7 @@ private:
} }
if (translation.size()) { if (translation.size()) {
InterpolateKeys(out_translation, times, translation, false, maxTime, minTime); InterpolateKeys(out_translation, times, translation, def_translate, maxTime, minTime);
} }
else { else {
for (size_t i = 0; i < times.size(); ++i) { for (size_t i = 0; i < times.size(); ++i) {
@ -2935,7 +2968,7 @@ private:
na->mNumScalingKeys = static_cast<unsigned int>(keys.size()); na->mNumScalingKeys = static_cast<unsigned int>(keys.size());
na->mScalingKeys = new aiVectorKey[keys.size()]; na->mScalingKeys = new aiVectorKey[keys.size()];
if (keys.size() > 0) if (keys.size() > 0)
InterpolateKeys(na->mScalingKeys, keys, inputs, true, maxTime, minTime); InterpolateKeys(na->mScalingKeys, keys, inputs, aiVector3D(1.0f, 1.0f, 1.0f), maxTime, minTime);
} }
@ -2955,7 +2988,7 @@ private:
na->mNumPositionKeys = static_cast<unsigned int>(keys.size()); na->mNumPositionKeys = static_cast<unsigned int>(keys.size());
na->mPositionKeys = new aiVectorKey[keys.size()]; na->mPositionKeys = new aiVectorKey[keys.size()];
if (keys.size() > 0) if (keys.size() > 0)
InterpolateKeys(na->mPositionKeys, keys, inputs, false, maxTime, minTime); InterpolateKeys(na->mPositionKeys, keys, inputs, aiVector3D(0.0f, 0.0f, 0.0f), maxTime, minTime);
} }
@ -2976,7 +3009,7 @@ private:
na->mNumRotationKeys = static_cast<unsigned int>(keys.size()); na->mNumRotationKeys = static_cast<unsigned int>(keys.size());
na->mRotationKeys = new aiQuatKey[keys.size()]; na->mRotationKeys = new aiQuatKey[keys.size()];
if (keys.size() > 0) if (keys.size() > 0)
InterpolateKeys(na->mRotationKeys, keys, inputs, false, maxTime, minTime, order); InterpolateKeys(na->mRotationKeys, keys, inputs, aiVector3D(0.0f, 0.0f, 0.0f), maxTime, minTime, order);
} }
@ -3024,6 +3057,13 @@ private:
std::swap_ranges(cameras.begin(),cameras.end(),out->mCameras); std::swap_ranges(cameras.begin(),cameras.end(),out->mCameras);
} }
if(textures.size()) {
out->mTextures = new aiTexture*[textures.size()]();
out->mNumTextures = static_cast<unsigned int>(textures.size());
std::swap_ranges(textures.begin(),textures.end(),out->mTextures);
}
} }
@ -3037,10 +3077,14 @@ private:
std::vector<aiAnimation*> animations; std::vector<aiAnimation*> animations;
std::vector<aiLight*> lights; std::vector<aiLight*> lights;
std::vector<aiCamera*> cameras; std::vector<aiCamera*> cameras;
std::vector<aiTexture*> textures;
typedef std::map<const Material*, unsigned int> MaterialMap; typedef std::map<const Material*, unsigned int> MaterialMap;
MaterialMap materials_converted; MaterialMap materials_converted;
typedef std::map<const Video*, unsigned int> VideoMap;
VideoMap textures_converted;
typedef std::map<const Geometry*, std::vector<unsigned int> > MeshMap; typedef std::map<const Geometry*, std::vector<unsigned int> > MeshMap;
MeshMap meshes_converted; MeshMap meshes_converted;

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -180,6 +180,9 @@ const Object* LazyObject::Get(bool dieOnError)
else if (!strncmp(obtype,"LayeredTexture",length)) { else if (!strncmp(obtype,"LayeredTexture",length)) {
object.reset(new LayeredTexture(id,element,doc,name)); object.reset(new LayeredTexture(id,element,doc,name));
} }
else if (!strncmp(obtype,"Video",length)) {
object.reset(new Video(id,element,doc,name));
}
else if (!strncmp(obtype,"AnimationStack",length)) { else if (!strncmp(obtype,"AnimationStack",length)) {
object.reset(new AnimationStack(id,element,name,doc)); object.reset(new AnimationStack(id,element,name,doc));
} }
@ -483,6 +486,11 @@ void Document::ReadConnections()
for(ElementMap::const_iterator it = conns.first; it != conns.second; ++it) { for(ElementMap::const_iterator it = conns.first; it != conns.second; ++it) {
const Element& el = *(*it).second; const Element& el = *(*it).second;
const std::string& type = ParseTokenAsString(GetRequiredToken(el,0)); const std::string& type = ParseTokenAsString(GetRequiredToken(el,0));
// PP = property-property connection, ignored for now
// (tokens: "PP", ID1, "Property1", ID2, "Property2")
if(type == "PP") continue;
const uint64_t src = ParseTokenAsID(GetRequiredToken(el,1)); const uint64_t src = ParseTokenAsID(GetRequiredToken(el,1));
const uint64_t dest = ParseTokenAsID(GetRequiredToken(el,2)); const uint64_t dest = ParseTokenAsID(GetRequiredToken(el,2));

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,
@ -73,6 +73,8 @@ namespace FBX {
class Material; class Material;
class Geometry; class Geometry;
class Video;
class AnimationCurve; class AnimationCurve;
class AnimationCurveNode; class AnimationCurveNode;
class AnimationLayer; class AnimationLayer;
@ -571,6 +573,10 @@ public:
return crop; return crop;
} }
const Video* Media() const {
return media;
}
private: private:
aiVector2D uvTrans; aiVector2D uvTrans;
@ -583,6 +589,8 @@ private:
boost::shared_ptr<const PropertyTable> props; boost::shared_ptr<const PropertyTable> props;
unsigned int crop[4]; unsigned int crop[4];
const Video* media;
}; };
/** DOM class for layered FBX textures */ /** DOM class for layered FBX textures */
@ -654,6 +662,59 @@ typedef std::fbx_unordered_map<std::string, const Texture*> TextureMap;
typedef std::fbx_unordered_map<std::string, const LayeredTexture*> LayeredTextureMap; typedef std::fbx_unordered_map<std::string, const LayeredTexture*> LayeredTextureMap;
/** DOM class for generic FBX videos */
class Video : public Object
{
public:
Video(uint64_t id, const Element& element, const Document& doc, const std::string& name);
~Video();
public:
const std::string& Type() const {
return type;
}
const std::string& FileName() const {
return fileName;
}
const std::string& RelativeFilename() const {
return relativeFileName;
}
const PropertyTable& Props() const {
ai_assert(props.get());
return *props.get();
}
const uint8_t* Content() const {
ai_assert(content);
return content;
}
const uint32_t ContentLength() const {
return contentLength;
}
uint8_t* RelinquishContent() {
uint8_t* ptr = content;
content = 0;
return ptr;
}
private:
std::string type;
std::string relativeFileName;
std::string fileName;
boost::shared_ptr<const PropertyTable> props;
uint32_t contentLength;
uint8_t* content;
};
/** DOM class for generic FBX materials */ /** DOM class for generic FBX materials */
class Material : public Object class Material : public Object
{ {

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2015, 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,6 +55,7 @@ struct ImportSettings
, readAllLayers(true) , readAllLayers(true)
, readAllMaterials(false) , readAllMaterials(false)
, readMaterials(true) , readMaterials(true)
, readTextures(true)
, readCameras(true) , readCameras(true)
, readLights(true) , readLights(true)
, readAnimations(true) , readAnimations(true)
@ -92,6 +93,9 @@ struct ImportSettings
* material. The default value is true.*/ * material. The default value is true.*/
bool readMaterials; bool readMaterials;
/** import embedded textures? Default value is true.*/
bool readTextures;
/** import cameras? Default value is true.*/ /** import cameras? Default value is true.*/
bool readCameras; bool readCameras;

Some files were not shown because too many files have changed in this diff Show More