Merge remote-tracking branch 'github/master' into contrib

pull/1208/head
Leo Terziman 2017-03-09 17:28:47 +01:00
commit bbd487308b
75 changed files with 6384 additions and 13572 deletions

7
.gitattributes vendored
View File

@ -2,7 +2,14 @@
*.cpp text eol=lf
*.h text eol=lf
*.c text eol=lf
*.cc text eol=lf
*.cpp text eol=lf
*.rc text eol=lf
*.hpp text eol=lf
*.txt text eol=lf
*.cmake text eol=lf
*.sh text eol=lf
CHANGES text eol=lf
CREDITS text eol=lf
LICENSE text eol=lf
Readme.md text eol=lf

378
CHANGES
View File

@ -1,173 +1,205 @@
----------------------------------------------------------------------
CHANGELOG
----------------------------------------------------------------------
3.2.1 (2016-10-01)
FEATURES:
- Updated glTF exporter to meet 1.0 specification.
FIXES/HOUSEKEEPING:
- Fixed glTF Validator errors for exported glTF format.
ISSUES:
- Hard coded sampler setting for
- magFilter
- minFilter
- void* in ExportData for accessor max and min.
3.2.0 (2015-11-03)
FEATURES:
- OpenDDL-Parser is part of contrib-source.
- Experimental OpenGEX-support
- CI-check for linux and windows
- Coverity check added
- New regression testsuite.
FIXES/HOUSEKEEPING:
- Hundreds of bugfixes in all parts of the library
- Unified line endings
API COMPATIBILITY:
- Removed precompiled header to increase build speed for linux
3.1.1 (2014-06-15)
FEATURES:
- Support for FBX 2013 and newer, binary and ASCII (this is partly
work from Google Summer of Code 2012)
- Support for OGRE binary mesh and skeleton format
- Updated BLEND support for newer Blender versions
- Support for arbitrary meta data, used to hold FBX and DAE metadata
- OBJ Export now produces smaller files
- Meshes can now have names, this is supported by the major importers
- Improved IFC geometry generation
- M3 support has been removed
FIXES/HOUSEKEEPING:
- Hundreds of bugfixes in all parts of the library
- CMake is now the primary build system
API COMPATIBILITY:
- 3.1.1 is not binary compatible to 3.0 due to aiNode::mMetaData
and aiMesh::mName
- Export interface has been cleaned up and unified
- Other than that no relevant changes
3.0 (2012-07-07)
FEATURES:
- new export interface similar to the import API.
- Supported export formats: Collada, OBJ, PLY and STL
- added new import formats: XGL/ZGL, M3 (experimental)
- new postprocessing steps: Debone
- vastly improved IFC (Industry Foundation Classes) support
- introduced API to query importer meta information (such as supported
format versions, full name, maintainer info).
- reworked Ogre XML import
- C-API now supports per-import properties
FIXES/HOUSEKEEPING:
- hundreds of bugfixes in all parts of the library
- unified naming and cleanup of public headers
- improved CMake build system
- templatized math library
- reduce dependency on boost.thread, only remaining spot
is synchronization for the C logging API
API COMPATIBILITY:
- renamed headers, export interface, C API properties and meta data
prevent compatibility with code written for 2.0, but in
most cases these can be easily resolved
- Note: 3.0 is not binary compatible with 2.0
2.0 (2010-11-21)
FEATURES:
- Add support for static Blender (*.blend) scenes
- Add support for Q3BSP scenes
- Add a windows-based OpenGL sample featuring texturing & basic materials
- Add an experimental progress feedback interface.
- Vastly improved performance (up to 500%, depending on mesh size and
spatial structure) in some expensive postprocessing steps
- AssimpView now uses a reworked layout which leaves more space
to the scene hierarchy window
- Add C# bindings ('Assimp.NET')
- Keep BSD-licensed and otherwise free test files in separate
folders (./test/models and ./test/models-nonbsd).
FIXES:
- Many Collada bugfixes, improve fault tolerance
- Fix possible crashes in the Obj loader
- Improve the Ogre XML loader
- OpenGL-sample now works with MinGW
- Fix Importer::FindLoader failing on uppercase file extensions
- Fix flawed path handling when locating external files
- Limit the maximum number of vertices, faces, face indices and
weights that Assimp is able to handle. This is to avoid
crashes due to overflowing counters.
- Updated XCode project files
- Further CMAKE build improvements
API CHANGES:
- Add data structures for vertex-based animations (These are not
currently used, however ...)
- Some Assimp::Importer methods are const now.
1.1 (2010-04-17)
This is the list of relevant changes from the 1.0 (r412) release to 1.1 (r700).
FEATURES:
- Vastly improved Collada support
- Add MS3D (Milkshape 3D) support
- Add support for Ogre XML static meshes
- Add experimental COB (TrueSpace) support
- Automatic test suite to quickly locate regressions
- D bindings (`dAssimp`)
- Python 2.n bindings (`PyAssimp`)
- Add basic support for Unicode input files (utf8, utf16 and utf32)
- Add further utilities to the `assimp` tool (xml/binary dumps, quick file stats)
- Switch to a CMAKE-based build system including an install target for unix'es
- Automatic evaluation of subdivision surfaces for some formats.
- Add `Importer::ReadFileFromMemory` and the corresponding C-API `aiReadFileFromMemory`
- Expose further math utilities via the C-API (i.e. `aiMultiplyMatrix4`)
- Move noboost files away from the public include directory
- Many, many bugfixes and improvements in existing loaders and postprocessing steps
- Documentation improved and clarified in many places.
- Add a sample on using Assimp in conjunction with OpenGL
- Distribution/packaging: comfortable SDK installer for Windows
- Distribution/packaging: improved release packages for other architectures
CRITICAL FIXES:
- Resolve problems with clashing heap managers, STL ABIs and runtime libraries (win32)
- Fix automatic detection of file type if no file extension is given
- Improved exception safety and robustness, prevent leaking of exceptions through the C interface
- Fix possible heap corruption due to material properties pulled in incorrectly
- Avoid leaking in certain error scenarios
- Fix 64 bit compatibility problems in some loaders (i.e. MDL)
BREAKING API CHANGES:
- None -
MINOR API BEHAVIOUR CHANGES:
- Change quaternion orientation to suit to the more common convention (-w).
- aiString is utf8 now. Not yet consistent, however.
----------------------------------------------------------------------
CHANGELOG
----------------------------------------------------------------------
3.3.1 (2016-07-08)
FIXES/HOUSEKEEPING:
- Setup of default precision for 17 exporters
- Fix xcode project files
- Fix BlenderTesselator: offsetof operator
- Invalid version in cmake file
- Update pstdint.h to latest greatest
3.3.0 (2016-07-05)
FEATURES:
- C++11 support enabled
- New regression-test-UI
- Experimental glTF-importer support
- OpenGEX: add support for cameras and lights
- C4D: update to latest Melange-SDK
- Add a gitter channel
- Coverity check enabled
- Switch to <...> include brackets for public headers
- Enable export by pyAssimp
- CI: check windows build
- Add functionality to perform a singlepost-processing step
- many more, just check the history
FIXES/HOUSEKEEPING:
- Fix of many resource leaks in unittests and main lib
- Fix iOS-buildfor X64
- Choosing zlib manually for cmake
- many more, just check the history
3.2.1 (2016-010-10)
FEATURES:
- Updated glTF exporter to meet 1.0 specification.
FIXES/HOUSEKEEPING:
- Fixed glTF Validator errors for exported glTF format.
ISSUES:
- Hard coded sampler setting for
- magFilter
- minFilter
- void* in ExportData for accessor max and min.
3.2.0 (2015-11-03)
FEATURES:
- OpenDDL-Parser is part of contrib-source.
- Experimental OpenGEX-support
- CI-check for linux and windows
- Coverity check added
- New regression testsuite.
FIXES/HOUSEKEEPING:
- Hundreds of bugfixes in all parts of the library
- Unified line endings
API COMPATIBILITY:
- Removed precompiled header to increase build speed for linux
3.1.1 (2014-06-15)
FEATURES:
- Support for FBX 2013 and newer, binary and ASCII (this is partly
work from Google Summer of Code 2012)
- Support for OGRE binary mesh and skeleton format
- Updated BLEND support for newer Blender versions
- Support for arbitrary meta data, used to hold FBX and DAE metadata
- OBJ Export now produces smaller files
- Meshes can now have names, this is supported by the major importers
- Improved IFC geometry generation
- M3 support has been removed
FIXES/HOUSEKEEPING:
- Hundreds of bugfixes in all parts of the library
- CMake is now the primary build system
API COMPATIBILITY:
- 3.1.1 is not binary compatible to 3.0 due to aiNode::mMetaData
and aiMesh::mName
- Export interface has been cleaned up and unified
- Other than that no relevant changes
3.0 (2012-07-07)
FEATURES:
- new export interface similar to the import API.
- Supported export formats: Collada, OBJ, PLY and STL
- added new import formats: XGL/ZGL, M3 (experimental)
- new postprocessing steps: Debone
- vastly improved IFC (Industry Foundation Classes) support
- introduced API to query importer meta information (such as supported
format versions, full name, maintainer info).
- reworked Ogre XML import
- C-API now supports per-import properties
FIXES/HOUSEKEEPING:
- hundreds of bugfixes in all parts of the library
- unified naming and cleanup of public headers
- improved CMake build system
- templatized math library
- reduce dependency on boost.thread, only remaining spot
is synchronization for the C logging API
API COMPATIBILITY:
- renamed headers, export interface, C API properties and meta data
prevent compatibility with code written for 2.0, but in
most cases these can be easily resolved
- Note: 3.0 is not binary compatible with 2.0
2.0 (2010-11-21)
FEATURES:
- Add support for static Blender (*.blend) scenes
- Add support for Q3BSP scenes
- Add a windows-based OpenGL sample featuring texturing & basic materials
- Add an experimental progress feedback interface.
- Vastly improved performance (up to 500%, depending on mesh size and
spatial structure) in some expensive postprocessing steps
- AssimpView now uses a reworked layout which leaves more space
to the scene hierarchy window
- Add C# bindings ('Assimp.NET')
- Keep BSD-licensed and otherwise free test files in separate
folders (./test/models and ./test/models-nonbsd).
FIXES:
- Many Collada bugfixes, improve fault tolerance
- Fix possible crashes in the Obj loader
- Improve the Ogre XML loader
- OpenGL-sample now works with MinGW
- Fix Importer::FindLoader failing on uppercase file extensions
- Fix flawed path handling when locating external files
- Limit the maximum number of vertices, faces, face indices and
weights that Assimp is able to handle. This is to avoid
crashes due to overflowing counters.
- Updated XCode project files
- Further CMAKE build improvements
API CHANGES:
- Add data structures for vertex-based animations (These are not
currently used, however ...)
- Some Assimp::Importer methods are const now.
1.1 (2010-04-17)
This is the list of relevant changes from the 1.0 (r412) release to 1.1 (r700).
FEATURES:
- Vastly improved Collada support
- Add MS3D (Milkshape 3D) support
- Add support for Ogre XML static meshes
- Add experimental COB (TrueSpace) support
- Automatic test suite to quickly locate regressions
- D bindings (`dAssimp`)
- Python 2.n bindings (`PyAssimp`)
- Add basic support for Unicode input files (utf8, utf16 and utf32)
- Add further utilities to the `assimp` tool (xml/binary dumps, quick file stats)
- Switch to a CMAKE-based build system including an install target for unix'es
- Automatic evaluation of subdivision surfaces for some formats.
- Add `Importer::ReadFileFromMemory` and the corresponding C-API `aiReadFileFromMemory`
- Expose further math utilities via the C-API (i.e. `aiMultiplyMatrix4`)
- Move noboost files away from the public include directory
- Many, many bugfixes and improvements in existing loaders and postprocessing steps
- Documentation improved and clarified in many places.
- Add a sample on using Assimp in conjunction with OpenGL
- Distribution/packaging: comfortable SDK installer for Windows
- Distribution/packaging: improved release packages for other architectures
CRITICAL FIXES:
- Resolve problems with clashing heap managers, STL ABIs and runtime libraries (win32)
- Fix automatic detection of file type if no file extension is given
- Improved exception safety and robustness, prevent leaking of exceptions through the C interface
- Fix possible heap corruption due to material properties pulled in incorrectly
- Avoid leaking in certain error scenarios
- Fix 64 bit compatibility problems in some loaders (i.e. MDL)
BREAKING API CHANGES:
- None -
MINOR API BEHAVIOUR CHANGES:
- Change quaternion orientation to suit to the more common convention (-w).
- aiString is utf8 now. Not yet consistent, however.

View File

