Merge branch 'master' into coverity_scan

pull/2286/head
Kim Kulling 2017-03-26 15:03:25 +02:00
commit b3089a5f33
294 changed files with 15677 additions and 15128 deletions

7
.gitattributes vendored
View File

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

36
CHANGES
View File

@ -2,7 +2,40 @@
CHANGELOG CHANGELOG
---------------------------------------------------------------------- ----------------------------------------------------------------------
3.2.1 (2016-10-01) 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: FEATURES:
- Updated glTF exporter to meet 1.0 specification. - Updated glTF exporter to meet 1.0 specification.
@ -17,7 +50,6 @@ ISSUES:
- void* in ExportData for accessor max and min. - void* in ExportData for accessor max and min.
3.2.0 (2015-11-03) 3.2.0 (2015-11-03)
FEATURES: FEATURES:

View File

@ -168,14 +168,15 @@ IF((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
ENDIF() ENDIF()
# hide all not-exported symbols # hide all not-exported symbols
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -std=c++0x" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fvisibility=hidden -Wall -std=c++0x" )
ELSEIF(MSVC) ELSEIF(MSVC)
# enable multi-core compilation with MSVC # enable multi-core compilation with MSVC
add_compile_options(/MP) add_compile_options(/MP)
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wno-long-long -pedantic -std=c++11" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fvisibility=hidden -Wall -Wno-long-long -pedantic -std=c++11" )
ELSEIF( CMAKE_COMPILER_IS_MINGW ) ELSEIF( CMAKE_COMPILER_IS_MINGW )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wno-long-long -pedantic -std=c++11" ) SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wno-long-long -pedantic -std=c++11" )
add_definitions( -U__STRICT_ANSI__ )
ENDIF() ENDIF()
if (ASSIMP_COVERALLS) if (ASSIMP_COVERALLS)
@ -184,9 +185,9 @@ if (ASSIMP_COVERALLS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
endif() endif()
INCLUDE (FindPkgConfig)
INCLUDE_DIRECTORIES( include ) INCLUDE_DIRECTORIES( include )
INCLUDE (FindPkgMacros)
INCLUDE (PrecompiledHeader) INCLUDE (PrecompiledHeader)
# If this is an in-source build (CMAKE_SOURCE_DIR == CMAKE_BINARY_DIR), # If this is an in-source build (CMAKE_SOURCE_DIR == CMAKE_BINARY_DIR),
@ -254,9 +255,7 @@ ENDIF(NOT ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
# Search for unzip # Search for unzip
IF (PKG_CONFIG_FOUND) use_pkgconfig(UNZIP minizip)
PKG_CHECK_MODULES(UNZIP minizip)
ENDIF (PKG_CONFIG_FOUND)
IF ( ASSIMP_NO_EXPORT ) IF ( ASSIMP_NO_EXPORT )
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_EXPORT) ADD_DEFINITIONS( -DASSIMP_BUILD_NO_EXPORT)
@ -329,12 +328,12 @@ ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
ADD_SUBDIRECTORY( code/ ) ADD_SUBDIRECTORY( code/ )
IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
IF ( WIN32 ) IF ( WIN32 AND DirectX_D3DX9_LIBRARY )
option ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} ) option ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} )
IF ( ASSIMP_BUILD_ASSIMP_VIEW ) IF ( ASSIMP_BUILD_ASSIMP_VIEW )
ADD_SUBDIRECTORY( tools/assimp_view/ ) ADD_SUBDIRECTORY( tools/assimp_view/ )
ENDIF ( ASSIMP_BUILD_ASSIMP_VIEW ) ENDIF ( ASSIMP_BUILD_ASSIMP_VIEW )
ENDIF ( WIN32 ) ENDIF ( WIN32 AND DirectX_D3DX9_LIBRARY )
ADD_SUBDIRECTORY( tools/assimp_cmd/ ) ADD_SUBDIRECTORY( tools/assimp_cmd/ )

View File

@ -92,7 +92,7 @@ Contributed the 'SimpleTexturedOpenGl' sample.
- Matthias Fauconneau - Matthias Fauconneau
Contributed a fix for the Q3-BSP loader. Contributed a fix for the Q3-BSP loader.
- J<EFBFBD>rgen P. Tjern<72> - Jørgen P. Tjernø
Contributed updated and improved xcode workspaces Contributed updated and improved xcode workspaces
- drparallax - drparallax
@ -137,7 +137,7 @@ GCC/Linux fixes for the SimpleOpenGL sample.
- Brian Miller - Brian Miller
Bugfix for a compiler fix for iOS on arm. Bugfix for a compiler fix for iOS on arm.
- S<EFBFBD>verin Lemaignan - Séverin Lemaignan
Rewrite of PyAssimp, distutils and Python3 support Rewrite of PyAssimp, distutils and Python3 support
- albert-wang - albert-wang

View File