@ -185,9 +185,9 @@ if (ASSIMP_COVERALLS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
endif()
INCLUDE (FindPkgConfig)
INCLUDE_DIRECTORIES( include )
INCLUDE (FindPkgMacros)
INCLUDE (PrecompiledHeader)
# If this is an in-source build (CMAKE_SOURCE_DIR == CMAKE_BINARY_DIR),
@ -255,9 +255,7 @@ ENDIF(NOT ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
# Search for unzip
IF (PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(UNZIP minizip)
ENDIF (PKG_CONFIG_FOUND)
use_pkgconfig(UNZIP minizip)
IF ( ASSIMP_NO_EXPORT )
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_EXPORT)

320
CREDITS
View File

@ -1,160 +1,160 @@
===============================================================
Open Asset Import Library (Assimp)
Developers and Contributors
===============================================================
The following is a non-exhaustive list of all constributors over the years.
If you think your name should be listed here, drop us a line and we'll add you.
- Alexander Gessler,
3DS-, BLEND-, ASE-, DXF-, HMP-, MDL-, MD2-, MD3-, MD5-, MDC-, NFF-, PLY-, STL-, RAW-, OFF-, MS3D-, Q3D- and LWO-Loader, Assimp-Viewer, assimp-cmd, -noboost, Website (Design).
- Thomas Schulze,
X-, Collada-, BVH-Loader, Postprocessing framework. Data structure & Interface design, documentation.
- Kim Kulling,
Obj-, Q3BSD-, OpenGEX-Loader, Logging system, CMake-build-environment, Linux-build, Website ( Admin ), Coverity ( Admin ), Glitter ( Admin ).
- R.Schmidt,
Linux build, eclipse support.
- Matthias Gubisch,
Assimp.net
Visual Studio 9 support, bugfixes.
- Mark Sibly
B3D-Loader, Assimp testing
- Jonathan Klein
Ogre Loader, VC2010 fixes and CMake fixes.
- Sebastian Hempel,
PyAssimp (first version)
Compile-Bugfixes for mingw, add environment for static library support in make.
- Jonathan Pokrass
Supplied a bugfix concerning the scaling in the md3 loader.
- Andrew Galante,
Submitted patches to make Assimp compile with GCC-4, a makefile and the xcode3 workspace.
- Andreas Nagel
First Assimp testing & verification under Windows Vista 64 Bit.
- Marius Schr<68>der
Allowed us to use many of his models for screenshots and testing.
- Christian Schubert
Supplied various XFiles for testing purposes.
- Tizian Wieland
Searched the web for hundreds of test models for internal use
- John Connors
Supplied patches for linux and SCons.
- T. R.
The GUY who performed some of the CSM mocaps.
- Andy Maloney
Contributed fixes for the documentation and the doxygen markup
- Zhao Lei
Contributed several bugfixes fixing memory leaks and improving float parsing
- sueastside
Updated PyAssimp to the latest Assimp data structures and provided a script to keep the Python binding up-to-date.
- Tobias Rittig
Collada testing with Cinema 4D
- Brad Grantham
Improvements in OpenGL-Sample.
- Robert Ramirez
Add group loading feature to Obj-Loader.
- Chris Maiwald
Many bugreports, improving Assimp's portability, regular testing & feedback.
- Stepan Hrbek
Bugreport and fix for a obj-materialloader crash.
- David Nadlinger
D bindings, CMake install support.
- Dario Accornero
Contributed several patches regarding Mac OS/XCode targets, bug reports.
- Martin Walser (Samhayne)
Contributed the 'SimpleTexturedOpenGl' sample.
- Matthias Fauconneau
Contributed a fix for the Q3-BSP loader.
- J<EFBFBD>rgen P. Tjern<72>
Contributed updated and improved xcode workspaces
- drparallax
Contributed the /samples/SimpleAssimpViewX sample
- Carsten Fuchs
Contributed a fix for the Normalize method in aiQuaternion.
- dbburgess
Contributes a Android-specific build issue: log the hardware architecture for ARM.
- alfiereinre7
Contributes a obj-fileparser fix: missing tokens in the obj-token list.
- Roman Kharitonov
Contributes a fix for the configure script environment.
- Ed Diana
Contributed AssimpDelphi (/port/AssimpDelphi).
- rdb
Contributes a bundle of fixes and improvements for the bsp-importer.
- Mick P
For contributing the De-bone postprocessing step and filing various bug reports.
- Rosen Diankov
Contributed patches to build assimp debian packages using cmake.
- Mark Page
Contributed a patch to fix the VertexTriangleAdjacency postprocessing step.
- IOhannes
Contributed the Debian build fixes ( architecture macro ).
- gellule
Several LWO and LWS fixes (pivoting).
- Marcel Metz
GCC/Linux fixes for the SimpleOpenGL sample.
- Brian Miller
Bugfix for a compiler fix for iOS on arm.
- S<EFBFBD>verin Lemaignan
Rewrite of PyAssimp, distutils and Python3 support
- albert-wang
Bugfixes for the collada parser
- Ya ping Jin
Bugfixes for uv-tanget calculation.
- Jonne Nauha
Ogre Binary format support
- Filip Wasil, Tieto Poland Sp. z o.o.
Android JNI asset extraction support
- Richard Steffen
Contributed ExportProperties interface
Contributed X File exporter
Contributed Step (stp) exporter
===============================================================
Open Asset Import Library (Assimp)
Developers and Contributors
===============================================================
The following is a non-exhaustive list of all constributors over the years.
If you think your name should be listed here, drop us a line and we'll add you.
- Alexander Gessler,
3DS-, BLEND-, ASE-, DXF-, HMP-, MDL-, MD2-, MD3-, MD5-, MDC-, NFF-, PLY-, STL-, RAW-, OFF-, MS3D-, Q3D- and LWO-Loader, Assimp-Viewer, assimp-cmd, -noboost, Website (Design).
- Thomas Schulze,
X-, Collada-, BVH-Loader, Postprocessing framework. Data structure & Interface design, documentation.
- Kim Kulling,
Obj-, Q3BSD-, OpenGEX-Loader, Logging system, CMake-build-environment, Linux-build, Website ( Admin ), Coverity ( Admin ), Glitter ( Admin ).
- R.Schmidt,
Linux build, eclipse support.
- Matthias Gubisch,
Assimp.net
Visual Studio 9 support, bugfixes.
- Mark Sibly
B3D-Loader, Assimp testing
- Jonathan Klein
Ogre Loader, VC2010 fixes and CMake fixes.
- Sebastian Hempel,
PyAssimp (first version)
Compile-Bugfixes for mingw, add environment for static library support in make.
- Jonathan Pokrass
Supplied a bugfix concerning the scaling in the md3 loader.
- Andrew Galante,
Submitted patches to make Assimp compile with GCC-4, a makefile and the xcode3 workspace.
- Andreas Nagel
First Assimp testing & verification under Windows Vista 64 Bit.
- Marius Schr<68>der
Allowed us to use many of his models for screenshots and testing.
- Christian Schubert
Supplied various XFiles for testing purposes.
- Tizian Wieland
Searched the web for hundreds of test models for internal use
- John Connors
Supplied patches for linux and SCons.
- T. R.
The GUY who performed some of the CSM mocaps.
- Andy Maloney
Contributed fixes for the documentation and the doxygen markup
- Zhao Lei
Contributed several bugfixes fixing memory leaks and improving float parsing
- sueastside
Updated PyAssimp to the latest Assimp data structures and provided a script to keep the Python binding up-to-date.
- Tobias Rittig
Collada testing with Cinema 4D
- Brad Grantham
Improvements in OpenGL-Sample.
- Robert Ramirez
Add group loading feature to Obj-Loader.
- Chris Maiwald
Many bugreports, improving Assimp's portability, regular testing & feedback.
- Stepan Hrbek
Bugreport and fix for a obj-materialloader crash.
- David Nadlinger
D bindings, CMake install support.
- Dario Accornero
Contributed several patches regarding Mac OS/XCode targets, bug reports.
- Martin Walser (Samhayne)
Contributed the 'SimpleTexturedOpenGl' sample.
- Matthias Fauconneau
Contributed a fix for the Q3-BSP loader.
- Jørgen P. Tjernø
Contributed updated and improved xcode workspaces
- drparallax
Contributed the /samples/SimpleAssimpViewX sample
- Carsten Fuchs
Contributed a fix for the Normalize method in aiQuaternion.
- dbburgess
Contributes a Android-specific build issue: log the hardware architecture for ARM.
- alfiereinre7
Contributes a obj-fileparser fix: missing tokens in the obj-token list.
- Roman Kharitonov
Contributes a fix for the configure script environment.
- Ed Diana
Contributed AssimpDelphi (/port/AssimpDelphi).
- rdb
Contributes a bundle of fixes and improvements for the bsp-importer.
- Mick P
For contributing the De-bone postprocessing step and filing various bug reports.
- Rosen Diankov
Contributed patches to build assimp debian packages using cmake.
- Mark Page
Contributed a patch to fix the VertexTriangleAdjacency postprocessing step.
- IOhannes
Contributed the Debian build fixes ( architecture macro ).
- gellule
Several LWO and LWS fixes (pivoting).
- Marcel Metz
GCC/Linux fixes for the SimpleOpenGL sample.
- Brian Miller
Bugfix for a compiler fix for iOS on arm.
- SĂ©verin Lemaignan
Rewrite of PyAssimp, distutils and Python3 support
- albert-wang
Bugfixes for the collada parser
- Ya ping Jin
Bugfixes for uv-tanget calculation.
- Jonne Nauha
Ogre Binary format support
- Filip Wasil, Tieto Poland Sp. z o.o.
Android JNI asset extraction support
- Richard Steffen
Contributed ExportProperties interface
Contributed X File exporter
Contributed Step (stp) exporter

156
LICENSE
View File

@ -1,78 +1,78 @@
Open Asset Import Library (assimp)
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************
AN EXCEPTION applies to all files in the ./test/models-nonbsd folder.
These are 3d models for testing purposes, from various free sources
on the internet. They are - unless otherwise stated - copyright of
their respective creators, which may impose additional requirements
on the use of their work. For any of these models, see
<model-name>.source.txt for more legal information. Contact us if you
are a copyright holder and believe that we credited you inproperly or
if you don't want your files to appear in the repository.
******************************************************************************
Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
http://code.google.com/p/poly2tri/
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Poly2Tri nor the names of its contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Open Asset Import Library (assimp)
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************
AN EXCEPTION applies to all files in the ./test/models-nonbsd folder.
These are 3d models for testing purposes, from various free sources
on the internet. They are - unless otherwise stated - copyright of
their respective creators, which may impose additional requirements
on the use of their work. For any of these models, see
<model-name>.source.txt for more legal information. Contact us if you
are a copyright holder and believe that we credited you inproperly or
if you don't want your files to appear in the repository.
******************************************************************************
Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
http://code.google.com/p/poly2tri/
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Poly2Tri nor the names of its contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

289
Readme.md
View File

@ -1,142 +1,147 @@
Open Asset Import Library (assimp)
==================================
[![Linux Build Status](https://travis-ci.org/assimp/assimp.png)](https://travis-ci.org/assimp/assimp)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp)
<a href="https://scan.coverity.com/projects/5607">
<img alt="Coverity Scan Build Status"
src="https://scan.coverity.com/projects/5607/badge.svg"/>
</a>
[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
<br>
APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS.
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.
The current build status is:
Gitter chat: [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br>
__[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.__
Please check our Wiki as well: https://github.com/assimp/assimp/wiki
#### Supported file formats ####
A full list [is here](http://assimp.org/main_features_formats.html).
__Importers__:
- 3DS
- BLEND (Blender)
- DAE/Collada
- FBX
- IFC-STEP
- ASE
- DXF
- HMP
- MD2
- MD3
- MD5
- MDC
- MDL
- NFF
- PLY
- STL
- X
- OBJ
- OpenGEX
- SMD
- LWO
- LXO
- LWS
- TER
- AC3D
- MS3D
- COB
- Q3BSP
- XGL
- CSM
- BVH
- B3D
- NDO
- Ogre Binary
- Ogre XML
- Q3D
- ASSBIN (Assimp custom format)
- glTF (partial)
- 3MF
Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default):
- C4D (https://github.com/acgessler/assimp-cinema4d)
__Exporters__:
- DAE (Collada)
- STL
- OBJ
- PLY
- X
- 3DS
- JSON (for WebGl, via https://github.com/acgessler/assimp2json)
- ASSBIN
- STEP
- glTF (partial)
### Building ###
Take a look into the `INSTALL` file. Our build system is CMake, if you used CMake before there is a good chance you know what to do.
### Ports ###
* [Android](port/AndroidJNI/README.md)
* [Python](port/PyAssimp/README.md)
* [.NET](port/AssimpNET/Readme.md)
* [Pascal](port/AssimpPascal/Readme.md)
#### Repository structure ####
Open Asset Import Library is implemented in C++. The directory structure is:
/code Source code
/contrib Third-party libraries
/doc Documentation (doxysource and pre-compiled docs)
/include Public header C and C++ header files
/scripts Scripts used to generate the loading code for some formats
/port Ports to other languages and scripts to maintain those.
/test Unit- and regression tests, test suite of models
/tools Tools (old assimp viewer, command line `assimp`)
/samples A small number of samples to illustrate possible
use cases for Assimp
/workspaces Build environments for vc,xcode,... (deprecated,
CMake has superseeded all legacy build options!)
### Where to get help ###
For more information, visit [our website](http://assimp.org/). Or check out the `./doc`- folder, which contains the official documentation in HTML format.
(CHMs for Windows are included in some release packages and should be located right here in the root folder).
If the docs don't solve your problem, ask on [StackOverflow](http://stackoverflow.com/questions/tagged/assimp?sort=newest). If you think you found a bug, please open an issue on Github.
For development discussions, there is also a (very low-volume) mailing list, _assimp-discussions_
[(subscribe here)]( https://lists.sourceforge.net/lists/listinfo/assimp-discussions)
Open Asset Import Library is a library to load various 3d file formats into a shared, in-memory format. It supports more than __40 file formats__ for import and a growing selection of file formats for export.
And we also have a Gitter-channel:Gitter [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br>
### Contributing ###
Contributions to assimp are highly appreciated. The easiest way to get involved is to submit
a pull request with your changes against the main repository's `master` branch.
### Donate ###
If you like assimp, consider buying us a beer (or two):
[Donate](http://sourceforge.net/donate/index.php?group_id=226462)
### License ###
Our license is based on the modified, __3-clause BSD__-License.
An _informal_ summary is: do whatever you want, but include Assimp's license text with your product -
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.
### Why this name ###
Sorry, we're germans :-), no english native speakers ...
Open Asset Import Library (assimp)
==================================
[![Linux Build Status](https://travis-ci.org/assimp/assimp.svg)](https://travis-ci.org/assimp/assimp)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp)
<a href="https://scan.coverity.com/projects/5607">
<img alt="Coverity Scan Build Status"
src="https://scan.coverity.com/projects/5607/badge.svg"/>
</a>
[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
<br>
APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS.
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.
The current build status is:
Gitter chat: [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br>
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
<br>
__[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.__
Please check our Wiki as well: https://github.com/assimp/assimp/wiki
#### Supported file formats ####
A full list [is here](http://assimp.org/main_features_formats.html).
__Importers__:
- 3DS
- BLEND (Blender)
- DAE/Collada
- FBX
- IFC-STEP
- ASE
- DXF
- HMP
- MD2
- MD3
- MD5
- MDC
- MDL
- NFF
- PLY
- STL
- X
- OBJ
- OpenGEX
- SMD
- LWO
- LXO
- LWS
- TER
- AC3D
- MS3D
- COB
- Q3BSP
- XGL
- CSM
- BVH
- B3D
- NDO
- Ogre Binary
- Ogre XML
- Q3D
- ASSBIN (Assimp custom format)
- glTF (partial)
- 3MF
Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default):
- C4D (https://github.com/acgessler/assimp-cinema4d)
__Exporters__:
- DAE (Collada)
- STL
- OBJ
- PLY
- X
- 3DS
- JSON (for WebGl, via https://github.com/acgessler/assimp2json)
- ASSBIN
- STEP
- glTF (partial)
### Building ###
Take a look into the `INSTALL` file. Our build system is CMake, if you used CMake before there is a good chance you know what to do.
### Ports ###
* [Android](port/AndroidJNI/README.md)
* [Python](port/PyAssimp/README.md)
* [.NET](port/AssimpNET/Readme.md)
* [Pascal](port/AssimpPascal/Readme.md)
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
#### Repository structure ####
Open Asset Import Library is implemented in C++. The directory structure is:
/code Source code
/contrib Third-party libraries
/doc Documentation (doxysource and pre-compiled docs)
/include Public header C and C++ header files
/scripts Scripts used to generate the loading code for some formats
/port Ports to other languages and scripts to maintain those.
/test Unit- and regression tests, test suite of models
/tools Tools (old assimp viewer, command line `assimp`)
/samples A small number of samples to illustrate possible
use cases for Assimp
/workspaces Build environments for vc,xcode,... (deprecated,
CMake has superseeded all legacy build options!)
### Where to get help ###
For more information, visit [our website](http://assimp.org/). Or check out the `./doc`- folder, which contains the official documentation in HTML format.
(CHMs for Windows are included in some release packages and should be located right here in the root folder).
If the docs don't solve your problem, ask on [StackOverflow](http://stackoverflow.com/questions/tagged/assimp?sort=newest). If you think you found a bug, please open an issue on Github.
For development discussions, there is also a (very low-volume) mailing list, _assimp-discussions_
[(subscribe here)]( https://lists.sourceforge.net/lists/listinfo/assimp-discussions)
Open Asset Import Library is a library to load various 3d file formats into a shared, in-memory format. It supports more than __40 file formats__ for import and a growing selection of file formats for export.
And we also have a Gitter-channel:Gitter [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br>
### Contributing ###
Contributions to assimp are highly appreciated. The easiest way to get involved is to submit
a pull request with your changes against the main repository's `master` branch.
### Donate ###
If you like assimp, consider buying us a beer (or two):
[Donate](http://sourceforge.net/donate/index.php?group_id=226462)
### License ###
Our license is based on the modified, __3-clause BSD__-License.
An _informal_ summary is: do whatever you want, but include Assimp's license text with your product -
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.
### Why this name ###
Sorry, we're germans :-), no english native speakers ...

View File

@ -59,10 +59,13 @@ endmacro(clear_if_changed)
# Try to get some hints from pkg-config, if available
macro(use_pkgconfig PREFIX PKGNAME)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif ()
# Android does not support PKG_CONFIG so we disable it
IF ( NOT ANDROID )
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif ()
ENDIF ( NOT ANDROID )
endmacro (use_pkgconfig)
# Couple a set of release AND debug libraries (or frameworks)

View File

@ -11,7 +11,7 @@
# Once done, this will define
#
# ZLIB_FOUND - system has ZLIB
# ZLIB_INCLUDE_DIRS - the ZLIB include directories
# ZLIB_INCLUDE_DIRS - the ZLIB include directories
# ZLIB_LIBRARIES - link these to use ZLIB
include(FindPkgMacros)

View File

@ -261,11 +261,20 @@ std::string TextureConverted_ID;
size_t off_b = 0;
// Calculate size of the target array and rule how data will be copied.
if(!pID_R.empty()) { tex_size += src_texture[0]->Data.size(); step++, off_g++, off_b++; }
if(!pID_G.empty()) { tex_size += src_texture[1]->Data.size(); step++, off_b++; }
if(!pID_B.empty()) { tex_size += src_texture[2]->Data.size(); step++; }
if(!pID_A.empty()) { tex_size += src_texture[3]->Data.size(); step++; }
if ( nullptr != src_texture ) {
if(!pID_R.empty()) {
tex_size += src_texture[0]->Data.size(); step++, off_g++, off_b++;
}
if(!pID_G.empty()) {
tex_size += src_texture[1]->Data.size(); step++, off_b++;
}
if(!pID_B.empty()) {
tex_size += src_texture[2]->Data.size(); step++;
}
if(!pID_A.empty()) {
tex_size += src_texture[3]->Data.size(); step++;
}
}
// Create target array.
converted_texture.Data = new uint8_t[tex_size];
// And copy data

View File

@ -1858,7 +1858,7 @@ void Parser::ParseLV3MeshCFaceListBlock(unsigned int iNumFaces, ASE::Mesh& mesh)
++filePtr;
// Face entry
if (TokenMatch(filePtr,"MESH_CFACE" ,11))
if (TokenMatch(filePtr,"MESH_CFACE" ,10))
{
unsigned int aiValues[3];
unsigned int iIndex = 0;

View File

@ -96,8 +96,9 @@ static const aiImporterDesc blenderDesc = {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
BlenderImporter::BlenderImporter()
: modifier_cache(new BlenderModifierShowcase())
{}
: modifier_cache(new BlenderModifierShowcase()) {
// empty
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
@ -145,8 +146,7 @@ void BlenderImporter::SetupProperties(const Importer* /*pImp*/)
// nothing to be done for the moment
}
struct free_it
{
struct free_it {
free_it(void* free) : free(free) {}
~free_it() {
::free(this->free);
@ -165,6 +165,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
free_it free_it_really(dest);
#endif
FileDatabase file;
std::shared_ptr<IOStream> stream(pIOHandler->Open(pFile,"rb"));
if (!stream) {

View File

@ -522,7 +522,7 @@ template <> void Structure :: Convert<MVert> (
ReadFieldArray<ErrorPolicy_Fail>(dest.co,"co",db);
ReadFieldArray<ErrorPolicy_Fail>(dest.no,"no",db);
ReadField<ErrorPolicy_Igno>(dest.flag,"flag",db);
ReadField<ErrorPolicy_Warn>(dest.mat_nr,"mat_nr",db);
//ReadField<ErrorPolicy_Warn>(dest.mat_nr,"mat_nr",db);
ReadField<ErrorPolicy_Igno>(dest.bweight,"bweight",db);
db.reader->IncPtr(size);

View File

@ -163,6 +163,7 @@ SET( Common_SRCS
RemoveComments.h
Subdivision.cpp
Subdivision.h
scene.cpp
Vertex.h
LineSplitter.h
TinyFormatter.h
@ -173,6 +174,8 @@ SET( Common_SRCS
XMLTools.h
Version.cpp
IOStreamBuffer.h
CreateAnimMesh.h
CreateAnimMesh.cpp
)
SOURCE_GROUP(Common FILES ${Common_SRCS})
@ -184,10 +187,16 @@ IF ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER )
SOURCE_GROUP( C4D FILES ${C4D_SRCS})
ENDIF ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER )
# if this variable is set to TRUE, the user can manually disable importers by setting
# ASSIMP_BUILD_XXX_IMPORTER to FALSE for each importer
# if this variable is set to FALSE, the user can manually enable importers by setting
# ASSIMP_BUILD_XXX_IMPORTER to TRUE for each importer
OPTION(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_IMPORTER value" TRUE)
# macro to add the CMake Option ADD_ASSIMP_IMPORTER_<name> which enables compile of loader
# this way selective loaders can be compiled (reduces filesize + compile time)
MACRO(ADD_ASSIMP_IMPORTER name)
OPTION(ASSIMP_BUILD_${name}_IMPORTER "build the ${name} importer" TRUE)
OPTION(ASSIMP_BUILD_${name}_IMPORTER "build the ${name} importer" ${ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT})
IF(ASSIMP_BUILD_${name}_IMPORTER)
LIST(APPEND ASSIMP_LOADER_SRCS ${ARGN})
SET(ASSIMP_IMPORTERS_ENABLED "${ASSIMP_IMPORTERS_ENABLED} ${name}")

View File

@ -652,7 +652,7 @@ void ColladaExporter::WriteMaterials()
if( materialCountWithThisName == 0 ) {
materials[a].name = name.C_Str();
} else {
materials[a].name = std::string(name.C_Str()) + to_string(materialCountWithThisName);
materials[a].name = std::string(name.C_Str()) + to_string(materialCountWithThisName);
}
}
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) {
@ -809,8 +809,8 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
const std::string idstr = GetMeshId( pIndex);
const std::string idstrEscaped = XMLEscape(idstr);
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
return;
if ( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
return;
// opening tag
mOutput << startstr << "<geometry id=\"" << idstrEscaped << "\" name=\"" << idstrEscaped << "_name\" >" << endstr;
@ -843,22 +843,10 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
}
// assemble vertex structure
// Only write input for POSITION since we will write other as shared inputs in polygon definition
mOutput << startstr << "<vertices id=\"" << idstrEscaped << "-vertices" << "\">" << endstr;
PushTag();
mOutput << startstr << "<input semantic=\"POSITION\" source=\"#" << idstrEscaped << "-positions\" />" << endstr;
if( mesh->HasNormals() )
mOutput << startstr << "<input semantic=\"NORMAL\" source=\"#" << idstrEscaped << "-normals\" />" << endstr;
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
{
if( mesh->HasTextureCoords(static_cast<unsigned int>(a)) )
mOutput << startstr << "<input semantic=\"TEXCOORD\" source=\"#" << idstrEscaped << "-tex" << a << "\" " /*<< "set=\"" << a << "\"" */ << " />" << endstr;
}
for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
{
if( mesh->HasVertexColors(static_cast<unsigned int>(a) ) )
mOutput << startstr << "<input semantic=\"COLOR\" source=\"#" << idstrEscaped << "-color" << a << "\" " /*<< set=\"" << a << "\"" */ << " />" << endstr;
}
PopTag();
mOutput << startstr << "</vertices>" << endstr;
@ -877,6 +865,19 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
mOutput << startstr << "<lines count=\"" << countLines << "\" material=\"defaultMaterial\">" << endstr;
PushTag();
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstrEscaped << "-vertices\" />" << endstr;
if( mesh->HasNormals() )
mOutput << startstr << "<input semantic=\"NORMAL\" source=\"#" << idstrEscaped << "-normals\" />" << endstr;
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
{
if( mesh->HasTextureCoords(static_cast<unsigned int>(a)) )
mOutput << startstr << "<input semantic=\"TEXCOORD\" source=\"#" << idstrEscaped << "-tex" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
}
for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
{
if( mesh->HasVertexColors(static_cast<unsigned int>(a) ) )
mOutput << startstr << "<input semantic=\"COLOR\" source=\"#" << idstrEscaped << "-color" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
}
mOutput << startstr << "<p>";
for( size_t a = 0; a < mesh->mNumFaces; ++a )
{
@ -898,10 +899,17 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
mOutput << startstr << "<polylist count=\"" << countPoly << "\" material=\"defaultMaterial\">" << endstr;
PushTag();
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstrEscaped << "-vertices\" />" << endstr;
if( mesh->HasNormals() )
mOutput << startstr << "<input offset=\"0\" semantic=\"NORMAL\" source=\"#" << idstrEscaped << "-normals\" />" << endstr;
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
{
if( mesh->HasTextureCoords(static_cast<unsigned int>(a) ) )
mOutput << startstr << "<input offset=\"0\" semantic=\"TEXCOORD\" source=\"#" << idstrEscaped << "-tex" << a << "\" set=\"" << a << "\" />" << endstr;
if( mesh->HasTextureCoords(static_cast<unsigned int>(a)) )
mOutput << startstr << "<input offset=\"0\" semantic=\"TEXCOORD\" source=\"#" << idstrEscaped << "-tex" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
}
for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
{
if( mesh->HasVertexColors(static_cast<unsigned int>(a) ) )
mOutput << startstr << "<input offset=\"0\" semantic=\"COLOR\" source=\"#" << idstrEscaped << "-color" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
}
mOutput << startstr << "<vcount>";

View File

@ -89,6 +89,21 @@ enum InputType
IT_Bitangent
};
/** Supported controller types */
enum ControllerType
{
Skin,
Morph
};
/** Supported morph methods */
enum MorphMethod
{
Normalized,
Relative
};
/** Contains all data for one of the different transformation types */
struct Transform
{
@ -380,6 +395,12 @@ enum PrimitiveType
/** A skeleton controller to deform a mesh with the use of joints */
struct Controller
{
// controller type
ControllerType mType;
// Morphing method if type is Morph
MorphMethod mMethod;
// the URL of the mesh deformed by the controller.
std::string mMeshId;
@ -402,6 +423,9 @@ struct Controller
// JointIndex-WeightIndex pairs for all vertices
std::vector< std::pair<size_t, size_t> > mWeights;
std::string mMorphTarget;
std::string mMorphWeight;
};
/** A collada material. Pretty much the only member is a reference to an effect. */
@ -577,6 +601,12 @@ struct AnimationChannel
std::string mSourceTimes;
/** Source URL of the value values. Collada calls them "output". */
std::string mSourceValues;
/** Source URL of the IN_TANGENT semantic values. */
std::string mInTanValues;
/** Source URL of the OUT_TANGENT semantic values. */
std::string mOutTanValues;
/** Source URL of the INTERPOLATION semantic values. */
std::string mInterpolationValues;
};
/** An animation. Container for 0-x animation channels or 0-x animations */
@ -645,6 +675,7 @@ struct Animation
struct ChannelEntry
{
const Collada::AnimationChannel* mChannel; ///> the source channel
std::string mTargetId;
std::string mTransformId; // the ID of the transformation step of the node which is influenced
size_t mTransformIndex; // Index into the node's transform chain to apply the channel to
size_t mSubElement; // starting index inside the transform data

View File

@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ParsingUtils.h"
#include "SkeletonMeshBuilder.h"
#include "Defines.h"
#include "CreateAnimMesh.h"
#include "time.h"
#include "math.h"
@ -150,6 +151,7 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
mMeshIndexByID.clear();
mMaterialIndexByName.clear();
mMeshes.clear();
mTargetMeshes.clear();
newMats.clear();
mLights.clear();
mCameras.clear();
@ -571,6 +573,21 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
}
}
// ------------------------------------------------------------------------------------------------
// Find mesh from either meshes or morph target meshes
aiMesh *ColladaLoader::findMesh(std::string meshid)
{
for (unsigned int i = 0; i < mMeshes.size(); i++)
if (std::string(mMeshes[i]->mName.data) == meshid)
return mMeshes[i];
for (unsigned int i = 0; i < mTargetMeshes.size(); i++)
if (std::string(mTargetMeshes[i]->mName.data) == meshid)
return mTargetMeshes[i];
return NULL;
}
// ------------------------------------------------------------------------------------------------
// Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh
aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::Mesh* pSrcMesh, const Collada::SubMesh& pSubMesh,
@ -656,8 +673,70 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
face.mIndices[b] = static_cast<unsigned int>(vertex++);
}
// create morph target meshes if any
std::vector<aiMesh*> targetMeshes;
std::vector<float> targetWeights;
Collada::MorphMethod method;
for(std::map<std::string, Collada::Controller>::const_iterator it = pParser.mControllerLibrary.begin();
it != pParser.mControllerLibrary.end(); it++)
{
const Collada::Controller &c = it->second;
const Collada::Mesh* baseMesh = pParser.ResolveLibraryReference( pParser.mMeshLibrary, c.mMeshId);
if (c.mType == Collada::Morph && baseMesh->mName == pSrcMesh->mName)
{
const Collada::Accessor& targetAccessor = pParser.ResolveLibraryReference( pParser.mAccessorLibrary, c.mMorphTarget);
const Collada::Accessor& weightAccessor = pParser.ResolveLibraryReference( pParser.mAccessorLibrary, c.mMorphWeight);
const Collada::Data& targetData = pParser.ResolveLibraryReference( pParser.mDataLibrary, targetAccessor.mSource);
const Collada::Data& weightData = pParser.ResolveLibraryReference( pParser.mDataLibrary, weightAccessor.mSource);
// take method
method = c.mMethod;
if (!targetData.mIsStringArray)
throw DeadlyImportError( "target data must contain id. ");
if (weightData.mIsStringArray)
throw DeadlyImportError( "target weight data must not be textual ");
for (unsigned int i = 0; i < targetData.mStrings.size(); ++i)
{
const Collada::Mesh* targetMesh = pParser.ResolveLibraryReference(pParser.mMeshLibrary, targetData.mStrings.at(i));
aiMesh *aimesh = findMesh(targetMesh->mName);
if (!aimesh)
{
if (targetMesh->mSubMeshes.size() > 1)
throw DeadlyImportError( "Morhing target mesh must be a single");
aimesh = CreateMesh(pParser, targetMesh, targetMesh->mSubMeshes.at(0), NULL, 0, 0);
mTargetMeshes.push_back(aimesh);
}
targetMeshes.push_back(aimesh);
}
for (unsigned int i = 0; i < weightData.mValues.size(); ++i)
targetWeights.push_back(weightData.mValues.at(i));
}
}
if (targetMeshes.size() > 0 && targetWeights.size() == targetMeshes.size())
{
std::vector<aiAnimMesh*> animMeshes;
for (unsigned int i = 0; i < targetMeshes.size(); i++)
{
aiAnimMesh *animMesh = aiCreateAnimMesh(targetMeshes.at(i));
animMesh->mWeight = targetWeights[i];
animMeshes.push_back(animMesh);
}
dstMesh->mMethod = (method == Collada::Relative)
? aiMorphingMethod_MORPH_RELATIVE
: aiMorphingMethod_MORPH_NORMALIZED;
dstMesh->mAnimMeshes = new aiAnimMesh*[animMeshes.size()];
dstMesh->mNumAnimMeshes = animMeshes.size();
for (unsigned int i = 0; i < animMeshes.size(); i++)
dstMesh->mAnimMeshes[i] = animMeshes.at(i);
}
// create bones if given
if( pSrcController)
if( pSrcController && pSrcController->mType == Collada::Skin)
{
// refuse if the vertex count does not match
// if( pSrcController->mWeightCounts.size() != dstMesh->mNumVertices)
@ -956,6 +1035,68 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
CreateAnimation( pScene, pParser, pSrcAnim, animName);
}
struct MorphTimeValues
{
float mTime;
struct key
{
float mWeight;
unsigned int mValue;
};
std::vector<key> mKeys;
};
void insertMorphTimeValue(std::vector<MorphTimeValues> &values, float time, float weight, unsigned int value)
{
MorphTimeValues::key k;
k.mValue = value;
k.mWeight = weight;
if (values.size() == 0 || time < values[0].mTime)
{
MorphTimeValues val;
val.mTime = time;
val.mKeys.push_back(k);
values.insert(values.begin(), val);
return;
}
if (time > values.back().mTime)
{
MorphTimeValues val;
val.mTime = time;
val.mKeys.push_back(k);
values.insert(values.end(), val);
return;
}
for (unsigned int i = 0; i < values.size(); i++)
{
if (std::abs(time - values[i].mTime) < 1e-6f)
{
values[i].mKeys.push_back(k);
return;
} else if (time > values[i].mTime && time < values[i+1].mTime)
{
MorphTimeValues val;
val.mTime = time;
val.mKeys.push_back(k);
values.insert(values.begin() + i, val);
return;
}
}
// should not get here
}
float getWeightAtKey(const std::vector<MorphTimeValues> &values, int key, unsigned int value)
{
for (unsigned int i = 0; i < values[key].mKeys.size(); i++)
{
if (values[key].mKeys[i].mValue == value)
return values[key].mKeys[i].mWeight;
}
// no value at key found, try to interpolate if present at other keys. if not, return zero
// TODO: interpolation
return 0.0f;
}
// ------------------------------------------------------------------------------------------------
// Constructs the animation for the given source anim
void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName)
@ -965,6 +1106,8 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
CollectNodes( pScene->mRootNode, nodes);
std::vector<aiNodeAnim*> anims;
std::vector<aiMeshMorphAnim*> morphAnims;
for( std::vector<const aiNode*>::const_iterator nit = nodes.begin(); nit != nodes.end(); ++nit)
{
// find all the collada anim channels which refer to the current node
@ -988,7 +1131,20 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
// find the slash that separates the node name - there should be only one
std::string::size_type slashPos = srcChannel.mTarget.find( '/');
if( slashPos == std::string::npos)
{
std::string::size_type targetPos = srcChannel.mTarget.find(srcNode->mID);
if (targetPos == std::string::npos)
continue;
// not node transform, but something else. store as unknown animation channel for now
entry.mChannel = &(*cit);
entry.mTargetId = srcChannel.mTarget.substr(targetPos + pSrcAnim->mName.length(),
srcChannel.mTarget.length() - targetPos - pSrcAnim->mName.length());
if (entry.mTargetId.front() == '-')
entry.mTargetId = entry.mTargetId.substr(1);
entries.push_back(entry);
continue;
}
if( srcChannel.mTarget.find( '/', slashPos+1) != std::string::npos)
continue;
std::string targetID = srcChannel.mTarget.substr( 0, slashPos);
@ -1068,8 +1224,14 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
if( srcNode->mTransforms[a].mID == entry.mTransformId)
entry.mTransformIndex = a;
if( entry.mTransformIndex == SIZE_MAX) {
continue;
if( entry.mTransformIndex == SIZE_MAX)
{
if (entry.mTransformId.find("morph-weights") != std::string::npos)
{
entry.mTargetId = entry.mTransformId;
entry.mTransformId = "";
} else
continue;
}
entry.mChannel = &(*cit);
@ -1213,49 +1375,125 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
// ai_assert( resultTrafos.size() > 0);
// build an animation channel for the given node out of these trafo keys
if( !resultTrafos.empty() )
{
aiNodeAnim* dstAnim = new aiNodeAnim;
dstAnim->mNodeName = nodeName;
dstAnim->mNumPositionKeys = static_cast<unsigned int>(resultTrafos.size());
dstAnim->mNumRotationKeys= static_cast<unsigned int>(resultTrafos.size());
dstAnim->mNumScalingKeys = static_cast<unsigned int>(resultTrafos.size());
dstAnim->mPositionKeys = new aiVectorKey[resultTrafos.size()];
dstAnim->mRotationKeys = new aiQuatKey[resultTrafos.size()];
dstAnim->mScalingKeys = new aiVectorKey[resultTrafos.size()];
if( !resultTrafos.empty() )
{
aiNodeAnim* dstAnim = new aiNodeAnim;
dstAnim->mNodeName = nodeName;
dstAnim->mNumPositionKeys = resultTrafos.size();
dstAnim->mNumRotationKeys= resultTrafos.size();
dstAnim->mNumScalingKeys = resultTrafos.size();
dstAnim->mPositionKeys = new aiVectorKey[resultTrafos.size()];
dstAnim->mRotationKeys = new aiQuatKey[resultTrafos.size()];
dstAnim->mScalingKeys = new aiVectorKey[resultTrafos.size()];
for( size_t a = 0; a < resultTrafos.size(); ++a)
{
aiMatrix4x4 mat = resultTrafos[a];
double time = double( mat.d4); // remember? time is stored in mat.d4
mat.d4 = 1.0f;
for( size_t a = 0; a < resultTrafos.size(); ++a)
{
aiMatrix4x4 mat = resultTrafos[a];
double time = double( mat.d4); // remember? time is stored in mat.d4
mat.d4 = 1.0f;
dstAnim->mPositionKeys[a].mTime = time;
dstAnim->mRotationKeys[a].mTime = time;
dstAnim->mScalingKeys[a].mTime = time;
mat.Decompose( dstAnim->mScalingKeys[a].mValue, dstAnim->mRotationKeys[a].mValue, dstAnim->mPositionKeys[a].mValue);
}
dstAnim->mPositionKeys[a].mTime = time;
dstAnim->mRotationKeys[a].mTime = time;
dstAnim->mScalingKeys[a].mTime = time;
mat.Decompose( dstAnim->mScalingKeys[a].mValue, dstAnim->mRotationKeys[a].mValue, dstAnim->mPositionKeys[a].mValue);
}
anims.push_back( dstAnim);
} else
{
DefaultLogger::get()->warn( "Collada loader: found empty animation channel, ignored. Please check your exporter.");
}
anims.push_back( dstAnim);
} else
{
DefaultLogger::get()->warn( "Collada loader: found empty animation channel, ignored. Please check your exporter.");
}
if( !entries.empty() && entries.front().mTimeAccessor->mCount > 0 )
{
std::vector<Collada::ChannelEntry> morphChannels;
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
{
Collada::ChannelEntry& e = *it;
// skip non-transform types
if (e.mTargetId.empty())
continue;
if (e.mTargetId.find("morph-weights") != std::string::npos)
morphChannels.push_back(e);
}
if (morphChannels.size() > 0)
{
// either 1) morph weight animation count should contain morph target count channels
// or 2) one channel with morph target count arrays
// assume first
aiMeshMorphAnim *morphAnim = new aiMeshMorphAnim;
morphAnim->mName.Set(nodeName);
std::vector<MorphTimeValues> morphTimeValues;
int morphAnimChannelIndex = 0;
for( std::vector<Collada::ChannelEntry>::iterator it = morphChannels.begin(); it != morphChannels.end(); ++it)
{
Collada::ChannelEntry& e = *it;
std::string::size_type apos = e.mTargetId.find('(');
std::string::size_type bpos = e.mTargetId.find(')');
if (apos == std::string::npos || bpos == std::string::npos)
// unknown way to specify weight -> ignore this animation
continue;
// weight target can be in format Weight_M_N, Weight_N, WeightN, or some other way
// we ignore the name and just assume the channels are in the right order
for (unsigned int i = 0; i < e.mTimeData->mValues.size(); i++)
insertMorphTimeValue(morphTimeValues, e.mTimeData->mValues.at(i), e.mValueData->mValues.at(i), morphAnimChannelIndex);
++morphAnimChannelIndex;
}
morphAnim->mNumKeys = morphTimeValues.size();
morphAnim->mKeys = new aiMeshMorphKey[morphAnim->mNumKeys];
for (unsigned int key = 0; key < morphAnim->mNumKeys; key++)
{
morphAnim->mKeys[key].mNumValuesAndWeights = morphChannels.size();
morphAnim->mKeys[key].mValues = new unsigned int [morphChannels.size()];
morphAnim->mKeys[key].mWeights = new double [morphChannels.size()];
morphAnim->mKeys[key].mTime = morphTimeValues[key].mTime;
for (unsigned int valueIndex = 0; valueIndex < morphChannels.size(); valueIndex++)
{
morphAnim->mKeys[key].mValues[valueIndex] = valueIndex;
morphAnim->mKeys[key].mWeights[valueIndex] = getWeightAtKey(morphTimeValues, key, valueIndex);
}
}
morphAnims.push_back(morphAnim);
}
}
}
if( !anims.empty())
if( !anims.empty() || !morphAnims.empty())
{
aiAnimation* anim = new aiAnimation;
anim->mName.Set( pName);
anim->mNumChannels = static_cast<unsigned int>(anims.size());
anim->mChannels = new aiNodeAnim*[anims.size()];
std::copy( anims.begin(), anims.end(), anim->mChannels);
anim->mNumChannels = anims.size();
if (anim->mNumChannels > 0)
{
anim->mChannels = new aiNodeAnim*[anims.size()];
std::copy( anims.begin(), anims.end(), anim->mChannels);
}
anim->mNumMorphMeshChannels = morphAnims.size();
if (anim->mNumMorphMeshChannels > 0)
{
anim->mMorphMeshChannels = new aiMeshMorphAnim*[anim->mNumMorphMeshChannels];
std::copy( morphAnims.begin(), morphAnims.end(), anim->mMorphMeshChannels);
}
anim->mDuration = 0.0f;
for( size_t a = 0; a < anims.size(); ++a)
{
anim->mDuration = std::max( anim->mDuration, anims[a]->mPositionKeys[anims[a]->mNumPositionKeys-1].mTime);
anim->mDuration = std::max( anim->mDuration, anims[a]->mRotationKeys[anims[a]->mNumRotationKeys-1].mTime);
anim->mDuration = std::max( anim->mDuration, anims[a]->mScalingKeys[anims[a]->mNumScalingKeys-1].mTime);
anim->mDuration = std::max( anim->mDuration, anims[a]->mPositionKeys[anims[a]->mNumPositionKeys-1].mTime);
anim->mDuration = std::max( anim->mDuration, anims[a]->mRotationKeys[anims[a]->mNumRotationKeys-1].mTime);
anim->mDuration = std::max( anim->mDuration, anims[a]->mScalingKeys[anims[a]->mNumScalingKeys-1].mTime);
}
for (size_t a = 0; a < morphAnims.size(); ++a)
{
anim->mDuration = std::max(anim->mDuration, morphAnims[a]->mKeys[morphAnims[a]->mNumKeys-1].mTime);
}
anim->mTicksPerSecond = 1;
mAnims.push_back( anim);

View File

@ -117,6 +117,8 @@ protected:
/** Builds meshes for the given node and references them */
void BuildMeshesForNode( const ColladaParser& pParser, const Collada::Node* pNode,
aiNode* pTarget);
aiMesh *findMesh(std::string meshid);
/** Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh */
aiMesh* CreateMesh( const ColladaParser& pParser, const Collada::Mesh* pSrcMesh, const Collada::SubMesh& pSubMesh,
@ -223,6 +225,9 @@ protected:
/** Accumulated meshes for the target scene */
std::vector<aiMesh*> mMeshes;
/** Accumulated morph target meshes */
std::vector<aiMesh*> mTargetMeshes;
/** Temporary material list */
std::vector<std::pair<Collada::Effect*, aiMaterial*> > newMats;

View File

@ -585,6 +585,12 @@ void ColladaParser::ReadAnimationSampler( Collada::AnimationChannel& pChannel)
pChannel.mSourceTimes = source;
else if( strcmp( semantic, "OUTPUT") == 0)
pChannel.mSourceValues = source;
else if( strcmp( semantic, "IN_TANGENT") == 0)
pChannel.mInTanValues = source;
else if( strcmp( semantic, "OUT_TANGENT") == 0)
pChannel.mOutTanValues = source;
else if( strcmp( semantic, "INTERPOLATION") == 0)
pChannel.mInterpolationValues = source;
if( !mReader->isEmptyElement())
SkipElement();
@ -647,6 +653,9 @@ void ColladaParser::ReadControllerLibrary()
// Reads a controller into the given mesh structure
void ColladaParser::ReadController( Collada::Controller& pController)
{
// initial values
pController.mType = Skin;
pController.mMethod = Normalized;
while( mReader->read())
{
if( mReader->getNodeType() == irr::io::EXN_ELEMENT)
@ -654,8 +663,15 @@ void ColladaParser::ReadController( Collada::Controller& pController)
// two types of controllers: "skin" and "morph". Only the first one is relevant, we skip the other
if( IsElement( "morph"))
{
// should skip everything inside, so there's no danger of catching elements in between
SkipElement();
pController.mType = Morph;
int baseIndex = GetAttribute("source");
pController.mMeshId = mReader->getAttributeValue(baseIndex) + 1;
int methodIndex = GetAttribute("method");
if (methodIndex > 0) {
const char *method = mReader->getAttributeValue(methodIndex);
if (strcmp(method, "RELATIVE") == 0)
pController.mMethod = Relative;
}
}
else if( IsElement( "skin"))
{
@ -667,18 +683,18 @@ void ColladaParser::ReadController( Collada::Controller& pController)
else if( IsElement( "bind_shape_matrix"))
{
// content is 16 floats to define a matrix... it seems to be important for some models
const char* content = GetTextContent();
const char* content = GetTextContent();
// read the 16 floats
for( unsigned int a = 0; a < 16; a++)
{
// read a number
content = fast_atoreal_move<ai_real>( content, pController.mBindShapeMatrix[a]);
// skip whitespace after it
SkipSpacesAndLineEnd( &content);
}
// read the 16 floats
for( unsigned int a = 0; a < 16; a++)
{
// read a number
content = fast_atoreal_move<ai_real>( content, pController.mBindShapeMatrix[a]);
// skip whitespace after it
SkipSpacesAndLineEnd( &content);
}
TestClosing( "bind_shape_matrix");
TestClosing( "bind_shape_matrix");
}
else if( IsElement( "source"))
{
@ -693,6 +709,32 @@ void ColladaParser::ReadController( Collada::Controller& pController)
{
ReadControllerWeights( pController);
}
else if ( IsElement( "targets" ))
{
while (mReader->read()) {
if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
if ( IsElement( "input")) {
int semanticsIndex = GetAttribute("semantic");
int sourceIndex = GetAttribute("source");
const char *semantics = mReader->getAttributeValue(semanticsIndex);
const char *source = mReader->getAttributeValue(sourceIndex);
if (strcmp(semantics, "MORPH_TARGET") == 0) {
pController.mMorphTarget = source + 1;
}
else if (strcmp(semantics, "MORPH_WEIGHT") == 0)
{
pController.mMorphWeight = source + 1;
}
}
} else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
if( strcmp( mReader->getNodeName(), "targets") == 0)
break;
else
ThrowException( "Expected end of <targets> element.");
}
}
}
else
{
// ignore the rest
@ -703,7 +745,7 @@ void ColladaParser::ReadController( Collada::Controller& pController)
{
if( strcmp( mReader->getNodeName(), "controller") == 0)
break;
else if( strcmp( mReader->getNodeName(), "skin") != 0)
else if( strcmp( mReader->getNodeName(), "skin") != 0 && strcmp( mReader->getNodeName(), "morph") != 0)
ThrowException( "Expected end of <controller> element.");
}
}
@ -1592,7 +1634,7 @@ void ColladaParser::ReadEffectColor( aiColor4D& pColor, Sampler& pSampler)
}
else if( IsElement( "texture"))
{
// get name of source textur/sampler
// get name of source texture/sampler
int attrTex = GetAttribute( "texture");
pSampler.mName = mReader->getAttributeValue( attrTex);
@ -2311,9 +2353,9 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
ThrowException( "Expected different index count in <p> element.");
// find the data for all sources
for( std::vector<InputChannel>::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it)
for( std::vector<InputChannel>::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it)
{
InputChannel& input = *it;
InputChannel& input = *it;
if( input.mResolved)
continue;
@ -2325,9 +2367,9 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
acc->mData = &ResolveLibraryReference( mDataLibrary, acc->mSource);
}
// and the same for the per-index channels
for( std::vector<InputChannel>::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it)
{
InputChannel& input = *it;
for( std::vector<InputChannel>::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it)
{
InputChannel& input = *it;
if( input.mResolved)
continue;
@ -2409,6 +2451,9 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
return numPrimitives;
}
///@note This function willn't work correctly if both PerIndex and PerVertex channels have same channels.
///For example if TEXCOORD present in both <vertices> and <polylist> tags this function will create wrong uv coordinates.
///It's not clear from COLLADA documentation is this allowed or not. For now only exporter fixed to avoid such behavior
void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, Mesh* pMesh, std::vector<InputChannel>& pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t>& indices){
// calculate the base offset of the vertex whose attributes we ant to copy
size_t baseOffset = currentPrimitive * numOffsets * numPoints + currentVertex * numOffsets;

View File

@ -0,0 +1,92 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (C) 2016 The Qt Company Ltd.
Copyright (c) 2006-2012, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "CreateAnimMesh.h"
namespace Assimp {
aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh)
{
aiAnimMesh *animesh = new aiAnimMesh;
animesh->mVertices = NULL;
animesh->mNormals = NULL;
animesh->mTangents = NULL;
animesh->mBitangents = NULL;
animesh->mNumVertices = mesh->mNumVertices;
if (mesh->mVertices) {
animesh->mVertices = new aiVector3D[animesh->mNumVertices];
std::memcpy(animesh->mVertices, mesh->mVertices, mesh->mNumVertices * sizeof(aiVector3D));
}
if (mesh->mNormals) {
animesh->mNormals = new aiVector3D[animesh->mNumVertices];
std::memcpy(animesh->mNormals, mesh->mNormals, mesh->mNumVertices * sizeof(aiVector3D));
}
if (mesh->mTangents) {
animesh->mTangents = new aiVector3D[animesh->mNumVertices];
std::memcpy(animesh->mTangents, mesh->mTangents, mesh->mNumVertices * sizeof(aiVector3D));
}
if (mesh->mBitangents) {
animesh->mBitangents = new aiVector3D[animesh->mNumVertices];
std::memcpy(animesh->mBitangents, mesh->mBitangents, mesh->mNumVertices * sizeof(aiVector3D));
}
for (int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
if (mesh->mColors[i]) {
animesh->mColors[i] = new aiColor4D[animesh->mNumVertices];
std::memcpy(animesh->mColors[i], mesh->mColors[i], mesh->mNumVertices * sizeof(aiColor4D));
} else {
animesh->mColors[i] = NULL;
}
}
for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
if (mesh->mTextureCoords[i]) {
animesh->mTextureCoords[i] = new aiVector3D[animesh->mNumVertices];
std::memcpy(animesh->mTextureCoords[i], mesh->mTextureCoords[i], mesh->mNumVertices * sizeof(aiVector3D));
} else {
animesh->mTextureCoords[i] = NULL;
}
}
return animesh;
}
} // end of namespace Assimp

View File

@ -0,0 +1,56 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
/** @file CreateAnimMesh.h
* Create AnimMesh from Mesh
*/
#ifndef INCLUDED_AI_CREATE_ANIM_MESH_H
#define INCLUDED_AI_CREATE_ANIM_MESH_H
#include <assimp/mesh.h>
namespace Assimp {
/** Create aiAnimMesh from aiMesh. */
aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh);
} // end of namespace Assimp
#endif // INCLUDED_AI_CREATE_ANIM_MESH_H

View File

@ -49,7 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "StringComparison.h"
#include "StringUtils.h"
#include <string>
#include <sstream>
#include <vector>
@ -68,7 +67,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace D3MF {
namespace XmlTag {
static const std::string model = "model";
static const std::string metadata = "metadata";
@ -229,9 +227,10 @@ private:
aiVector3D ReadVertex()
{
aiVector3D vertex;
vertex.x = ai_strtof(xmlReader->getAttributeValue(D3MF::XmlTag::x.c_str()), nullptr);
vertex.y = ai_strtof(xmlReader->getAttributeValue(D3MF::XmlTag::y.c_str()), nullptr);
vertex.z = ai_strtof>(xmlReader->getAttributeValue(D3MF::XmlTag::z.c_str()), nullptr);
vertex.z = ai_strtof(xmlReader->getAttributeValue(D3MF::XmlTag::z.c_str()), nullptr);
return vertex;
}

View File

@ -126,7 +126,7 @@ size_t DefaultIOStream::FileSize() const
if (0 != err)
return 0;
mCachedSize = (size_t) (fileStat.st_size);
#elif defined __GNUC__ || defined __APPLE__ || defined __MACH__
#elif defined __GNUC__ || defined __APPLE__ || defined __MACH__ || defined __FreeBSD__
struct stat fileStat;
int err = stat(mFilename.c_str(), &fileStat );
if (0 != err)

View File

@ -201,65 +201,48 @@ public:
std::vector<Exporter::ExportFormatEntry> mExporters;
};
} // end of namespace Assimp
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
Exporter :: Exporter()
: pimpl(new ExporterPimpl())
{
: pimpl(new ExporterPimpl()) {
// empty
}
// ------------------------------------------------------------------------------------------------
Exporter :: ~Exporter()
{
Exporter::~Exporter() {
FreeBlob();
delete pimpl;
}
// ------------------------------------------------------------------------------------------------
void Exporter :: SetIOHandler( IOSystem* pIOHandler)
{
void Exporter::SetIOHandler( IOSystem* pIOHandler) {
pimpl->mIsDefaultIOHandler = !pIOHandler;
pimpl->mIOSystem.reset(pIOHandler);
}
// ------------------------------------------------------------------------------------------------
IOSystem* Exporter :: GetIOHandler() const
{
IOSystem* Exporter::GetIOHandler() const {
return pimpl->mIOSystem.get();
}
// ------------------------------------------------------------------------------------------------
bool Exporter :: IsDefaultIOHandler() const
{
bool Exporter::IsDefaultIOHandler() const {
return pimpl->mIsDefaultIOHandler;
}
// ------------------------------------------------------------------------------------------------
const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int, const ExportProperties* pProperties)
{
const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const char* pFormatId,
unsigned int, const ExportProperties* pProperties ) {
if (pimpl->blob) {
delete pimpl->blob;
pimpl->blob = NULL;
}
std::shared_ptr<IOSystem> old = pimpl->mIOSystem;
BlobIOSystem* blobio = new BlobIOSystem();
pimpl->mIOSystem = std::shared_ptr<IOSystem>( blobio );
@ -274,10 +257,8 @@ const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const
return pimpl->blob;
}
// ------------------------------------------------------------------------------------------------
bool IsVerboseFormat(const aiMesh* mesh)
{
bool IsVerboseFormat(const aiMesh* mesh) {
// avoid slow vector<bool> specialization
std::vector<unsigned int> seen(mesh->mNumVertices,0);
for(unsigned int i = 0; i < mesh->mNumFaces; ++i) {
@ -292,10 +273,8 @@ bool IsVerboseFormat(const aiMesh* mesh)
return true;
}
// ------------------------------------------------------------------------------------------------
bool IsVerboseFormat(const aiScene* pScene)
{
bool IsVerboseFormat(const aiScene* pScene) {
for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
if(!IsVerboseFormat(pScene->mMeshes[i])) {
return false;
@ -304,10 +283,8 @@ bool IsVerboseFormat(const aiScene* pScene)
return true;
}
// ------------------------------------------------------------------------------------------------
aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing, const ExportProperties* pProperties)
{
aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing, const ExportProperties* pProperties) {
ASSIMP_BEGIN_EXCEPTION_REGION();
// when they create scenes from scratch, users will likely create them not in verbose
@ -320,9 +297,7 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
for (size_t i = 0; i < pimpl->mExporters.size(); ++i) {
const Exporter::ExportFormatEntry& exp = pimpl->mExporters[i];
if (!strcmp(exp.mDescription.id,pFormatId)) {
try {
// Always create a full copy of the scene. We might optimize this one day,
// but for now it is the most pragmatic way.
aiScene* scenecopy_tmp = NULL;
@ -341,18 +316,17 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
? (priv->mPPStepsApplied & ~nonIdempotentSteps)
: 0u);
// If no extra postprocessing was specified, and we obtained this scene from an
// If no extra post-processing was specified, and we obtained this scene from an
// Assimp importer, apply the reverse steps automatically.
// TODO: either drop this, or document it. Otherwise it is just a bad surprise.
//if (!pPreprocessing && priv) {
// pp |= (nonIdempotentSteps & priv->mPPStepsApplied);
//}
// If the input scene is not in verbose format, but there is at least postprocessing step that relies on it,
// If the input scene is not in verbose format, but there is at least post-processing step that relies on it,
// we need to run the MakeVerboseFormat step first.
bool must_join_again = false;
if (!is_verbose_format) {
bool verbosify = false;
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
BaseProcess* const p = pimpl->mPostProcessingSteps[a];
@ -423,8 +397,7 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
ExportProperties emptyProperties; // Never pass NULL ExportProperties so Exporters don't have to worry.
exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProperties ? pProperties : &emptyProperties);
}
catch (DeadlyExportError& err) {
} catch (DeadlyExportError& err) {
pimpl->mError = err.what();
return AI_FAILURE;
}
@ -437,64 +410,53 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
return AI_FAILURE;
}
// ------------------------------------------------------------------------------------------------
const char* Exporter :: GetErrorString() const
{
const char* Exporter::GetErrorString() const {
return pimpl->mError.c_str();
}
// ------------------------------------------------------------------------------------------------
void Exporter :: FreeBlob( )
{
void Exporter::FreeBlob() {
delete pimpl->blob;
pimpl->blob = NULL;
pimpl->mError = "";
}
// ------------------------------------------------------------------------------------------------
const aiExportDataBlob* Exporter :: GetBlob() const
{
const aiExportDataBlob* Exporter::GetBlob() const {
return pimpl->blob;
}
// ------------------------------------------------------------------------------------------------
const aiExportDataBlob* Exporter :: GetOrphanedBlob() const
{
const aiExportDataBlob* Exporter::GetOrphanedBlob() const {
const aiExportDataBlob* tmp = pimpl->blob;
pimpl->blob = NULL;
return tmp;
}
// ------------------------------------------------------------------------------------------------
size_t Exporter :: GetExportFormatCount() const
{
size_t Exporter::GetExportFormatCount() const {
return pimpl->mExporters.size();
}
// ------------------------------------------------------------------------------------------------
const aiExportFormatDesc* Exporter :: GetExportFormatDescription( size_t pIndex ) const
{
if (pIndex >= GetExportFormatCount()) {
const aiExportFormatDesc* Exporter::GetExportFormatDescription( size_t index ) const {
if (index >= GetExportFormatCount()) {
return NULL;
}
// Return from static storage if the requested index is built-in.
if (pIndex < sizeof(gExporters) / sizeof(gExporters[0])) {
return &gExporters[pIndex].mDescription;
if (index < sizeof(gExporters) / sizeof(gExporters[0])) {
return &gExporters[index].mDescription;
}
return &pimpl->mExporters[pIndex].mDescription;
return &pimpl->mExporters[index].mDescription;
}
// ------------------------------------------------------------------------------------------------
aiReturn Exporter :: RegisterExporter(const ExportFormatEntry& desc)
{
aiReturn Exporter::RegisterExporter(const ExportFormatEntry& desc) {
for(const ExportFormatEntry& e : pimpl->mExporters) {
if (!strcmp(e.mDescription.id,desc.mDescription.id)) {
return aiReturn_FAILURE;
@ -505,10 +467,8 @@ aiReturn Exporter :: RegisterExporter(const ExportFormatEntry& desc)
return aiReturn_SUCCESS;
}
// ------------------------------------------------------------------------------------------------
void Exporter :: UnregisterExporter(const char* id)
{
void Exporter::UnregisterExporter(const char* id) {
for(std::vector<ExportFormatEntry>::iterator it = pimpl->mExporters.begin(); it != pimpl->mExporters.end(); ++it) {
if (!strcmp((*it).mDescription.id,id)) {
pimpl->mExporters.erase(it);
@ -517,29 +477,30 @@ void Exporter :: UnregisterExporter(const char* id)
}
}
ExportProperties :: ExportProperties() {}
// ------------------------------------------------------------------------------------------------
ExportProperties::ExportProperties() {
// empty
}
// ------------------------------------------------------------------------------------------------
ExportProperties::ExportProperties(const ExportProperties &other)
: mIntProperties(other.mIntProperties),
mFloatProperties(other.mFloatProperties),
mStringProperties(other.mStringProperties),
mMatrixProperties(other.mMatrixProperties)
{
: mIntProperties(other.mIntProperties)
, mFloatProperties(other.mFloatProperties)
, mStringProperties(other.mStringProperties)
, mMatrixProperties(other.mMatrixProperties) {
// empty
}
// ------------------------------------------------------------------------------------------------
// Set a configuration property
bool ExportProperties :: SetPropertyInteger(const char* szName, int iValue)
{
bool ExportProperties::SetPropertyInteger(const char* szName, int iValue) {
return SetGenericProperty<int>(mIntProperties, szName,iValue);
}
// ------------------------------------------------------------------------------------------------
// Set a configuration property
bool ExportProperties :: SetPropertyFloat(const char* szName, ai_real iValue)
{
bool ExportProperties::SetPropertyFloat(const char* szName, ai_real iValue) {
return SetGenericProperty<ai_real>(mFloatProperties, szName,iValue);
}

View File

@ -108,7 +108,7 @@ static const aiImporterDesc desc = {
0,
0,
0,
"ifc ifczip"
"ifc ifczip stp"
};
@ -128,11 +128,9 @@ IFCImporter::~IFCImporter()
bool IFCImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
{
const std::string& extension = GetExtension(pFile);
if (extension == "ifc" || extension == "ifczip") {
if (extension == "ifc" || extension == "ifczip" || extension == "stp" ) {
return true;
}
else if ((!extension.length() || checkSig) && pIOHandler) {
} else if ((!extension.length() || checkSig) && pIOHandler) {
// note: this is the common identification for STEP-encoded files, so
// it is only unambiguous as long as we don't support any further
// file formats with STEP as their encoding.

View File

@ -46,6 +46,9 @@ directly (unless you are adding new loaders), instead use the
corresponding preprocessor flag to selectively disable formats.
*/
#include <vector>
#include "BaseImporter.h"
// ------------------------------------------------------------------------------------------------
// Importers
// (include_new_importers_here)

View File

@ -38,8 +38,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
#ifndef ASSIMP_BUILD_NO_EXPORT
#ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER
@ -53,14 +51,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h>
#include <memory>
using namespace Assimp;
namespace Assimp {
namespace Assimp {
// ------------------------------------------------------------------------------------------------
// Worker function for exporting a scene to Wavefront OBJ. Prototyped and registered in Exporter.cpp
void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
{
void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) {
// invoke the exporter
ObjExporter exporter(pFile, pScene);
@ -86,11 +83,14 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
static const std::string MaterialExt = ".mtl";
// ------------------------------------------------------------------------------------------------
ObjExporter :: ObjExporter(const char* _filename, const aiScene* pScene)
ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene)
: filename(_filename)
, pScene(pScene)
, endl("\n")
{
, vp()
, vn()
, vt()
, vc() {
// make sure that all formatting happens using the standard, C locale and not the user's current locale
const std::locale& l = std::locale("C");
mOutput.imbue(l);
@ -102,6 +102,11 @@ ObjExporter :: ObjExporter(const char* _filename, const aiScene* pScene)
WriteMaterialFile();
}
// ------------------------------------------------------------------------------------------------
ObjExporter::~ObjExporter() {
}
// ------------------------------------------------------------------------------------------------
std::string ObjExporter :: GetMaterialLibName()
{
@ -166,11 +171,17 @@ void ObjExporter::WriteMaterialFile()
if(AI_SUCCESS == mat->Get(AI_MATKEY_COLOR_EMISSIVE,c)) {
mOutputMat << "Ke " << c.r << " " << c.g << " " << c.b << endl;
}
if(AI_SUCCESS == mat->Get(AI_MATKEY_COLOR_TRANSPARENT,c)) {
mOutputMat << "Tf " << c.r << " " << c.g << " " << c.b << endl;
}
ai_real o;
if(AI_SUCCESS == mat->Get(AI_MATKEY_OPACITY,o)) {
mOutputMat << "d " << o << endl;
}
if(AI_SUCCESS == mat->Get(AI_MATKEY_REFRACTI,o)) {
mOutputMat << "Ni " << o << endl;
}
if(AI_SUCCESS == mat->Get(AI_MATKEY_SHININESS,o) && o) {
mOutputMat << "Ns " << o << endl;
@ -206,8 +217,7 @@ void ObjExporter::WriteMaterialFile()
}
// ------------------------------------------------------------------------------------------------
void ObjExporter :: WriteGeometryFile()
{
void ObjExporter::WriteGeometryFile() {
WriteHeader(mOutput);
mOutput << "mtllib " << GetMaterialLibName() << endl << endl;
@ -215,11 +225,21 @@ void ObjExporter :: WriteGeometryFile()
aiMatrix4x4 mBase;
AddNode(pScene->mRootNode, mBase);
// write vertex positions
vpMap.getVectors(vp);
mOutput << "# " << vp.size() << " vertex positions" << endl;
for(const aiVector3D& v : vp) {
mOutput << "v " << v.x << " " << v.y << " " << v.z << endl;
// write vertex positions with colors, if any
vpMap.getVectors( vp );
vcMap.getColors( vc );
if ( vc.empty() ) {
mOutput << "# " << vp.size() << " vertex positions" << endl;
for ( const aiVector3D& v : vp ) {
mOutput << "v " << v.x << " " << v.y << " " << v.z << endl;
}
} else {
mOutput << "# " << vp.size() << " vertex positions and colors" << endl;
size_t colIdx = 0;
for ( const aiVector3D& v : vp ) {
mOutput << "v " << v.x << " " << v.y << " " << v.z << " " << vc[ colIdx ].r << " " << vc[ colIdx ].g << " " << vc[ colIdx ].b << endl;
colIdx++;
}
}
mOutput << endl;
@ -272,8 +292,7 @@ void ObjExporter :: WriteGeometryFile()
}
// ------------------------------------------------------------------------------------------------
int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec)
{
int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec) {
vecIndexMap::dataType::iterator vertIt = vecMap.find(vec);
// vertex already exists, so reference it
if(vertIt != vecMap.end()){
@ -286,8 +305,7 @@ int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec)
}
// ------------------------------------------------------------------------------------------------
void ObjExporter::vecIndexMap::getVectors( std::vector<aiVector3D>& vecs )
{
void ObjExporter::vecIndexMap::getVectors( std::vector<aiVector3D>& vecs ) {
vecs.resize(vecMap.size());
for(vecIndexMap::dataType::iterator it = vecMap.begin(); it != vecMap.end(); ++it){
vecs[it->second-1] = it->first;
@ -295,8 +313,29 @@ void ObjExporter::vecIndexMap::getVectors( std::vector<aiVector3D>& vecs )
}
// ------------------------------------------------------------------------------------------------
void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat)
{
int ObjExporter::colIndexMap::getIndex( const aiColor4D& col ) {
colIndexMap::dataType::iterator vertIt = colMap.find( col );
// vertex already exists, so reference it
if ( vertIt != colMap.end() ) {
return vertIt->second;
}
colMap[ col ] = mNextIndex;
int ret = mNextIndex;
mNextIndex++;
return ret;
}
// ------------------------------------------------------------------------------------------------
void ObjExporter::colIndexMap::getColors( std::vector<aiColor4D> &colors ) {
colors.resize( colMap.size() );
for ( colIndexMap::dataType::iterator it = colMap.begin(); it != colMap.end(); ++it ) {
colors[ it->second - 1 ] = it->first;
}
}
// ------------------------------------------------------------------------------------------------
void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat) {
meshes.push_back(MeshInstance());
MeshInstance& mesh = meshes.back();
@ -330,15 +369,20 @@ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4
if (m->mNormals) {
aiVector3D norm = aiMatrix3x3(mat) * m->mNormals[idx];
face.indices[a].vn = vnMap.getIndex(norm);
}
else{
} else {
face.indices[a].vn = 0;
}
if (m->mTextureCoords[0]) {
face.indices[a].vt = vtMap.getIndex(m->mTextureCoords[0][idx]);
if ( nullptr != m->mColors[ 0 ] ) {
aiColor4D col4 = m->mColors[ 0 ][ idx ];
face.indices[ a ].vc = vcMap.getIndex( col4 );
} else {
face.indices[ a ].vc = 0;
}
else{
if ( m->mTextureCoords[ 0 ] ) {
face.indices[a].vt = vtMap.getIndex(m->mTextureCoords[0][idx]);
} else {
face.indices[a].vt = 0;
}
}

View File

@ -53,40 +53,35 @@ struct aiScene;
struct aiNode;
struct aiMesh;
namespace Assimp
{
namespace Assimp {
// ------------------------------------------------------------------------------------------------
/** Helper class to export a given scene to an OBJ file. */
// ------------------------------------------------------------------------------------------------
class ObjExporter
{
class ObjExporter {
public:
/// Constructor for a specific scene to export
ObjExporter(const char* filename, const aiScene* pScene);
public:
~ObjExporter();
std::string GetMaterialLibName();
std::string GetMaterialLibFileName();
public:
/// public stringstreams to write all output into
/// public string-streams to write all output into
std::ostringstream mOutput, mOutputMat;
private:
// intermediate data structures
struct FaceVertex
{
struct FaceVertex {
FaceVertex()
: vp(),vn(),vt()
{
: vp()
, vn()
, vt()
, vc() {
// empty
}
// one-based, 0 means: 'does not exist'
unsigned int vp,vn,vt;
unsigned int vp, vn, vt, vc;
};
struct Face {
@ -95,13 +90,11 @@ private:
};
struct MeshInstance {
std::string name, matname;
std::vector<Face> faces;
};
void WriteHeader(std::ostringstream& out);
void WriteMaterialFile();
void WriteGeometryFile();
@ -111,17 +104,14 @@ private:
void AddNode(const aiNode* nd, const aiMatrix4x4& mParent);
private:
const std::string filename;
const aiScene* const pScene;
std::vector<aiVector3D> vp, vn, vt;
std::vector<aiColor4D> vc;
struct aiVectorCompare
{
bool operator() (const aiVector3D& a, const aiVector3D& b) const
{
struct aiVectorCompare {
bool operator() (const aiVector3D& a, const aiVector3D& b) const {
if(a.x < b.x) return true;
if(a.x > b.x) return false;
if(a.y < b.y) return true;
@ -131,21 +121,52 @@ private:
}
};
class vecIndexMap
{
struct aiColor4Compare {
bool operator() ( const aiColor4D& a, const aiColor4D& b ) const {
if ( a.r < b.r ) return true;
if ( a.r > b.r ) return false;
if ( a.g < b.g ) return true;
if ( a.g > b.g ) return false;
if ( a.b < b.b ) return true;
if ( a.b > b.b ) return false;
if ( a.a < b.a ) return true;
if ( a.a > b.a ) return false;
return false;
}
};
class vecIndexMap {
int mNextIndex;
typedef std::map<aiVector3D, int, aiVectorCompare> dataType;
dataType vecMap;
public:
vecIndexMap():mNextIndex(1)
{}
vecIndexMap()
: mNextIndex(1) {
// empty
}
int getIndex(const aiVector3D& vec);
void getVectors( std::vector<aiVector3D>& vecs );
};
class colIndexMap {
int mNextIndex;
typedef std::map<aiColor4D, int, aiColor4Compare> dataType;
dataType colMap;
public:
colIndexMap()
: mNextIndex( 1 ) {
// empty
}
int getIndex( const aiColor4D& col );
void getColors( std::vector<aiColor4D> &colors );
};
vecIndexMap vpMap, vnMap, vtMap;
colIndexMap vcMap;
std::vector<MeshInstance> meshes;
// this endl() doesn't flush() the stream

View File

@ -178,6 +178,8 @@ struct Material {
int illumination_model;
//! Index of refraction
ai_real ior;
//! Transparency color
aiColor3D transparent;
//! Constructor
Material()
@ -185,7 +187,8 @@ struct Material {
, alpha (ai_real( 1.0 ) )
, shineness ( ai_real( 0.0) )
, illumination_model (1)
, ior ( ai_real( 1.0 ) ) {
, ior ( ai_real( 1.0 ) )
, transparent( ai_real( 1.0), ai_real (1.0), ai_real(1.0)) {
// empty
for (size_t i = 0; i < TextureTypeCount; ++i) {
clamp[ i ] = false;

View File

@ -607,6 +607,7 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
mat->AddProperty( &pCurrentMaterial->emissive, 1, AI_MATKEY_COLOR_EMISSIVE );
mat->AddProperty( &pCurrentMaterial->shineness, 1, AI_MATKEY_SHININESS );
mat->AddProperty( &pCurrentMaterial->alpha, 1, AI_MATKEY_OPACITY );
mat->AddProperty( &pCurrentMaterial->transparent,1,AI_MATKEY_COLOR_TRANSPARENT);
// Adding refraction index
mat->AddProperty( &pCurrentMaterial->ior, 1, AI_MATKEY_REFRACTI );

View File

@ -163,7 +163,17 @@ void ObjFileMtlImporter::load()
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
}
break;
case 'T':
{
++m_DataIt;
if (*m_DataIt == 'f') // Material transmission
{
++m_DataIt;
getColorRGBA( &m_pModel->m_pCurrentMaterial->transparent);
}
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
}
break;
case 'd':
{
if( *(m_DataIt+1) == 'i' && *( m_DataIt + 2 ) == 's' && *( m_DataIt + 3 ) == 'p' ) {
@ -292,6 +302,9 @@ void ObjFileMtlImporter::createMaterial()
// New Material created
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
if (m_pModel->m_pCurrentMesh) {
m_pModel->m_pCurrentMesh->m_uiMaterialIndex = m_pModel->m_MaterialLib.size() - 1;
}
m_pModel->m_MaterialLib.push_back( name );
m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
} else {

View File

@ -140,15 +140,13 @@ inline char_t getName( char_t it, char_t end, std::string &name )
}
char *pStart = &( *it );
while( !isEndOfBuffer( it, end ) && !IsLineEnd( *it ) && !IsSpaceOrNewLine( *it ) ) {
while( !isEndOfBuffer( it, end ) && !IsLineEnd( *it )) {
++it;
}
/*while( isEndOfBuffer( it, end ) || IsLineEnd( *it ) || IsSpaceOrNewLine( *it ) ) {
while(IsSpace( *it ) ) {
--it;
}
++it;
*/
// Get name
// if there is no name, and the previous char is a separator, come back to start
while (&(*it) < pStart) {

View File

@ -90,14 +90,16 @@ namespace
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
PLYImporter::PLYImporter()
: mBuffer(),
pcDOM()
{}
: mBuffer()
, pcDOM(){
// empty
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
PLYImporter::~PLYImporter()
{}
PLYImporter::~PLYImporter() {
// empty
}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
@ -439,7 +441,7 @@ void PLYImporter::LoadTextureCoordinates(std::vector<aiVector2D>* pvOut)
PLY::ElementInstanceList* pcList = NULL;
unsigned int cnt = 0;
// serach in the DOM for a vertex entry
// search in the DOM for a vertex entry
unsigned int _i = 0;
for (std::vector<PLY::Element>::const_iterator i = pcDOM->alElements.begin();
i != pcDOM->alElements.end();++i,++_i)
@ -653,7 +655,7 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
unsigned int cnt = 0;
PLY::ElementInstanceList* pcList = NULL;
// serach in the DOM for a vertex entry
// search in the DOM for a vertex entry
unsigned int _i = 0;
for (std::vector<PLY::Element>::const_iterator i = pcDOM->alElements.begin();
i != pcDOM->alElements.end();++i,++_i)
@ -752,13 +754,13 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
// index of the vertex index list
unsigned int iProperty = 0xFFFFFFFF;
PLY::EDataType eType = EDT_Char;
bool bIsTristrip = false;
bool bIsTriStrip = false;
// index of the material index property
unsigned int iMaterialIndex = 0xFFFFFFFF;
PLY::EDataType eType2 = EDT_Char;
// serach in the DOM for a face entry
// search in the DOM for a face entry
unsigned int _i = 0;
for (std::vector<PLY::Element>::const_iterator i = pcDOM->alElements.begin();
i != pcDOM->alElements.end();++i,++_i)
@ -803,7 +805,7 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
if (!(*a).bIsList)continue;
iProperty = _a;
bOne = true;
bIsTristrip = true;
bIsTriStrip = true;
eType = (*a).eType;
break;
}
@ -813,7 +815,7 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
// check whether we have at least one per-face information set
if (pcList && bOne)
{
if (!bIsTristrip)
if (!bIsTriStrip)
{
pvOut->reserve(pcList->alInstances.size());
for (std::vector<ElementInstance>::const_iterator i = pcList->alInstances.begin();
@ -957,7 +959,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial*>* pvOut)
unsigned int iOpacity = 0xFFFFFFFF;
PLY::EDataType eOpacity = EDT_Char;
// serach in the DOM for a vertex entry
// search in the DOM for a vertex entry
unsigned int _i = 0;
for (std::vector<PLY::Element>::const_iterator i = this->pcDOM->alElements.begin();
i != this->pcDOM->alElements.end();++i,++_i)
@ -1074,7 +1076,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial*>* pvOut)
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_AMBIENT);
// handle phong power and shading mode
int iMode;
int iMode = (int)aiShadingMode_Gouraud;
if (0xFFFFFFFF != iPhong) {
ai_real fSpec = PLY::PropertyInstance::ConvertTo<ai_real>(GetProperty((*i).alProperties, iPhong).avList.front(),ePhong);
@ -1087,9 +1089,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial*>* pvOut)
iMode = (int)aiShadingMode_Phong;
}
else iMode = (int)aiShadingMode_Gouraud;
}
else iMode = (int)aiShadingMode_Gouraud;
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
// handle opacity

View File

@ -53,7 +53,7 @@ struct aiNode;
struct aiMaterial;
struct aiMesh;
namespace Assimp {
namespace Assimp {
using namespace PLY;

View File

@ -53,9 +53,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
PLY::EDataType PLY::Property::ParseDataType(const char* pCur,const char** pCurOut)
{
ai_assert(NULL != pCur && NULL != pCurOut);
PLY::EDataType PLY::Property::ParseDataType(const char* pCur,const char** pCurOut) {
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
PLY::EDataType eOut = PLY::EDT_INVALID;
if (TokenMatch(pCur,"char",4) ||
@ -100,33 +101,25 @@ PLY::EDataType PLY::Property::ParseDataType(const char* pCur,const char** pCurOu
DefaultLogger::get()->info("Found unknown data type in PLY file. This is OK");
}
*pCurOut = pCur;
return eOut;
}
// ------------------------------------------------------------------------------------------------
PLY::ESemantic PLY::Property::ParseSemantic(const char* pCur,const char** pCurOut)
{
ai_assert(NULL != pCur && NULL != pCurOut);
PLY::ESemantic PLY::Property::ParseSemantic(const char* pCur,const char** pCurOut) {
ai_assert (NULL != pCur );
ai_assert( NULL != pCurOut );
PLY::ESemantic eOut = PLY::EST_INVALID;
if (TokenMatch(pCur,"red",3))
{
if (TokenMatch(pCur,"red",3)) {
eOut = PLY::EST_Red;
}
else if (TokenMatch(pCur,"green",5))
{
} else if (TokenMatch(pCur,"green",5)) {
eOut = PLY::EST_Green;
}
else if (TokenMatch(pCur,"blue",4))
{
} else if (TokenMatch(pCur,"blue",4)) {
eOut = PLY::EST_Blue;
}
else if (TokenMatch(pCur,"alpha",5))
{
} else if (TokenMatch(pCur,"alpha",5)) {
eOut = PLY::EST_Alpha;
}
else if (TokenMatch(pCur,"vertex_index",12) || TokenMatch(pCur,"vertex_indices",14))
{
} else if (TokenMatch(pCur,"vertex_index",12) || TokenMatch(pCur,"vertex_indices",14)) {
eOut = PLY::EST_VertexIndex;
}
else if (TokenMatch(pCur,"material_index",14))
@ -213,29 +206,17 @@ PLY::ESemantic PLY::Property::ParseSemantic(const char* pCur,const char** pCurOu
else if (TokenMatch(pCur,"x",1))
{
eOut = PLY::EST_XCoord;
}
else if (TokenMatch(pCur,"y",1))
{
} else if (TokenMatch(pCur,"y",1)) {
eOut = PLY::EST_YCoord;
}
else if (TokenMatch(pCur,"z",1))
{
} else if (TokenMatch(pCur,"z",1)) {
eOut = PLY::EST_ZCoord;
}
else if (TokenMatch(pCur,"nx",2))
{
} else if (TokenMatch(pCur,"nx",2)) {
eOut = PLY::EST_XNormal;
}
else if (TokenMatch(pCur,"ny",2))
{
} else if (TokenMatch(pCur,"ny",2)) {
eOut = PLY::EST_YNormal;
}
else if (TokenMatch(pCur,"nz",2))
{
} else if (TokenMatch(pCur,"nz",2)) {
eOut = PLY::EST_ZNormal;
}
else
{
} else {
DefaultLogger::get()->info("Found unknown property semantic in file. This is ok");
SkipLine(&pCur);
}
@ -248,7 +229,8 @@ bool PLY::Property::ParseProperty (const char* pCur,
const char** pCurOut,
PLY::Property* pOut)
{
ai_assert(NULL != pCur && NULL != pCurOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
// Forms supported:
// "property float x"
@ -256,7 +238,9 @@ bool PLY::Property::ParseProperty (const char* pCur,
*pCurOut = pCur;
// skip leading spaces
if (!SkipSpaces(pCur,&pCur))return false;
if (!SkipSpaces(pCur,&pCur)) {
return false;
}
// skip the "property" string at the beginning
if (!TokenMatch(pCur,"property",8))
@ -265,7 +249,9 @@ bool PLY::Property::ParseProperty (const char* pCur,
return false;
}
// get next word
if (!SkipSpaces(pCur,&pCur))return false;
if (!SkipSpaces(pCur,&pCur)) {
return false;
}
if (TokenMatch(pCur,"list",4))
{
pOut->bIsList = true;
@ -313,6 +299,7 @@ bool PLY::Property::ParseProperty (const char* pCur,
SkipSpacesAndLineEnd(pCur,&pCur);
*pCurOut = pCur;
return true;
}
@ -350,6 +337,7 @@ PLY::EElementSemantic PLY::Element::ParseSemantic(const char* pCur,
eOut = PLY::EEST_Material;
}
*pCurOut = pCur;
return eOut;
}
@ -358,13 +346,17 @@ bool PLY::Element::ParseElement (const char* pCur,
const char** pCurOut,
PLY::Element* pOut)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != pOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != pOut );
// Example format: "element vertex 8"
*pCurOut = pCur;
// skip leading spaces
if (!SkipSpaces(&pCur))return false;
if (!SkipSpaces(&pCur)) {
return false;
}
// skip the "element" string at the beginning
if (!TokenMatch(pCur,"element",7))
@ -405,6 +397,7 @@ bool PLY::Element::ParseElement (const char* pCur,
pOut->alProperties.push_back(prop);
}
*pCurOut = pCur;
return true;
}
@ -412,30 +405,35 @@ bool PLY::Element::ParseElement (const char* pCur,
bool PLY::DOM::SkipComments (const char* pCur,
const char** pCurOut)
{
ai_assert(NULL != pCur && NULL != pCurOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
*pCurOut = pCur;
// skip spaces
if (!SkipSpaces(pCur,&pCur))return false;
if (!SkipSpaces(pCur,&pCur)) {
return false;
}
if (TokenMatch(pCur,"comment",7))
{
if ( !IsLineEnd(pCur[-1]) )
{
SkipLine(pCur,&pCur);
}
if ( !IsLineEnd(pCur[-1]) )
{
SkipLine(pCur,&pCur);
}
SkipComments(pCur,&pCur);
*pCurOut = pCur;
return true;
}
*pCurOut = pCur;
return false;
}
// ------------------------------------------------------------------------------------------------
bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut,bool isBinary)
{
ai_assert(NULL != pCur && NULL != pCurOut);
bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut,bool isBinary) {
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
DefaultLogger::get()->debug("PLY::DOM::ParseHeader() begin");
// after ply and format line
@ -479,7 +477,8 @@ bool PLY::DOM::ParseElementInstanceLists (
const char* pCur,
const char** pCurOut)
{
ai_assert(NULL != pCur && NULL != pCurOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
DefaultLogger::get()->debug("PLY::DOM::ParseElementInstanceLists() begin");
*pCurOut = pCur;
@ -507,7 +506,8 @@ bool PLY::DOM::ParseElementInstanceListsBinary (
const char** pCurOut,
bool p_bBE)
{
ai_assert(NULL != pCur && NULL != pCurOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut);
DefaultLogger::get()->debug("PLY::DOM::ParseElementInstanceListsBinary() begin");
*pCurOut = pCur;
@ -532,7 +532,8 @@ bool PLY::DOM::ParseElementInstanceListsBinary (
// ------------------------------------------------------------------------------------------------
bool PLY::DOM::ParseInstanceBinary (const char* pCur,DOM* p_pcOut,bool p_bBE)
{
ai_assert(NULL != pCur && NULL != p_pcOut);
ai_assert( NULL != pCur );
ai_assert( NULL != p_pcOut );
DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() begin");
@ -580,7 +581,10 @@ bool PLY::ElementInstanceList::ParseInstanceList (
const PLY::Element* pcElement,
PLY::ElementInstanceList* p_pcOut)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != pcElement && NULL != p_pcOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != pcElement );
ai_assert( NULL != p_pcOut );
if (EEST_INVALID == pcElement->eSemantic || pcElement->alProperties.empty())
{
@ -614,7 +618,10 @@ bool PLY::ElementInstanceList::ParseInstanceListBinary (
PLY::ElementInstanceList* p_pcOut,
bool p_bBE /* = false */)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != pcElement && NULL != p_pcOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != pcElement );
ai_assert( NULL != p_pcOut );
// we can add special handling code for unknown element semantics since
// we can't skip it as a whole block (we don't know its exact size
@ -636,9 +643,14 @@ bool PLY::ElementInstance::ParseInstance (
const PLY::Element* pcElement,
PLY::ElementInstance* p_pcOut)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != pcElement && NULL != p_pcOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != pcElement );
ai_assert( NULL != p_pcOut );
if (!SkipSpaces(pCur, &pCur))return false;
if (!SkipSpaces(pCur, &pCur)) {
return false;
}
// allocate enough storage
p_pcOut->alProperties.resize(pcElement->alProperties.size());
@ -671,7 +683,10 @@ bool PLY::ElementInstance::ParseInstanceBinary (
PLY::ElementInstance* p_pcOut,
bool p_bBE /* = false */)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != pcElement && NULL != p_pcOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != pcElement );
ai_assert( NULL != p_pcOut );
// allocate enough storage
p_pcOut->alProperties.resize(pcElement->alProperties.size());
@ -696,12 +711,17 @@ bool PLY::ElementInstance::ParseInstanceBinary (
bool PLY::PropertyInstance::ParseInstance (const char* pCur,const char** pCurOut,
const PLY::Property* prop, PLY::PropertyInstance* p_pcOut)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != prop && NULL != p_pcOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != prop );
ai_assert( NULL != p_pcOut );
*pCurOut = pCur;
// skip spaces at the beginning
if (!SkipSpaces(pCur, &pCur))return false;
if (!SkipSpaces(pCur, &pCur)) {
return false;
}
if (prop->bIsList)
{
@ -741,7 +761,10 @@ bool PLY::PropertyInstance::ParseInstanceBinary (
PLY::PropertyInstance* p_pcOut,
bool p_bBE)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != prop && NULL != p_pcOut);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != prop );
ai_assert( NULL != p_pcOut );
if (prop->bIsList)
{
@ -770,8 +793,7 @@ bool PLY::PropertyInstance::ParseInstanceBinary (
}
// ------------------------------------------------------------------------------------------------
PLY::PropertyInstance::ValueUnion PLY::PropertyInstance::DefaultValue(
PLY::EDataType eType)
PLY::PropertyInstance::ValueUnion PLY::PropertyInstance::DefaultValue( PLY::EDataType eType )
{
PLY::PropertyInstance::ValueUnion out;
@ -798,7 +820,9 @@ bool PLY::PropertyInstance::ParseValue(
PLY::EDataType eType,
PLY::PropertyInstance::ValueUnion* out)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != out);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != out );
bool ret = true;
*pCurOut = pCur;
@ -827,7 +851,6 @@ bool PLY::PropertyInstance::ParseValue(
break;
case EDT_Double:
double d;
pCur = fast_atoreal_move<double>(pCur,d);
out->fDouble = (double)d;
@ -835,8 +858,10 @@ bool PLY::PropertyInstance::ParseValue(
default:
ret = false;
break;
}
*pCurOut = pCur;
return ret;
}
@ -848,7 +873,9 @@ bool PLY::PropertyInstance::ParseValueBinary(
PLY::PropertyInstance::ValueUnion* out,
bool p_bBE)
{
ai_assert(NULL != pCur && NULL != pCurOut && NULL != out);
ai_assert( NULL != pCur );
ai_assert( NULL != pCurOut );
ai_assert( NULL != out );
bool ret = true;
switch (eType)
@ -925,6 +952,7 @@ bool PLY::PropertyInstance::ParseValueBinary(
ret = false;
}
*pCurOut = pCur;
return ret;
}

View File

@ -290,12 +290,12 @@ private:
throw DeadlyImportError("End of file or stream limit was reached");
}
#ifdef __arm__
///*#ifdef __arm__
T f;
::memcpy (&f, current, sizeof(T));
#else
T f = *((const T*)current);
#endif
//#else*/
// T f = *((const T*)current);
//#endif
Intern :: Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
current += sizeof(T);

View File

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

View File

@ -1,80 +1,80 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "..\..\revision.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Deutsch (Deutschland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
#ifdef _WIN32
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,SVNRevision, 0
PRODUCTVERSION 1,1,SVNRevision,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x7L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040704b0"
BEGIN
VALUE "Comments", "Licensed under a 3-clause BSD license"
VALUE "CompanyName", "assimp team"
VALUE "FileDescription", "Open Asset Import Library"
VALUE "FileVersion", 1,1,SVNRevision,0
VALUE "InternalName", "assimp "
VALUE "LegalCopyright", "Copyright (C) 2006-2010"
VALUE "OriginalFilename", "assimpNN.dll"
VALUE "ProductName", "Open Asset Import Library"
VALUE "ProductVersion", 1,1,SVNRevision,0
,0
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x407, 1200
END
END
#endif // Deutsch (Deutschland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "..\..\revision.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Deutsch (Deutschland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
#ifdef _WIN32
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,SVNRevision, 0
PRODUCTVERSION 1,1,SVNRevision,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x7L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040704b0"
BEGIN
VALUE "Comments", "Licensed under a 3-clause BSD license"
VALUE "CompanyName", "assimp team"
VALUE "FileDescription", "Open Asset Import Library"
VALUE "FileVersion", 1,1,SVNRevision,0
VALUE "InternalName", "assimp "
VALUE "LegalCopyright", "Copyright (C) 2006-2010"
VALUE "OriginalFilename", "assimpNN.dll"
VALUE "ProductName", "Open Asset Import Library"
VALUE "ProductVersion", 1,1,SVNRevision,0
,0
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x407, 1200
END
END
#endif // Deutsch (Deutschland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

138
code/scene.cpp 100644
View File

@ -0,0 +1,138 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include <assimp/scene.h>
aiNode::aiNode()
: mName("")
, mParent(NULL)
, mNumChildren(0)
, mChildren(NULL)
, mNumMeshes(0)
, mMeshes(NULL)
, mMetaData(NULL) {
// empty
}
aiNode::aiNode(const std::string& name)
: mName(name)
, mParent(NULL)
, mNumChildren(0)
, mChildren(NULL)
, mNumMeshes(0)
, mMeshes(NULL)
, mMetaData(NULL) {
// empty
}
/** Destructor */
aiNode::~aiNode() {
// delete all children recursively
// to make sure we won't crash if the data is invalid ...
if (mChildren && mNumChildren)
{
for (unsigned int a = 0; a < mNumChildren; a++)
delete mChildren[a];
}
delete[] mChildren;
delete[] mMeshes;
delete mMetaData;
}
const aiNode *aiNode::FindNode(const char* name) const {
if (nullptr == name) {
return nullptr;
}
if (!::strcmp(mName.data, name)) {
return this;
}
for (unsigned int i = 0; i < mNumChildren; ++i) {
const aiNode* const p = mChildren[i]->FindNode(name);
if (p) {
return p;
}
}
// there is definitely no sub-node with this name
return nullptr;
}
aiNode *aiNode::FindNode(const char* name) {
if (!::strcmp(mName.data, name))return this;
for (unsigned int i = 0; i < mNumChildren; ++i)
{
aiNode* const p = mChildren[i]->FindNode(name);
if (p) {
return p;
}
}
// there is definitely no sub-node with this name
return nullptr;
}
void aiNode::addChildren(unsigned int numChildren, aiNode **children) {
if (nullptr == children || 0 == numChildren) {
return;
}
for (unsigned int i = 0; i < numChildren; i++) {
aiNode *child = children[i];
if (nullptr != child) {
child->mParent = this;
}
}
if (mNumChildren > 0) {
aiNode **tmp = new aiNode*[mNumChildren];
::memcpy(tmp, mChildren, sizeof(aiNode*) * mNumChildren);
delete[] mChildren;
mChildren = new aiNode*[mNumChildren + numChildren];
::memcpy(mChildren, tmp, sizeof(aiNode*) * mNumChildren);
::memcpy(&mChildren[mNumChildren], children, sizeof(aiNode*)* numChildren);
mNumChildren += numChildren;
delete[] tmp;
}
else {
mChildren = new aiNode*[numChildren];
for (unsigned int i = 0; i < numChildren; i++) {
mChildren[i] = children[i];
}
mNumChildren = numChildren;
}
}

View File

@ -1,72 +1,72 @@
/*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "cdt.h"
namespace p2t {
CDT::CDT(std::vector<Point*> polyline)
{
sweep_context_ = new SweepContext(polyline);
sweep_ = new Sweep;
}
void CDT::AddHole(std::vector<Point*> polyline)
{
sweep_context_->AddHole(polyline);
}
void CDT::AddPoint(Point* point) {
sweep_context_->AddPoint(point);
}
void CDT::Triangulate()
{
sweep_->Triangulate(*sweep_context_);
}
std::vector<p2t::Triangle*> CDT::GetTriangles()
{
return sweep_context_->GetTriangles();
}
std::list<p2t::Triangle*> CDT::GetMap()
{
return sweep_context_->GetMap();
}
CDT::~CDT()
{
delete sweep_context_;
delete sweep_;
}
}
/*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "cdt.h"
namespace p2t {
CDT::CDT(std::vector<Point*> polyline)
{
sweep_context_ = new SweepContext(polyline);
sweep_ = new Sweep;
}
void CDT::AddHole(std::vector<Point*> polyline)
{
sweep_context_->AddHole(polyline);
}
void CDT::AddPoint(Point* point) {
sweep_context_->AddPoint(point);
}
void CDT::Triangulate()
{
sweep_->Triangulate(*sweep_context_);
}
std::vector<p2t::Triangle*> CDT::GetTriangles()
{
return sweep_context_->GetTriangles();
}
std::list<p2t::Triangle*> CDT::GetMap()
{
return sweep_context_->GetMap();
}
CDT::~CDT()
{
delete sweep_context_;
delete sweep_;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -296,8 +296,7 @@ protected:
ExporterPimpl* pimpl;
};
class ASSIMP_API ExportProperties
{
class ASSIMP_API ExportProperties {
public:
// Data type to store the key hash
typedef unsigned int KeyType;

View File

@ -58,7 +58,6 @@ namespace Assimp {
// =======================================================================
// Public interface to Assimp
class Importer;
class Exporter; // export.hpp
class IOStream;
class IOSystem;
class ProgressHandler;
@ -77,7 +76,6 @@ namespace Assimp {
// =======================================================================
// Holy stuff, only for members of the high council of the Jedi.
class ImporterPimpl;
class ExporterPimpl; // export.hpp
} //! namespace Assimp
#define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff

View File

@ -190,6 +190,39 @@ struct aiMeshKey
#endif
};
// ---------------------------------------------------------------------------
/** Binds a morph anim mesh to a specific point in time. */
struct aiMeshMorphKey
{
/** The time of this key */
double mTime;
/** The values and weights at the time of this key */
unsigned int *mValues;
double *mWeights;
/** The number of values and weights */
unsigned int mNumValuesAndWeights;
#ifdef __cplusplus
aiMeshMorphKey()
: mTime(0.0)
, mValues(NULL)
, mWeights(NULL)
, mNumValuesAndWeights(0)
{
}
~aiMeshMorphKey()
{
if (mNumValuesAndWeights && mValues && mWeights) {
delete [] mValues;
delete [] mWeights;
}
}
#endif
};
// ---------------------------------------------------------------------------
/** Defines how an animation channel behaves outside the defined time
* range. This corresponds to aiNodeAnim::mPreState and
@ -340,6 +373,37 @@ struct aiMeshAnim
#endif
};
// ---------------------------------------------------------------------------
/** Describes a morphing animation of a given mesh. */
struct aiMeshMorphAnim
{
/** Name of the mesh to be animated. An empty string is not allowed,
* animated meshes need to be named (not necessarily uniquely,
* the name can basically serve as wildcard to select a group
* of meshes with similar animation setup)*/
C_STRUCT aiString mName;
/** Size of the #mKeys array. Must be 1, at least. */
unsigned int mNumKeys;
/** Key frames of the animation. May not be NULL. */
C_STRUCT aiMeshMorphKey* mKeys;
#ifdef __cplusplus
aiMeshMorphAnim()
: mNumKeys()
, mKeys()
{}
~aiMeshMorphAnim()
{
delete[] mKeys;
}
#endif
};
// ---------------------------------------------------------------------------
/** An animation consists of key-frame data for a number of nodes. For
* each node affected by the animation a separate series of data is given.*/
@ -372,6 +436,14 @@ struct aiAnimation {
* The array is mNumMeshChannels in size. */
C_STRUCT aiMeshAnim** mMeshChannels;
/** The number of mesh animation channels. Each channel affects
* a single mesh and defines morphing animation. */
unsigned int mNumMorphMeshChannels;
/** The morph mesh animation channels. Each channel affects a single mesh.
* The array is mNumMorphMeshChannels in size. */
C_STRUCT aiMeshMorphAnim **mMorphMeshChannels;
#ifdef __cplusplus
aiAnimation()
: mDuration(-1.)
@ -379,7 +451,9 @@ struct aiAnimation {
, mNumChannels(0)
, mChannels(NULL)
, mNumMeshChannels(0)
, mMeshChannels(NULL) {
, mMeshChannels(NULL)
, mNumMorphMeshChannels(0)
, mMorphMeshChannels(NULL) {
// empty
}
@ -399,6 +473,13 @@ struct aiAnimation {
delete [] mMeshChannels;
}
if (mNumMorphMeshChannels && mMorphMeshChannels) {
for( unsigned int a = 0; a < mNumMorphMeshChannels; a++) {
delete mMorphMeshChannels[a];
}
delete [] mMorphMeshChannels;
}
}
#endif // __cplusplus
};

View File

@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_COLOR4D_H_INC
#define AI_COLOR4D_H_INC
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@ -89,7 +88,7 @@ public:
// Red, green, blue and alpha color values
TReal r, g, b, a;
} PACK_STRUCT; // !struct aiColor4D
}; // !struct aiColor4D
typedef aiColor4t<ai_real> aiColor4D;
@ -97,10 +96,8 @@ typedef aiColor4t<ai_real> aiColor4D;
struct aiColor4D {
ai_real r, g, b, a;
} PACK_STRUCT;
};
#endif // __cplusplus
#include "./Compiler/poppack1.h"
#endif // AI_COLOR4D_H_INC

View File

@ -76,12 +76,34 @@ AI_FORCE_INLINE const aiColor4t<TReal>& aiColor4t<TReal>::operator /= (TReal f)
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiColor4t<TReal>::operator[](unsigned int i) const {
return *(&r + i);
//return *(&r + i);
switch ( i ) {
case 0:
return r;
case 1:
return g;
case 2:
return b;
default:
break;
}
return r;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal& aiColor4t<TReal>::operator[](unsigned int i) {
return *(&r + i);
// return *(&r + i);
switch ( i ) {
case 0:
return r;
case 1:
return g;
case 2:
return b;
default:
break;
}
return r;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>

View File

@ -46,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_MATRIX3X3_H_INC
#define AI_MATRIX3X3_H_INC
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@ -153,7 +152,7 @@ public:
/** @brief A function for creating a rotation matrix that rotates a
* vector called "from" into another vector called "to".
* Input : from[3], to[3] which both must be *normalized* non-zero vectors
* Output: mtx[3][3] -- a 3x3 matrix in colum-major form
* Output: mtx[3][3] -- a 3x3 matrix in column-major form
* Authors: Tomas Möller, John Hughes
* "Efficiently Building a Matrix to Rotate One Vector to Another"
* Journal of Graphics Tools, 4(4):1-4, 1999
@ -165,7 +164,7 @@ public:
TReal a1, a2, a3;
TReal b1, b2, b3;
TReal c1, c2, c3;
} PACK_STRUCT;
};
typedef aiMatrix3x3t<ai_real> aiMatrix3x3;
@ -175,10 +174,8 @@ struct aiMatrix3x3 {
ai_real a1, a2, a3;
ai_real b1, b2, b3;
ai_real c1, c2, c3;
} PACK_STRUCT;
};
#endif // __cplusplus
#include "./Compiler/poppack1.h"
#endif // AI_MATRIX3X3_H_INC

View File

@ -101,16 +101,34 @@ inline aiMatrix3x3t<TReal> aiMatrix3x3t<TReal>::operator* (const aiMatrix3x3t<TR
// ------------------------------------------------------------------------------------------------
template <typename TReal>
inline TReal* aiMatrix3x3t<TReal>::operator[] (unsigned int p_iIndex)
{
return &this->a1 + p_iIndex * 3;
inline TReal* aiMatrix3x3t<TReal>::operator[] (unsigned int p_iIndex) {
switch ( p_iIndex ) {
case 0:
return &a1;
case 1:
return &b1;
case 2:
return &c1;
default:
break;
}
return &a1;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
inline const TReal* aiMatrix3x3t<TReal>::operator[] (unsigned int p_iIndex) const
{
return &this->a1 + p_iIndex * 3;
inline const TReal* aiMatrix3x3t<TReal>::operator[] (unsigned int p_iIndex) const {
switch ( p_iIndex ) {
case 0:
return &a1;
case 1:
return &b1;
case 2:
return &c1;
default:
break;
}
return &a1;
}
// ------------------------------------------------------------------------------------------------

View File

@ -46,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_MATRIX4X4_H_INC
#include "vector3.h"
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@ -257,7 +256,7 @@ public:
TReal b1, b2, b3, b4;
TReal c1, c2, c3, c4;
TReal d1, d2, d3, d4;
} PACK_STRUCT;
};
typedef aiMatrix4x4t<ai_real> aiMatrix4x4;
@ -268,11 +267,9 @@ struct aiMatrix4x4 {
ai_real b1, b2, b3, b4;
ai_real c1, c2, c3, c4;
ai_real d1, d2, d3, d4;
} PACK_STRUCT;
};
#endif // __cplusplus
#include "./Compiler/poppack1.h"
#endif // AI_MATRIX4X4_H_INC

View File

@ -243,9 +243,19 @@ inline TReal* aiMatrix4x4t<TReal>::operator[](unsigned int p_iIndex) {
if (p_iIndex > 3) {
return NULL;
}
// XXX this is UB. Has been for years. The fact that it works now does not make it better.
return &this->a1 + p_iIndex * 4;
switch ( p_iIndex ) {
case 0:
return &a1;
case 1:
return &b1;
case 2:
return &c1;
case 3:
return &d1;
default:
break;
}
return &a1;
}
// ----------------------------------------------------------------------------------------
@ -255,8 +265,19 @@ inline const TReal* aiMatrix4x4t<TReal>::operator[](unsigned int p_iIndex) const
return NULL;
}
// XXX same
return &this->a1 + p_iIndex * 4;
switch ( p_iIndex ) {
case 0:
return &a1;
case 1:
return &b1;
case 2:
return &c1;
case 3:
return &d1;
default:
break;
}
return &a1;
}
// ----------------------------------------------------------------------------------------

View File

@ -378,6 +378,9 @@ struct aiAnimMesh
*/
unsigned int mNumVertices;
/** Weight of the AnimMesh. */
float mWeight;
#ifdef __cplusplus
aiAnimMesh()
@ -446,6 +449,27 @@ struct aiAnimMesh
#endif
};
// ---------------------------------------------------------------------------
/** @brief Enumerates the methods of mesh morphing supported by Assimp.
*/
enum aiMorphingMethod
{
/** Interpolation between morph targets */
aiMorphingMethod_VERTEX_BLEND = 0x1,
/** Normalized morphing between morph targets */
aiMorphingMethod_MORPH_NORMALIZED = 0x2,
/** Relative morphing between morph targets */
aiMorphingMethod_MORPH_RELATIVE = 0x3,
/** This value is not used. It is just here to force the
* compiler to map this enum to a 32 Bit integer.
*/
#ifndef SWIG
_aiMorphingMethod_Force32Bit = INT_MAX
#endif
}; //! enum aiMorphingMethod
// ---------------------------------------------------------------------------
/** @brief A mesh represents a geometry or model with a single material.
@ -600,15 +624,18 @@ struct aiMesh
C_STRUCT aiString mName;
/** NOT CURRENTLY IN USE. The number of attachment meshes */
/** The number of attachment meshes. Note! Currently only works with Collada loader. */
unsigned int mNumAnimMeshes;
/** NOT CURRENTLY IN USE. Attachment meshes for this mesh, for vertex-based animation.
/** Attachment meshes for this mesh, for vertex-based animation.
* Attachment meshes carry replacement data for some of the
* mesh'es vertex components (usually positions, normals). */
* mesh'es vertex components (usually positions, normals).
* Note! Currently only works with Collada loader.*/
C_STRUCT aiAnimMesh** mAnimMeshes;
/** Method of morphing when animeshes are specified. */
unsigned int mMethod;
#ifdef __cplusplus
//! Default constructor. Initializes all members to 0
@ -733,7 +760,6 @@ struct aiMesh
#endif // __cplusplus
};
#ifdef __cplusplus
}
#endif //! extern "C"

View File

@ -69,7 +69,7 @@ extern "C" {
* the imported scene does consist of only a single root node without children.
*/
// -------------------------------------------------------------------------------
struct aiNode
struct ASSIMP_API aiNode
{
/** The name of the node.
*
@ -124,47 +124,13 @@ struct aiNode
#ifdef __cplusplus
/** Constructor */
aiNode()
// set all members to zero by default
: mName("")
, mParent(NULL)
, mNumChildren(0)
, mChildren(NULL)
, mNumMeshes(0)
, mMeshes(NULL)
, mMetaData(NULL)
{
}
aiNode();
/** Construction from a specific name */
explicit aiNode(const std::string& name)
// set all members to zero by default
: mName(name)
, mParent(NULL)
, mNumChildren(0)
, mChildren(NULL)
, mNumMeshes(0)
, mMeshes(NULL)
, mMetaData(NULL)
{
}
explicit aiNode(const std::string& name);
/** Destructor */
~aiNode()
{
// delete all children recursively
// to make sure we won't crash if the data is invalid ...
if (mChildren && mNumChildren)
{
for( unsigned int a = 0; a < mNumChildren; a++)
delete mChildren[a];
}
delete [] mChildren;
delete [] mMeshes;
delete mMetaData;
}
~aiNode();
/** Searches for a node with a specific name, beginning at this
* nodes. Normally you will call this method on the root node
@ -173,46 +139,26 @@ struct aiNode
* @param name Name to search for
* @return NULL or a valid Node if the search was successful.
*/
inline const aiNode* FindNode(const aiString& name) const
{
inline
const aiNode* FindNode(const aiString& name) const {
return FindNode(name.data);
}
inline aiNode* FindNode(const aiString& name)
{
inline
aiNode* FindNode(const aiString& name) {
return FindNode(name.data);
}
const aiNode* FindNode(const char* name) const;
inline const aiNode* FindNode(const char* name) const
{
if (!::strcmp( mName.data,name))return this;
for (unsigned int i = 0; i < mNumChildren;++i)
{
const aiNode* const p = mChildren[i]->FindNode(name);
if (p) {
return p;
}
}
// there is definitely no sub-node with this name
return NULL;
}
inline aiNode* FindNode(const char* name)
{
if (!::strcmp( mName.data,name))return this;
for (unsigned int i = 0; i < mNumChildren;++i)
{
aiNode* const p = mChildren[i]->FindNode(name);
if (p) {
return p;
}
}
// there is definitely no sub-node with this name
return NULL;
}
aiNode* FindNode(const char* name);
/**
* @brief Will add new children.
* @param numChildren Number of children to add.
* @param children The array with pointers showing to the children.
*/
void addChildren(unsigned int numChildren, aiNode **children);
#endif // __cplusplus
};

View File

@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# include <math.h>
#endif
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@ -126,7 +125,7 @@ public:
const aiVector3t SymMul(const aiVector3t& o);
TReal x, y, z;
} PACK_STRUCT;
};
typedef aiVector3t<ai_real> aiVector3D;
@ -135,16 +134,12 @@ typedef aiVector3t<ai_real> aiVector3D;
struct aiVector3D {
ai_real x, y, z;
} PACK_STRUCT;
};
#endif // __cplusplus
#include "./Compiler/poppack1.h"
#ifdef __cplusplus
#endif // __cplusplus
#endif // AI_VECTOR3D_H_INC

View File

@ -141,12 +141,34 @@ AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatri
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const {
return *(&x + i);
// return *(&x + i);
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
break;
}
return x;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) {
return *(&x + i);
// return *(&x + i);
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
break;
}
return x;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>

View File

@ -46,7 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <android/api-level.h>
#if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
#include <libgen.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <android/log.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
@ -100,6 +102,27 @@ void AndroidJNIIOSystem::AndroidActivityInit(ANativeActivity* activity)
mApkAssetManager = activity->assetManager;
}
// ------------------------------------------------------------------------------------------------
// Create the directory for the extracted resource
static int mkpath(std::string path, mode_t mode)
{
if (mkdir(path.c_str(), mode) == -1) {
switch(errno) {
case ENOENT:
if (mkpath(path.substr(0, path.find_last_of('/')), mode) == -1)
return -1;
else
return mkdir(path.c_str(), mode);
case EEXIST:
return 0;
default:
return -1;
}
}
return 0;
}
// ------------------------------------------------------------------------------------------------
// Extracts android asset
bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name)
@ -131,6 +154,15 @@ bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name)
// Close
AAsset_close(asset);
// Prepare directory for output buffer
std::string directoryNewPath = newPath;
directoryNewPath = dirname(&directoryNewPath[0]);
if (mkpath(directoryNewPath, S_IRUSR | S_IWUSR | S_IXUSR) == -1) {
__android_log_print(ANDROID_LOG_ERROR, "assimp",
"Can not create the directory for the output file");
}
// Prepare output buffer
std::ofstream assetExtracted(newPath.c_str(),
std::ios::out | std::ios::binary);

View File

@ -22,7 +22,7 @@ CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min)
CPP_DEV_TARGET=
CPP_STD_LIB_LIST=(libc++ libstdc++)
CPP_STD_LIB=
CPP_STD_LIST=(c++03 c++11 c++14)
CPP_STD_LIST=(c++11 c++14)
CPP_STD=
function join { local IFS="$1"; shift; echo "$*"; }

View File

@ -58,24 +58,16 @@ template_src = "BlenderScene.cpp.template"
# workaround for stackoverflowing when reading the linked list of scene objects
# with the usual approach. See embedded notes for details.
Structure_Convert_Base_fullcode = """
template <> void Structure :: Convert<Base> (
Base& dest,
const FileDatabase& db
) const
{
template <> void Structure::Convert<Base>( Base& dest, const FileDatabase& db ) const {
// note: as per https://github.com/assimp/assimp/issues/128,
// reading the Object linked list recursively is prone to stack overflow.
// This structure converter is therefore an hand-written exception that
// does it iteratively.
const int initial_pos = db.reader->GetCurrentPos();
std::pair<Base*, int> todo = std::make_pair(&dest, initial_pos);
Base* saved_prev = NULL;
while(true) {
Base& cur_dest = *todo.first;
db.reader->SetCurrentPos(todo.second);
@ -303,8 +295,3 @@ def main():
if __name__ == "__main__":
sys.exit(main())

View File

@ -94,6 +94,7 @@ SET( TEST_SRCS
unit/utIssues.cpp
unit/utJoinVertices.cpp
unit/utLimitBoneWeights.cpp
unit/utLWSImportExport.cpp
unit/utMaterialSystem.cpp
unit/utMatrix3x3.cpp
unit/utMatrix4x4.cpp
@ -103,6 +104,7 @@ SET( TEST_SRCS
unit/utSIBImporter.cpp
unit/utObjImportExport.cpp
unit/utPretransformVertices.cpp
unit/utPLYImportExport.cpp
unit/utRemoveComments.cpp
unit/utRemoveComponent.cpp
unit/utRemoveRedundantMaterials.cpp
@ -118,6 +120,7 @@ SET( TEST_SRCS
unit/utTypes.cpp
unit/utVertexTriangleAdjacency.cpp
unit/utVersion.cpp
unit/utVector3.cpp
unit/utXImporterExporter.cpp
)

View File

@ -0,0 +1,30 @@
g cube
v 0.0 0.0 0.0 124 110 120
v 0.0 0.0 1.0 24 0 121
v 0.0 1.0 0.0 4 0 44
v 0.0 1.0 1.0 224 0 10
v 1.0 0.0 0.0 24 200 25
v 1.0 0.0 1.0 124 10 56
v 1.0 1.0 0.0 78 10 50
v 1.0 1.0 1.0 23 0 200
vn 0.0 0.0 1.0
vn 0.0 0.0 -1.0
vn 0.0 1.0 0.0
vn 0.0 -1.0 0.0
vn 1.0 0.0 0.0
vn -1.0 0.0 0.0
f 1//2 7//2 5//2
f 1//2 3//2 7//2
f 1//6 4//6 3//6
f 1//6 2//6 4//6
f 3//3 8//3 7//3
f 3//3 4//3 8//3
f 5//5 7//5 8//5
f 5//5 8//5 6//5
f 1//4 5//4 6//4
f 1//4 6//4 2//4
f 2//1 6//1 8//1
f 2//1 8//1 4//1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
ply
format ascii 1.0
comment VCGLIB generated
element vertex 3
property float x
property float y
property float z
property float red
property float green
property float blue
property float alpha
element face 1
property list uchar int vertex_indices
end_header
0.0 0.0 0.0 0 0 1 1
100.0 0.0 0.0 0 0 1 1
200.0 200.0 0.0 0 0 1 1
3 0 1 2

View File

@ -46,4 +46,10 @@ class AbstractImportExportBase : public ::testing::Test {
public:
virtual ~AbstractImportExportBase();
virtual bool importerTest() = 0;
virtual bool exporterTest();
};
inline
bool AbstractImportExportBase::exporterTest() {
return true;
}

View File

@ -56,6 +56,6 @@ public:
}
};
TEST_F( utIFCImportExport, importHMPFromFileTest ) {
TEST_F( utIFCImportExport, importIFCFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View File

@ -0,0 +1,62 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
using namespace Assimp;
class utLWSImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/LWS/move_x.lws", 0 );
return nullptr != scene;
return true;
}
};
TEST_F( utLWSImportExport, importLWSFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View File

@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace ::Assimp;
class utMatrix3x3Test : public ::testing::Test {
// empty
};
TEST_F( utMatrix3x3Test, FromToMatrixTest ) {

View File

@ -42,9 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "UnitTestPCH.h"
#include "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
using namespace Assimp;
@ -189,13 +189,27 @@ protected:
}
virtual bool importerTest() {
Assimp::Importer importer;
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", 0 );
return nullptr != scene;
}
#ifndef ASSIMP_BUILD_NO_EXPORT
virtual bool exporterTest() {
::Assimp::Importer importer;
::Assimp::Exporter exporter;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", 0 );
EXPECT_NE( nullptr, scene );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj" ) );
return true;
}
#endif // ASSIMP_BUILD_NO_EXPORT
protected:
Assimp::Importer *m_im;
::Assimp::Importer *m_im;
aiScene *m_expectedScene;
};
@ -203,6 +217,14 @@ TEST_F( utObjImportExport, importObjFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F( utObjImportExport, exportObjFromFileTest ) {
EXPECT_TRUE( exporterTest() );
}
#endif // ASSIMP_BUILD_NO_EXPORT
TEST_F( utObjImportExport, obj_import_test ) {
const aiScene *scene = m_im->ReadFileFromMemory( (void*) ObjModel.c_str(), ObjModel.size(), 0 );
aiScene *expected = createScene();
@ -219,3 +241,14 @@ TEST_F( utObjImportExport, issue1111_no_mat_name_Test ) {
const aiScene *scene = m_im->ReadFileFromMemory( ( void* ) ObjModel_Issue1111.c_str(), ObjModel_Issue1111.size(), 0 );
EXPECT_NE( nullptr, scene );
}
TEST_F( utObjImportExport, issue809_vertex_color_Test ) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors.obj", 0 );
EXPECT_NE( nullptr, scene );
#ifndef ASSIMP_BUILD_NO_EXPORT
::Assimp::Exporter exporter;
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/test.obj" ) );
#endif // ASSIMP_BUILD_NO_EXPORT
}

View File

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/Importer.hpp>
#include "AbstractImportExportBase.h"
using namespace ::Assimp;
class utPLYImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", 0 );
return nullptr != scene;
}
};
TEST_F( utPLYImportExport, importTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utPLYImportExport, vertexColorTest ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/PLY/float-color.ply", 0 );
}

View File

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/scene.h>
using namespace ::Assimp;
class utScene : public ::testing::Test {
// empty
};
TEST_F( utScene, aiNode_addChildrenTest ) {
aiNode myNode;
static const size_t NumChildren = 10;
aiNode **childrenPtr = new aiNode*[ NumChildren ];
for ( unsigned int i = 0; i < NumChildren; i++ ) {
childrenPtr[ i ] = new aiNode;
}
myNode.addChildren( NumChildren, childrenPtr );
EXPECT_EQ( NumChildren, myNode.mNumChildren );
for ( unsigned int i = 0; i < NumChildren; i++ ) {
EXPECT_EQ( childrenPtr[ i ], myNode.mChildren[ i ] );
}
}

View File

@ -0,0 +1,69 @@
/*-------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------*/
#include "UnitTestPCH.h"
#include <assimp/vector3.h>
using namespace ::Assimp;
class utVector3 : public ::testing::Test {
// empty
};
TEST_F(utVector3, CreationTest) {
aiVector3D v0;
aiVector3D v1( 1.0f, 2.0f, 3.0f );
EXPECT_FLOAT_EQ (1.0f, v1[ 0 ] );
EXPECT_FLOAT_EQ( 2.0f, v1[ 1 ] );
EXPECT_FLOAT_EQ( 3.0f, v1[ 2 ] );
aiVector3D v2( 1 );
EXPECT_FLOAT_EQ( 1.0f, v2[ 0 ] );
EXPECT_FLOAT_EQ( 1.0f, v2[ 1 ] );
EXPECT_FLOAT_EQ( 1.0f, v2[ 2 ] );
aiVector3D v3( v1 );
EXPECT_FLOAT_EQ( v1[ 0 ], v3[ 0 ] );
EXPECT_FLOAT_EQ( v1[ 1 ], v3[ 1 ] );
EXPECT_FLOAT_EQ( v1[ 2 ], v3[ 2 ] );
}
TEST_F( utVector3, BracketOpTest ) {
aiVector3D v(1.0f, 2.0f, 3.0f);
EXPECT_FLOAT_EQ( 1.0f, v[ 0 ] );
EXPECT_FLOAT_EQ( 2.0f, v[ 1 ] );
EXPECT_FLOAT_EQ( 3.0f, v[ 2 ] );
}

View File

@ -1,124 +0,0 @@
LOCAL_PATH := $(call my-dir)/../../../
include $(CLEAR_VARS)
LOCAL_MODULE := assimp_static
ASSIMP_SRC_DIR = code
FILE_LIST := $(wildcard $(LOCAL_PATH)/$(ASSIMP_SRC_DIR)/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/contrib/openddlparser/code/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/contrib/unzip/*.c)
FILE_LIST += $(wildcard $(LOCAL_PATH)/contrib/poly2tri/poly2tri/*/*.cc)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_SRC_FILES += contrib/clipper/clipper.cpp \
contrib/ConvertUTF/ConvertUTF.c \
contrib/irrXML/irrXML.cpp
# enables -frtti and -fexceptions
LOCAL_CPP_FEATURES := exceptions
# identifier 'nullptr' will become a keyword in C++0x [-Wc++0x-compat]
# but next breaks blender and other importer
# LOCAL_CFLAGS += -std=c++11
# can't be disabled? rudamentary function?
# -DASSIMP_BUILD_NO_FLIPWINDING_PROCESS \
#
DontBuildProcess = \
-DASSIMP_BUILD_NO_FLIPUVS_PROCESS \
-DASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS \
-DASSIMP_BUILD_NO_CALCTANGENTS_PROCESS \
-DASSIMP_BUILD_NO_DEBONE_PROCESS \
-DASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS \
-DASSIMP_BUILD_NO_FINDINSTANCES_PROCESS \
-DASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS \
-DASSIMP_BUILD_NO_FIXINFACINGNORMALS_PROCESS \
-DASSIMP_BUILD_NO_GENFACENORMALS_PROCESS \
-DASSIMP_BUILD_NO_GENUVCOORDS_PROCESS \
-DASSIMP_BUILD_NO_GENVERTEXNORMALS_PROCESS \
-DASSIMP_BUILD_NO_IMPROVECACHELOCALITY_PROCESS \
-DASSIMP_BUILD_NO_JOINVERTICES_PROCESS \
-DASSIMP_BUILD_NO_LIMITBONEWEIGHTS_PROCESS \
-DASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS \
-DASSIMP_BUILD_NO_OPTIMIZEMESHES_PROCESS \
-DASSIMP_BUILD_NO_PRETRANSFORMVERTICES_PROCESS \
-DASSIMP_BUILD_NO_REMOVEVC_PROCESS \
-DASSIMP_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS \
-DASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS \
-DASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS \
-DASSIMP_BUILD_NO_SPLITLARGEMESHES_PROCESS \
-DASSIMP_BUILD_NO_TRANSFORMTEXCOORDS_PROCESS \
-DASSIMP_BUILD_NO_TRIANGULATE_PROCESS \
-DASSIMP_BUILD_NO_VALIDATEDS_PROCESS
DontBuildImporters = \
-DASSIMP_BUILD_NO_X_IMPORTER \
-DASSIMP_BUILD_NO_3DS_IMPORTER \
-DASSIMP_BUILD_NO_MD3_IMPORTER \
-DASSIMP_BUILD_NO_MDL_IMPORTER \
-DASSIMP_BUILD_NO_MD2_IMPORTER \
-DASSIMP_BUILD_NO_PLY_IMPORTER \
-DASSIMP_BUILD_NO_ASE_IMPORTER \
-DASSIMP_BUILD_NO_HMP_IMPORTER \
-DASSIMP_BUILD_NO_SMD_IMPORTER \
-DASSIMP_BUILD_NO_MDC_IMPORTER \
-DASSIMP_BUILD_NO_MD5_IMPORTER \
-DASSIMP_BUILD_NO_STL_IMPORTER \
-DASSIMP_BUILD_NO_LWO_IMPORTER \
-DASSIMP_BUILD_NO_DXF_IMPORTER \
-DASSIMP_BUILD_NO_NFF_IMPORTER \
-DASSIMP_BUILD_NO_RAW_IMPORTER \
-DASSIMP_BUILD_NO_OFF_IMPORTER \
-DASSIMP_BUILD_NO_AC_IMPORTER \
-DASSIMP_BUILD_NO_BVH_IMPORTER \
-DASSIMP_BUILD_NO_IRRMESH_IMPORTER \
-DASSIMP_BUILD_NO_IRR_IMPORTER \
-DASSIMP_BUILD_NO_Q3D_IMPORTER \
-DASSIMP_BUILD_NO_B3D_IMPORTER \
-DASSIMP_BUILD_NO_COLLADA_IMPORTER \
-DASSIMP_BUILD_NO_TERRAGEN_IMPORTER \
-DASSIMP_BUILD_NO_CSM_IMPORTER \
-DASSIMP_BUILD_NO_3D_IMPORTER \
-DASSIMP_BUILD_NO_LWS_IMPORTER \
-DASSIMP_BUILD_NO_OGRE_IMPORTER \
-DASSIMP_BUILD_NO_MS3D_IMPORTER \
-DASSIMP_BUILD_NO_COB_IMPORTER \
-DASSIMP_BUILD_NO_Q3BSP_IMPORTER \
-DASSIMP_BUILD_NO_NDO_IMPORTER \
-DASSIMP_BUILD_NO_IFC_IMPORTER \
-DASSIMP_BUILD_NO_XGL_IMPORTER \
-DASSIMP_BUILD_NO_FBX_IMPORTER \
-DASSIMP_BUILD_NO_C4D_IMPORTER \
-DASSIMP_BUILD_NO_OPENGEX_IMPORTER \
-DASSIMP_BUILD_NO_ASSBIN_IMPORTER
# -DASSIMP_BUILD_NO_BLEND_IMPORTER \
# -DASSIMP_BUILD_NO_GEO_IMPORTER
# -DASSIMP_BUILD_NO_OBJ_IMPORTER \
#
DontBuildImporters := -DASSIMP_BUILD_NO_IFC_IMPORTER -DASSIMP_BUILD_NO_IRRMESH_IMPORTER -DASSIMP_BUILD_NO_IRR_IMPORTER -DASSIMP_BUILD_NO_C4D_IMPORTER
ASSIMP_FLAGS_3_0 = -DASSIMP_BUILD_DLL_EXPORT -DASSIMP_BUILD_NO_OWN_ZLIB -DASSIMP_BUILD_BOOST_WORKAROUND -Dassimp_EXPORTS -fPIC -fvisibility=hidden -Wall
ASSIMP_FLAGS_3_1 = $(ASSIMP_FLAGS_3_0) # -DASSIMP_BUILD_BLENDER_DEBUG
LOCAL_CFLAGS += $(ASSIMP_FLAGS_3_1) -DASSIMP_BUILD_NO_EXPORT -DOPENDDL_NO_USE_CPP11 $(DontBuildImporters) # $(DontBuildProcess)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/$(ASSIMP_SRC_DIR)/BoostWorkaround $(LOCAL_PATH)/contrib/openddlparser/include ./
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/$(ASSIMP_SRC_DIR)/BoostWorkaround
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := assimp
LOCAL_CFLAGS += -UASSIMP_BUILD_DLL_EXPORT
LOCAL_WHOLE_STATIC_LIBRARIES = assimp_static
LOCAL_LDLIBS := -lz
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/$(ASSIMP_SRC_DIR)/BoostWorkaround
include $(BUILD_SHARED_LIBRARY)
-include $(LOCAL_PATH)/assimp_cmd.mk
# let it on original place
include $(LOCAL_PATH)/port/jassimp/jassimp-native/Android.mk

View File

@ -1,8 +0,0 @@
ifeq ($(CC),clang)
NDK_TOOLCHAIN_VERSION := $(CC)
$(info "Use llvm Compiler")
endif
APP_ABI := armeabi-v7a
APP_STL := stlport_static

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
The xcode project files in this directory are contributed by Andy Maloney and are not continuously updated.
Currently, it's for Assimp r352. If you're using a newer revision, watch out for missing files/includes/...
See Andy's description at
http://sourceforge.net/tracker/index.php?func=detail&aid=2659135&group_id=226462&atid=1067634 (Tracker item 2659135)
for more information.

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Assimp.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,80 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7F79227F1AB43AC3005A8E5D"
BuildableName = "libassimp.a"
BlueprintName = "assimp"
ReferencedContainer = "container:workspaces/xcode6/Assimp.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7F79227F1AB43AC3005A8E5D"
BuildableName = "libassimp.a"
BlueprintName = "assimp"
ReferencedContainer = "container:workspaces/xcode6/Assimp.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7F79227F1AB43AC3005A8E5D"
BuildableName = "libassimp.a"
BlueprintName = "assimp"
ReferencedContainer = "container:workspaces/xcode6/Assimp.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>