@ -1,6 +1,15 @@
Open Asset Import Library (assimp) 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. 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. 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.
@ -8,21 +17,19 @@ Additionally, assimp features various __mesh post processing tools__: normals an
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. 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: The current build status is:
Linux [![Linux Build Status](https://travis-ci.org/assimp/assimp.png)](https://travis-ci.org/assimp/assimp)
Windows [![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp)
Coverity<a href="https://scan.coverity.com/projects/5607">
<img alt="Coverity Scan Build Status"
src="https://scan.coverity.com/projects/5607/badge.svg"/>
</a>
<br>
Code coverage:[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
<br>
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> 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.__ __[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 #### #### Supported file formats ####
A full list [is here](http://assimp.sourceforge.net/main_features_formats.html). A full list [is here](http://assimp.org/main_features_formats.html).
__Importers__: __Importers__:
- 3DS - 3DS
@ -90,6 +97,7 @@ Take a look into the `INSTALL` file. Our build system is CMake, if you used CMak
* [Python](port/PyAssimp/README.md) * [Python](port/PyAssimp/README.md)
* [.NET](port/AssimpNET/Readme.md) * [.NET](port/AssimpNET/Readme.md)
* [Pascal](port/AssimpPascal/Readme.md) * [Pascal](port/AssimpPascal/Readme.md)
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
#### Repository structure #### #### Repository structure ####
Open Asset Import Library is implemented in C++. The directory structure is: Open Asset Import Library is implemented in C++. The directory structure is:
@ -109,7 +117,7 @@ Open Asset Import Library is implemented in C++. The directory structure is:
### Where to get help ### ### Where to get help ###
For more information, visit [our website](http://assimp.sourceforge.net/). Or check out the `./doc`- folder, which contains the official documentation in HTML format. 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). (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. 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.

View File

@ -40,4 +40,3 @@ after_build:
artifacts: artifacts:
- path: assimp.7z - path: assimp.7z
name: assimp_lib name: assimp_lib

View File

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

View File

@ -690,7 +690,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,
pcOut->mChildren = new aiNode*[pcIn->mChildren.size()]; pcOut->mChildren = new aiNode*[pcIn->mChildren.size()];
// Recursively process all children // Recursively process all children
const unsigned int size = pcIn->mChildren.size(); const unsigned int size = static_cast<unsigned int>(pcIn->mChildren.size());
for (unsigned int i = 0; i < size;++i) for (unsigned int i = 0; i < size;++i)
{ {
pcOut->mChildren[i] = new aiNode(); pcOut->mChildren[i] = new aiNode();
@ -742,7 +742,7 @@ void Discreet3DSImporter::GenerateNodeGraph(aiScene* pcOut)
DefaultLogger::get()->warn("No hierarchy information has been found in the file. "); DefaultLogger::get()->warn("No hierarchy information has been found in the file. ");
pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes + pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes +
mScene->mCameras.size() + mScene->mLights.size(); static_cast<unsigned int>(mScene->mCameras.size() + mScene->mLights.size());
pcOut->mRootNode->mChildren = new aiNode* [ pcOut->mRootNode->mNumChildren ]; pcOut->mRootNode->mChildren = new aiNode* [ pcOut->mRootNode->mNumChildren ];
pcOut->mRootNode->mName.Set("<3DSDummyRoot>"); pcOut->mRootNode->mName.Set("<3DSDummyRoot>");

View File

@ -87,7 +87,7 @@ namespace {
const std::size_t chunk_size = head_pos - chunk_start_pos; const std::size_t chunk_size = head_pos - chunk_start_pos;
writer.SetCurrentPos(chunk_start_pos + SIZE_OFFSET); writer.SetCurrentPos(chunk_start_pos + SIZE_OFFSET);
writer.PutU4(chunk_size); writer.PutU4(static_cast<uint32_t>(chunk_size));
writer.SetCurrentPos(head_pos); writer.SetCurrentPos(head_pos);
} }

View File

@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
#include "StreamWriter.h" #include "StreamWriter.h"
#include "./../include/assimp/material.h" #include <assimp/material.h>
struct aiScene; struct aiScene;
struct aiNode; struct aiNode;

View File

@ -48,10 +48,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SmoothingGroups.h" #include "SmoothingGroups.h"
#include "StringUtils.h" #include "StringUtils.h"
#include "qnan.h" #include "qnan.h"
#include "./../include/assimp/material.h" #include <assimp/material.h>
#include "./../include/assimp/camera.h" #include <assimp/camera.h>
#include "./../include/assimp/light.h" #include <assimp/light.h>
#include "./../include/assimp/anim.h" #include <assimp/anim.h>
#include <stdio.h> //sprintf #include <stdio.h> //sprintf
namespace Assimp { namespace Assimp {

View File

@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/importerdesc.h>
#include "StringComparison.h" #include "StringComparison.h"
using namespace Assimp; using namespace Assimp;
@ -182,7 +183,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
ParseMainChunk(); ParseMainChunk();
// Process all meshes in the file. First check whether all // Process all meshes in the file. First check whether all
// face indices haev valid values. The generate our // face indices have valid values. The generate our
// internal verbose representation. Finally compute normal // internal verbose representation. Finally compute normal
// vectors from the smoothing groups we read from the // vectors from the smoothing groups we read from the
// file. // file.
@ -679,7 +680,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
if ( pcNode) if ( pcNode)
{ {
// if the source is not a CHUNK_TRACKINFO block it wont be an object instance // if the source is not a CHUNK_TRACKINFO block it won't be an object instance
if (parent != Discreet3DS::CHUNK_TRACKINFO) if (parent != Discreet3DS::CHUNK_TRACKINFO)
{ {
mCurrentNode = pcNode; mCurrentNode = pcNode;

View File

@ -60,6 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/config.h> #include <assimp/config.h>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/importerdesc.h>
#include <memory> #include <memory>
using namespace Assimp; using namespace Assimp;

View File

@ -51,11 +51,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AMFImporter_Macro.hpp" #include "AMFImporter_Macro.hpp"
#include "fast_atof.h" #include "fast_atof.h"
#include "DefaultIOSystem.h" #include <assimp/DefaultIOSystem.h>
// Header files, stdlib. // Header files, stdlib.
#include <memory> #include <memory>
#include <string>
namespace Assimp namespace Assimp
{ {
@ -188,15 +187,15 @@ void AMFImporter::XML_CheckNode_MustHaveChildren()
void AMFImporter::XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName) void AMFImporter::XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName)
{ {
const size_t Uns_Skip_Len = 3; static const size_t Uns_Skip_Len = 3;
const char* Uns_Skip[Uns_Skip_Len] = { "composite", "edge", "normal" }; const char* Uns_Skip[Uns_Skip_Len] = { "composite", "edge", "normal" };
static bool skipped_before[Uns_Skip_Len] = { false, false, false }; static bool skipped_before[Uns_Skip_Len] = { false, false, false };
std::string nn(mReader->getNodeName()); std::string nn(mReader->getNodeName());
bool found = false; bool found = false;
bool close_found = false; bool close_found = false;
size_t sk_idx; size_t sk_idx;
for(sk_idx = 0; sk_idx < Uns_Skip_Len; sk_idx++) for(sk_idx = 0; sk_idx < Uns_Skip_Len; sk_idx++)
{ {
@ -245,7 +244,7 @@ bool AMFImporter::XML_SearchNode(const std::string& pNodeName)
bool AMFImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx) bool AMFImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx)
{ {
std::string val(mReader->getAttributeValue(pAttrIdx)); std::string val(mReader->getAttributeValue(pAttrIdx));
if((val == "false") || (val == "0")) if((val == "false") || (val == "0"))
return false; return false;
@ -257,8 +256,8 @@ std::string val(mReader->getAttributeValue(pAttrIdx));
float AMFImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) float AMFImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx)
{ {
std::string val; std::string val;
float tvalf; float tvalf;
ParseHelper_FixTruncatedFloatString(mReader->getAttributeValue(pAttrIdx), val); ParseHelper_FixTruncatedFloatString(mReader->getAttributeValue(pAttrIdx), val);
fast_atoreal_move(val.c_str(), tvalf, false); fast_atoreal_move(val.c_str(), tvalf, false);
@ -273,8 +272,8 @@ uint32_t AMFImporter::XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx)
float AMFImporter::XML_ReadNode_GetVal_AsFloat() float AMFImporter::XML_ReadNode_GetVal_AsFloat()
{ {
std::string val; std::string val;
float tvalf; float tvalf;
if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. No data, seems file is corrupt."); if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. No data, seems file is corrupt.");
if(mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. Invalid type of XML element, seems file is corrupt."); if(mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. Invalid type of XML element, seems file is corrupt.");
@ -320,7 +319,7 @@ void AMFImporter::ParseHelper_Node_Exit()
void AMFImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString) void AMFImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString)
{ {
size_t instr_len; size_t instr_len;
pOutString.clear(); pOutString.clear();
instr_len = strlen(pInStr); instr_len = strlen(pInStr);
@ -352,12 +351,12 @@ static bool ParseHelper_Decode_Base64_IsBase64(const char pChar)
void AMFImporter::ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const void AMFImporter::ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const
{ {
// With help from // With help from
// RenИ Nyffenegger http://www.adp-gmbh.ch/cpp/common/base64.html // René Nyffenegger http://www.adp-gmbh.ch/cpp/common/base64.html
const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
uint8_t tidx = 0; uint8_t tidx = 0;
uint8_t arr4[4], arr3[3]; uint8_t arr4[4], arr3[3];
// check input data // check input data
if(pInputBase64.size() % 4) throw DeadlyImportError("Base64-encoded data must have size multiply of four."); if(pInputBase64.size() % 4) throw DeadlyImportError("Base64-encoded data must have size multiply of four.");
@ -402,8 +401,8 @@ uint8_t arr4[4], arr3[3];
void AMFImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler) void AMFImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
{ {
irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader. irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader.
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb")); std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
// Check whether we can read from the file // Check whether we can read from the file
if(file.get() == NULL) throw DeadlyImportError("Failed to open AMF file " + pFile + "."); if(file.get() == NULL) throw DeadlyImportError("Failed to open AMF file " + pFile + ".");
@ -434,8 +433,8 @@ std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
// Multi elements - No. // Multi elements - No.
void AMFImporter::ParseNode_Root() void AMFImporter::ParseNode_Root()
{ {
std::string unit, version; std::string unit, version;
CAMFImporter_NodeElement* ne; CAMFImporter_NodeElement *ne( nullptr );
// Read attributes for node <amf>. // Read attributes for node <amf>.
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
@ -481,8 +480,8 @@ CAMFImporter_NodeElement* ne;
// Parent element - <amf>. // Parent element - <amf>.
void AMFImporter::ParseNode_Constellation() void AMFImporter::ParseNode_Constellation()
{ {
std::string id; std::string id;
CAMFImporter_NodeElement* ne; CAMFImporter_NodeElement* ne( nullptr );
// Read attributes for node <constellation>. // Read attributes for node <constellation>.
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
@ -522,8 +521,8 @@ CAMFImporter_NodeElement* ne;
// Parent element - <amf>. // Parent element - <amf>.
void AMFImporter::ParseNode_Instance() void AMFImporter::ParseNode_Instance()
{ {
std::string objectid; std::string objectid;
CAMFImporter_NodeElement* ne; CAMFImporter_NodeElement* ne( nullptr );
// Read attributes for node <constellation>. // Read attributes for node <constellation>.
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
@ -577,8 +576,8 @@ CAMFImporter_NodeElement* ne;
// Parent element - <amf>. // Parent element - <amf>.
void AMFImporter::ParseNode_Object() void AMFImporter::ParseNode_Object()
{ {
std::string id; std::string id;
CAMFImporter_NodeElement* ne; CAMFImporter_NodeElement* ne( nullptr );
// Read attributes for node <object>. // Read attributes for node <object>.
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
@ -642,8 +641,8 @@ CAMFImporter_NodeElement* ne;
// "Volume" - specifies the total volume of the entity, in the entity's unit system, to be used for verification (object and volume only) // "Volume" - specifies the total volume of the entity, in the entity's unit system, to be used for verification (object and volume only)
void AMFImporter::ParseNode_Metadata() void AMFImporter::ParseNode_Metadata()
{ {
std::string type, value; std::string type, value;
CAMFImporter_NodeElement* ne; CAMFImporter_NodeElement* ne( nullptr );
// read attribute // read attribute
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
@ -665,15 +664,17 @@ CAMFImporter_NodeElement* ne;
bool AMFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const bool AMFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const
{ {
const std::string extension = GetExtension(pFile); const std::string extension = GetExtension(pFile);
if(extension == "amf") return true; if ( extension == "amf" ) {
return true;
}
if(!extension.length() || pCheckSig) if(!extension.length() || pCheckSig)
{ {
const char* tokens[] = { "<?xml", "<amf" }; const char* tokens[] = { "<amf" };
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2); return SearchFileHeaderForToken( pIOHandler, pFile, tokens, 1 );
} }
return false; return false;

View File

@ -52,9 +52,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AMFImporter_Node.hpp" #include "AMFImporter_Node.hpp"
// Header files, Assimp. // Header files, Assimp.
#include "assimp/DefaultLogger.hpp" #include <assimp/DefaultLogger.hpp>
#include "assimp/importerdesc.h" #include <assimp/importerdesc.h>
#include "assimp/ProgressHandler.hpp"
#include "assimp/types.h" #include "assimp/types.h"
#include "BaseImporter.h" #include "BaseImporter.h"
#include "irrXMLWrapper.h" #include "irrXMLWrapper.h"
@ -135,18 +134,18 @@ private:
}; };
/// \struct SPP_Texture /// \struct SPP_Texture
/// Data type for postprocessing step. More suitable container for texture. /// Data type for post-processing step. More suitable container for texture.
struct SPP_Texture struct SPP_Texture
{ {
std::string ID; std::string ID;
size_t Width, Height, Depth; size_t Width, Height, Depth;
bool Tiled; bool Tiled;
decltype(aiTexture::achFormatHint) FormatHint; char FormatHint[ 9 ];// 8 for string + 1 for terminator.
uint8_t* Data; uint8_t *Data;
}; };
/// \struct SComplexFace /// \struct SComplexFace
/// Data type for postprocessing step. Contain face data. /// Data type for post-processing step. Contain face data.
struct SComplexFace struct SComplexFace
{ {
aiFace Face;///< Face vertices. aiFace Face;///< Face vertices.

View File

@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "StringUtils.h" #include "StringUtils.h"
// Header files, stdlib. // Header files, stdlib.
#include <algorithm>
#include <iterator> #include <iterator>
namespace Assimp namespace Assimp
@ -62,7 +61,7 @@ namespace Assimp
aiColor4D AMFImporter::SPP_Material::GetColor(const float pX, const float pY, const float pZ) const aiColor4D AMFImporter::SPP_Material::GetColor(const float pX, const float pY, const float pZ) const
{ {
aiColor4D tcol; aiColor4D tcol;
// Check if stored data are supported. // Check if stored data are supported.
if(Composition.size() != 0) if(Composition.size() != 0)
@ -93,8 +92,8 @@ aiColor4D tcol;
void AMFImporter::PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray, void AMFImporter::PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray,
std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const
{ {
CAMFImporter_NodeElement_Vertices* vn = nullptr; CAMFImporter_NodeElement_Vertices* vn = nullptr;
size_t col_idx; size_t col_idx;
// All data stored in "vertices", search for it. // All data stored in "vertices", search for it.
for(CAMFImporter_NodeElement* ne_child: pNodeElement.Child) for(CAMFImporter_NodeElement* ne_child: pNodeElement.Child)
@ -142,8 +141,8 @@ size_t col_idx;
size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B,
const std::string& pID_A) const std::string& pID_A)
{ {
size_t TextureConverted_Index; size_t TextureConverted_Index;
std::string TextureConverted_ID; std::string TextureConverted_ID;
// check input data // check input data
if(pID_R.empty() && pID_G.empty() && pID_B.empty() && pID_A.empty()) if(pID_R.empty() && pID_G.empty() && pID_B.empty() && pID_A.empty())
@ -261,11 +260,20 @@ std::string TextureConverted_ID;
size_t off_b = 0; size_t off_b = 0;
// Calculate size of the target array and rule how data will be copied. // 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 ( nullptr != src_texture ) {
if(!pID_G.empty()) { tex_size += src_texture[1]->Data.size(); step++, off_b++; } if(!pID_R.empty()) {
if(!pID_B.empty()) { tex_size += src_texture[2]->Data.size(); step++; } tex_size += src_texture[0]->Data.size(); step++, off_g++, off_b++;
if(!pID_A.empty()) { tex_size += src_texture[3]->Data.size(); step++; } }
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. // Create target array.
converted_texture.Data = new uint8_t[tex_size]; converted_texture.Data = new uint8_t[tex_size];
// And copy data // And copy data
@ -293,8 +301,8 @@ std::string TextureConverted_ID;
void AMFImporter::PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> >& pOutputList_Separated) void AMFImporter::PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> >& pOutputList_Separated)
{ {
auto texmap_is_equal = [](const CAMFImporter_NodeElement_TexMap* pTexMap1, const CAMFImporter_NodeElement_TexMap* pTexMap2) -> bool auto texmap_is_equal = [](const CAMFImporter_NodeElement_TexMap* pTexMap1, const CAMFImporter_NodeElement_TexMap* pTexMap2) -> bool
{ {
if((pTexMap1 == nullptr) && (pTexMap2 == nullptr)) return true; if((pTexMap1 == nullptr) && (pTexMap2 == nullptr)) return true;
if(pTexMap1 == nullptr) return false; if(pTexMap1 == nullptr) return false;
if(pTexMap2 == nullptr) return false; if(pTexMap2 == nullptr) return false;
@ -305,7 +313,7 @@ auto texmap_is_equal = [](const CAMFImporter_NodeElement_TexMap* pTexMap1, const
if(pTexMap1->TextureID_A != pTexMap2->TextureID_A) return false; if(pTexMap1->TextureID_A != pTexMap2->TextureID_A) return false;
return true; return true;
}; };
pOutputList_Separated.clear(); pOutputList_Separated.clear();
if(pInputList.size() == 0) return; if(pInputList.size() == 0) return;
@ -343,12 +351,12 @@ void AMFImporter::Postprocess_AddMetadata(const std::list<CAMFImporter_NodeEleme
if(sceneNode.mMetaData != nullptr) throw DeadlyImportError("Postprocess. MetaData member in node are not nullptr. Something went wrong."); if(sceneNode.mMetaData != nullptr) throw DeadlyImportError("Postprocess. MetaData member in node are not nullptr. Something went wrong.");
// copy collected metadata to output node. // copy collected metadata to output node.
sceneNode.mMetaData = aiMetadata::Alloc( metadataList.size() ); sceneNode.mMetaData = aiMetadata::Alloc( static_cast<unsigned int>(metadataList.size()) );
size_t meta_idx( 0 ); size_t meta_idx( 0 );
for(const CAMFImporter_NodeElement_Metadata& metadata: metadataList) for(const CAMFImporter_NodeElement_Metadata& metadata: metadataList)
{ {
sceneNode.mMetaData->Set(meta_idx++, metadata.Type, aiString(metadata.Value)); sceneNode.mMetaData->Set(static_cast<unsigned int>(meta_idx++), metadata.Type, aiString(metadata.Value));
} }
}// if(!metadataList.empty()) }// if(!metadataList.empty())
} }
@ -437,9 +445,9 @@ std::list<unsigned int> mesh_idx;
// create new face and store it. // create new face and store it.
complex_face.Face.mNumIndices = 3; complex_face.Face.mNumIndices = 3;
complex_face.Face.mIndices = new unsigned int[3]; complex_face.Face.mIndices = new unsigned int[3];
complex_face.Face.mIndices[0] = tri_al.V[0]; complex_face.Face.mIndices[0] = static_cast<unsigned int>(tri_al.V[0]);
complex_face.Face.mIndices[1] = tri_al.V[1]; complex_face.Face.mIndices[1] = static_cast<unsigned int>(tri_al.V[1]);
complex_face.Face.mIndices[2] = tri_al.V[2]; complex_face.Face.mIndices[2] = static_cast<unsigned int>(tri_al.V[2]);
complex_faces_list.push_back(complex_face); complex_faces_list.push_back(complex_face);
} }
}// for(const CAMFImporter_NodeElement* ne_volume_child: ne_volume->Child) }// for(const CAMFImporter_NodeElement* ne_volume_child: ne_volume->Child)
@ -508,7 +516,7 @@ std::list<unsigned int> mesh_idx;
{ {
for(size_t vi = 0; vi < face.Face.mNumIndices; vi++) for(size_t vi = 0; vi < face.Face.mNumIndices; vi++)
{ {
if(face.Face.mIndices[vi] == pIdx_From) face.Face.mIndices[vi] = pIdx_To; if(face.Face.mIndices[vi] == pIdx_From) face.Face.mIndices[vi] = static_cast<unsigned int>(pIdx_To);
} }
} }
};// auto VertexIndex_Replace = [](std::list<SComplexFace>& pFaceList, const size_t pIdx_From, const size_t pIdx_To) -> void };// auto VertexIndex_Replace = [](std::list<SComplexFace>& pFaceList, const size_t pIdx_From, const size_t pIdx_To) -> void
@ -563,7 +571,7 @@ std::list<unsigned int> mesh_idx;
// set geometry and colors (vertices) // set geometry and colors (vertices)
// //
// copy faces/triangles // copy faces/triangles
tmesh->mNumFaces = face_list_cur.size(); tmesh->mNumFaces = static_cast<unsigned int>(face_list_cur.size());
tmesh->mFaces = new aiFace[tmesh->mNumFaces]; tmesh->mFaces = new aiFace[tmesh->mNumFaces];
// Create vertices list and optimize indices. Optimisation mean following.In AMF all volumes use one big list of vertices. And one volume // Create vertices list and optimize indices. Optimisation mean following.In AMF all volumes use one big list of vertices. And one volume
@ -590,7 +598,7 @@ std::list<unsigned int> mesh_idx;
do do
{ {
vert_idx_from = VertexIndex_GetMinimal(face_list_cur, &vert_idx_to); vert_idx_from = VertexIndex_GetMinimal(face_list_cur, &vert_idx_to);
if(vert_idx_from == vert_idx_to) break;// all indices are transfered, if(vert_idx_from == vert_idx_to) break;// all indices are transferred,
vert_arr.push_back(pVertexCoordinateArray.at(vert_idx_from)); vert_arr.push_back(pVertexCoordinateArray.at(vert_idx_from));
col_arr.push_back(Vertex_CalculateColor(vert_idx_from)); col_arr.push_back(Vertex_CalculateColor(vert_idx_from));
@ -619,7 +627,7 @@ std::list<unsigned int> mesh_idx;
{ {
vert_arr.push_back(vert_arr.at(face_cur.Face.mIndices[idx_ind])); vert_arr.push_back(vert_arr.at(face_cur.Face.mIndices[idx_ind]));
col_arr.push_back(face_color); col_arr.push_back(face_color);
face_cur.Face.mIndices[idx_ind] = vert_idx_new++; face_cur.Face.mIndices[idx_ind] = static_cast<unsigned int>(vert_idx_new++);
} }
}// if(face_cur.Color != nullptr) }// if(face_cur.Color != nullptr)
}// for(const SComplexFace& face_cur: face_list_cur) }// for(const SComplexFace& face_cur: face_list_cur)
@ -639,10 +647,10 @@ std::list<unsigned int> mesh_idx;
for(size_t i = 0, i_e = VertexCount_Max * 2; i < i_e; i++) idx_vert_used[i] = false; for(size_t i = 0, i_e = VertexCount_Max * 2; i < i_e; i++) idx_vert_used[i] = false;
// This ID's will be used when set materials ID in scene. // This ID's will be used when set materials ID in scene.
tmesh->mMaterialIndex = PostprocessHelper_GetTextureID_Or_Create(face_list_cur.front().TexMap->TextureID_R, tmesh->mMaterialIndex = static_cast<unsigned int>(PostprocessHelper_GetTextureID_Or_Create(face_list_cur.front().TexMap->TextureID_R,
face_list_cur.front().TexMap->TextureID_G, face_list_cur.front().TexMap->TextureID_G,
face_list_cur.front().TexMap->TextureID_B, face_list_cur.front().TexMap->TextureID_B,
face_list_cur.front().TexMap->TextureID_A); face_list_cur.front().TexMap->TextureID_A));
texcoord_arr.resize(VertexCount_Max * 2); texcoord_arr.resize(VertexCount_Max * 2);
for(const SComplexFace& face_cur: face_list_cur) for(const SComplexFace& face_cur: face_list_cur)
{ {
@ -662,7 +670,7 @@ std::list<unsigned int> mesh_idx;
vert_arr.push_back(vert_arr.at(idx_vert)); vert_arr.push_back(vert_arr.at(idx_vert));
col_arr.push_back(col_arr.at(idx_vert)); col_arr.push_back(col_arr.at(idx_vert));
texcoord_arr.at(idx_vert_new) = face_cur.TexMap->TextureCoordinate[idx_ind]; texcoord_arr.at(idx_vert_new) = face_cur.TexMap->TextureCoordinate[idx_ind];
face_cur.Face.mIndices[idx_ind] = idx_vert_new++; face_cur.Face.mIndices[idx_ind] = static_cast<unsigned int>(idx_vert_new++);
} }
}// for(size_t idx_ind = 0; idx_ind < face_cur.Face.mNumIndices; idx_ind++) }// for(size_t idx_ind = 0; idx_ind < face_cur.Face.mNumIndices; idx_ind++)
}// for(const SComplexFace& face_cur: face_list_cur) }// for(const SComplexFace& face_cur: face_list_cur)
@ -675,7 +683,7 @@ std::list<unsigned int> mesh_idx;
// //
// copy collected data to mesh // copy collected data to mesh
// //
tmesh->mNumVertices = vert_arr.size(); tmesh->mNumVertices = static_cast<unsigned int>(vert_arr.size());
tmesh->mVertices = new aiVector3D[tmesh->mNumVertices]; tmesh->mVertices = new aiVector3D[tmesh->mNumVertices];
tmesh->mColors[0] = new aiColor4D[tmesh->mNumVertices]; tmesh->mColors[0] = new aiColor4D[tmesh->mNumVertices];
tmesh->mFaces = new aiFace[face_list_cur.size()]; tmesh->mFaces = new aiFace[face_list_cur.size()];
@ -693,7 +701,7 @@ std::list<unsigned int> mesh_idx;
for(const SComplexFace& face_cur: face_list_cur) tmesh->mFaces[idx_face++] = face_cur.Face; for(const SComplexFace& face_cur: face_list_cur) tmesh->mFaces[idx_face++] = face_cur.Face;
// store new aiMesh // store new aiMesh
mesh_idx.push_back(pMeshList.size()); mesh_idx.push_back(static_cast<unsigned int>(pMeshList.size()));
pMeshList.push_back(tmesh); pMeshList.push_back(tmesh);
}// for(const std::list<SComplexFace>& face_list_cur: complex_faces_toplist) }// for(const std::list<SComplexFace>& face_list_cur: complex_faces_toplist)
}// if(ne_child->Type == CAMFImporter_NodeElement::ENET_Volume) }// if(ne_child->Type == CAMFImporter_NodeElement::ENET_Volume)
@ -704,7 +712,7 @@ std::list<unsigned int> mesh_idx;
{ {
std::list<unsigned int>::const_iterator mit = mesh_idx.begin(); std::list<unsigned int>::const_iterator mit = mesh_idx.begin();
pSceneNode.mNumMeshes = mesh_idx.size(); pSceneNode.mNumMeshes = static_cast<unsigned int>(mesh_idx.size());
pSceneNode.mMeshes = new unsigned int[pSceneNode.mNumMeshes]; pSceneNode.mMeshes = new unsigned int[pSceneNode.mNumMeshes];
for(size_t i = 0; i < pSceneNode.mNumMeshes; i++) pSceneNode.mMeshes[i] = *mit++; for(size_t i = 0; i < pSceneNode.mNumMeshes; i++) pSceneNode.mMeshes[i] = *mit++;
}// if(mesh_idx.size() > 0) }// if(mesh_idx.size() > 0)
@ -743,7 +751,7 @@ std::list<aiNode*> ch_node;
// \_ aiNode for transformation (<instance> -> <delta...>, <r...>) - aiNode for pointing to object ("objectid") // \_ aiNode for transformation (<instance> -> <delta...>, <r...>) - aiNode for pointing to object ("objectid")
con_node = new aiNode; con_node = new aiNode;
con_node->mName = pConstellation.ID; con_node->mName = pConstellation.ID;
// Walk thru children and search for instances of another objects, constellations. // Walk through children and search for instances of another objects, constellations.
for(const CAMFImporter_NodeElement* ne: pConstellation.Child) for(const CAMFImporter_NodeElement* ne: pConstellation.Child)
{ {
aiMatrix4x4 tmat; aiMatrix4x4 tmat;
@ -779,7 +787,7 @@ std::list<aiNode*> ch_node;
size_t ch_idx = 0; size_t ch_idx = 0;
con_node->mNumChildren = ch_node.size(); con_node->mNumChildren = static_cast<unsigned int>(ch_node.size());
con_node->mChildren = new aiNode*[con_node->mNumChildren]; con_node->mChildren = new aiNode*[con_node->mNumChildren];
for(aiNode* node: ch_node) con_node->mChildren[ch_idx++] = node; for(aiNode* node: ch_node) con_node->mChildren[ch_idx++] = node;
@ -815,7 +823,7 @@ std::list<CAMFImporter_NodeElement_Metadata*> meta_list;
// Check if root element are found. // Check if root element are found.
if(root_el == nullptr) throw DeadlyImportError("Root(<amf>) element not found."); if(root_el == nullptr) throw DeadlyImportError("Root(<amf>) element not found.");
// after that walk thru children of root and collect data. Five types of nodes can be placed at top level - in <amf>: <object>, <material>, <texture>, // after that walk through children of root and collect data. Five types of nodes can be placed at top level - in <amf>: <object>, <material>, <texture>,
// <constellation> and <metadata>. But at first we must read <material> and <texture> because they will be used in <object>. <metadata> can be read // <constellation> and <metadata>. But at first we must read <material> and <texture> because they will be used in <object>. <metadata> can be read
// at any moment. // at any moment.
// //
@ -870,7 +878,7 @@ nl_clean_loop:
if(node_list.size() > 1) if(node_list.size() > 1)
{ {
// walk thru all nodes // walk through all nodes
for(std::list<aiNode*>::iterator nl_it = node_list.begin(); nl_it != node_list.end(); nl_it++) for(std::list<aiNode*>::iterator nl_it = node_list.begin(); nl_it != node_list.end(); nl_it++)
{ {
// and try to find them in another top nodes. // and try to find them in another top nodes.
@ -899,7 +907,7 @@ nl_clean_loop:
{ {
std::list<aiNode*>::const_iterator nl_it = node_list.begin(); std::list<aiNode*>::const_iterator nl_it = node_list.begin();
pScene->mRootNode->mNumChildren = node_list.size(); pScene->mRootNode->mNumChildren = static_cast<unsigned int>(node_list.size());
pScene->mRootNode->mChildren = new aiNode*[pScene->mRootNode->mNumChildren]; pScene->mRootNode->mChildren = new aiNode*[pScene->mRootNode->mNumChildren];
for(size_t i = 0; i < pScene->mRootNode->mNumChildren; i++) for(size_t i = 0; i < pScene->mRootNode->mNumChildren; i++)
{ {
@ -916,14 +924,14 @@ nl_clean_loop:
{ {
std::list<aiMesh*>::const_iterator ml_it = mesh_list.begin(); std::list<aiMesh*>::const_iterator ml_it = mesh_list.begin();
pScene->mNumMeshes = mesh_list.size(); pScene->mNumMeshes = static_cast<unsigned int>(mesh_list.size());
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
for(size_t i = 0; i < pScene->mNumMeshes; i++) pScene->mMeshes[i] = *ml_it++; for(size_t i = 0; i < pScene->mNumMeshes; i++) pScene->mMeshes[i] = *ml_it++;
}// if(mesh_list.size() > 0) }// if(mesh_list.size() > 0)
// //
// Textures // Textures
pScene->mNumTextures = mTexture_Converted.size(); pScene->mNumTextures = static_cast<unsigned int>(mTexture_Converted.size());
if(pScene->mNumTextures > 0) if(pScene->mNumTextures > 0)
{ {
size_t idx; size_t idx;
@ -933,8 +941,8 @@ nl_clean_loop:
for(const SPP_Texture& tex_convd: mTexture_Converted) for(const SPP_Texture& tex_convd: mTexture_Converted)
{ {
pScene->mTextures[idx] = new aiTexture; pScene->mTextures[idx] = new aiTexture;
pScene->mTextures[idx]->mWidth = tex_convd.Width; pScene->mTextures[idx]->mWidth = static_cast<unsigned int>(tex_convd.Width);
pScene->mTextures[idx]->mHeight = tex_convd.Height; pScene->mTextures[idx]->mHeight = static_cast<unsigned int>(tex_convd.Height);
pScene->mTextures[idx]->pcData = (aiTexel*)tex_convd.Data; pScene->mTextures[idx]->pcData = (aiTexel*)tex_convd.Data;
// texture format description. // texture format description.
strcpy(pScene->mTextures[idx]->achFormatHint, tex_convd.FormatHint); strcpy(pScene->mTextures[idx]->achFormatHint, tex_convd.FormatHint);
@ -943,7 +951,7 @@ nl_clean_loop:
// Create materials for embedded textures. // Create materials for embedded textures.
idx = 0; idx = 0;
pScene->mNumMaterials = mTexture_Converted.size(); pScene->mNumMaterials = static_cast<unsigned int>(mTexture_Converted.size());
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
for(const SPP_Texture& tex_convd: mTexture_Converted) for(const SPP_Texture& tex_convd: mTexture_Converted)
{ {
@ -959,7 +967,7 @@ nl_clean_loop:
idx++; idx++;
} }
}// if(pScene->mNumTextures > 0) }// if(pScene->mNumTextures > 0)
}// END: after that walk thru children of root and collect data }// END: after that walk through children of root and collect data
}// namespace Assimp }// namespace Assimp

View File

@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/importerdesc.h>
#include <memory> #include <memory>

View File

@ -46,9 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BaseImporter.h" #include "BaseImporter.h"
#include <assimp/types.h> #include <assimp/types.h>
#include "ASEParser.h"
struct aiNode; struct aiNode;
#include "ASEParser.h"
namespace Assimp { namespace Assimp {

View File

@ -49,7 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// internal headers // internal headers
#include "TextureTransform.h" #include "TextureTransform.h"
#include "ASELoader.h" #include "ASELoader.h"
#include "MaterialSystem.h"
#include "fast_atof.h" #include "fast_atof.h"
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
@ -1135,7 +1134,7 @@ void Parser::ParseLV3ScaleAnimationBlock(ASE::Animation& anim)
bool b = false; bool b = false;
// For the moment we're just reading the three floats - // For the moment we're just reading the three floats -
// we ignore the <EFBFBD>dditional information for bezier's and TCBs // we ignore the additional information for bezier's and TCBs
// simple scaling keyframe // simple scaling keyframe
if (TokenMatch(filePtr,"CONTROL_SCALE_SAMPLE" ,20)) if (TokenMatch(filePtr,"CONTROL_SCALE_SAMPLE" ,20))
@ -1181,7 +1180,7 @@ void Parser::ParseLV3PosAnimationBlock(ASE::Animation& anim)
bool b = false; bool b = false;
// For the moment we're just reading the three floats - // For the moment we're just reading the three floats -
// we ignore the <EFBFBD>dditional information for bezier's and TCBs // we ignore the additional information for bezier's and TCBs
// simple scaling keyframe // simple scaling keyframe
if (TokenMatch(filePtr,"CONTROL_POS_SAMPLE" ,18)) if (TokenMatch(filePtr,"CONTROL_POS_SAMPLE" ,18))
@ -1227,7 +1226,7 @@ void Parser::ParseLV3RotAnimationBlock(ASE::Animation& anim)
bool b = false; bool b = false;
// For the moment we're just reading the floats - // For the moment we're just reading the floats -
// we ignore the <EFBFBD>dditional information for bezier's and TCBs // we ignore the additional information for bezier's and TCBs
// simple scaling keyframe // simple scaling keyframe
if (TokenMatch(filePtr,"CONTROL_ROT_SAMPLE" ,18)) if (TokenMatch(filePtr,"CONTROL_ROT_SAMPLE" ,18))
@ -1858,7 +1857,7 @@ void Parser::ParseLV3MeshCFaceListBlock(unsigned int iNumFaces, ASE::Mesh& mesh)
++filePtr; ++filePtr;
// Face entry // Face entry
if (TokenMatch(filePtr,"MESH_CFACE" ,11)) if (TokenMatch(filePtr,"MESH_CFACE" ,10))
{ {
unsigned int aiValues[3]; unsigned int aiValues[3];
unsigned int iIndex = 0; unsigned int iIndex = 0;

View File

@ -737,7 +737,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size)
AssbinChunkWriter uncompressedStream( NULL, 0 ); AssbinChunkWriter uncompressedStream( NULL, 0 );
WriteBinaryScene( &uncompressedStream, pScene ); WriteBinaryScene( &uncompressedStream, pScene );
uLongf uncompressedSize = uncompressedStream.Tell(); uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());
uLongf compressedSize = (uLongf)(uncompressedStream.Tell() * 1.001 + 12.); uLongf compressedSize = (uLongf)(uncompressedStream.Tell() * 1.001 + 12.);
uint8_t* compressedBuffer = new uint8_t[ compressedSize ]; uint8_t* compressedBuffer = new uint8_t[ compressedSize ];

View File

@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/mesh.h> #include <assimp/mesh.h>
#include <assimp/anim.h> #include <assimp/anim.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/importerdesc.h>
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB #ifdef ASSIMP_BUILD_NO_OWN_ZLIB
# include <zlib.h> # include <zlib.h>
@ -659,7 +660,7 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
if (compressed) if (compressed)
{ {
uLongf uncompressedSize = Read<uint32_t>(stream); uLongf uncompressedSize = Read<uint32_t>(stream);
uLongf compressedSize = stream->FileSize() - stream->Tell(); uLongf compressedSize = static_cast<uLongf>(stream->FileSize() - stream->Tell());
unsigned char * compressedData = new unsigned char[ compressedSize ]; unsigned char * compressedData = new unsigned char[ compressedSize ];
stream->Read( compressedData, 1, compressedSize ); stream->Read( compressedData, 1, compressedSize );

View File

@ -46,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_ASSBINIMPORTER_H_INC #define AI_ASSBINIMPORTER_H_INC
#include "BaseImporter.h" #include "BaseImporter.h"
#include <assimp/types.h>
struct aiMesh; struct aiMesh;
struct aiNode; struct aiNode;

View File

@ -150,7 +150,7 @@ void ReportSceneNotFoundError()
DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. " DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. "
"The C-API does not accept scenes produced by the C++ API and vice versa"); "The C-API does not accept scenes produced by the C++ API and vice versa");
assert(false); ai_assert(false);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ASSXML exporter main code * ASSXML exporter main code
*/ */
#include <stdarg.h> #include <stdarg.h>
#include "./../include/assimp/version.h" #include <assimp/version.h>
#include "ProcessHelper.h" #include "ProcessHelper.h"
#include <assimp/IOStream.hpp> #include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
@ -72,7 +72,7 @@ static int ioprintf( IOStream * io, const char *format, ... ) {
return -1; return -1;
} }
static const size_t Size = 4096; static const int Size = 4096;
char sz[ Size ]; char sz[ Size ];
::memset( sz, '\0', Size ); ::memset( sz, '\0', Size );
va_list va; va_list va;

View File

@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/anim.h> #include <assimp/anim.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/importerdesc.h>
using namespace Assimp; using namespace Assimp;
using namespace std; using namespace std;
@ -331,7 +331,7 @@ void B3DImporter::ReadVRTS(){
int sz=12+(_vflags&1?12:0)+(_vflags&2?16:0)+(_tcsets*_tcsize*4); int sz=12+(_vflags&1?12:0)+(_vflags&2?16:0)+(_tcsets*_tcsize*4);
int n_verts=ChunkSize()/sz; int n_verts=ChunkSize()/sz;
int v0=_vertices.size(); int v0=static_cast<int>(_vertices.size());
_vertices.resize( v0+n_verts ); _vertices.resize( v0+n_verts );
for( int i=0;i<n_verts;++i ){ for( int i=0;i<n_verts;++i ){
@ -404,7 +404,7 @@ void B3DImporter::ReadTRIS( int v0 ){
void B3DImporter::ReadMESH(){ void B3DImporter::ReadMESH(){
/*int matid=*/ReadInt(); /*int matid=*/ReadInt();
int v0=_vertices.size(); int v0= static_cast<int>(_vertices.size());
while( ChunkSize() ){ while( ChunkSize() ){
string t=ReadChunk(); string t=ReadChunk();
@ -462,17 +462,17 @@ void B3DImporter::ReadKEYS( aiNodeAnim *nodeAnim ){
} }
if( flags & 1 ){ if( flags & 1 ){
nodeAnim->mNumPositionKeys=trans.size(); nodeAnim->mNumPositionKeys=static_cast<unsigned int>(trans.size());
nodeAnim->mPositionKeys=to_array( trans ); nodeAnim->mPositionKeys=to_array( trans );
} }
if( flags & 2 ){ if( flags & 2 ){
nodeAnim->mNumScalingKeys=scale.size(); nodeAnim->mNumScalingKeys=static_cast<unsigned int>(scale.size());
nodeAnim->mScalingKeys=to_array( scale ); nodeAnim->mScalingKeys=to_array( scale );
} }
if( flags & 4 ){ if( flags & 4 ){
nodeAnim->mNumRotationKeys=rot.size(); nodeAnim->mNumRotationKeys=static_cast<unsigned int>(rot.size());
nodeAnim->mRotationKeys=to_array( rot ); nodeAnim->mRotationKeys=to_array( rot );
} }
} }
@ -506,7 +506,7 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
aiMatrix4x4 tform=trans * rot * scale; aiMatrix4x4 tform=trans * rot * scale;
int nodeid=_nodes.size(); int nodeid=static_cast<int>(_nodes.size());
aiNode *node=new aiNode( name ); aiNode *node=new aiNode( name );
_nodes.push_back( node ); _nodes.push_back( node );
@ -521,9 +521,9 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
while( ChunkSize() ){ while( ChunkSize() ){
string t=ReadChunk(); string t=ReadChunk();
if( t=="MESH" ){ if( t=="MESH" ){
int n=_meshes.size(); unsigned int n= static_cast<unsigned int>(_meshes.size());
ReadMESH(); ReadMESH();
for( int i=n;i<(int)_meshes.size();++i ){ for( unsigned int i=n;i<static_cast<unsigned int>(_meshes.size());++i ){
meshes.push_back( i ); meshes.push_back( i );
} }
}else if( t=="BONE" ){ }else if( t=="BONE" ){
@ -544,10 +544,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
ExitChunk(); ExitChunk();
} }
node->mNumMeshes=meshes.size(); node->mNumMeshes= static_cast<unsigned int>(meshes.size());
node->mMeshes=to_array( meshes ); node->mMeshes=to_array( meshes );
node->mNumChildren=children.size(); node->mNumChildren=static_cast<unsigned int>(children.size());
node->mChildren=to_array( children ); node->mChildren=to_array( children );
return node; return node;
@ -645,7 +645,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
aiNode *bnode=_nodes[i]; aiNode *bnode=_nodes[i];
bone->mName=bnode->mName; bone->mName=bnode->mName;
bone->mNumWeights=weights.size(); bone->mNumWeights= static_cast<unsigned int>(weights.size());
bone->mWeights=to_array( weights ); bone->mWeights=to_array( weights );
aiMatrix4x4 mat=bnode->mTransformation; aiMatrix4x4 mat=bnode->mTransformation;
@ -655,7 +655,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
} }
bone->mOffsetMatrix=mat.Inverse(); bone->mOffsetMatrix=mat.Inverse();
} }
mesh->mNumBones=bones.size(); mesh->mNumBones= static_cast<unsigned int>(bones.size());
mesh->mBones=to_array( bones ); mesh->mBones=to_array( bones );
} }
} }
@ -667,21 +667,21 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
if( !_materials.size() ){ if( !_materials.size() ){
_materials.push_back( new aiMaterial ); _materials.push_back( new aiMaterial );
} }
scene->mNumMaterials=_materials.size(); scene->mNumMaterials= static_cast<unsigned int>(_materials.size());
scene->mMaterials=to_array( _materials ); scene->mMaterials=to_array( _materials );
//meshes //meshes
scene->mNumMeshes=_meshes.size(); scene->mNumMeshes= static_cast<unsigned int>(_meshes.size());
scene->mMeshes=to_array( _meshes ); scene->mMeshes=to_array( _meshes );
//animations //animations
if( _animations.size()==1 && _nodeAnims.size() ){ if( _animations.size()==1 && _nodeAnims.size() ){
aiAnimation *anim=_animations.back(); aiAnimation *anim=_animations.back();
anim->mNumChannels=_nodeAnims.size(); anim->mNumChannels=static_cast<unsigned int>(_nodeAnims.size());
anim->mChannels=to_array( _nodeAnims ); anim->mChannels=to_array( _nodeAnims );
scene->mNumAnimations=_animations.size(); scene->mNumAnimations=static_cast<unsigned int>(_animations.size());
scene->mAnimations=to_array( _animations ); scene->mAnimations=to_array( _animations );
} }

View File

@ -48,7 +48,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/material.h> #include <assimp/material.h>
#include "BaseImporter.h" #include "BaseImporter.h"
#include <string>
#include <vector> #include <vector>
struct aiNodeAnim; struct aiNodeAnim;

View File

@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "TinyFormatter.h" #include "TinyFormatter.h"
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/importerdesc.h>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Formatter; using namespace Assimp::Formatter;
@ -237,7 +238,7 @@ aiNode* BVHLoader::ReadNode()
// add the child nodes if there are any // add the child nodes if there are any
if( childNodes.size() > 0) if( childNodes.size() > 0)
{ {
node->mNumChildren = childNodes.size(); node->mNumChildren = static_cast<unsigned int>(childNodes.size());
node->mChildren = new aiNode*[node->mNumChildren]; node->mChildren = new aiNode*[node->mNumChildren];
std::copy( childNodes.begin(), childNodes.end(), node->mChildren); std::copy( childNodes.begin(), childNodes.end(), node->mChildren);
} }
@ -443,7 +444,7 @@ void BVHLoader::CreateAnimation( aiScene* pScene)
anim->mDuration = double( mAnimNumFrames - 1); anim->mDuration = double( mAnimNumFrames - 1);
// now generate the tracks for all nodes // now generate the tracks for all nodes
anim->mNumChannels = mNodes.size(); anim->mNumChannels = static_cast<unsigned int>(mNodes.size());
anim->mChannels = new aiNodeAnim*[anim->mNumChannels]; anim->mChannels = new aiNodeAnim*[anim->mNumChannels];
// FIX: set the array elements to NULL to ensure proper deletion if an exception is thrown // FIX: set the array elements to NULL to ensure proper deletion if an exception is thrown

View File

@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/importerdesc.h>
#include <ios> #include <ios>
#include <list> #include <list>
#include <memory> #include <memory>
@ -136,14 +137,17 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
/*static*/ bool BaseImporter::SearchFileHeaderForToken(IOSystem* pIOHandler, /*static*/ bool BaseImporter::SearchFileHeaderForToken( IOSystem* pIOHandler,
const std::string& pFile, const std::string& pFile,
const char** tokens, const char** tokens,
unsigned int numTokens, unsigned int numTokens,
unsigned int searchBytes /* = 200 */, unsigned int searchBytes /* = 200 */,
bool tokensSol /* false */) bool tokensSol /* false */)
{ {
ai_assert(NULL != tokens && 0 != numTokens && 0 != searchBytes); ai_assert( NULL != tokens );
ai_assert( 0 != numTokens );
ai_assert( 0 != searchBytes);
if (!pIOHandler) if (!pIOHandler)
return false; return false;
@ -178,8 +182,6 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
for (unsigned int i = 0; i < numTokens;++i) { for (unsigned int i = 0; i < numTokens;++i) {
ai_assert(NULL != tokens[i]); ai_assert(NULL != tokens[i]);
const char* r = strstr(buffer,tokens[i]); const char* r = strstr(buffer,tokens[i]);
if( !r ) { if( !r ) {
continue; continue;

View File

@ -44,14 +44,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Exceptional.h" #include "Exceptional.h"
#include <string>
#include <map>
#include <vector> #include <vector>
#include <set> #include <set>
#include <assimp/types.h> #include <assimp/types.h>
#include <assimp/ProgressHandler.hpp> #include <assimp/ProgressHandler.hpp>
struct aiScene; struct aiScene;
struct aiImporterDesc;
namespace Assimp { namespace Assimp {

View File

@ -43,8 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_BASEPROCESS_H #define INCLUDED_AI_BASEPROCESS_H
#include <map> #include <map>
#include <assimp/types.h>
#include "GenericProperty.h" #include "GenericProperty.h"
struct aiScene; struct aiScene;

View File

@ -50,25 +50,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdint.h> #include <stdint.h>
#include <cstddef> #include <cstddef>
struct aiTexture; struct aiTexture;
namespace Assimp { namespace Assimp {
class IOStream; class IOStream;
class Bitmap {
protected: class Bitmap {
protected:
struct Header { struct Header {
uint16_t type; uint16_t type;
uint32_t size; uint32_t size;
uint16_t reserved1; uint16_t reserved1;
uint16_t reserved2; uint16_t reserved2;
uint32_t offset; uint32_t offset;
// We define the struct size because sizeof(Header) might return a wrong result because of structure padding. // We define the struct size because sizeof(Header) might return a wrong result because of structure padding.
@ -79,31 +75,19 @@ class Bitmap {
sizeof(uint16_t) + // reserved1 sizeof(uint16_t) + // reserved1
sizeof(uint16_t) + // reserved2 sizeof(uint16_t) + // reserved2
sizeof(uint32_t); // offset sizeof(uint32_t); // offset
}; };
struct DIB { struct DIB {
uint32_t size; uint32_t size;
int32_t width; int32_t width;
int32_t height; int32_t height;
uint16_t planes; uint16_t planes;
uint16_t bits_per_pixel; uint16_t bits_per_pixel;
uint32_t compression; uint32_t compression;
uint32_t image_size; uint32_t image_size;
int32_t x_resolution; int32_t x_resolution;
int32_t y_resolution; int32_t y_resolution;
uint32_t nb_colors; uint32_t nb_colors;
uint32_t nb_important_colors; uint32_t nb_important_colors;
// We define the struct size because sizeof(DIB) might return a wrong result because of structure padding. // We define the struct size because sizeof(DIB) might return a wrong result because of structure padding.
@ -120,23 +104,17 @@ class Bitmap {
sizeof(int32_t) + // y_resolution sizeof(int32_t) + // y_resolution
sizeof(uint32_t) + // nb_colors sizeof(uint32_t) + // nb_colors
sizeof(uint32_t); // nb_important_colors sizeof(uint32_t); // nb_important_colors
}; };
static const std::size_t mBytesPerPixel = 4; static const std::size_t mBytesPerPixel = 4;
public: public:
static void Save(aiTexture* texture, IOStream* file); static void Save(aiTexture* texture, IOStream* file);
protected: protected:
static void WriteHeader(Header& header, IOStream* file); static void WriteHeader(Header& header, IOStream* file);
static void WriteDIB(DIB& dib, IOStream* file); static void WriteDIB(DIB& dib, IOStream* file);
static void WriteData(aiTexture* texture, IOStream* file); static void WriteData(aiTexture* texture, IOStream* file);
}; };
} }

View File

@ -180,7 +180,7 @@ void BlenderBMeshConverter::AddFace( int v1, int v2, int v3, int v4 )
// TODO - Work out how materials work // TODO - Work out how materials work
face.mat_nr = 0; face.mat_nr = 0;
triMesh->mface.push_back( face ); triMesh->mface.push_back( face );
triMesh->totface = triMesh->mface.size( ); triMesh->totface = static_cast<int>(triMesh->mface.size( ));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BlenderDNA.h" #include "BlenderDNA.h"
#include "StreamReader.h" #include "StreamReader.h"
#include "fast_atof.h" #include "fast_atof.h"
#include "TinyFormatter.h"
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Blender; using namespace Assimp::Blender;

View File

@ -46,12 +46,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_BLEND_DNA_H #define INCLUDED_AI_BLEND_DNA_H
#include "BaseImporter.h" #include "BaseImporter.h"
#include "TinyFormatter.h"
#include "StreamReader.h" #include "StreamReader.h"
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <stdint.h> #include <stdint.h>
#include <memory> #include <memory>
#include <map>
// enable verbose log output. really verbose, so be careful. // enable verbose log output. really verbose, so be careful.
#ifdef ASSIMP_BUILD_DEBUG #ifdef ASSIMP_BUILD_DEBUG

View File

@ -46,9 +46,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_BLEND_DNA_INL #define INCLUDED_AI_BLEND_DNA_INL
#include <memory> #include <memory>
#include "TinyFormatter.h"
namespace Assimp { namespace Assimp {
namespace Blender { namespace Blender {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
const Field& Structure :: operator [] (const std::string& ss) const const Field& Structure :: operator [] (const std::string& ss) const

View File

@ -48,9 +48,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BlenderLoader.h" #include "BlenderLoader.h"
#include "BlenderDNA.h" #include "BlenderDNA.h"
#include "BlenderScene.h" #include "BlenderScene.h"
#include "BlenderSceneGen.h"
#include <deque> #include <deque>
#include "./../include/assimp/material.h" #include <assimp/material.h>
struct aiTexture; struct aiTexture;

View File

@ -54,10 +54,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BlenderBMesh.h" #include "BlenderBMesh.h"
#include "StringUtils.h" #include "StringUtils.h"
#include <assimp/scene.h> #include <assimp/scene.h>
#include "StringComparison.h" #include <assimp/importerdesc.h>
#include "StringComparison.h"
#include "StreamReader.h" #include "StreamReader.h"
#include "MemoryIOWrapper.h" #include "MemoryIOWrapper.h"
#include <cctype> #include <cctype>
@ -95,8 +97,9 @@ static const aiImporterDesc blenderDesc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
BlenderImporter::BlenderImporter() BlenderImporter::BlenderImporter()
: modifier_cache(new BlenderModifierShowcase()) : modifier_cache(new BlenderModifierShowcase()) {
{} // empty
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Destructor, private as well // Destructor, private as well
@ -144,8 +147,7 @@ void BlenderImporter::SetupProperties(const Importer* /*pImp*/)
// nothing to be done for the moment // nothing to be done for the moment
} }
struct free_it struct free_it {
{
free_it(void* free) : free(free) {} free_it(void* free) : free(free) {}
~free_it() { ~free_it() {
::free(this->free); ::free(this->free);
@ -164,6 +166,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
free_it free_it_really(dest); free_it free_it_really(dest);
#endif #endif
FileDatabase file; FileDatabase file;
std::shared_ptr<IOStream> stream(pIOHandler->Open(pFile,"rb")); std::shared_ptr<IOStream> stream(pIOHandler->Open(pFile,"rb"));
if (!stream) { if (!stream) {
@ -423,7 +426,7 @@ void BlenderImporter::ResolveImage(aiMaterial* out, const Material* mat, const M
// check if the file contents are bundled with the BLEND file // check if the file contents are bundled with the BLEND file
if (img->packedfile) { if (img->packedfile) {
name.data[0] = '*'; name.data[0] = '*';
name.length = 1+ ASSIMP_itoa10(name.data+1,MAXLEN-1,conv_data.textures->size()); name.length = 1+ ASSIMP_itoa10(name.data+1,static_cast<unsigned int>(MAXLEN-1), static_cast<int32_t>(conv_data.textures->size()));
conv_data.textures->push_back(new aiTexture()); conv_data.textures->push_back(new aiTexture());
aiTexture* tex = conv_data.textures->back(); aiTexture* tex = conv_data.textures->back();
@ -1230,7 +1233,7 @@ aiNode* BlenderImporter::ConvertNode(const Scene& in, const Object* obj, Convers
if (conv_data.meshes->size() > old) { if (conv_data.meshes->size() > old) {
node->mMeshes = new unsigned int[node->mNumMeshes = static_cast<unsigned int>(conv_data.meshes->size()-old)]; node->mMeshes = new unsigned int[node->mNumMeshes = static_cast<unsigned int>(conv_data.meshes->size()-old)];
for (unsigned int i = 0; i < node->mNumMeshes; ++i) { for (unsigned int i = 0; i < node->mNumMeshes; ++i) {
node->mMeshes[i] = i + old; node->mMeshes[i] = static_cast<unsigned int>(i + old);
} }
}} }}
break; break;

View File

@ -44,9 +44,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER #ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
#include "BlenderDNA.h"
#include "BlenderScene.h" #include "BlenderScene.h"
#include "BlenderSceneGen.h" #include "BlenderSceneGen.h"
#include "BlenderDNA.h"
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Blender; using namespace Assimp::Blender;
@ -522,7 +522,7 @@ template <> void Structure :: Convert<MVert> (
ReadFieldArray<ErrorPolicy_Fail>(dest.co,"co",db); ReadFieldArray<ErrorPolicy_Fail>(dest.co,"co",db);
ReadFieldArray<ErrorPolicy_Fail>(dest.no,"no",db); ReadFieldArray<ErrorPolicy_Fail>(dest.no,"no",db);
ReadField<ErrorPolicy_Igno>(dest.flag,"flag",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); ReadField<ErrorPolicy_Igno>(dest.bweight,"bweight",db);
db.reader->IncPtr(size); db.reader->IncPtr(size);

View File

@ -616,6 +616,17 @@ struct Object : ElemBase {
std::shared_ptr<ElemBase> data FAIL; std::shared_ptr<ElemBase> data FAIL;
ListBase modifiers; ListBase modifiers;
Object()
: ElemBase()
, type( Type_EMPTY )
, parent( nullptr )
, track()
, proxy()
, proxy_from()
, data() {
// empty
}
}; };
@ -624,6 +635,14 @@ struct Base : ElemBase {
Base* prev WARN; Base* prev WARN;
std::shared_ptr<Base> next WARN; std::shared_ptr<Base> next WARN;
std::shared_ptr<Object> object WARN; std::shared_ptr<Object> object WARN;
Base()
: ElemBase()
, next()
, object() {
// empty
// empty
}
}; };
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
@ -635,8 +654,15 @@ struct Scene : ElemBase {
std::shared_ptr<Base> basact WARN; std::shared_ptr<Base> basact WARN;
ListBase base; ListBase base;
};
Scene()
: ElemBase()
, camera()
, world()
, basact() {
// empty
}
};
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
struct Image : ElemBase { struct Image : ElemBase {
@ -664,6 +690,11 @@ struct Image : ElemBase {
short animspeed; short animspeed;
short gen_x, gen_y, gen_type; short gen_x, gen_y, gen_type;
Image()
: ElemBase() {
// empty
}
}; };
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
@ -751,6 +782,12 @@ struct Tex : ElemBase {
//VoxelData *vd; //VoxelData *vd;
//char use_nodes; //char use_nodes;
Tex()
: ElemBase() {
// empty
}
}; };
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
@ -839,9 +876,13 @@ struct MTex : ElemBase {
//float lifefac, sizefac, ivelfac, pvelfac; //float lifefac, sizefac, ivelfac, pvelfac;
//float shadowfac; //float shadowfac;
//float zenupfac, zendownfac, blendfac; //float zenupfac, zendownfac, blendfac;
MTex()
: ElemBase() {
// empty
}
}; };
}
}
} }
#endif #endif

View File

@ -412,9 +412,9 @@ float BlenderTessellatorP2T::FindLargestMatrixElem( const aiMatrix3x3& mtx ) con
{ {
float result = 0.0f; float result = 0.0f;
for ( size_t x = 0; x < 3; ++x ) for ( unsigned int x = 0; x < 3; ++x )
{ {
for ( size_t y = 0; y < 3; ++y ) for ( unsigned int y = 0; y < 3; ++y )
{ {
result = p2tMax( std::fabs( mtx[ x ][ y ] ), result ); result = p2tMax( std::fabs( mtx[ x ][ y ] ), result );
} }
@ -429,9 +429,9 @@ aiMatrix3x3 BlenderTessellatorP2T::ScaleMatrix( const aiMatrix3x3& mtx, float sc
{ {
aiMatrix3x3 result; aiMatrix3x3 result;
for ( size_t x = 0; x < 3; ++x ) for ( unsigned int x = 0; x < 3; ++x )
{ {
for ( size_t y = 0; y < 3; ++y ) for ( unsigned int y = 0; y < 3; ++y )
{ {
result[ x ][ y ] = mtx[ x ][ y ] * scale; result[ x ][ y ] = mtx[ x ][ y ] * scale;
} }

View File

@ -45,10 +45,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_BLOBIOSYSTEM_H_INCLUDED #ifndef AI_BLOBIOSYSTEM_H_INCLUDED
#define AI_BLOBIOSYSTEM_H_INCLUDED #define AI_BLOBIOSYSTEM_H_INCLUDED
#include "./../include/assimp/IOStream.hpp" #include <assimp/IOStream.hpp>
#include "./../include/assimp/cexport.h" #include <assimp/cexport.h>
#include "./../include/assimp/IOSystem.hpp" #include <assimp/IOSystem.hpp>
#include "./../include/assimp/DefaultLogger.hpp" #include <assimp/DefaultLogger.hpp>
#include <stdint.h> #include <stdint.h>
#include <set> #include <set>
#include <vector> #include <vector>

View File

@ -93,6 +93,8 @@ SET( PUBLIC_HEADERS
${HEADER_PATH}/NullLogger.hpp ${HEADER_PATH}/NullLogger.hpp
${HEADER_PATH}/cexport.h ${HEADER_PATH}/cexport.h
${HEADER_PATH}/Exporter.hpp ${HEADER_PATH}/Exporter.hpp
${HEADER_PATH}/DefaultIOStream.h
${HEADER_PATH}/DefaultIOSystem.h
) )
SET( Core_SRCS SET( Core_SRCS
@ -125,9 +127,7 @@ SET( Common_SRCS
ByteSwapper.h ByteSwapper.h
DefaultProgressHandler.h DefaultProgressHandler.h
DefaultIOStream.cpp DefaultIOStream.cpp
DefaultIOStream.h
DefaultIOSystem.cpp DefaultIOSystem.cpp
DefaultIOSystem.h
CInterfaceIOWrapper.cpp CInterfaceIOWrapper.cpp
CInterfaceIOWrapper.h CInterfaceIOWrapper.h
Hash.h Hash.h
@ -163,6 +163,7 @@ SET( Common_SRCS
RemoveComments.h RemoveComments.h
Subdivision.cpp Subdivision.cpp
Subdivision.h Subdivision.h
scene.cpp
Vertex.h Vertex.h
LineSplitter.h LineSplitter.h
TinyFormatter.h TinyFormatter.h
@ -173,6 +174,8 @@ SET( Common_SRCS
XMLTools.h XMLTools.h
Version.cpp Version.cpp
IOStreamBuffer.h IOStreamBuffer.h
CreateAnimMesh.h
CreateAnimMesh.cpp
) )
SOURCE_GROUP(Common FILES ${Common_SRCS}) SOURCE_GROUP(Common FILES ${Common_SRCS})
@ -184,10 +187,16 @@ IF ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER )
SOURCE_GROUP( C4D FILES ${C4D_SRCS}) SOURCE_GROUP( C4D FILES ${C4D_SRCS})
ENDIF ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER ) 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 # 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) # this way selective loaders can be compiled (reduces filesize + compile time)
MACRO(ADD_ASSIMP_IMPORTER name) 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) IF(ASSIMP_BUILD_${name}_IMPORTER)
LIST(APPEND ASSIMP_LOADER_SRCS ${ARGN}) LIST(APPEND ASSIMP_LOADER_SRCS ${ARGN})
SET(ASSIMP_IMPORTERS_ENABLED "${ASSIMP_IMPORTERS_ENABLED} ${name}") SET(ASSIMP_IMPORTERS_ENABLED "${ASSIMP_IMPORTERS_ENABLED} ${name}")
@ -197,6 +206,7 @@ MACRO(ADD_ASSIMP_IMPORTER name)
SET(${name}_SRC "") SET(${name}_SRC "")
SET(ASSIMP_IMPORTERS_DISABLED "${ASSIMP_IMPORTERS_DISABLED} ${name}") SET(ASSIMP_IMPORTERS_DISABLED "${ASSIMP_IMPORTERS_DISABLED} ${name}")
add_definitions(-DASSIMP_BUILD_NO_${name}_IMPORTER) add_definitions(-DASSIMP_BUILD_NO_${name}_IMPORTER)
add_definitions(-DASSIMP_BUILD_NO_${name}_EXPORTER)
ENDIF() ENDIF()
ENDMACRO() ENDMACRO()
@ -462,9 +472,13 @@ ADD_ASSIMP_IMPORTER( IFC
STEPFileEncoding.cpp STEPFileEncoding.cpp
STEPFileEncoding.h STEPFileEncoding.h
) )
if (MSVC AND ASSIMP_BUILD_IFC_IMPORTER) if (ASSIMP_BUILD_IFC_IMPORTER)
if (MSVC)
set_source_files_properties(IFCReaderGen1.cpp IFCReaderGen2.cpp PROPERTIES COMPILE_FLAGS "/bigobj") set_source_files_properties(IFCReaderGen1.cpp IFCReaderGen2.cpp PROPERTIES COMPILE_FLAGS "/bigobj")
endif (MSVC AND ASSIMP_BUILD_IFC_IMPORTER) elseif(CMAKE_COMPILER_IS_MINGW)
set_source_files_properties(IFCReaderGen1.cpp IFCReaderGen2.cpp PROPERTIES COMPILE_FLAGS "-O2 -Wa,-mbig-obj")
endif()
endif (ASSIMP_BUILD_IFC_IMPORTER)
ADD_ASSIMP_IMPORTER( XGL ADD_ASSIMP_IMPORTER( XGL
XGLLoader.cpp XGLLoader.cpp
@ -642,7 +656,6 @@ ADD_ASSIMP_IMPORTER( GLTF
glTFExporter.cpp glTFExporter.cpp
) )
ADD_ASSIMP_IMPORTER( 3MF ADD_ASSIMP_IMPORTER( 3MF
D3MFImporter.h D3MFImporter.h
D3MFImporter.cpp D3MFImporter.cpp

View File

@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/importerdesc.h>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::COB; using namespace Assimp::COB;
@ -181,7 +181,7 @@ void COBImporter::InternReadFile( const std::string& pFile,
if (n->type == Node::TYPE_MESH) { if (n->type == Node::TYPE_MESH) {
Mesh& mesh = (Mesh&)(*n.get()); Mesh& mesh = (Mesh&)(*n.get());
if (mesh.vertex_positions.size() && mesh.texture_coords.size()) { if (mesh.vertex_positions.size() && mesh.texture_coords.size()) {
pScene->mNumMeshes += mesh.temp_map.size(); pScene->mNumMeshes += static_cast<unsigned int>(mesh.temp_map.size());
} }
} }
} }

View File

@ -46,12 +46,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
#include <deque> #include <deque>
#include <map>
#include "BaseImporter.h" #include "BaseImporter.h"
#include "./../include/assimp/material.h" #include <assimp/material.h>
namespace Assimp { namespace Assimp {
namespace COB { namespace COB {
// ------------------ // ------------------
/** Represents a single vertex index in a face */ /** Represents a single vertex index in a face */

View File

@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/anim.h> #include <assimp/anim.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/importerdesc.h>
using namespace Assimp; using namespace Assimp;
@ -179,7 +179,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
nda->mNodeName.length = (size_t)(ot-nda->mNodeName.data); nda->mNodeName.length = (size_t)(ot-nda->mNodeName.data);
} }
anim->mNumChannels = anims_temp.size(); anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
if (!anim->mNumChannels) if (!anim->mNumChannels)
throw DeadlyImportError("CSM: Empty $order section"); throw DeadlyImportError("CSM: Empty $order section");

View File

@ -38,18 +38,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
#ifndef ASSIMP_BUILD_NO_EXPORT #ifndef ASSIMP_BUILD_NO_EXPORT
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER #ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
#include "ColladaExporter.h"
#include "ColladaExporter.h"
#include "Bitmap.h" #include "Bitmap.h"
#include "fast_atof.h" #include "fast_atof.h"
#include "SceneCombiner.h" #include "SceneCombiner.h"
#include "DefaultIOSystem.h"
#include "StringUtils.h" #include "StringUtils.h"
#include "XMLTools.h" #include "XMLTools.h"
#include <assimp/DefaultIOSystem.h>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/Exporter.hpp> #include <assimp/Exporter.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
@ -384,6 +382,7 @@ void ColladaExporter::WriteLight(size_t pIndex){
case aiLightSource_SPOT: case aiLightSource_SPOT:
WriteSpotLight(light); WriteSpotLight(light);
break; break;
case aiLightSource_AREA:
case aiLightSource_UNDEFINED: case aiLightSource_UNDEFINED:
case _aiLightSource_Force32Bit: case _aiLightSource_Force32Bit:
break; break;
@ -524,7 +523,7 @@ void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial*
} else } else
{ {
if( pKey ) if( pKey )
poSurface.exist = pSrcMat->Get( pKey, pType, pIndex, poSurface.color) == aiReturn_SUCCESS; poSurface.exist = pSrcMat->Get( pKey, static_cast<unsigned int>(pType), static_cast<unsigned int>(pIndex), poSurface.color) == aiReturn_SUCCESS;
} }
} }
@ -691,7 +690,7 @@ void ColladaExporter::WriteMaterials()
materials[a].shininess.exist = mat->Get( AI_MATKEY_SHININESS, materials[a].shininess.value) == aiReturn_SUCCESS; materials[a].shininess.exist = mat->Get( AI_MATKEY_SHININESS, materials[a].shininess.value) == aiReturn_SUCCESS;
materials[a].transparency.exist = mat->Get( AI_MATKEY_OPACITY, materials[a].transparency.value) == aiReturn_SUCCESS; materials[a].transparency.exist = mat->Get( AI_MATKEY_OPACITY, materials[a].transparency.value) == aiReturn_SUCCESS;
materials[a].transparency.value = 1 - materials[a].transparency.value; materials[a].transparency.value = materials[a].transparency.value;
materials[a].index_refraction.exist = mat->Get( AI_MATKEY_REFRACTI, materials[a].index_refraction.value) == aiReturn_SUCCESS; materials[a].index_refraction.exist = mat->Get( AI_MATKEY_REFRACTI, materials[a].index_refraction.value) == aiReturn_SUCCESS;
} }
@ -808,7 +807,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
const std::string idstr = GetMeshId( pIndex); const std::string idstr = GetMeshId( pIndex);
const std::string idstrEscaped = XMLEscape(idstr); const std::string idstrEscaped = XMLEscape(idstr);
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 ) if ( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
return; return;
// opening tag // opening tag
@ -827,7 +826,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
// texture coords // texture coords
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a)
{ {
if( mesh->HasTextureCoords( a) ) if( mesh->HasTextureCoords(static_cast<unsigned int>(a)) )
{ {
WriteFloatArray( idstr + "-tex" + to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2, WriteFloatArray( idstr + "-tex" + to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2,
(ai_real*) mesh->mTextureCoords[a], mesh->mNumVertices); (ai_real*) mesh->mTextureCoords[a], mesh->mNumVertices);
@ -837,27 +836,15 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
// vertex colors // vertex colors
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a)
{ {
if( mesh->HasVertexColors( a) ) if( mesh->HasVertexColors(static_cast<unsigned int>(a)) )
WriteFloatArray( idstr + "-color" + to_string(a), FloatType_Color, (ai_real*) mesh->mColors[a], mesh->mNumVertices); WriteFloatArray( idstr + "-color" + to_string(a), FloatType_Color, (ai_real*) mesh->mColors[a], mesh->mNumVertices);
} }
// assemble vertex structure // 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; mOutput << startstr << "<vertices id=\"" << idstrEscaped << "-vertices" << "\">" << endstr;
PushTag(); PushTag();
mOutput << startstr << "<input semantic=\"POSITION\" source=\"#" << idstrEscaped << "-positions\" />" << endstr; 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( 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( a) )
mOutput << startstr << "<input semantic=\"COLOR\" source=\"#" << idstrEscaped << "-color" << a << "\" " /*<< set=\"" << a << "\"" */ << " />" << endstr;
}
PopTag(); PopTag();
mOutput << startstr << "</vertices>" << endstr; mOutput << startstr << "</vertices>" << endstr;
@ -876,6 +863,19 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
mOutput << startstr << "<lines count=\"" << countLines << "\" material=\"defaultMaterial\">" << endstr; mOutput << startstr << "<lines count=\"" << countLines << "\" material=\"defaultMaterial\">" << endstr;
PushTag(); PushTag();
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstrEscaped << "-vertices\" />" << endstr; 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>"; mOutput << startstr << "<p>";
for( size_t a = 0; a < mesh->mNumFaces; ++a ) for( size_t a = 0; a < mesh->mNumFaces; ++a )
{ {
@ -897,10 +897,17 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
mOutput << startstr << "<polylist count=\"" << countPoly << "\" material=\"defaultMaterial\">" << endstr; mOutput << startstr << "<polylist count=\"" << countPoly << "\" material=\"defaultMaterial\">" << endstr;
PushTag(); PushTag();
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstrEscaped << "-vertices\" />" << endstr; 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 ) for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
{ {
if( mesh->HasTextureCoords( a) ) if( mesh->HasTextureCoords(static_cast<unsigned int>(a)) )
mOutput << startstr << "<input offset=\"0\" semantic=\"TEXCOORD\" source=\"#" << idstrEscaped << "-tex" << a << "\" set=\"" << a << "\" />" << endstr; 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>"; mOutput << startstr << "<vcount>";
@ -1129,7 +1136,7 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
PushTag(); PushTag();
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
{ {
if( mesh->HasTextureCoords( a) ) if( mesh->HasTextureCoords( static_cast<unsigned int>(a) ) )
// semantic as in <texture texcoord=...> // semantic as in <texture texcoord=...>
// input_semantic as in <input semantic=...> // input_semantic as in <input semantic=...>
// input_set as in <input set=...> // input_set as in <input set=...>

View File

@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_COLLADAHELPER_H_INC #ifndef AI_COLLADAHELPER_H_INC
#define AI_COLLADAHELPER_H_INC #define AI_COLLADAHELPER_H_INC
#include <string>
#include <map> #include <map>
#include <vector> #include <vector>
#include <stdint.h> #include <stdint.h>
@ -89,6 +88,21 @@ enum InputType
IT_Bitangent 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 */ /** Contains all data for one of the different transformation types */
struct Transform struct Transform
{ {
@ -380,6 +394,12 @@ enum PrimitiveType
/** A skeleton controller to deform a mesh with the use of joints */ /** A skeleton controller to deform a mesh with the use of joints */
struct Controller struct Controller
{ {
// controller type
ControllerType mType;
// Morphing method if type is Morph
MorphMethod mMethod;
// the URL of the mesh deformed by the controller. // the URL of the mesh deformed by the controller.
std::string mMeshId; std::string mMeshId;
@ -402,6 +422,9 @@ struct Controller
// JointIndex-WeightIndex pairs for all vertices // JointIndex-WeightIndex pairs for all vertices
std::vector< std::pair<size_t, size_t> > mWeights; 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. */ /** A collada material. Pretty much the only member is a reference to an effect. */
@ -577,6 +600,12 @@ struct AnimationChannel
std::string mSourceTimes; std::string mSourceTimes;
/** Source URL of the value values. Collada calls them "output". */ /** Source URL of the value values. Collada calls them "output". */
std::string mSourceValues; 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 */ /** An animation. Container for 0-x animation channels or 0-x animations */
@ -645,6 +674,7 @@ struct Animation
struct ChannelEntry struct ChannelEntry
{ {
const Collada::AnimationChannel* mChannel; ///> the source channel 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 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 mTransformIndex; // Index into the node's transform chain to apply the channel to
size_t mSubElement; // starting index inside the transform data size_t mSubElement; // starting index inside the transform data

View File

@ -49,18 +49,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include "ColladaParser.h" #include <assimp/importerdesc.h>
#include "ColladaParser.h"
#include "fast_atof.h" #include "fast_atof.h"
#include "ParsingUtils.h" #include "ParsingUtils.h"
#include "SkeletonMeshBuilder.h" #include "SkeletonMeshBuilder.h"
#include "Defines.h" #include "CreateAnimMesh.h"
#include "time.h" #include "time.h"
#include "math.h" #include "math.h"
#include <algorithm>
#include <numeric> #include <numeric>
#include "Defines.h" #include <assimp/Defines.h>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Formatter; using namespace Assimp::Formatter;
@ -148,6 +149,7 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
mMeshIndexByID.clear(); mMeshIndexByID.clear();
mMaterialIndexByName.clear(); mMaterialIndexByName.clear();
mMeshes.clear(); mMeshes.clear();
mTargetMeshes.clear();
newMats.clear(); newMats.clear();
mLights.clear(); mLights.clear();
mCameras.clear(); mCameras.clear();
@ -240,7 +242,7 @@ aiNode* ColladaLoader::BuildHierarchy( const ColladaParser& pParser, const Colla
ResolveNodeInstances(pParser,pNode,instances); ResolveNodeInstances(pParser,pNode,instances);
// add children. first the *real* ones // add children. first the *real* ones
node->mNumChildren = pNode->mChildren.size()+instances.size(); node->mNumChildren = static_cast<unsigned int>(pNode->mChildren.size()+instances.size());
node->mChildren = new aiNode*[node->mNumChildren]; node->mChildren = new aiNode*[node->mNumChildren];
for( size_t a = 0; a < pNode->mChildren.size(); a++) for( size_t a = 0; a < pNode->mChildren.size(); a++)
@ -506,7 +508,7 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
std::map<std::string, size_t>::const_iterator matIt = mMaterialIndexByName.find( meshMaterial); std::map<std::string, size_t>::const_iterator matIt = mMaterialIndexByName.find( meshMaterial);
unsigned int matIdx; unsigned int matIdx;
if( matIt != mMaterialIndexByName.end()) if( matIt != mMaterialIndexByName.end())
matIdx = matIt->second; matIdx = static_cast<unsigned int>(matIt->second);
else else
matIdx = 0; matIdx = 0;
@ -553,12 +555,35 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
} }
// now place all mesh references we gathered in the target node // now place all mesh references we gathered in the target node
pTarget->mNumMeshes = newMeshRefs.size(); pTarget->mNumMeshes = static_cast<unsigned int>(newMeshRefs.size());
if( newMeshRefs.size()) if( newMeshRefs.size())
{ {
pTarget->mMeshes = new unsigned int[pTarget->mNumMeshes]; struct UIntTypeConverter
std::copy( newMeshRefs.begin(), newMeshRefs.end(), pTarget->mMeshes); {
unsigned int operator()(const size_t& v) const
{
return static_cast<unsigned int>(v);
} }
};
pTarget->mMeshes = new unsigned int[pTarget->mNumMeshes];
std::transform( newMeshRefs.begin(), newMeshRefs.end(), pTarget->mMeshes, UIntTypeConverter());
}
}
// ------------------------------------------------------------------------------------------------
// 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;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -572,10 +597,10 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
// count the vertices addressed by its faces // count the vertices addressed by its faces
const size_t numVertices = std::accumulate( pSrcMesh->mFaceSize.begin() + pStartFace, const size_t numVertices = std::accumulate( pSrcMesh->mFaceSize.begin() + pStartFace,
pSrcMesh->mFaceSize.begin() + pStartFace + pSubMesh.mNumFaces, 0); pSrcMesh->mFaceSize.begin() + pStartFace + pSubMesh.mNumFaces, size_t(0));
// copy positions // copy positions
dstMesh->mNumVertices = numVertices; dstMesh->mNumVertices = static_cast<unsigned int>(numVertices);
dstMesh->mVertices = new aiVector3D[numVertices]; dstMesh->mVertices = new aiVector3D[numVertices];
std::copy( pSrcMesh->mPositions.begin() + pStartVertex, pSrcMesh->mPositions.begin() + std::copy( pSrcMesh->mPositions.begin() + pStartVertex, pSrcMesh->mPositions.begin() +
pStartVertex + numVertices, dstMesh->mVertices); pStartVertex + numVertices, dstMesh->mVertices);
@ -634,20 +659,82 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
// create faces. Due to the fact that each face uses unique vertices, we can simply count up on each vertex // create faces. Due to the fact that each face uses unique vertices, we can simply count up on each vertex
size_t vertex = 0; size_t vertex = 0;
dstMesh->mNumFaces = pSubMesh.mNumFaces; dstMesh->mNumFaces = static_cast<unsigned int>(pSubMesh.mNumFaces);
dstMesh->mFaces = new aiFace[dstMesh->mNumFaces]; dstMesh->mFaces = new aiFace[dstMesh->mNumFaces];
for( size_t a = 0; a < dstMesh->mNumFaces; ++a) for( size_t a = 0; a < dstMesh->mNumFaces; ++a)
{ {
size_t s = pSrcMesh->mFaceSize[ pStartFace + a]; size_t s = pSrcMesh->mFaceSize[ pStartFace + a];
aiFace& face = dstMesh->mFaces[a]; aiFace& face = dstMesh->mFaces[a];
face.mNumIndices = s; face.mNumIndices = static_cast<unsigned int>(s);
face.mIndices = new unsigned int[s]; face.mIndices = new unsigned int[s];
for( size_t b = 0; b < s; ++b) for( size_t b = 0; b < s; ++b)
face.mIndices[b] = vertex++; 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 // create bones if given
if( pSrcController) if( pSrcController && pSrcController->mType == Collada::Skin)
{ {
// refuse if the vertex count does not match // refuse if the vertex count does not match
// if( pSrcController->mWeightCounts.size() != dstMesh->mNumVertices) // if( pSrcController->mWeightCounts.size() != dstMesh->mNumVertices)
@ -710,7 +797,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
if( weight > 0.0f) if( weight > 0.0f)
{ {
aiVertexWeight w; aiVertexWeight w;
w.mVertexId = a - pStartVertex; w.mVertexId = static_cast<unsigned int>(a - pStartVertex);
w.mWeight = weight; w.mWeight = weight;
dstBones[jointIndex].push_back( w); dstBones[jointIndex].push_back( w);
} }
@ -724,7 +811,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
numRemainingBones++; numRemainingBones++;
// create bone array and copy bone weights one by one // create bone array and copy bone weights one by one
dstMesh->mNumBones = numRemainingBones; dstMesh->mNumBones = static_cast<unsigned int>(numRemainingBones);
dstMesh->mBones = new aiBone*[numRemainingBones]; dstMesh->mBones = new aiBone*[numRemainingBones];
size_t boneCount = 0; size_t boneCount = 0;
for( size_t a = 0; a < numBones; ++a) for( size_t a = 0; a < numBones; ++a)
@ -748,7 +835,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
bone->mOffsetMatrix.c2 = ReadFloat( jointMatrixAcc, jointMatrices, a, 9); bone->mOffsetMatrix.c2 = ReadFloat( jointMatrixAcc, jointMatrices, a, 9);
bone->mOffsetMatrix.c3 = ReadFloat( jointMatrixAcc, jointMatrices, a, 10); bone->mOffsetMatrix.c3 = ReadFloat( jointMatrixAcc, jointMatrices, a, 10);
bone->mOffsetMatrix.c4 = ReadFloat( jointMatrixAcc, jointMatrices, a, 11); bone->mOffsetMatrix.c4 = ReadFloat( jointMatrixAcc, jointMatrices, a, 11);
bone->mNumWeights = dstBones[a].size(); bone->mNumWeights = static_cast<unsigned int>(dstBones[a].size());
bone->mWeights = new aiVertexWeight[bone->mNumWeights]; bone->mWeights = new aiVertexWeight[bone->mNumWeights];
std::copy( dstBones[a].begin(), dstBones[a].end(), bone->mWeights); std::copy( dstBones[a].begin(), dstBones[a].end(), bone->mWeights);
@ -798,7 +885,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
// Stores all meshes in the given scene // Stores all meshes in the given scene
void ColladaLoader::StoreSceneMeshes( aiScene* pScene) void ColladaLoader::StoreSceneMeshes( aiScene* pScene)
{ {
pScene->mNumMeshes = mMeshes.size(); pScene->mNumMeshes = static_cast<unsigned int>(mMeshes.size());
if( mMeshes.size() > 0) if( mMeshes.size() > 0)
{ {
pScene->mMeshes = new aiMesh*[mMeshes.size()]; pScene->mMeshes = new aiMesh*[mMeshes.size()];
@ -811,7 +898,7 @@ void ColladaLoader::StoreSceneMeshes( aiScene* pScene)
// Stores all cameras in the given scene // Stores all cameras in the given scene
void ColladaLoader::StoreSceneCameras( aiScene* pScene) void ColladaLoader::StoreSceneCameras( aiScene* pScene)
{ {
pScene->mNumCameras = mCameras.size(); pScene->mNumCameras = static_cast<unsigned int>(mCameras.size());
if( mCameras.size() > 0) if( mCameras.size() > 0)
{ {
pScene->mCameras = new aiCamera*[mCameras.size()]; pScene->mCameras = new aiCamera*[mCameras.size()];
@ -824,7 +911,7 @@ void ColladaLoader::StoreSceneCameras( aiScene* pScene)
// Stores all lights in the given scene // Stores all lights in the given scene
void ColladaLoader::StoreSceneLights( aiScene* pScene) void ColladaLoader::StoreSceneLights( aiScene* pScene)
{ {
pScene->mNumLights = mLights.size(); pScene->mNumLights = static_cast<unsigned int>(mLights.size());
if( mLights.size() > 0) if( mLights.size() > 0)
{ {
pScene->mLights = new aiLight*[mLights.size()]; pScene->mLights = new aiLight*[mLights.size()];
@ -837,7 +924,7 @@ void ColladaLoader::StoreSceneLights( aiScene* pScene)
// Stores all textures in the given scene // Stores all textures in the given scene
void ColladaLoader::StoreSceneTextures( aiScene* pScene) void ColladaLoader::StoreSceneTextures( aiScene* pScene)
{ {
pScene->mNumTextures = mTextures.size(); pScene->mNumTextures = static_cast<unsigned int>(mTextures.size());
if( mTextures.size() > 0) if( mTextures.size() > 0)
{ {
pScene->mTextures = new aiTexture*[mTextures.size()]; pScene->mTextures = new aiTexture*[mTextures.size()];
@ -850,7 +937,7 @@ void ColladaLoader::StoreSceneTextures( aiScene* pScene)
// Stores all materials in the given scene // Stores all materials in the given scene
void ColladaLoader::StoreSceneMaterials( aiScene* pScene) void ColladaLoader::StoreSceneMaterials( aiScene* pScene)
{ {
pScene->mNumMaterials = newMats.size(); pScene->mNumMaterials = static_cast<unsigned int>(newMats.size());
if (newMats.size() > 0) { if (newMats.size() > 0) {
pScene->mMaterials = new aiMaterial*[newMats.size()]; pScene->mMaterials = new aiMaterial*[newMats.size()];
@ -891,7 +978,7 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
combinedAnim->mName = aiString( std::string( "combinedAnim_") + char( '0' + a)); combinedAnim->mName = aiString( std::string( "combinedAnim_") + char( '0' + a));
combinedAnim->mDuration = templateAnim->mDuration; combinedAnim->mDuration = templateAnim->mDuration;
combinedAnim->mTicksPerSecond = templateAnim->mTicksPerSecond; combinedAnim->mTicksPerSecond = templateAnim->mTicksPerSecond;
combinedAnim->mNumChannels = collectedAnimIndices.size() + 1; combinedAnim->mNumChannels = static_cast<unsigned int>(collectedAnimIndices.size() + 1);
combinedAnim->mChannels = new aiNodeAnim*[combinedAnim->mNumChannels]; combinedAnim->mChannels = new aiNodeAnim*[combinedAnim->mNumChannels];
// add the template anim as first channel by moving its aiNodeAnim to the combined animation // add the template anim as first channel by moving its aiNodeAnim to the combined animation
combinedAnim->mChannels[0] = templateAnim->mChannels[0]; combinedAnim->mChannels[0] = templateAnim->mChannels[0];
@ -923,7 +1010,7 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
// now store all anims in the scene // now store all anims in the scene
if( !mAnims.empty()) if( !mAnims.empty())
{ {
pScene->mNumAnimations = mAnims.size(); pScene->mNumAnimations = static_cast<unsigned int>(mAnims.size());
pScene->mAnimations = new aiAnimation*[mAnims.size()]; pScene->mAnimations = new aiAnimation*[mAnims.size()];
std::copy( mAnims.begin(), mAnims.end(), pScene->mAnimations); std::copy( mAnims.begin(), mAnims.end(), pScene->mAnimations);
} }
@ -946,6 +1033,68 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
CreateAnimation( pScene, pParser, pSrcAnim, animName); 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 // Constructs the animation for the given source anim
void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName) void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName)
@ -955,6 +1104,8 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
CollectNodes( pScene->mRootNode, nodes); CollectNodes( pScene->mRootNode, nodes);
std::vector<aiNodeAnim*> anims; std::vector<aiNodeAnim*> anims;
std::vector<aiMeshMorphAnim*> morphAnims;
for( std::vector<const aiNode*>::const_iterator nit = nodes.begin(); nit != nodes.end(); ++nit) 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 // find all the collada anim channels which refer to the current node
@ -978,7 +1129,20 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
// find the slash that separates the node name - there should be only one // find the slash that separates the node name - there should be only one
std::string::size_type slashPos = srcChannel.mTarget.find( '/'); std::string::size_type slashPos = srcChannel.mTarget.find( '/');
if( slashPos == std::string::npos) if( slashPos == std::string::npos)
{
std::string::size_type targetPos = srcChannel.mTarget.find(srcNode->mID);
if (targetPos == std::string::npos)
continue; 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) if( srcChannel.mTarget.find( '/', slashPos+1) != std::string::npos)
continue; continue;
std::string targetID = srcChannel.mTarget.substr( 0, slashPos); std::string targetID = srcChannel.mTarget.substr( 0, slashPos);
@ -1058,7 +1222,13 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
if( srcNode->mTransforms[a].mID == entry.mTransformId) if( srcNode->mTransforms[a].mID == entry.mTransformId)
entry.mTransformIndex = a; entry.mTransformIndex = a;
if( entry.mTransformIndex == SIZE_MAX) { if( entry.mTransformIndex == SIZE_MAX)
{
if (entry.mTransformId.find("morph-weights") != std::string::npos)
{
entry.mTargetId = entry.mTransformId;
entry.mTransformId = "";
} else
continue; continue;
} }
@ -1231,15 +1401,87 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
{ {
DefaultLogger::get()->warn( "Collada loader: found empty animation channel, ignored. Please check your exporter."); 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;
} }
if( !anims.empty()) 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() || !morphAnims.empty())
{ {
aiAnimation* anim = new aiAnimation; aiAnimation* anim = new aiAnimation;
anim->mName.Set( pName); anim->mName.Set( pName);
anim->mNumChannels = anims.size(); anim->mNumChannels = anims.size();
if (anim->mNumChannels > 0)
{
anim->mChannels = new aiNodeAnim*[anims.size()]; anim->mChannels = new aiNodeAnim*[anims.size()];
std::copy( anims.begin(), anims.end(), anim->mChannels); 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; anim->mDuration = 0.0f;
for( size_t a = 0; a < anims.size(); ++a) for( size_t a = 0; a < anims.size(); ++a)
{ {
@ -1247,6 +1489,10 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
anim->mDuration = std::max( anim->mDuration, anims[a]->mRotationKeys[anims[a]->mNumRotationKeys-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]->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; anim->mTicksPerSecond = 1;
mAnims.push_back( anim); mAnims.push_back( anim);
} }
@ -1520,13 +1766,13 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars
// and copy texture data // and copy texture data
tex->mHeight = 0; tex->mHeight = 0;
tex->mWidth = imIt->second.mImageData.size(); tex->mWidth = static_cast<unsigned int>(imIt->second.mImageData.size());
tex->pcData = (aiTexel*)new char[tex->mWidth]; tex->pcData = (aiTexel*)new char[tex->mWidth];
memcpy(tex->pcData,&imIt->second.mImageData[0],tex->mWidth); memcpy(tex->pcData,&imIt->second.mImageData[0],tex->mWidth);
// setup texture reference string // setup texture reference string
result.data[0] = '*'; result.data[0] = '*';
result.length = 1 + ASSIMP_itoa10(result.data+1,MAXLEN-1,mTextures.size()); result.length = 1 + ASSIMP_itoa10(result.data+1,static_cast<unsigned int>(MAXLEN-1),static_cast<int32_t>(mTextures.size()));
// and add this texture to the list // and add this texture to the list
mTextures.push_back(tex); mTextures.push_back(tex);

View File

@ -118,6 +118,8 @@ protected:
void BuildMeshesForNode( const ColladaParser& pParser, const Collada::Node* pNode, void BuildMeshesForNode( const ColladaParser& pParser, const Collada::Node* pNode,
aiNode* pTarget); aiNode* pTarget);
aiMesh *findMesh(std::string meshid);
/** Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh */ /** 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, aiMesh* CreateMesh( const ColladaParser& pParser, const Collada::Mesh* pSrcMesh, const Collada::SubMesh& pSubMesh,
const Collada::Controller* pSrcController, size_t pStartVertex, size_t pStartFace); const Collada::Controller* pSrcController, size_t pStartVertex, size_t pStartFace);
@ -224,6 +226,9 @@ protected:
/** Accumulated meshes for the target scene */ /** Accumulated meshes for the target scene */
std::vector<aiMesh*> mMeshes; std::vector<aiMesh*> mMeshes;
/** Accumulated morph target meshes */
std::vector<aiMesh*> mTargetMeshes;
/** Temporary material list */ /** Temporary material list */
std::vector<std::pair<Collada::Effect*, aiMaterial*> > newMats; std::vector<std::pair<Collada::Effect*, aiMaterial*> > newMats;

View File

@ -59,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Collada; using namespace Assimp::Collada;
using namespace Assimp::Formatter; using namespace Assimp::Formatter;
@ -586,6 +585,12 @@ void ColladaParser::ReadAnimationSampler( Collada::AnimationChannel& pChannel)
pChannel.mSourceTimes = source; pChannel.mSourceTimes = source;
else if( strcmp( semantic, "OUTPUT") == 0) else if( strcmp( semantic, "OUTPUT") == 0)
pChannel.mSourceValues = source; 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()) if( !mReader->isEmptyElement())
SkipElement(); SkipElement();
@ -648,6 +653,9 @@ void ColladaParser::ReadControllerLibrary()
// Reads a controller into the given mesh structure // Reads a controller into the given mesh structure
void ColladaParser::ReadController( Collada::Controller& pController) void ColladaParser::ReadController( Collada::Controller& pController)
{ {
// initial values
pController.mType = Skin;
pController.mMethod = Normalized;
while( mReader->read()) while( mReader->read())
{ {
if( mReader->getNodeType() == irr::io::EXN_ELEMENT) if( mReader->getNodeType() == irr::io::EXN_ELEMENT)
@ -655,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 // two types of controllers: "skin" and "morph". Only the first one is relevant, we skip the other
if( IsElement( "morph")) if( IsElement( "morph"))
{ {
// should skip everything inside, so there's no danger of catching elements inbetween pController.mType = Morph;
SkipElement(); 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")) else if( IsElement( "skin"))
{ {
@ -694,6 +709,32 @@ void ColladaParser::ReadController( Collada::Controller& pController)
{ {
ReadControllerWeights( 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 else
{ {
// ignore the rest // ignore the rest
@ -704,7 +745,7 @@ void ColladaParser::ReadController( Collada::Controller& pController)
{ {
if( strcmp( mReader->getNodeName(), "controller") == 0) if( strcmp( mReader->getNodeName(), "controller") == 0)
break; 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."); ThrowException( "Expected end of <controller> element.");
} }
} }
@ -1593,7 +1634,7 @@ void ColladaParser::ReadEffectColor( aiColor4D& pColor, Sampler& pSampler)
} }
else if( IsElement( "texture")) else if( IsElement( "texture"))
{ {
// get name of source textur/sampler // get name of source texture/sampler
int attrTex = GetAttribute( "texture"); int attrTex = GetAttribute( "texture");
pSampler.mName = mReader->getAttributeValue( attrTex); pSampler.mName = mReader->getAttributeValue( attrTex);
@ -2410,6 +2451,9 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
return numPrimitives; 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){ 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 // calculate the base offset of the vertex whose attributes we ant to copy
size_t baseOffset = currentPrimitive * numOffsets * numPoints + currentVertex * numOffsets; size_t baseOffset = currentPrimitive * numOffsets * numPoints + currentVertex * numOffsets;
@ -2535,7 +2579,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
aiColor4D result(0, 0, 0, 1); aiColor4D result(0, 0, 0, 1);
for (size_t i = 0; i < pInput.mResolved->mSize; ++i) for (size_t i = 0; i < pInput.mResolved->mSize; ++i)
{ {
result[i] = obj[pInput.mResolved->mSubOffset[i]]; result[static_cast<unsigned int>(i)] = obj[pInput.mResolved->mSubOffset[i]];
} }
pMesh->mColors[pInput.mIndex].push_back(result); pMesh->mColors[pInput.mIndex].push_back(result);
} else } else
@ -2828,7 +2872,7 @@ void ColladaParser::ReadNodeGeometry( Node* pNode)
if( !mReader->isEmptyElement()) if( !mReader->isEmptyElement())
{ {
// read material associations. Ignore additional elements inbetween // read material associations. Ignore additional elements in between
while( mReader->read()) while( mReader->read())
{ {
if( mReader->getNodeType() == irr::io::EXN_ELEMENT) if( mReader->getNodeType() == irr::io::EXN_ELEMENT)

View File

@ -49,7 +49,6 @@
#include "ColladaHelper.h" #include "ColladaHelper.h"
#include <assimp/ai_assert.h> #include <assimp/ai_assert.h>
#include "TinyFormatter.h" #include "TinyFormatter.h"
#include <memory>
namespace Assimp namespace Assimp
{ {
@ -268,8 +267,7 @@ namespace Assimp
Collada::InputType GetTypeForSemantic( const std::string& pSemantic); Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
/** Finds the item in the given library by its reference, throws if not found */ /** Finds the item in the given library by its reference, throws if not found */
template <typename Type> const Type& ResolveLibraryReference( template <typename Type> const Type& ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
protected: protected:
/** Filename, for a verbose error message */ /** Filename, for a verbose error message */

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

@ -38,29 +38,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
#include "D3MFImporter.h" #include "D3MFImporter.h"
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/importerdesc.h>
#include "StringComparison.h" #include "StringComparison.h"
#include "StringUtils.h" #include "StringUtils.h"
#include <string> #include <string>
#include <sstream>
#include <vector> #include <vector>
#include <map> #include <map>
#include <algorithm>
#include <cassert> #include <cassert>
#include <cstdlib>
#include <memory> #include <memory>
#include <assimp/ai_assert.h>
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
#include "D3MFOpcPackage.h" #include "D3MFOpcPackage.h"
#include <contrib/unzip/unzip.h> #include <contrib/unzip/unzip.h>
#include "irrXMLWrapper.h" #include "irrXMLWrapper.h"
@ -68,7 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
namespace D3MF { namespace D3MF {
namespace XmlTag { namespace XmlTag {
static const std::string model = "model"; static const std::string model = "model";
static const std::string metadata = "metadata"; static const std::string metadata = "metadata";
@ -104,31 +97,21 @@ public:
} }
void ImportXml(aiScene* scene) void ImportXml(aiScene* scene) {
{
scene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
scene->mRootNode = new aiNode(); scene->mRootNode = new aiNode();
std::vector<aiNode*> children; std::vector<aiNode*> children;
while(ReadToEndElement(D3MF::XmlTag::model)) while(ReadToEndElement(D3MF::XmlTag::model)) {
{ if(xmlReader->getNodeName() == D3MF::XmlTag::object) {
if(xmlReader->getNodeName() == D3MF::XmlTag::object)
{
children.push_back(ReadObject(scene)); children.push_back(ReadObject(scene));
} } else if(xmlReader->getNodeName() == D3MF::XmlTag::build) {
else if(xmlReader->getNodeName() == D3MF::XmlTag::build) // ???
{
} }
} }
if(scene->mRootNode->mName.length == 0) if(scene->mRootNode->mName.length == 0)
scene->mRootNode->mName.Set("3MF"); scene->mRootNode->mName.Set("3MF");
scene->mNumMeshes = static_cast<unsigned int>(meshes.size()); scene->mNumMeshes = static_cast<unsigned int>(meshes.size());
scene->mMeshes = new aiMesh*[scene->mNumMeshes](); scene->mMeshes = new aiMesh*[scene->mNumMeshes]();
@ -172,7 +155,7 @@ private:
mesh->mName.Set(name); mesh->mName.Set(name);
meshes.push_back(mesh); meshes.push_back(mesh);
meshIds.push_back(meshIdx); meshIds.push_back(static_cast<unsigned long>(meshIdx));
meshIdx++; meshIdx++;
} }
@ -229,9 +212,10 @@ private:
aiVector3D ReadVertex() aiVector3D ReadVertex()
{ {
aiVector3D vertex; aiVector3D vertex;
vertex.x = ai_strtof(xmlReader->getAttributeValue(D3MF::XmlTag::x.c_str()), nullptr); 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.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; return vertex;
} }
@ -312,8 +296,6 @@ private:
private: private:
std::vector<aiMesh*> meshes; std::vector<aiMesh*> meshes;
XmlReader* xmlReader; XmlReader* xmlReader;
}; };
} //namespace D3MF } //namespace D3MF

View File

@ -41,9 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_D3MFLOADER_H_INCLUDED #ifndef AI_D3MFLOADER_H_INCLUDED
#define AI_D3MFLOADER_H_INCLUDED #define AI_D3MFLOADER_H_INCLUDED
#include <vector>
#include <cstdint>
#include "BaseImporter.h" #include "BaseImporter.h"
namespace Assimp { namespace Assimp {

View File

@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
#include "D3MFOpcPackage.h" #include "D3MFOpcPackage.h"
#include "Exceptional.h" #include "Exceptional.h"
@ -52,9 +53,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <map> #include <map>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cstdlib>
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
#include <contrib/unzip/unzip.h> #include <contrib/unzip/unzip.h>
@ -123,19 +121,19 @@ voidpf IOSystem2Unzip::open(voidpf opaque, const char* filename, int mode) {
uLong IOSystem2Unzip::read(voidpf /*opaque*/, voidpf stream, void* buf, uLong size) { uLong IOSystem2Unzip::read(voidpf /*opaque*/, voidpf stream, void* buf, uLong size) {
IOStream* io_stream = (IOStream*) stream; IOStream* io_stream = (IOStream*) stream;
return io_stream->Read(buf, 1, size); return static_cast<uLong>(io_stream->Read(buf, 1, size));
} }
uLong IOSystem2Unzip::write(voidpf /*opaque*/, voidpf stream, const void* buf, uLong size) { uLong IOSystem2Unzip::write(voidpf /*opaque*/, voidpf stream, const void* buf, uLong size) {
IOStream* io_stream = (IOStream*) stream; IOStream* io_stream = (IOStream*) stream;
return io_stream->Write(buf, 1, size); return static_cast<uLong>(io_stream->Write(buf, 1, size));
} }
long IOSystem2Unzip::tell(voidpf /*opaque*/, voidpf stream) { long IOSystem2Unzip::tell(voidpf /*opaque*/, voidpf stream) {
IOStream* io_stream = (IOStream*) stream; IOStream* io_stream = (IOStream*) stream;
return io_stream->Tell(); return static_cast<long>(io_stream->Tell());
} }
long IOSystem2Unzip::seek(voidpf /*opaque*/, voidpf stream, uLong offset, int origin) { long IOSystem2Unzip::seek(voidpf /*opaque*/, voidpf stream, uLong offset, int origin) {

View File

@ -41,7 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef D3MFOPCPACKAGE_H #ifndef D3MFOPCPACKAGE_H
#define D3MFOPCPACKAGE_H #define D3MFOPCPACKAGE_H
#include <string>
#include <memory> #include <memory>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>

View File

@ -54,6 +54,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "DXFHelper.h" #include "DXFHelper.h"
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/importerdesc.h>
#include <numeric> #include <numeric>
using namespace Assimp; using namespace Assimp;
@ -223,8 +225,8 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
unsigned int vcount = 0, icount = 0; unsigned int vcount = 0, icount = 0;
for (const DXF::Block& bl : output.blocks) { for (const DXF::Block& bl : output.blocks) {
for (std::shared_ptr<const DXF::PolyLine> pl : bl.lines) { for (std::shared_ptr<const DXF::PolyLine> pl : bl.lines) {
vcount += pl->positions.size(); vcount += static_cast<unsigned int>(pl->positions.size());
icount += pl->counts.size(); icount += static_cast<unsigned int>(pl->counts.size());
} }
} }
@ -296,7 +298,7 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
for(const DXF::PolyLine* pl : corr[elem.second]){ for(const DXF::PolyLine* pl : corr[elem.second]){
// sum over all faces since we need to 'verbosify' them. // sum over all faces since we need to 'verbosify' them.
cvert += std::accumulate(pl->counts.begin(),pl->counts.end(),0); cvert += std::accumulate(pl->counts.begin(),pl->counts.end(),0);
cface += pl->counts.size(); cface += static_cast<unsigned int>(pl->counts.size());
} }
aiVector3D* verts = mesh->mVertices = new aiVector3D[cvert]; aiVector3D* verts = mesh->mVertices = new aiVector3D[cvert];
@ -705,7 +707,7 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
// closed polyline? // closed polyline?
if (line.flags & DXF_POLYLINE_FLAG_CLOSED) { if (line.flags & DXF_POLYLINE_FLAG_CLOSED) {
line.indices.push_back(line.positions.size()-1); line.indices.push_back(static_cast<unsigned int>(line.positions.size()-1));
line.indices.push_back(0); line.indices.push_back(0);
line.counts.push_back(2); line.counts.push_back(2);
} }
@ -906,7 +908,7 @@ void DXFImporter::Parse3DFace(DXF::LineReader& reader, DXF::FileData& output)
line.counts.push_back(cnt); line.counts.push_back(cnt);
for (unsigned int i = 0; i < cnt; ++i) { for (unsigned int i = 0; i < cnt; ++i) {
line.indices.push_back(line.positions.size()); line.indices.push_back(static_cast<unsigned int>(line.positions.size()));
line.positions.push_back(vip[i]); line.positions.push_back(vip[i]);
line.colors.push_back(clr); line.colors.push_back(clr);
} }

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_DXFLOADER_H_INCLUDED #define AI_DXFLOADER_H_INCLUDED
#include "BaseImporter.h" #include "BaseImporter.h"
#include <map>
namespace Assimp { namespace Assimp {
namespace DXF { namespace DXF {

View File

@ -137,7 +137,7 @@ void DeboneProcess::Execute( aiScene* pScene)
const aiString *find = newMeshes[b].second?&newMeshes[b].second->mName:0; const aiString *find = newMeshes[b].second?&newMeshes[b].second->mName:0;
aiNode *theNode = find?pScene->mRootNode->FindNode(*find):0; aiNode *theNode = find?pScene->mRootNode->FindNode(*find):0;
std::pair<unsigned int,aiNode*> push_pair(meshes.size(),theNode); std::pair<unsigned int,aiNode*> push_pair(static_cast<unsigned int>(meshes.size()),theNode);
mSubMeshIndices[a].push_back(push_pair); mSubMeshIndices[a].push_back(push_pair);
meshes.push_back(newMeshes[b].first); meshes.push_back(newMeshes[b].first);
@ -156,13 +156,13 @@ void DeboneProcess::Execute( aiScene* pScene)
} }
else { else {
// Mesh is kept unchanged - store it's new place in the mesh array // Mesh is kept unchanged - store it's new place in the mesh array
mSubMeshIndices[a].push_back(std::pair<unsigned int,aiNode*>(meshes.size(),(aiNode*)0)); mSubMeshIndices[a].push_back(std::pair<unsigned int,aiNode*>(static_cast<unsigned int>(meshes.size()),(aiNode*)0));
meshes.push_back(srcMesh); meshes.push_back(srcMesh);
} }
} }
// rebuild the scene's mesh array // rebuild the scene's mesh array
pScene->mNumMeshes = meshes.size(); pScene->mNumMeshes = static_cast<unsigned int>(meshes.size());
delete [] pScene->mMeshes; delete [] pScene->mMeshes;
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
std::copy( meshes.begin(), meshes.end(), pScene->mMeshes); std::copy( meshes.begin(), meshes.end(), pScene->mMeshes);
@ -382,7 +382,7 @@ void DeboneProcess::UpdateNode(aiNode* pNode) const
// this will require two passes // this will require two passes
unsigned int m = pNode->mNumMeshes, n = mSubMeshIndices.size(); unsigned int m = static_cast<unsigned int>(pNode->mNumMeshes), n = static_cast<unsigned int>(mSubMeshIndices.size());
// first pass, look for meshes which have not moved // first pass, look for meshes which have not moved
@ -390,7 +390,7 @@ void DeboneProcess::UpdateNode(aiNode* pNode) const
unsigned int srcIndex = pNode->mMeshes[a]; unsigned int srcIndex = pNode->mMeshes[a];
const std::vector< std::pair< unsigned int,aiNode* > > &subMeshes = mSubMeshIndices[srcIndex]; const std::vector< std::pair< unsigned int,aiNode* > > &subMeshes = mSubMeshIndices[srcIndex];
unsigned int nSubmeshes = subMeshes.size(); unsigned int nSubmeshes = static_cast<unsigned int>(subMeshes.size());
for(unsigned int b=0;b<nSubmeshes;b++) { for(unsigned int b=0;b<nSubmeshes;b++) {
if(!subMeshes[b].second) { if(!subMeshes[b].second) {
@ -404,7 +404,7 @@ void DeboneProcess::UpdateNode(aiNode* pNode) const
for(unsigned int a=0;a<n;a++) for(unsigned int a=0;a<n;a++)
{ {
const std::vector< std::pair< unsigned int,aiNode* > > &subMeshes = mSubMeshIndices[a]; const std::vector< std::pair< unsigned int,aiNode* > > &subMeshes = mSubMeshIndices[a];
unsigned int nSubmeshes = subMeshes.size(); unsigned int nSubmeshes = static_cast<unsigned int>(subMeshes.size());
for(unsigned int b=0;b<nSubmeshes;b++) { for(unsigned int b=0;b<nSubmeshes;b++) {
if(subMeshes[b].second == pNode) { if(subMeshes[b].second == pNode) {
@ -417,7 +417,7 @@ void DeboneProcess::UpdateNode(aiNode* pNode) const
delete [] pNode->mMeshes; pNode->mMeshes = NULL; delete [] pNode->mMeshes; pNode->mMeshes = NULL;
} }
pNode->mNumMeshes = newMeshList.size(); pNode->mNumMeshes = static_cast<unsigned int>(newMeshList.size());
if(pNode->mNumMeshes) { if(pNode->mNumMeshes) {
pNode->mMeshes = new unsigned int[pNode->mNumMeshes]; pNode->mMeshes = new unsigned int[pNode->mNumMeshes];

View File

@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/ai_assert.h> #include <assimp/ai_assert.h>
#include "DefaultIOStream.h" #include <assimp/DefaultIOStream.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -120,13 +120,13 @@ size_t DefaultIOStream::FileSize() const
// //
// See here for details: // See here for details:
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file // https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
#if defined _WIN32 #if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
struct __stat64 fileStat; struct __stat64 fileStat;
int err = _stat64( mFilename.c_str(), &fileStat ); int err = _stat64( mFilename.c_str(), &fileStat );
if (0 != err) if (0 != err)
return 0; return 0;
mCachedSize = (size_t) (fileStat.st_size); mCachedSize = (size_t) (fileStat.st_size);
#elif defined __gnu_linux__ || defined __APPLE__ || defined __MACH__ #elif defined __GNUC__ || defined __APPLE__ || defined __MACH__ || defined __FreeBSD__
struct stat fileStat; struct stat fileStat;
int err = stat(mFilename.c_str(), &fileStat ); int err = stat(mFilename.c_str(), &fileStat );
if (0 != err) if (0 != err)

View File

@ -40,10 +40,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** @file Default implementation of IOSystem using the standard C file functions */ /** @file Default implementation of IOSystem using the standard C file functions */
#include "DefaultIOSystem.h"
#include "DefaultIOStream.h"
#include "StringComparison.h" #include "StringComparison.h"
#include <assimp/DefaultIOSystem.h>
#include <assimp/DefaultIOStream.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/ai_assert.h> #include <assimp/ai_assert.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -43,13 +43,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Implementation of DefaultLogger (and Logger) * @brief Implementation of DefaultLogger (and Logger)
*/ */
#include "DefaultIOSystem.h"
// Default log streams // Default log streams
#include "Win32DebugLogStream.h" #include "Win32DebugLogStream.h"
#include "StdOStreamLogStream.h" #include "StdOStreamLogStream.h"
#include "FileLogStream.h" #include "FileLogStream.h"
#include "StringUtils.h" #include "StringUtils.h"
#include <assimp/DefaultIOSystem.h>
#include <assimp/NullLogger.hpp> #include <assimp/NullLogger.hpp>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/ai_assert.h> #include <assimp/ai_assert.h>

View File

@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_EXCEPTIONAL_H #define INCLUDED_EXCEPTIONAL_H
#include <stdexcept> #include <stdexcept>
#include "DefaultIOStream.h" #include <assimp/DefaultIOStream.h>
using std::runtime_error; using std::runtime_error;
#ifdef _MSC_VER #ifdef _MSC_VER

View File

@ -52,7 +52,6 @@ Here we implement only the C++ interface (Assimp::Exporter).
#ifndef ASSIMP_BUILD_NO_EXPORT #ifndef ASSIMP_BUILD_NO_EXPORT
#include "DefaultIOSystem.h"
#include "BlobIOSystem.h" #include "BlobIOSystem.h"
#include "SceneCombiner.h" #include "SceneCombiner.h"
#include "BaseProcess.h" #include "BaseProcess.h"
@ -64,11 +63,12 @@ Here we implement only the C++ interface (Assimp::Exporter).
#include "Exceptional.h" #include "Exceptional.h"
#include "ScenePrivate.h" #include "ScenePrivate.h"
#include <memory> #include <memory>
#include <assimp/DefaultIOSystem.h>
#include <assimp/Exporter.hpp> #include <assimp/Exporter.hpp>
#include <assimp/mesh.h> #include <assimp/mesh.h>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <memory>
namespace Assimp { namespace Assimp {
@ -101,7 +101,7 @@ Exporter::ExportFormatEntry gExporters[] =
Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada), Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada),
#endif #endif
#ifndef ASSIMP_BUILD_NO_XFILE_EXPORTER #ifndef ASSIMP_BUILD_NO_X_EXPORTER
Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile, Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile,
aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs), aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs),
#endif #endif
@ -163,7 +163,6 @@ Exporter::ExportFormatEntry gExporters[] =
class ExporterPimpl { class ExporterPimpl {
public: public:
ExporterPimpl() ExporterPimpl()
: blob() : blob()
, mIOSystem(new Assimp::DefaultIOSystem()) , mIOSystem(new Assimp::DefaultIOSystem())
@ -171,7 +170,7 @@ public:
{ {
GetPostProcessingStepInstanceList(mPostProcessingSteps); GetPostProcessingStepInstanceList(mPostProcessingSteps);
// grab all builtin exporters // grab all built-in exporters
mExporters.resize(ASSIMP_NUM_EXPORTERS); mExporters.resize(ASSIMP_NUM_EXPORTERS);
std::copy(gExporters,gExporters+ASSIMP_NUM_EXPORTERS,mExporters.begin()); std::copy(gExporters,gExporters+ASSIMP_NUM_EXPORTERS,mExporters.begin());
} }
@ -202,65 +201,48 @@ public:
std::vector<Exporter::ExportFormatEntry> mExporters; std::vector<Exporter::ExportFormatEntry> mExporters;
}; };
} // end of namespace Assimp } // end of namespace Assimp
using namespace Assimp; using namespace Assimp;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Exporter :: Exporter() Exporter :: Exporter()
: pimpl(new ExporterPimpl()) : pimpl(new ExporterPimpl()) {
{ // empty
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Exporter :: ~Exporter() Exporter::~Exporter() {
{
FreeBlob(); FreeBlob();
delete pimpl; delete pimpl;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Exporter :: SetIOHandler( IOSystem* pIOHandler) void Exporter::SetIOHandler( IOSystem* pIOHandler) {
{
pimpl->mIsDefaultIOHandler = !pIOHandler; pimpl->mIsDefaultIOHandler = !pIOHandler;
pimpl->mIOSystem.reset(pIOHandler); pimpl->mIOSystem.reset(pIOHandler);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
IOSystem* Exporter :: GetIOHandler() const IOSystem* Exporter::GetIOHandler() const {
{
return pimpl->mIOSystem.get(); return pimpl->mIOSystem.get();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool Exporter :: IsDefaultIOHandler() const bool Exporter::IsDefaultIOHandler() const {
{
return pimpl->mIsDefaultIOHandler; 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) { if (pimpl->blob) {
delete pimpl->blob; delete pimpl->blob;
pimpl->blob = NULL; pimpl->blob = NULL;
} }
std::shared_ptr<IOSystem> old = pimpl->mIOSystem; std::shared_ptr<IOSystem> old = pimpl->mIOSystem;
BlobIOSystem* blobio = new BlobIOSystem(); BlobIOSystem* blobio = new BlobIOSystem();
pimpl->mIOSystem = std::shared_ptr<IOSystem>( blobio ); pimpl->mIOSystem = std::shared_ptr<IOSystem>( blobio );
@ -275,10 +257,8 @@ const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const
return pimpl->blob; return pimpl->blob;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool IsVerboseFormat(const aiMesh* mesh) bool IsVerboseFormat(const aiMesh* mesh) {
{
// avoid slow vector<bool> specialization // avoid slow vector<bool> specialization
std::vector<unsigned int> seen(mesh->mNumVertices,0); std::vector<unsigned int> seen(mesh->mNumVertices,0);
for(unsigned int i = 0; i < mesh->mNumFaces; ++i) { for(unsigned int i = 0; i < mesh->mNumFaces; ++i) {
@ -293,10 +273,8 @@ bool IsVerboseFormat(const aiMesh* mesh)
return true; return true;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool IsVerboseFormat(const aiScene* pScene) bool IsVerboseFormat(const aiScene* pScene) {
{
for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
if(!IsVerboseFormat(pScene->mMeshes[i])) { if(!IsVerboseFormat(pScene->mMeshes[i])) {
return false; return false;
@ -305,10 +283,8 @@ bool IsVerboseFormat(const aiScene* pScene)
return true; 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(); ASSIMP_BEGIN_EXCEPTION_REGION();
// when they create scenes from scratch, users will likely create them not in verbose // when they create scenes from scratch, users will likely create them not in verbose
@ -321,9 +297,7 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
for (size_t i = 0; i < pimpl->mExporters.size(); ++i) { for (size_t i = 0; i < pimpl->mExporters.size(); ++i) {
const Exporter::ExportFormatEntry& exp = pimpl->mExporters[i]; const Exporter::ExportFormatEntry& exp = pimpl->mExporters[i];
if (!strcmp(exp.mDescription.id,pFormatId)) { if (!strcmp(exp.mDescription.id,pFormatId)) {
try { try {
// Always create a full copy of the scene. We might optimize this one day, // Always create a full copy of the scene. We might optimize this one day,
// but for now it is the most pragmatic way. // but for now it is the most pragmatic way.
aiScene* scenecopy_tmp = NULL; aiScene* scenecopy_tmp = NULL;
@ -342,18 +316,17 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
? (priv->mPPStepsApplied & ~nonIdempotentSteps) ? (priv->mPPStepsApplied & ~nonIdempotentSteps)
: 0u); : 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. // Assimp importer, apply the reverse steps automatically.
// TODO: either drop this, or document it. Otherwise it is just a bad surprise. // TODO: either drop this, or document it. Otherwise it is just a bad surprise.
//if (!pPreprocessing && priv) { //if (!pPreprocessing && priv) {
// pp |= (nonIdempotentSteps & priv->mPPStepsApplied); // 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. // we need to run the MakeVerboseFormat step first.
bool must_join_again = false; bool must_join_again = false;
if (!is_verbose_format) { if (!is_verbose_format) {
bool verbosify = false; bool verbosify = false;
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) { for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
BaseProcess* const p = pimpl->mPostProcessingSteps[a]; BaseProcess* const p = pimpl->mPostProcessingSteps[a];
@ -424,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. ExportProperties emptyProperties; // Never pass NULL ExportProperties so Exporters don't have to worry.
exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProperties ? pProperties : &emptyProperties); exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProperties ? pProperties : &emptyProperties);
} } catch (DeadlyExportError& err) {
catch (DeadlyExportError& err) {
pimpl->mError = err.what(); pimpl->mError = err.what();
return AI_FAILURE; return AI_FAILURE;
} }
@ -438,64 +410,53 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
return AI_FAILURE; return AI_FAILURE;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const char* Exporter :: GetErrorString() const const char* Exporter::GetErrorString() const {
{
return pimpl->mError.c_str(); return pimpl->mError.c_str();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Exporter :: FreeBlob( ) void Exporter::FreeBlob() {
{
delete pimpl->blob; delete pimpl->blob;
pimpl->blob = NULL; pimpl->blob = NULL;
pimpl->mError = ""; pimpl->mError = "";
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const aiExportDataBlob* Exporter :: GetBlob() const const aiExportDataBlob* Exporter::GetBlob() const {
{
return pimpl->blob; return pimpl->blob;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const aiExportDataBlob* Exporter :: GetOrphanedBlob() const const aiExportDataBlob* Exporter::GetOrphanedBlob() const {
{
const aiExportDataBlob* tmp = pimpl->blob; const aiExportDataBlob* tmp = pimpl->blob;
pimpl->blob = NULL; pimpl->blob = NULL;
return tmp; return tmp;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
size_t Exporter :: GetExportFormatCount() const size_t Exporter::GetExportFormatCount() const {
{
return pimpl->mExporters.size(); return pimpl->mExporters.size();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const aiExportFormatDesc* Exporter :: GetExportFormatDescription( size_t pIndex ) const const aiExportFormatDesc* Exporter::GetExportFormatDescription( size_t index ) const {
{ if (index >= GetExportFormatCount()) {
if (pIndex >= GetExportFormatCount()) {
return NULL; return NULL;
} }
// Return from static storage if the requested index is built-in. // Return from static storage if the requested index is built-in.
if (pIndex < sizeof(gExporters) / sizeof(gExporters[0])) { if (index < sizeof(gExporters) / sizeof(gExporters[0])) {
return &gExporters[pIndex].mDescription; 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) { for(const ExportFormatEntry& e : pimpl->mExporters) {
if (!strcmp(e.mDescription.id,desc.mDescription.id)) { if (!strcmp(e.mDescription.id,desc.mDescription.id)) {
return aiReturn_FAILURE; return aiReturn_FAILURE;
@ -506,10 +467,8 @@ aiReturn Exporter :: RegisterExporter(const ExportFormatEntry& desc)
return aiReturn_SUCCESS; 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) { for(std::vector<ExportFormatEntry>::iterator it = pimpl->mExporters.begin(); it != pimpl->mExporters.end(); ++it) {
if (!strcmp((*it).mDescription.id,id)) { if (!strcmp((*it).mDescription.id,id)) {
pimpl->mExporters.erase(it); pimpl->mExporters.erase(it);
@ -518,29 +477,30 @@ void Exporter :: UnregisterExporter(const char* id)
} }
} }
ExportProperties :: ExportProperties() {} // ------------------------------------------------------------------------------------------------
ExportProperties::ExportProperties() {
// empty
}
// ------------------------------------------------------------------------------------------------
ExportProperties::ExportProperties(const ExportProperties &other) ExportProperties::ExportProperties(const ExportProperties &other)
: mIntProperties(other.mIntProperties), : mIntProperties(other.mIntProperties)
mFloatProperties(other.mFloatProperties), , mFloatProperties(other.mFloatProperties)
mStringProperties(other.mStringProperties), , mStringProperties(other.mStringProperties)
mMatrixProperties(other.mMatrixProperties) , mMatrixProperties(other.mMatrixProperties) {
{ // empty
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Set a configuration property // 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); return SetGenericProperty<int>(mIntProperties, szName,iValue);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Set a configuration property // 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); return SetGenericProperty<ai_real>(mFloatProperties, szName,iValue);
} }
@ -602,28 +562,28 @@ bool ExportProperties :: HasPropertyInteger(const char* szName) const
bool ExportProperties :: HasPropertyBool(const char* szName) const bool ExportProperties :: HasPropertyBool(const char* szName) const
{ {
return HasGenericProperty<int>(mIntProperties, szName); return HasGenericProperty<int>(mIntProperties, szName);
}; }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Has a configuration property // Has a configuration property
bool ExportProperties :: HasPropertyFloat(const char* szName) const bool ExportProperties :: HasPropertyFloat(const char* szName) const
{ {
return HasGenericProperty<ai_real>(mFloatProperties, szName); return HasGenericProperty<ai_real>(mFloatProperties, szName);
}; }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Has a configuration property // Has a configuration property
bool ExportProperties :: HasPropertyString(const char* szName) const bool ExportProperties :: HasPropertyString(const char* szName) const
{ {
return HasGenericProperty<std::string>(mStringProperties, szName); return HasGenericProperty<std::string>(mStringProperties, szName);
}; }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Has a configuration property // Has a configuration property
bool ExportProperties :: HasPropertyMatrix(const char* szName) const bool ExportProperties :: HasPropertyMatrix(const char* szName) const
{ {
return HasGenericProperty<aiMatrix4x4>(mMatrixProperties, szName); return HasGenericProperty<aiMatrix4x4>(mMatrixProperties, szName);
}; }
#endif // !ASSIMP_BUILD_NO_EXPORT #endif // !ASSIMP_BUILD_NO_EXPORT

View File

@ -48,7 +48,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXParser.h" #include "FBXParser.h"
#include "FBXDocument.h" #include "FBXDocument.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "FBXImportSettings.h"
#include "FBXDocumentUtil.h" #include "FBXDocumentUtil.h"
#include "FBXProperties.h" #include "FBXProperties.h"

View File

@ -146,18 +146,20 @@ void TokenizeError(const std::string& message, const char* begin, const char* cu
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
uint32_t ReadWord(const char* input, const char*& cursor, const char* end) uint32_t ReadWord(const char* input, const char*& cursor, const char* end)
{ {
if(Offset(cursor, end) < 4) { const size_t k_to_read = sizeof( uint32_t );
if(Offset(cursor, end) < k_to_read ) {
TokenizeError("cannot ReadWord, out of bounds",input, cursor); TokenizeError("cannot ReadWord, out of bounds",input, cursor);
} }
uint32_t word = *reinterpret_cast<const uint32_t*>(cursor); uint32_t word = *reinterpret_cast<const uint32_t*>(cursor);
AI_SWAP4(word); AI_SWAP4(word);
cursor += 4; cursor += k_to_read;
return word; return word;
} }
// ------------------------------------------------------------------------------------------------
uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end) uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end)
{ {
const size_t k_to_read = sizeof(uint64_t); const size_t k_to_read = sizeof(uint64_t);
@ -177,7 +179,7 @@ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
uint8_t ReadByte(const char* input, const char*& cursor, const char* end) uint8_t ReadByte(const char* input, const char*& cursor, const char* end)
{ {
if(Offset(cursor, end) < 1) { if(Offset(cursor, end) < sizeof( uint8_t ) ) {
TokenizeError("cannot ReadByte, out of bounds",input, cursor); TokenizeError("cannot ReadByte, out of bounds",input, cursor);
} }
@ -220,8 +222,6 @@ unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const ch
return length; return length;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end) void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end)
{ {
@ -345,7 +345,7 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, const char* end, uint32_t const flags) bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, const char* end, uint32_t const flags)
{ {
// the first word contains the offset at which this block ends // the first word contains the offset at which this block ends
const uint64_t end_offset = check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end); const uint64_t end_offset = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : */ReadWord(input, cursor, end);
// we may get 0 if reading reached the end of the file - // we may get 0 if reading reached the end of the file -
// fbx files have a mysterious extra footer which I don't know // fbx files have a mysterious extra footer which I don't know
@ -363,10 +363,10 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
} }
// the second data word contains the number of properties in the scope // the second data word contains the number of properties in the scope
const uint64_t prop_count = check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end); const uint64_t prop_count = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : */ReadWord(input, cursor, end);
// the third data word contains the length of the property list // the third data word contains the length of the property list
const uint64_t prop_length = check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end); const uint64_t prop_length = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) :*/ ReadWord(input, cursor, end);
// now comes the name of the scope/key // now comes the name of the scope/key
const char* sbeg, *send; const char* sbeg, *send;
@ -393,7 +393,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
// at the end of each nested block, there is a NUL record to indicate // at the end of each nested block, there is a NUL record to indicate
// that the sub-scope exists (i.e. to distinguish between P: and P : {}) // that the sub-scope exists (i.e. to distinguish between P: and P : {})
// this NUL record is 13 bytes long on 32 bit version and 25 bytes long on 64 bit. // this NUL record is 13 bytes long on 32 bit version and 25 bytes long on 64 bit.
const size_t sentinel_block_length = check_flag(flags, e_flag_field_size_64_bit) ? (sizeof(uint64_t) * 3 + 1) : (sizeof(uint32_t) * 3 + 1); const size_t sentinel_block_length = /*check_flag(flags, e_flag_field_size_64_bit) ? (sizeof(uint64_t) * 3 + 1) : */(sizeof(uint32_t) * 3 + 1);
if (Offset(input, cursor) < end_offset) { if (Offset(input, cursor) < end_offset) {
if (end_offset - Offset(input, cursor) < sentinel_block_length) { if (end_offset - Offset(input, cursor) < sentinel_block_length) {

View File

@ -44,6 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef INCLUDED_AI_FBX_COMPILECONFIG_H #ifndef INCLUDED_AI_FBX_COMPILECONFIG_H
#define INCLUDED_AI_FBX_COMPILECONFIG_H #define INCLUDED_AI_FBX_COMPILECONFIG_H
#include <map>
// //
#if _MSC_VER > 1500 || (defined __GNUC___) #if _MSC_VER > 1500 || (defined __GNUC___)
# define ASSIMP_FBX_USE_UNORDERED_MULTIMAP # define ASSIMP_FBX_USE_UNORDERED_MULTIMAP

View File

@ -58,7 +58,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
#include <iterator> #include <iterator>
#include <sstream>
#include <vector> #include <vector>
namespace Assimp { namespace Assimp {
@ -71,7 +70,7 @@ using namespace Util;
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000L #define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000L
// XXX vc9's debugger won't step into anonymous namespaces // XXX vc9's debugger won't step into anonymous namespaces
//namespace { //namespace {
/** Dummy class to encapsulate the conversion process */ /** Dummy class to encapsulate the conversion process */
@ -114,11 +113,9 @@ private:
// collect and assign child nodes // collect and assign child nodes
void ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform = aiMatrix4x4() ); void ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform = aiMatrix4x4() );
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ConvertLights( const Model& model ); void ConvertLights( const Model& model );
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ConvertCameras( const Model& model ); void ConvertCameras( const Model& model );
@ -189,7 +186,6 @@ private:
static const unsigned int NO_MATERIAL_SEPARATION = /* std::numeric_limits<unsigned int>::max() */ static const unsigned int NO_MATERIAL_SEPARATION = /* std::numeric_limits<unsigned int>::max() */
static_cast<unsigned int>(-1); static_cast<unsigned int>(-1);
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
/** /**
* - if materialIndex == NO_MATERIAL_SEPARATION, materials are not taken into * - if materialIndex == NO_MATERIAL_SEPARATION, materials are not taken into
@ -341,8 +337,6 @@ private:
typedef std::tuple<std::shared_ptr<KeyTimeList>, std::shared_ptr<KeyValueList>, unsigned int > KeyFrameList; typedef std::tuple<std::shared_ptr<KeyTimeList>, std::shared_ptr<KeyValueList>, unsigned int > KeyFrameList;
typedef std::vector<KeyFrameList> KeyFrameListList; typedef std::vector<KeyFrameList> KeyFrameListList;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
KeyFrameListList GetKeyframeList( const std::vector<const AnimationCurveNode*>& nodes, int64_t start, int64_t stop ); KeyFrameListList GetKeyframeList( const std::vector<const AnimationCurveNode*>& nodes, int64_t start, int64_t stop );
@ -645,7 +639,7 @@ void Converter::ConvertLight( const Model& model, const Light& light )
out_light->mName.Set( FixNodeName( model.Name() ) ); out_light->mName.Set( FixNodeName( model.Name() ) );
const float intensity = light.Intensity(); const float intensity = light.Intensity() / 100.0f;
const aiVector3D& col = light.Color(); const aiVector3D& col = light.Color();
out_light->mColorDiffuse = aiColor3D( col.x, col.y, col.z ); out_light->mColorDiffuse = aiColor3D( col.x, col.y, col.z );
@ -655,6 +649,11 @@ void Converter::ConvertLight( const Model& model, const Light& light )
out_light->mColorSpecular = out_light->mColorDiffuse; out_light->mColorSpecular = out_light->mColorDiffuse;
//lights are defined along negative y direction
out_light->mPosition = aiVector3D(0.0f);
out_light->mDirection = aiVector3D(0.0f, -1.0f, 0.0f);
out_light->mUp = aiVector3D(0.0f, 0.0f, -1.0f);
switch ( light.LightType() ) switch ( light.LightType() )
{ {
case Light::Type_Point: case Light::Type_Point:
@ -684,17 +683,23 @@ void Converter::ConvertLight( const Model& model, const Light& light )
ai_assert( false ); ai_assert( false );
} }
// XXX: how to best convert the near and far decay ranges? float decay = light.DecayStart();
switch ( light.DecayType() ) switch ( light.DecayType() )
{ {
case Light::Decay_None: case Light::Decay_None:
out_light->mAttenuationConstant = 1.0f; out_light->mAttenuationConstant = decay;
out_light->mAttenuationLinear = 0.0f;
out_light->mAttenuationQuadratic = 0.0f;
break; break;
case Light::Decay_Linear: case Light::Decay_Linear:
out_light->mAttenuationLinear = 1.0f; out_light->mAttenuationConstant = 0.0f;
out_light->mAttenuationLinear = 2.0f / decay;
out_light->mAttenuationQuadratic = 0.0f;
break; break;
case Light::Decay_Quadratic: case Light::Decay_Quadratic:
out_light->mAttenuationQuadratic = 1.0f; out_light->mAttenuationConstant = 0.0f;
out_light->mAttenuationLinear = 0.0f;
out_light->mAttenuationQuadratic = 2.0f / (decay * decay);
break; break;
case Light::Decay_Cubic: case Light::Decay_Cubic:
FBXImporter::LogWarn( "cannot represent cubic attenuation, set to Quadratic" ); FBXImporter::LogWarn( "cannot represent cubic attenuation, set to Quadratic" );
@ -713,10 +718,13 @@ void Converter::ConvertCamera( const Model& model, const Camera& cam )
out_camera->mName.Set( FixNodeName( model.Name() ) ); out_camera->mName.Set( FixNodeName( model.Name() ) );
out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight(); out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
out_camera->mPosition = cam.Position(); //cameras are defined along positive x direction
out_camera->mUp = cam.UpVector(); out_camera->mPosition = aiVector3D(0.0f);
out_camera->mLookAt = cam.InterestPosition() - out_camera->mPosition; out_camera->mLookAt = aiVector3D(1.0f, 0.0f, 0.0f);
out_camera->mUp = aiVector3D(0.0f, 1.0f, 0.0f);
out_camera->mHorizontalFOV = AI_DEG_TO_RAD( cam.FieldOfView() ); out_camera->mHorizontalFOV = AI_DEG_TO_RAD( cam.FieldOfView() );
out_camera->mClipPlaneNear = cam.NearPlane();
out_camera->mClipPlaneFar = cam.FarPlane();
} }
@ -899,7 +907,6 @@ void Converter::GetRotationMatrix( Model::RotOrder mode, const aiVector3D& rotat
} }
} }
bool Converter::NeedsComplexTransformationChain( const Model& model ) bool Converter::NeedsComplexTransformationChain( const Model& model )
{ {
const PropertyTable& props = model.Props(); const PropertyTable& props = model.Props();
@ -923,7 +930,6 @@ bool Converter::NeedsComplexTransformationChain( const Model& model )
return false; return false;
} }
std::string Converter::NameTransformationChainNode( const std::string& name, TransformationComp comp ) std::string Converter::NameTransformationChainNode( const std::string& name, TransformationComp comp )
{ {
return name + std::string( MAGIC_NODE_TAG ) + "_" + NameTransformationComp( comp ); return name + std::string( MAGIC_NODE_TAG ) + "_" + NameTransformationComp( comp );
@ -1067,7 +1073,6 @@ void Converter::GenerateTransformationNodeChain( const Model& model,
} }
} }
void Converter::SetupNodeMetadata( const Model& model, aiNode& nd ) void Converter::SetupNodeMetadata( const Model& model, aiNode& nd )
{ {
const PropertyTable& props = model.Props(); const PropertyTable& props = model.Props();
@ -1075,7 +1080,7 @@ void Converter::SetupNodeMetadata( const Model& model, aiNode& nd )
// create metadata on node // create metadata on node
std::size_t numStaticMetaData = 2; std::size_t numStaticMetaData = 2;
aiMetadata* data = aiMetadata::Alloc( unparsedProperties.size() + numStaticMetaData ); aiMetadata* data = aiMetadata::Alloc( static_cast<unsigned int>(unparsedProperties.size() + numStaticMetaData) );
nd.mMetaData = data; nd.mMetaData = data;
int index = 0; int index = 0;
@ -1132,7 +1137,6 @@ void Converter::ConvertModel( const Model& model, aiNode& nd, const aiMatrix4x4&
} }
} }
std::vector<unsigned int> Converter::ConvertMesh( const MeshGeometry& mesh, const Model& model, std::vector<unsigned int> Converter::ConvertMesh( const MeshGeometry& mesh, const Model& model,
const aiMatrix4x4& node_global_transform ) const aiMatrix4x4& node_global_transform )
{ {
@ -1168,7 +1172,6 @@ std::vector<unsigned int> Converter::ConvertMesh( const MeshGeometry& mesh, cons
return temp; return temp;
} }
aiMesh* Converter::SetupEmptyMesh( const MeshGeometry& mesh ) aiMesh* Converter::SetupEmptyMesh( const MeshGeometry& mesh )
{ {
aiMesh* const out_mesh = new aiMesh(); aiMesh* const out_mesh = new aiMesh();
@ -1188,7 +1191,6 @@ aiMesh* Converter::SetupEmptyMesh( const MeshGeometry& mesh )
return out_mesh; return out_mesh;
} }
unsigned int Converter::ConvertMeshSingleMaterial( const MeshGeometry& mesh, const Model& model, unsigned int Converter::ConvertMeshSingleMaterial( const MeshGeometry& mesh, const Model& model,
const aiMatrix4x4& node_global_transform ) const aiMatrix4x4& node_global_transform )
{ {
@ -1511,7 +1513,6 @@ unsigned int Converter::ConvertMeshMultiMaterial( const MeshGeometry& mesh, cons
return static_cast<unsigned int>( meshes.size() - 1 ); return static_cast<unsigned int>( meshes.size() - 1 );
} }
void Converter::ConvertWeights( aiMesh* out, const Model& model, const MeshGeometry& geo, void Converter::ConvertWeights( aiMesh* out, const Model& model, const MeshGeometry& geo,
const aiMatrix4x4& node_global_transform , const aiMatrix4x4& node_global_transform ,
unsigned int materialIndex, unsigned int materialIndex,
@ -1658,7 +1659,6 @@ void Converter::ConvertCluster( std::vector<aiBone*>& bones, const Model& /*mode
} }
} }
void Converter::ConvertMaterialForMesh( aiMesh* out, const Model& model, const MeshGeometry& geo, void Converter::ConvertMaterialForMesh( aiMesh* out, const Model& model, const MeshGeometry& geo,
MatIndexArray::value_type materialIndex ) MatIndexArray::value_type materialIndex )
{ {
@ -2133,6 +2133,16 @@ void Converter::SetShadingPropertiesCommon( aiMaterial* out_mat, const PropertyT
if ( ok ) { if ( ok ) {
out_mat->AddProperty( &ShininessExponent, 1, AI_MATKEY_SHININESS ); out_mat->AddProperty( &ShininessExponent, 1, AI_MATKEY_SHININESS );
} }
const float BumpFactor = PropertyGet<float>(props, "BumpFactor", ok);
if (ok) {
out_mat->AddProperty(&BumpFactor, 1, AI_MATKEY_BUMPSCALING);
}
const float DispFactor = PropertyGet<float>(props, "DisplacementFactor", ok);
if (ok) {
out_mat->AddProperty(&DispFactor, 1, "$mat.displacementscaling", 0, 0);
}
} }
@ -2961,10 +2971,10 @@ Converter::KeyFrameListList Converter::GetKeyframeList( const std::vector<const
//get values within the start/stop time window //get values within the start/stop time window
std::shared_ptr<KeyTimeList> Keys( new KeyTimeList() ); std::shared_ptr<KeyTimeList> Keys( new KeyTimeList() );
std::shared_ptr<KeyValueList> Values( new KeyValueList() ); std::shared_ptr<KeyValueList> Values( new KeyValueList() );
const int count = curve->GetKeys().size(); const size_t count = curve->GetKeys().size();
Keys->reserve( count ); Keys->reserve( count );
Values->reserve( count ); Values->reserve( count );
for ( int n = 0; n < count; n++ ) for (size_t n = 0; n < count; n++ )
{ {
int64_t k = curve->GetKeys().at( n ); int64_t k = curve->GetKeys().at( n );
if ( k >= adj_start && k <= adj_stop ) if ( k >= adj_start && k <= adj_stop )
@ -3065,7 +3075,7 @@ void Converter::InterpolateKeys( aiVectorKey* valOut, const KeyTimeList& keys, c
const KeyTimeList::value_type timeA = std::get<0>(kfl)->at( id0 ); const KeyTimeList::value_type timeA = std::get<0>(kfl)->at( id0 );
const KeyTimeList::value_type timeB = std::get<0>(kfl)->at( id1 ); const KeyTimeList::value_type timeB = std::get<0>(kfl)->at( id1 );
const ai_real factor = timeB == timeA ? 0. : static_cast<ai_real>( ( time - timeA ) ) / ( timeB - timeA ); const ai_real factor = timeB == timeA ? ai_real(0.) : static_cast<ai_real>( ( time - timeA ) ) / ( timeB - timeA );
const ai_real interpValue = static_cast<ai_real>( valueA + ( valueB - valueA ) * factor ); const ai_real interpValue = static_cast<ai_real>( valueA + ( valueB - valueA ) * factor );
result[ std::get<2>(kfl) ] = interpValue; result[ std::get<2>(kfl) ] = interpValue;

View File

@ -47,14 +47,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXParser.h" #include "FBXParser.h"
#include "FBXDocument.h" #include "FBXDocument.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "FBXImportSettings.h"
#include "FBXDocumentUtil.h" #include "FBXDocumentUtil.h"
#include "FBXProperties.h"
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
using namespace Util; using namespace Util;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Deformer::Deformer(uint64_t id, const Element& element, const Document& doc, const std::string& name) Deformer::Deformer(uint64_t id, const Element& element, const Document& doc, const std::string& name)
@ -159,8 +157,6 @@ Skin::~Skin()
} }
} }
} }

View File

@ -55,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <map>
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
@ -78,12 +78,6 @@ LazyObject::~LazyObject()
} }
// ------------------------------------------------------------------------------------------------
static void dumpObjectClassInfo( const char* obtype, const std::string &classtag ) {
DefaultLogger::get()->debug( "obtype: " + std::string(obtype ));
DefaultLogger::get()->debug( "Classtag: " + classtag );
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const Object* LazyObject::Get(bool dieOnError) const Object* LazyObject::Get(bool dieOnError)
{ {
@ -252,17 +246,15 @@ FileGlobalSettings::FileGlobalSettings(const Document& doc, std::shared_ptr<cons
: props(props) : props(props)
, doc(doc) , doc(doc)
{ {
// empty
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
FileGlobalSettings::~FileGlobalSettings() FileGlobalSettings::~FileGlobalSettings()
{ {
// empty
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Document::Document(const Parser& parser, const ImportSettings& settings) Document::Document(const Parser& parser, const ImportSettings& settings)
: settings(settings) : settings(settings)
@ -285,7 +277,6 @@ Document::Document(const Parser& parser, const ImportSettings& settings)
ReadConnections(); ReadConnections();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Document::~Document() Document::~Document()
{ {
@ -315,7 +306,7 @@ void Document::ReadHeader()
const Scope& shead = *ehead->Compound(); const Scope& shead = *ehead->Compound();
fbxVersion = ParseTokenAsInt(GetRequiredToken(GetRequiredElement(shead,"FBXVersion",ehead),0)); fbxVersion = ParseTokenAsInt(GetRequiredToken(GetRequiredElement(shead,"FBXVersion",ehead),0));
// While we maye have some success with newer files, we don't support // While we may have some success with newer files, we don't support
// the older 6.n fbx format // the older 6.n fbx format
if(fbxVersion < LowerSupportedVersion ) { if(fbxVersion < LowerSupportedVersion ) {
DOMError("unsupported, old format version, supported are only FBX 2011, FBX 2012 and FBX 2013"); DOMError("unsupported, old format version, supported are only FBX 2011, FBX 2012 and FBX 2013");
@ -331,7 +322,6 @@ void Document::ReadHeader()
} }
} }
const Element* const ecreator = shead["Creator"]; const Element* const ecreator = shead["Creator"];
if(ecreator) { if(ecreator) {
creator = ParseTokenAsString(GetRequiredToken(*ecreator,0)); creator = ParseTokenAsString(GetRequiredToken(*ecreator,0));

View File

@ -240,6 +240,9 @@ public:
fbx_simple_property(FilmWidth, float, 1.0f) fbx_simple_property(FilmWidth, float, 1.0f)
fbx_simple_property(FilmHeight, float, 1.0f) fbx_simple_property(FilmHeight, float, 1.0f)
fbx_simple_property(NearPlane, float, 0.1f)
fbx_simple_property(FarPlane, float, 100.0f)
fbx_simple_property(FilmAspectRatio, float, 1.0f) fbx_simple_property(FilmAspectRatio, float, 1.0f)
fbx_simple_property(ApertureMode, int, 0) fbx_simple_property(ApertureMode, int, 0)
@ -302,12 +305,12 @@ public:
fbx_simple_property(DrawVolumetricLight, bool, true) fbx_simple_property(DrawVolumetricLight, bool, true)
fbx_simple_property(DrawGroundProjection, bool, true) fbx_simple_property(DrawGroundProjection, bool, true)
fbx_simple_property(DrawFrontFacingVolumetricLight, bool, false) fbx_simple_property(DrawFrontFacingVolumetricLight, bool, false)
fbx_simple_property(Intensity, float, 1.0f) fbx_simple_property(Intensity, float, 100.0f)
fbx_simple_property(InnerAngle, float, 0.0f) fbx_simple_property(InnerAngle, float, 0.0f)
fbx_simple_property(OuterAngle, float, 45.0f) fbx_simple_property(OuterAngle, float, 45.0f)
fbx_simple_property(Fog, int, 50) fbx_simple_property(Fog, int, 50)
fbx_simple_enum_property(DecayType, Decay, 0) fbx_simple_enum_property(DecayType, Decay, 2)
fbx_simple_property(DecayStart, int, 0) fbx_simple_property(DecayStart, float, 1.0f)
fbx_simple_property(FileName, std::string, "") fbx_simple_property(FileName, std::string, "")
fbx_simple_property(EnableNearAttenuation, bool, false) fbx_simple_property(EnableNearAttenuation, bool, false)
@ -600,7 +603,7 @@ public:
} }
const int textureCount() const { const int textureCount() const {
return textures.size(); return static_cast<int>(textures.size());
} }
const BlendMode GetBlendMode() const const BlendMode GetBlendMode() const
{ {

View File

@ -44,9 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
#include <exception>
#include <iterator>
#include "FBXImporter.h" #include "FBXImporter.h"
#include "FBXTokenizer.h" #include "FBXTokenizer.h"
@ -58,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "StreamReader.h" #include "StreamReader.h"
#include "MemoryIOWrapper.h" #include "MemoryIOWrapper.h"
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/importerdesc.h>
namespace Assimp { namespace Assimp {
template<> const std::string LogFunctions<FBXImporter>::log_prefix = "FBX: "; template<> const std::string LogFunctions<FBXImporter>::log_prefix = "FBX: ";
@ -99,7 +97,7 @@ FBXImporter::~FBXImporter()
bool FBXImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const bool FBXImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
{ {
const std::string& extension = GetExtension(pFile); const std::string& extension = GetExtension(pFile);
if (extension == "fbx") { if (extension == std::string( desc.mFileExtensions ) ) {
return true; return true;
} }
@ -118,7 +116,6 @@ const aiImporterDesc* FBXImporter::GetInfo () const
return &desc; return &desc;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Setup configuration properties for the loader // Setup configuration properties for the loader
void FBXImporter::SetupProperties(const Importer* pImp) void FBXImporter::SetupProperties(const Importer* pImp)
@ -135,7 +132,6 @@ void FBXImporter::SetupProperties(const Importer* pImp)
settings.optimizeEmptyAnimationCurves = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES, true); settings.optimizeEmptyAnimationCurves = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES, true);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure. // Imports the given file into the given scene structure.
void FBXImporter::InternReadFile( const std::string& pFile, void FBXImporter::InternReadFile( const std::string& pFile,
@ -165,7 +161,7 @@ void FBXImporter::InternReadFile( const std::string& pFile,
bool is_binary = false; bool is_binary = false;
if (!strncmp(begin,"Kaydara FBX Binary",18)) { if (!strncmp(begin,"Kaydara FBX Binary",18)) {
is_binary = true; is_binary = true;
TokenizeBinary(tokens,begin,contents.size()); TokenizeBinary(tokens,begin,static_cast<unsigned int>(contents.size()));
} }
else { else {
Tokenize(tokens,begin); Tokenize(tokens,begin);

View File

@ -48,9 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXMeshGeometry.h" #include "FBXMeshGeometry.h"
#include "FBXDocument.h" #include "FBXDocument.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "FBXImportSettings.h"
#include "FBXDocumentUtil.h" #include "FBXDocumentUtil.h"
#include "FBXProperties.h"
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {

View File

@ -47,9 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXParser.h" #include "FBXParser.h"
#include "FBXDocument.h" #include "FBXDocument.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "FBXImportSettings.h"
#include "FBXDocumentUtil.h" #include "FBXDocumentUtil.h"
#include "FBXProperties.h"
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {

View File

@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# include "../contrib/zlib/zlib.h" # include "../contrib/zlib/zlib.h"
#endif #endif
#include "FBXTokenizer.h" #include "FBXTokenizer.h"
#include "FBXParser.h" #include "FBXParser.h"
#include "FBXUtil.h" #include "FBXUtil.h"
@ -583,7 +582,7 @@ void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const cha
zstream.next_in = reinterpret_cast<Bytef*>( const_cast<char*>(data) ); zstream.next_in = reinterpret_cast<Bytef*>( const_cast<char*>(data) );
zstream.avail_in = comp_len; zstream.avail_in = comp_len;
zstream.avail_out = buff.size(); zstream.avail_out = static_cast<uInt>(buff.size());
zstream.next_out = reinterpret_cast<Bytef*>(&*buff.begin()); zstream.next_out = reinterpret_cast<Bytef*>(&*buff.begin());
const int ret = inflate(&zstream, Z_FINISH); const int ret = inflate(&zstream, Z_FINISH);

View File

@ -44,14 +44,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef INCLUDED_AI_FBX_PROPERTIES_H #ifndef INCLUDED_AI_FBX_PROPERTIES_H
#define INCLUDED_AI_FBX_PROPERTIES_H #define INCLUDED_AI_FBX_PROPERTIES_H
#include <map>
#include "FBXCompileConfig.h" #include "FBXCompileConfig.h"
#include <memory> #include <memory>
#include <string>
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
class Element; // Forward declarations
class Element;
/** Represents a dynamic property. Type info added by deriving classes, /** Represents a dynamic property. Type info added by deriving classes,

View File

@ -44,7 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef INCLUDED_AI_FBX_TOKENIZER_H #ifndef INCLUDED_AI_FBX_TOKENIZER_H
#define INCLUDED_AI_FBX_TOKENIZER_H #define INCLUDED_AI_FBX_TOKENIZER_H
#include <memory>
#include "FBXCompileConfig.h" #include "FBXCompileConfig.h"
#include <assimp/ai_assert.h> #include <assimp/ai_assert.h>
#include <vector> #include <vector>
@ -84,13 +83,10 @@ enum TokenType
* Offers iterator protocol. Tokens are immutable. */ * Offers iterator protocol. Tokens are immutable. */
class Token class Token
{ {
private: private:
static const unsigned int BINARY_MARKER = static_cast<unsigned int>(-1); static const unsigned int BINARY_MARKER = static_cast<unsigned int>(-1);
public: public:
/** construct a textual token */ /** construct a textual token */
Token(const char* sbegin, const char* send, TokenType type, unsigned int line, unsigned int column); Token(const char* sbegin, const char* send, TokenType type, unsigned int line, unsigned int column);
@ -100,13 +96,11 @@ public:
~Token(); ~Token();
public: public:
std::string StringContents() const { std::string StringContents() const {
return std::string(begin(),end()); return std::string(begin(),end());
} }
public: public:
bool IsBinary() const { bool IsBinary() const {
return column == BINARY_MARKER; return column == BINARY_MARKER;
} }

View File

@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXTokenizer.h" #include "FBXTokenizer.h"
#include "TinyFormatter.h" #include "TinyFormatter.h"
#include <string>
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER

View File

@ -44,7 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef INCLUDED_AI_FBX_UTIL_H #ifndef INCLUDED_AI_FBX_UTIL_H
#define INCLUDED_AI_FBX_UTIL_H #define INCLUDED_AI_FBX_UTIL_H
#include <string>
#include "FBXCompileConfig.h" #include "FBXCompileConfig.h"
#include "FBXTokenizer.h" #include "FBXTokenizer.h"

View File

@ -1,9 +1,50 @@
/*
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.
----------------------------------------------------------------------
*/
/** @file FileLofStream.h
*/
#ifndef ASSIMP_FILELOGSTREAM_H_INC #ifndef ASSIMP_FILELOGSTREAM_H_INC
#define ASSIMP_FILELOGSTREAM_H_INC #define ASSIMP_FILELOGSTREAM_H_INC
#include <assimp/LogStream.hpp> #include <assimp/LogStream.hpp>
#include <assimp/IOStream.hpp> #include <assimp/IOStream.hpp>
#include "DefaultIOSystem.h" #include <assimp/DefaultIOSystem.h>
namespace Assimp { namespace Assimp {

View File

@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/importerdesc.h>
using namespace Assimp; using namespace Assimp;

View File

@ -44,11 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_HMPLOADER_H_INCLUDED #ifndef AI_HMPLOADER_H_INCLUDED
#define AI_HMPLOADER_H_INCLUDED #define AI_HMPLOADER_H_INCLUDED
// public ASSIMP headers
#include <assimp/types.h>
#include <assimp/texture.h>
#include <assimp/material.h>
// internal headers // internal headers
#include "BaseImporter.h" #include "BaseImporter.h"
#include "MDLLoader.h" #include "MDLLoader.h"

View File

@ -49,7 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_MDLFILEHELPER2_H_INC #ifndef AI_MDLFILEHELPER2_H_INC
#define AI_MDLFILEHELPER2_H_INC #define AI_MDLFILEHELPER2_H_INC
#include "MDLFileData.h"
#include "./../include/assimp/Compiler/pushpack1.h" #include "./../include/assimp/Compiler/pushpack1.h"
namespace Assimp { namespace Assimp {

View File

@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "IFCUtil.h" #include "IFCUtil.h"
#include "PolyTools.h" #include "PolyTools.h"
#include "ProcessHelper.h" #include "ProcessHelper.h"
#include "Defines.h" #include <assimp/Defines.h>
#include <iterator> #include <iterator>
#include <tuple> #include <tuple>
@ -109,7 +109,7 @@ void FilterPolygon(std::vector<IfcVector3>& resultpoly)
} }
IfcVector3 vmin, vmax; IfcVector3 vmin, vmax;
ArrayBounds(resultpoly.data(), resultpoly.size(), vmin, vmax); ArrayBounds(resultpoly.data(), static_cast<unsigned int>(resultpoly.size()), vmin, vmax);
// filter our IfcFloat points - those may happen if a point lies // filter our IfcFloat points - those may happen if a point lies
// directly on the intersection line or directly on the clipping plane // directly on the intersection line or directly on the clipping plane
@ -132,7 +132,7 @@ void WritePolygon(std::vector<IfcVector3>& resultpoly, TempMesh& result)
if( resultpoly.size() > 2 ) if( resultpoly.size() > 2 )
{ {
result.verts.insert(result.verts.end(), resultpoly.begin(), resultpoly.end()); result.verts.insert(result.verts.end(), resultpoly.begin(), resultpoly.end());
result.vertcnt.push_back(resultpoly.size()); result.vertcnt.push_back(static_cast<unsigned int>(resultpoly.size()));
} }
} }
@ -589,7 +589,7 @@ void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const IfcPolygonalBounded
// to result mesh unchanged // to result mesh unchanged
if( !startedInside ) if( !startedInside )
{ {
outvertcnt.push_back(blackside.size()); outvertcnt.push_back(static_cast<unsigned int>(blackside.size()));
outvert.insert(outvert.end(), blackside.begin(), blackside.end()); outvert.insert(outvert.end(), blackside.begin(), blackside.end());
continue; continue;
} }

View File

@ -70,7 +70,7 @@ bool ProcessPolyloop(const IfcPolyLoop& loop, TempMesh& meshout, ConversionData&
++cnt; ++cnt;
} }
meshout.vertcnt.push_back(cnt); meshout.vertcnt.push_back(static_cast<unsigned int>(cnt));
// zero- or one- vertex polyloops simply ignored // zero- or one- vertex polyloops simply ignored
if (meshout.vertcnt.back() > 1) { if (meshout.vertcnt.back() > 1) {
@ -180,7 +180,7 @@ void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t m
// fill a mesh with ONLY the main polygon // fill a mesh with ONLY the main polygon
TempMesh temp; TempMesh temp;
temp.verts.reserve(outer_polygon_size); temp.verts.reserve(outer_polygon_size);
temp.vertcnt.push_back(outer_polygon_size); temp.vertcnt.push_back(static_cast<unsigned int>(outer_polygon_size));
std::copy(outer_vit, outer_vit+outer_polygon_size, std::copy(outer_vit, outer_vit+outer_polygon_size,
std::back_inserter(temp.verts)); std::back_inserter(temp.verts));
@ -258,7 +258,7 @@ void ProcessRevolvedAreaSolid(const IfcRevolvedAreaSolid& solid, TempMesh& resul
return; return;
} }
const unsigned int cnt_segments = std::max(2u,static_cast<unsigned int>(16 * std::fabs(max_angle)/AI_MATH_HALF_PI_F)); const unsigned int cnt_segments = std::max(2u,static_cast<unsigned int>(conv.settings.cylindricalTessellation * std::fabs(max_angle)/AI_MATH_HALF_PI_F));
const IfcFloat delta = max_angle/cnt_segments; const IfcFloat delta = max_angle/cnt_segments;
has_area = has_area && std::fabs(max_angle) < AI_MATH_TWO_PI_F*0.99; has_area = has_area && std::fabs(max_angle) < AI_MATH_TWO_PI_F*0.99;
@ -305,8 +305,8 @@ void ProcessRevolvedAreaSolid(const IfcRevolvedAreaSolid& solid, TempMesh& resul
for(size_t i = 0; i < size; ++i ) { for(size_t i = 0; i < size; ++i ) {
out.push_back(out[i*4]); out.push_back(out[i*4]);
} }
result.vertcnt.push_back(size); result.vertcnt.push_back(static_cast<unsigned int>(size));
result.vertcnt.push_back(size); result.vertcnt.push_back(static_cast<unsigned int>(size));
} }
IfcMatrix4 trafo; IfcMatrix4 trafo;
@ -327,7 +327,7 @@ void ProcessSweptDiskSolid(const IfcSweptDiskSolid solid, TempMesh& result, Conv
return; return;
} }
const unsigned int cnt_segments = 16; const unsigned int cnt_segments = conv.settings.cylindricalTessellation;
const IfcFloat deltaAngle = AI_MATH_TWO_PI/cnt_segments; const IfcFloat deltaAngle = AI_MATH_TWO_PI/cnt_segments;
const size_t samples = curve->EstimateSampleCount(solid.StartParam,solid.EndParam); const size_t samples = curve->EstimateSampleCount(solid.StartParam,solid.EndParam);
@ -638,7 +638,7 @@ void ProcessExtrudedArea(const IfcExtrudedAreaSolid& solid, const TempMesh& curv
out.push_back(in[i]); out.push_back(in[i]);
} }
curmesh.vertcnt.push_back(in.size()); curmesh.vertcnt.push_back(static_cast<unsigned int>(in.size()));
if( openings && in.size() > 2 ) { if( openings && in.size() > 2 ) {
if( GenerateOpenings(*conv.apply_openings, nors, temp, true, true, dir) ) { if( GenerateOpenings(*conv.apply_openings, nors, temp, true, true, dir) ) {
++sides_with_v_openings; ++sides_with_v_openings;
@ -665,7 +665,7 @@ void ProcessExtrudedArea(const IfcExtrudedAreaSolid& solid, const TempMesh& curv
std::shared_ptr<TempMesh> profile2D = std::shared_ptr<TempMesh>(new TempMesh()); std::shared_ptr<TempMesh> profile2D = std::shared_ptr<TempMesh>(new TempMesh());
profile2D->verts.insert(profile2D->verts.end(), in.begin(), in.end()); profile2D->verts.insert(profile2D->verts.end(), in.begin(), in.end());
profile2D->vertcnt.push_back(in.size()); profile2D->vertcnt.push_back(static_cast<unsigned int>(in.size()));
conv.collect_openings->push_back(TempOpening(&solid, dir, profile, profile2D)); conv.collect_openings->push_back(TempOpening(&solid, dir, profile, profile2D));
ai_assert(result.IsEmpty()); ai_assert(result.IsEmpty());
@ -810,7 +810,7 @@ bool ProcessGeometricItem(const IfcRepresentationItem& geo, unsigned int matid,
aiMesh* const mesh = meshtmp->ToMesh(); aiMesh* const mesh = meshtmp->ToMesh();
if(mesh) { if(mesh) {
mesh->mMaterialIndex = matid; mesh->mMaterialIndex = matid;
mesh_indices.push_back(conv.meshes.size()); mesh_indices.push_back(static_cast<unsigned int>(conv.meshes.size()));
conv.meshes.push_back(mesh); conv.meshes.push_back(mesh);
return true; return true;
} }
@ -827,9 +827,8 @@ void AssignAddedMeshes(std::vector<unsigned int>& mesh_indices,aiNode* nd,
std::sort(mesh_indices.begin(),mesh_indices.end()); std::sort(mesh_indices.begin(),mesh_indices.end());
std::vector<unsigned int>::iterator it_end = std::unique(mesh_indices.begin(),mesh_indices.end()); std::vector<unsigned int>::iterator it_end = std::unique(mesh_indices.begin(),mesh_indices.end());
const size_t size = std::distance(mesh_indices.begin(),it_end); nd->mNumMeshes = static_cast<unsigned int>(std::distance(mesh_indices.begin(),it_end));
nd->mNumMeshes = size;
nd->mMeshes = new unsigned int[nd->mNumMeshes]; nd->mMeshes = new unsigned int[nd->mNumMeshes];
for(unsigned int i = 0; i < nd->mNumMeshes; ++i) { for(unsigned int i = 0; i < nd->mNumMeshes; ++i) {
nd->mMeshes[i] = mesh_indices[i]; nd->mMeshes[i] = mesh_indices[i];

View File

@ -58,10 +58,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "IFCUtil.h" #include "IFCUtil.h"
#include "StreamReader.h"
#include "MemoryIOWrapper.h" #include "MemoryIOWrapper.h"
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/importerdesc.h>
namespace Assimp { namespace Assimp {
@ -108,7 +108,7 @@ static const aiImporterDesc desc = {
0, 0,
0, 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 bool IFCImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
{ {
const std::string& extension = GetExtension(pFile); const std::string& extension = GetExtension(pFile);
if (extension == "ifc" || extension == "ifczip") { if (extension == "ifc" || extension == "ifczip" || extension == "stp" ) {
return true; 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 // note: this is the common identification for STEP-encoded files, so
// it is only unambiguous as long as we don't support any further // it is only unambiguous as long as we don't support any further
// file formats with STEP as their encoding. // file formats with STEP as their encoding.
@ -155,10 +153,9 @@ const aiImporterDesc* IFCImporter::GetInfo () const
void IFCImporter::SetupProperties(const Importer* pImp) void IFCImporter::SetupProperties(const Importer* pImp)
{ {
settings.skipSpaceRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS,true); settings.skipSpaceRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS,true);
settings.skipCurveRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS,true);
settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true); settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true);
settings.conicSamplingAngle = std::min(std::max(pImp->GetPropertyFloat(AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE, AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE), 5.0f), 120.0f);
settings.conicSamplingAngle = 10.f; settings.cylindricalTessellation = std::min(std::max(pImp->GetPropertyInteger(AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION, AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION), 3), 180);
settings.skipAnnotations = true; settings.skipAnnotations = true;
} }
@ -707,7 +704,7 @@ aiNode* ProcessSpatialStructure(aiNode* parent, const IfcProduct& el, Conversion
} }
if (!properties.empty()) { if (!properties.empty()) {
aiMetadata* data = aiMetadata::Alloc( properties.size() ); aiMetadata* data = aiMetadata::Alloc( static_cast<unsigned int>(properties.size()) );
unsigned int index( 0 ); unsigned int index( 0 );
for ( const Metadata::value_type& kv : properties ) { for ( const Metadata::value_type& kv : properties ) {
data->Set( index++, kv.first, aiString( kv.second ) ); data->Set( index++, kv.first, aiString( kv.second ) );

View File

@ -107,18 +107,18 @@ public:
{ {
Settings() Settings()
: skipSpaceRepresentations() : skipSpaceRepresentations()
, skipCurveRepresentations()
, useCustomTriangulation() , useCustomTriangulation()
, skipAnnotations() , skipAnnotations()
, conicSamplingAngle(10.f) , conicSamplingAngle(10.f)
, cylindricalTessellation(32)
{} {}
bool skipSpaceRepresentations; bool skipSpaceRepresentations;
bool skipCurveRepresentations;
bool useCustomTriangulation; bool useCustomTriangulation;
bool skipAnnotations; bool skipAnnotations;
float conicSamplingAngle; float conicSamplingAngle;
int cylindricalTessellation;
}; };

View File

@ -159,7 +159,7 @@ unsigned int ProcessMaterials(uint64_t id, unsigned int prevMatId, ConversionDat
FillMaterial(mat.get(), surf, conv); FillMaterial(mat.get(), surf, conv);
conv.materials.push_back(mat.release()); conv.materials.push_back(mat.release());
unsigned int matindex = conv.materials.size() - 1; unsigned int matindex = static_cast<unsigned int>(conv.materials.size() - 1);
conv.cached_materials[surf] = matindex; conv.cached_materials[surf] = matindex;
return matindex; return matindex;
} }

View File

@ -364,7 +364,7 @@ void InsertWindowContours(const ContourVector& contours,
} }
if (const size_t d = curmesh.verts.size()-old) { if (const size_t d = curmesh.verts.size()-old) {
curmesh.vertcnt.push_back(d); curmesh.vertcnt.push_back(static_cast<unsigned int>(d));
std::reverse(curmesh.verts.rbegin(),curmesh.verts.rbegin()+d); std::reverse(curmesh.verts.rbegin(),curmesh.verts.rbegin()+d);
} }
if (n == very_first_hit) { if (n == very_first_hit) {
@ -549,7 +549,7 @@ void CleanupOuterContour(const std::vector<IfcVector2>& contour_flat, TempMesh&
clipper.Execute(ClipperLib::ctIntersection,clipped,ClipperLib::pftNonZero,ClipperLib::pftNonZero); clipper.Execute(ClipperLib::ctIntersection,clipped,ClipperLib::pftNonZero,ClipperLib::pftNonZero);
for(const ClipperLib::ExPolygon& ex : clipped) { for(const ClipperLib::ExPolygon& ex : clipped) {
iold.push_back(ex.outer.size()); iold.push_back(static_cast<unsigned int>(ex.outer.size()));
for(const ClipperLib::IntPoint& point : ex.outer) { for(const ClipperLib::IntPoint& point : ex.outer) {
vold.push_back(IfcVector3( vold.push_back(IfcVector3(
from_int64(point.X), from_int64(point.X),
@ -901,13 +901,21 @@ size_t CloseWindows(ContourVector& contours,
curmesh.verts.reserve(curmesh.verts.size() + (*it).contour.size() * 4); curmesh.verts.reserve(curmesh.verts.size() + (*it).contour.size() * 4);
curmesh.vertcnt.reserve(curmesh.vertcnt.size() + (*it).contour.size()); curmesh.vertcnt.reserve(curmesh.vertcnt.size() + (*it).contour.size());
bool reverseCountourFaces = false;
// compare base poly normal and contour normal to detect if we need to reverse the face winding // compare base poly normal and contour normal to detect if we need to reverse the face winding
IfcVector3 basePolyNormal = TempMesh::ComputePolygonNormal( curmesh.verts.data(), curmesh.vertcnt.front()); if(curmesh.vertcnt.size() > 0) {
std::vector<IfcVector3> worldSpaceContourVtx( it->contour.size()); IfcVector3 basePolyNormal = TempMesh::ComputePolygonNormal(curmesh.verts.data(), curmesh.vertcnt.front());
for( size_t a = 0; a < it->contour.size(); ++a )
worldSpaceContourVtx[a] = minv * IfcVector3( it->contour[a].x, it->contour[a].y, 0.0); std::vector<IfcVector3> worldSpaceContourVtx(it->contour.size());
IfcVector3 contourNormal = TempMesh::ComputePolygonNormal( worldSpaceContourVtx.data(), worldSpaceContourVtx.size());
bool reverseCountourFaces = (contourNormal * basePolyNormal) > 0.0; for(size_t a = 0; a < it->contour.size(); ++a)
worldSpaceContourVtx[a] = minv * IfcVector3(it->contour[a].x, it->contour[a].y, 0.0);
IfcVector3 contourNormal = TempMesh::ComputePolygonNormal(worldSpaceContourVtx.data(), worldSpaceContourVtx.size());
reverseCountourFaces = (contourNormal * basePolyNormal) > 0.0;
}
// XXX this algorithm is really a bit inefficient - both in terms // XXX this algorithm is really a bit inefficient - both in terms
// of constant factor and of asymptotic runtime. // of constant factor and of asymptotic runtime.

View File

@ -59,7 +59,7 @@ void ProcessPolyLine(const IfcPolyline& def, TempMesh& meshout, ConversionData&
ConvertCartesianPoint(t,cp); ConvertCartesianPoint(t,cp);
meshout.verts.push_back(t); meshout.verts.push_back(t);
} }
meshout.vertcnt.push_back(meshout.verts.size()); meshout.vertcnt.push_back(static_cast<unsigned int>(meshout.verts.size()));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -80,7 +80,7 @@ bool ProcessCurve(const IfcCurve& curve, TempMesh& meshout, ConversionData& con
IFCImporter::LogError(cv.s+ " (error occurred while processing curve)"); IFCImporter::LogError(cv.s+ " (error occurred while processing curve)");
return false; return false;
} }
meshout.vertcnt.push_back(meshout.verts.size()); meshout.vertcnt.push_back(static_cast<unsigned int>(meshout.verts.size()));
return true; return true;
} }
@ -101,7 +101,7 @@ void ProcessOpenProfile(const IfcArbitraryOpenProfileDef& def, TempMesh& meshout
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh& meshout, ConversionData& /*conv*/) void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh& meshout, ConversionData& conv)
{ {
if(const IfcRectangleProfileDef* const cprofile = def.ToPtr<IfcRectangleProfileDef>()) { if(const IfcRectangleProfileDef* const cprofile = def.ToPtr<IfcRectangleProfileDef>()) {
const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f; const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f;
@ -117,7 +117,7 @@ void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh&
if(def.ToPtr<IfcCircleHollowProfileDef>()) { if(def.ToPtr<IfcCircleHollowProfileDef>()) {
// TODO // TODO
} }
const size_t segments = 32; const size_t segments = conv.settings.cylindricalTessellation;
const IfcFloat delta = AI_MATH_TWO_PI_F/segments, radius = circle->Radius; const IfcFloat delta = AI_MATH_TWO_PI_F/segments, radius = circle->Radius;
meshout.verts.reserve(segments); meshout.verts.reserve(segments);

View File

@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "IFCUtil.h" #include "IFCUtil.h"
#include "PolyTools.h" #include "PolyTools.h"
#include "ProcessHelper.h" #include "ProcessHelper.h"
#include "Defines.h" #include <assimp/Defines.h>
namespace Assimp { namespace Assimp {
namespace IFC { namespace IFC {
@ -180,7 +180,7 @@ IfcVector3 TempMesh::ComputePolygonNormal(const IfcVector3* vtcs, size_t cnt, bo
} }
IfcVector3 nor; IfcVector3 nor;
NewellNormal<3, 3, 3>(nor, cnt, &temp[0], &temp[1], &temp[2]); NewellNormal<3, 3, 3>(nor, static_cast<int>(cnt), &temp[0], &temp[1], &temp[2]);
return normalize ? nor.Normalize() : nor; return normalize ? nor.Normalize() : nor;
} }
@ -548,7 +548,7 @@ void ConvertCartesianPoint(IfcVector3& out, const IfcCartesianPoint& in)
{ {
out = IfcVector3(); out = IfcVector3();
for(size_t i = 0; i < in.Coordinates.size(); ++i) { for(size_t i = 0; i < in.Coordinates.size(); ++i) {
out[i] = in.Coordinates[i]; out[static_cast<unsigned int>(i)] = in.Coordinates[i];
} }
} }
@ -564,7 +564,7 @@ void ConvertDirection(IfcVector3& out, const IfcDirection& in)
{ {
out = IfcVector3(); out = IfcVector3();
for(size_t i = 0; i < in.DirectionRatios.size(); ++i) { for(size_t i = 0; i < in.DirectionRatios.size(); ++i) {
out[i] = in.DirectionRatios[i]; out[static_cast<unsigned int>(i)] = in.DirectionRatios[i];
} }
const IfcFloat len = out.Length(); const IfcFloat len = out.Length();
if (len<1e-6) { if (len<1e-6) {

View File

@ -44,8 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOStream.hpp> #include <assimp/IOStream.hpp>
#include "ParsingUtils.h" #include "ParsingUtils.h"
#include <iostream>
namespace Assimp { namespace Assimp {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -65,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/importerdesc.h>
using namespace Assimp; using namespace Assimp;
using namespace irr; using namespace irr;
@ -215,7 +215,7 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh*>& meshes, std::vector<aiMateri
SkyboxVertex( l,-l,-l, 0, 0, 1, 0.0,1.0), SkyboxVertex( l,-l,-l, 0, 0, 1, 0.0,1.0),
SkyboxVertex( l, l,-l, 0, 0, 1, 0.0,0.0), SkyboxVertex( l, l,-l, 0, 0, 1, 0.0,0.0),
SkyboxVertex(-l, l,-l, 0, 0, 1, 1.0,0.0)) ); SkyboxVertex(-l, l,-l, 0, 0, 1, 1.0,0.0)) );
meshes.back()->mMaterialIndex = materials.size()-6u; meshes.back()->mMaterialIndex = static_cast<unsigned int>(materials.size()-6u);
// LEFT SIDE // LEFT SIDE
meshes.push_back( BuildSingleQuadMesh( meshes.push_back( BuildSingleQuadMesh(
@ -223,7 +223,7 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh*>& meshes, std::vector<aiMateri
SkyboxVertex( l,-l, l, -1, 0, 0, 0.0,1.0), SkyboxVertex( l,-l, l, -1, 0, 0, 0.0,1.0),
SkyboxVertex( l, l, l, -1, 0, 0, 0.0,0.0), SkyboxVertex( l, l, l, -1, 0, 0, 0.0,0.0),
SkyboxVertex( l, l,-l, -1, 0, 0, 1.0,0.0)) ); SkyboxVertex( l, l,-l, -1, 0, 0, 1.0,0.0)) );
meshes.back()->mMaterialIndex = materials.size()-5u; meshes.back()->mMaterialIndex = static_cast<unsigned int>(materials.size()-5u);
// BACK SIDE // BACK SIDE
meshes.push_back( BuildSingleQuadMesh( meshes.push_back( BuildSingleQuadMesh(
@ -231,7 +231,7 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh*>& meshes, std::vector<aiMateri
SkyboxVertex(-l,-l, l, 0, 0, -1, 0.0,1.0), SkyboxVertex(-l,-l, l, 0, 0, -1, 0.0,1.0),
SkyboxVertex(-l, l, l, 0, 0, -1, 0.0,0.0), SkyboxVertex(-l, l, l, 0, 0, -1, 0.0,0.0),
SkyboxVertex( l, l, l, 0, 0, -1, 1.0,0.0)) ); SkyboxVertex( l, l, l, 0, 0, -1, 1.0,0.0)) );
meshes.back()->mMaterialIndex = materials.size()-4u; meshes.back()->mMaterialIndex = static_cast<unsigned int>(materials.size()-4u);
// RIGHT SIDE // RIGHT SIDE
meshes.push_back( BuildSingleQuadMesh( meshes.push_back( BuildSingleQuadMesh(
@ -239,7 +239,7 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh*>& meshes, std::vector<aiMateri
SkyboxVertex(-l,-l,-l, 1, 0, 0, 0.0,1.0), SkyboxVertex(-l,-l,-l, 1, 0, 0, 0.0,1.0),
SkyboxVertex(-l, l,-l, 1, 0, 0, 0.0,0.0), SkyboxVertex(-l, l,-l, 1, 0, 0, 0.0,0.0),
SkyboxVertex(-l, l, l, 1, 0, 0, 1.0,0.0)) ); SkyboxVertex(-l, l, l, 1, 0, 0, 1.0,0.0)) );
meshes.back()->mMaterialIndex = materials.size()-3u; meshes.back()->mMaterialIndex = static_cast<unsigned int>(materials.size()-3u);
// TOP SIDE // TOP SIDE
meshes.push_back( BuildSingleQuadMesh( meshes.push_back( BuildSingleQuadMesh(
@ -247,7 +247,7 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh*>& meshes, std::vector<aiMateri
SkyboxVertex( l, l, l, 0, -1, 0, 0.0,1.0), SkyboxVertex( l, l, l, 0, -1, 0, 0.0,1.0),
SkyboxVertex(-l, l, l, 0, -1, 0, 0.0,0.0), SkyboxVertex(-l, l, l, 0, -1, 0, 0.0,0.0),
SkyboxVertex(-l, l,-l, 0, -1, 0, 1.0,0.0)) ); SkyboxVertex(-l, l,-l, 0, -1, 0, 1.0,0.0)) );
meshes.back()->mMaterialIndex = materials.size()-2u; meshes.back()->mMaterialIndex = static_cast<unsigned int>(materials.size()-2u);
// BOTTOM SIDE // BOTTOM SIDE
meshes.push_back( BuildSingleQuadMesh( meshes.push_back( BuildSingleQuadMesh(
@ -255,7 +255,7 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh*>& meshes, std::vector<aiMateri
SkyboxVertex( l,-l,-l, 0, 1, 0, 1.0,0.0), SkyboxVertex( l,-l,-l, 0, 1, 0, 1.0,0.0),
SkyboxVertex(-l,-l,-l, 0, 1, 0, 1.0,1.0), SkyboxVertex(-l,-l,-l, 0, 1, 0, 1.0,1.0),
SkyboxVertex(-l,-l, l, 0, 1, 0, 0.0,1.0)) ); SkyboxVertex(-l,-l, l, 0, 1, 0, 0.0,1.0)) );
meshes.back()->mMaterialIndex = materials.size()-1u; meshes.back()->mMaterialIndex = static_cast<unsigned int>(materials.size()-1u);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -642,7 +642,7 @@ void SetupMapping (aiMaterial* mat, aiTextureMapping mode, const aiVector3D& axi
delete[] mat->mProperties; delete[] mat->mProperties;
mat->mProperties = new aiMaterialProperty*[p.size()*2]; mat->mProperties = new aiMaterialProperty*[p.size()*2];
mat->mNumAllocated = p.size()*2; mat->mNumAllocated = static_cast<unsigned int>(p.size()*2);
} }
mat->mNumProperties = (unsigned int)p.size(); mat->mNumProperties = (unsigned int)p.size();
::memcpy(mat->mProperties,&p[0],sizeof(void*)*mat->mNumProperties); ::memcpy(mat->mProperties,&p[0],sizeof(void*)*mat->mNumProperties);

View File

@ -54,9 +54,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/material.h> #include <assimp/material.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/importerdesc.h>
#include "Macros.h" #include "Macros.h"
using namespace Assimp; using namespace Assimp;
using namespace irr; using namespace irr;
using namespace irr::io; using namespace irr::io;

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/version.h> #include <assimp/version.h>
#include <assimp/config.h> #include <assimp/config.h>
#include <assimp/importerdesc.h>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
/* Uncomment this line to prevent Assimp from catching unknown exceptions. /* Uncomment this line to prevent Assimp from catching unknown exceptions.
@ -65,8 +66,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BaseImporter.h" #include "BaseImporter.h"
#include "BaseProcess.h" #include "BaseProcess.h"
#include "DefaultIOStream.h"
#include "DefaultIOSystem.h"
#include "DefaultProgressHandler.h" #include "DefaultProgressHandler.h"
#include "GenericProperty.h" #include "GenericProperty.h"
#include "ProcessHelper.h" #include "ProcessHelper.h"
@ -81,6 +80,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
#include <cctype> #include <cctype>
#include <assimp/DefaultIOStream.h>
#include <assimp/DefaultIOSystem.h>
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS #ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
# include "ValidateDataStructure.h" # include "ValidateDataStructure.h"
#endif #endif
@ -654,7 +656,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
uint32_t fileSize = 0; uint32_t fileSize = 0;
if (fileIO) if (fileIO)
{ {
fileSize = fileIO->FileSize(); fileSize = static_cast<uint32_t>(fileIO->FileSize());
pimpl->mIOHandler->Close( fileIO ); pimpl->mIOHandler->Close( fileIO );
} }
@ -790,7 +792,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) { for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
BaseProcess* process = pimpl->mPostProcessingSteps[a]; BaseProcess* process = pimpl->mPostProcessingSteps[a];
pimpl->mProgressHandler->UpdatePostProcess( a, pimpl->mPostProcessingSteps.size() ); pimpl->mProgressHandler->UpdatePostProcess(static_cast<int>(a), static_cast<int>(pimpl->mPostProcessingSteps.size()) );
if( process->IsActive( pFlags)) { if( process->IsActive( pFlags)) {
if (profiler) { if (profiler) {
@ -825,7 +827,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
} }
#endif // ! DEBUG #endif // ! DEBUG
} }
pimpl->mProgressHandler->UpdatePostProcess( pimpl->mPostProcessingSteps.size(), pimpl->mPostProcessingSteps.size() ); pimpl->mProgressHandler->UpdatePostProcess( static_cast<int>(pimpl->mPostProcessingSteps.size()), static_cast<int>(pimpl->mPostProcessingSteps.size()) );
// update private scene flags // update private scene flags
if( pimpl->mScene ) if( pimpl->mScene )

View File

@ -44,8 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_IMPORTER_H #define INCLUDED_AI_IMPORTER_H
#include <map> #include <map>
#include <string>
#include <vector> #include <vector>
#include <string>
#include <assimp/matrix4x4.h> #include <assimp/matrix4x4.h>
struct aiScene; struct aiScene;

View File

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

View File

@ -62,7 +62,6 @@ namespace Assimp
class ASSIMP_API JoinVerticesProcess : public BaseProcess class ASSIMP_API JoinVerticesProcess : public BaseProcess
{ {
public: public:
JoinVerticesProcess(); JoinVerticesProcess();
~JoinVerticesProcess(); ~JoinVerticesProcess();

View File

@ -565,7 +565,7 @@ void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int flags /*= 0
std::vector<aiVectorKey> keys; std::vector<aiVectorKey> keys;
GetKeys(keys,trans_x,trans_y,trans_z,flags); GetKeys(keys,trans_x,trans_y,trans_z,flags);
anim->mPositionKeys = new aiVectorKey[ anim->mNumPositionKeys = keys.size() ]; anim->mPositionKeys = new aiVectorKey[ anim->mNumPositionKeys = static_cast<unsigned int>(keys.size()) ];
std::copy(keys.begin(),keys.end(),anim->mPositionKeys); std::copy(keys.begin(),keys.end(),anim->mPositionKeys);
} }
@ -574,7 +574,7 @@ void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int flags /*= 0
std::vector<aiVectorKey> keys; std::vector<aiVectorKey> keys;
GetKeys(keys,rotat_x,rotat_y,rotat_z,flags); GetKeys(keys,rotat_x,rotat_y,rotat_z,flags);
anim->mRotationKeys = new aiQuatKey[ anim->mNumRotationKeys = keys.size() ]; anim->mRotationKeys = new aiQuatKey[ anim->mNumRotationKeys = static_cast<unsigned int>(keys.size()) ];
// convert heading, pitch, bank to quaternion // convert heading, pitch, bank to quaternion
// mValue.x=Heading=Rot(Y), mValue.y=Pitch=Rot(X), mValue.z=Bank=Rot(Z) // mValue.x=Heading=Rot(Y), mValue.y=Pitch=Rot(X), mValue.z=Bank=Rot(Z)
@ -594,7 +594,7 @@ void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int flags /*= 0
std::vector<aiVectorKey> keys; std::vector<aiVectorKey> keys;
GetKeys(keys,scale_x,scale_y,scale_z,flags); GetKeys(keys,scale_x,scale_y,scale_z,flags);
anim->mScalingKeys = new aiVectorKey[ anim->mNumScalingKeys = keys.size() ]; anim->mScalingKeys = new aiVectorKey[ anim->mNumScalingKeys = static_cast<unsigned int>(keys.size()) ];
std::copy(keys.begin(),keys.end(),anim->mScalingKeys); std::copy(keys.begin(),keys.end(),anim->mScalingKeys);
} }
} }

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