pull/2395/head
commit
b15c93c726
|
@ -27,7 +27,6 @@ compiler:
|
|||
|
||||
env:
|
||||
global:
|
||||
# COVERITY_SCAN_TOKEN
|
||||
- secure: "lZ7pHQvl5dpZWzBQAaIMf0wqrvtcZ4wiZKeIZjf83TEsflW8+z0uTpIuN30ZV6Glth/Sq1OhLnTP5+N57fZU/1ebA5twHdvP4bS5CIUUg71/CXQZNl36xeaqvxsG/xRrdpKOsPdjAOsQ9KPTQulsX43XDLS7CasMiLvYOpqKcPc="
|
||||
- PV=r8e PLATF=linux-x86_64 NDK_HOME=${TRAVIS_BUILD_DIR}/android-ndk-${PV} PATH=${PATH}:${NDK_HOME}
|
||||
|
||||
|
@ -56,8 +55,7 @@ install:
|
|||
- if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi
|
||||
|
||||
before_script:
|
||||
# init coverage to 0 (optional)
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ${TRAVIS_BUILD_DIR} && lcov --directory . --zerocounters ; fi
|
||||
cmake . -DASSIMP_ENABLE_BOOST_WORKAROUND=YES
|
||||
|
||||
script:
|
||||
- export COVERALLS_SERVICE_NAME=travis-ci
|
||||
|
@ -72,6 +70,6 @@ addons:
|
|||
project:
|
||||
name: "assimp/assimp"
|
||||
notification_email: kim.kulling@googlemail.com
|
||||
build_command_prepend: "cmake"
|
||||
build_command: "make"
|
||||
build_command_prepend: "cmake . -DASSIMP_ENABLE_BOOST_WORKAROUND=YES"
|
||||
build_command: "make -j4"
|
||||
branch_pattern: coverity_scan
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Open Asset Import Library (assimp)
|
||||
# ----------------------------------------------------------------------
|
||||
# Copyright (c) 2006-2018, assimp team
|
||||
# Copyright (c) 2006-2019, assimp team
|
||||
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -198,7 +198,7 @@ CONFIGURE_FILE(
|
|||
${CMAKE_CURRENT_BINARY_DIR}/include/assimp/config.h
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
INCLUDE_DIRECTORIES( BEFORE
|
||||
./
|
||||
include
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
==================================
|
||||
A library to import and export various 3d-model-formats including scene-post-processing to generate missing render data.
|
||||
### Current build status ###
|
||||
### Current project status ###
|
||||
[![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">
|
||||
|
@ -12,6 +12,7 @@ A library to import and export various 3d-model-formats including scene-post-pro
|
|||
[![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)
|
||||
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
|
||||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5be56faac64f46fc941ac890fb4febef)](https://www.codacy.com/app/kimkulling/assimp?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
|
||||
[![Total alerts](https://img.shields.io/lgtm/alerts/g/assimp/assimp.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/assimp/assimp/alerts/)
|
||||
<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.
|
||||
|
|
|
@ -15,8 +15,8 @@ matrix:
|
|||
|
||||
image:
|
||||
- Visual Studio 2013
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2017
|
||||
# - Visual Studio 2015
|
||||
# - Visual Studio 2017
|
||||
|
||||
platform:
|
||||
- Win32
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
@ -249,13 +249,14 @@ void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene)
|
|||
// Reads a new chunk from the file
|
||||
void Discreet3DSImporter::ReadChunk(Discreet3DS::Chunk* pcOut)
|
||||
{
|
||||
ai_assert(pcOut != NULL);
|
||||
ai_assert(pcOut != nullptr);
|
||||
|
||||
pcOut->Flag = stream->GetI2();
|
||||
pcOut->Size = stream->GetI4();
|
||||
|
||||
if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize())
|
||||
if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize()) {
|
||||
throw DeadlyImportError("Chunk is too large");
|
||||
}
|
||||
|
||||
if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit()) {
|
||||
ASSIMP_LOG_ERROR("3DS: Chunk overflow");
|
||||
|
@ -1343,15 +1344,16 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Read a percentage chunk
|
||||
ai_real Discreet3DSImporter::ParsePercentageChunk()
|
||||
{
|
||||
ai_real Discreet3DSImporter::ParsePercentageChunk() {
|
||||
Discreet3DS::Chunk chunk;
|
||||
ReadChunk(&chunk);
|
||||
|
||||
if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag)
|
||||
return stream->GetF4();
|
||||
else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag)
|
||||
if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag) {
|
||||
return stream->GetF4() * ai_real(100) / ai_real(0xFFFF);
|
||||
} else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag) {
|
||||
return (ai_real)((uint16_t)stream->GetI2()) / (ai_real)0xFFFF;
|
||||
}
|
||||
|
||||
return get_qnan();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -760,7 +760,12 @@ public:
|
|||
if (!out) return;
|
||||
|
||||
time_t tt = time(NULL);
|
||||
#if _WIN32
|
||||
tm* p = gmtime(&tt);
|
||||
#else
|
||||
struct tm now;
|
||||
tm* p = gmtime_r(&tt, &now);
|
||||
#endif
|
||||
|
||||
// header
|
||||
char s[64];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
@ -60,7 +60,6 @@ ASSIMP_API size_t aiGetExportFormatCount(void)
|
|||
return Exporter().GetExportFormatCount();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -184,7 +184,12 @@ static std::string encodeXML(const std::string& data) {
|
|||
static
|
||||
void WriteDump(const aiScene* scene, IOStream* io, bool shortened) {
|
||||
time_t tt = ::time( NULL );
|
||||
tm* p = ::gmtime( &tt );
|
||||
#if _WIN32
|
||||
tm* p = gmtime(&tt);
|
||||
#else
|
||||
struct tm now;
|
||||
tm* p = gmtime_r(&tt, &now);
|
||||
#endif
|
||||
ai_assert(nullptr != p);
|
||||
|
||||
// write header
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,11 @@ namespace Assimp {
|
|||
|
||||
#define IMPL_STRUCT_READ(ty) \
|
||||
bool read##ty(ElemBase *v, const size_t cnt, const FileDatabase &db) { \
|
||||
return read<ty>(db.dna[#ty], dynamic_cast<ty *>(v), cnt, db); \
|
||||
ty *ptr = dynamic_cast<ty*>(v); \
|
||||
if (nullptr == ptr) { \
|
||||
return false; \
|
||||
} \
|
||||
return read<ty>(db.dna[#ty], ptr, cnt, db); \
|
||||
}
|
||||
|
||||
#define IMPL_STRUCT_CREATE(ty) \
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Open Asset Import Library (assimp)
|
||||
# ----------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006-2018, assimp team
|
||||
# Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
# All rights reserved.
|
||||
|
@ -47,6 +47,11 @@
|
|||
cmake_minimum_required( VERSION 2.6 )
|
||||
SET( HEADER_PATH ../include/assimp )
|
||||
|
||||
if(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
message(WARNING "Requesting Android JNI I/O-System in non-Android toolchain. Resetting ASSIMP_ANDROID_JNIIOSYSTEM to OFF.")
|
||||
set(ASSIMP_ANDROID_JNIIOSYSTEM OFF)
|
||||
endif(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
|
||||
SET( COMPILER_HEADERS
|
||||
${HEADER_PATH}/Compiler/pushpack1.h
|
||||
${HEADER_PATH}/Compiler/poppack1.h
|
||||
|
@ -890,7 +895,7 @@ SET( assimp_src
|
|||
${PostProcessing_SRCS}
|
||||
${MaterialSystem_SRCS}
|
||||
${STEPParser_SRCS}
|
||||
${Step_SRCS}
|
||||
# ${Step_SRCS} check if we need a different approach
|
||||
|
||||
# Model Support
|
||||
${ASSIMP_LOADER_SRCS}
|
||||
|
@ -932,11 +937,11 @@ TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
|
|||
|
||||
TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES} ${IRRXML_LIBRARY} )
|
||||
|
||||
if(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
if(ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
set(ASSIMP_ANDROID_JNIIOSYSTEM_PATH port/AndroidJNI)
|
||||
add_subdirectory(../${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/ ../${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/)
|
||||
target_link_libraries(assimp android_jniiosystem)
|
||||
endif(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
endif(ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
|
||||
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||
TARGET_LINK_LIBRARIES(assimp optimized ${C4D_RELEASE_LIBRARIES})
|
||||
|
@ -966,6 +971,9 @@ if( MSVC )
|
|||
set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library")
|
||||
endif()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "WindowsStore")
|
||||
set(WindowsStore TRUE)
|
||||
endif()
|
||||
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
||||
VERSION ${ASSIMP_VERSION}
|
||||
SOVERSION ${ASSIMP_SOVERSION} # use full version
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -1500,24 +1500,18 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
|
|||
// otherwise it is a normal node (NODE)
|
||||
const char * node_type;
|
||||
bool is_joint, is_skeleton_root = false;
|
||||
if (NULL == findBone(pScene, pNode->mName.C_Str())) {
|
||||
if (nullptr == findBone(pScene, pNode->mName.C_Str())) {
|
||||
node_type = "NODE";
|
||||
is_joint = false;
|
||||
} else {
|
||||
node_type = "JOINT";
|
||||
is_joint = true;
|
||||
if(!pNode->mParent || NULL == findBone(pScene, pNode->mParent->mName.C_Str()))
|
||||
if (!pNode->mParent || nullptr == findBone(pScene, pNode->mParent->mName.C_Str())) {
|
||||
is_skeleton_root = true;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string node_name_escaped = XMLEscape(pNode->mName.data);
|
||||
/* // customized, Note! the id field is crucial for inter-xml look up, it cannot be replaced with sid ?!
|
||||
mOutput << startstr
|
||||
<< "<node ";
|
||||
if(is_skeleton_root)
|
||||
mOutput << "id=\"" << "skeleton_root" << "\" "; // For now, only support one skeleton in a scene.
|
||||
mOutput << (is_joint ? "s" : "") << "id=\"" << node_name_escaped;
|
||||
*/
|
||||
mOutput << startstr << "<node ";
|
||||
if(is_skeleton_root) {
|
||||
mOutput << "id=\"" << node_name_escaped << "\" " << (is_joint ? "sid=\"" + node_name_escaped +"\"" : "") ; // For now, only support one skeleton in a scene.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
@ -96,23 +96,26 @@ ColladaLoader::ColladaLoader()
|
|||
, mAnims()
|
||||
, noSkeletonMesh( false )
|
||||
, ignoreUpDirection(false)
|
||||
, mNodeNameCounter( 0 )
|
||||
{}
|
||||
, useColladaName( false )
|
||||
, mNodeNameCounter( 0 ) {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
ColladaLoader::~ColladaLoader()
|
||||
{}
|
||||
ColladaLoader::~ColladaLoader() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
||||
{
|
||||
bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||
// check file extension
|
||||
std::string extension = GetExtension(pFile);
|
||||
|
||||
if( extension == "dae")
|
||||
if (extension == "dae") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// XML - too generic, we need to open the file and search for typical keywords
|
||||
if( extension == "xml" || !extension.length() || checkSig) {
|
||||
|
@ -120,10 +123,13 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo
|
|||
* support a specific file extension in general pIOHandler
|
||||
* might be NULL and it's our duty to return true here.
|
||||
*/
|
||||
if (!pIOHandler)return true;
|
||||
if (!pIOHandler) {
|
||||
return true;
|
||||
}
|
||||
const char* tokens[] = {"<collada"};
|
||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -144,8 +150,7 @@ const aiImporterDesc* ColladaLoader::GetInfo () const
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
|
||||
mFileName = pFile;
|
||||
|
||||
// clean all member arrays - just for safety, it should work even if we did not
|
||||
|
@ -181,7 +186,7 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
|
|||
// ... then fill the materials with the now adjusted settings
|
||||
FillMaterials(parser, pScene);
|
||||
|
||||
// Apply unitsize scale calculation
|
||||
// Apply unit-size scale calculation
|
||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(parser.mUnitSize, 0, 0, 0,
|
||||
0, parser.mUnitSize, 0, 0,
|
||||
0, 0, parser.mUnitSize, 0,
|
||||
|
@ -725,8 +730,11 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
|
|||
std::vector<aiAnimMesh*> animMeshes;
|
||||
for (unsigned int i = 0; i < targetMeshes.size(); i++)
|
||||
{
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(targetMeshes.at(i));
|
||||
animMesh->mWeight = targetWeights[i];
|
||||
aiMesh* targetMesh = targetMeshes.at(i);
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(targetMesh);
|
||||
float weight = targetWeights[i];
|
||||
animMesh->mWeight = weight == 0 ? 1.0f : weight;
|
||||
animMesh->mName = targetMesh->mName;
|
||||
animMeshes.push_back(animMesh);
|
||||
}
|
||||
dstMesh->mMethod = (method == Collada::Relative)
|
||||
|
@ -1918,10 +1926,16 @@ const Collada::Node* ColladaLoader::FindNodeBySID( const Collada::Node* pNode, c
|
|||
std::string ColladaLoader::FindNameForNode( const Collada::Node* pNode)
|
||||
{
|
||||
// If explicitly requested, just use the collada name.
|
||||
if (useColladaName) {
|
||||
if (useColladaName)
|
||||
{
|
||||
if (!pNode->mName.empty()) {
|
||||
return pNode->mName;
|
||||
} else {
|
||||
return format() << "$ColladaAutoName$_" << mNodeNameCounter++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now setup the name of the assimp node. The collada name might not be
|
||||
// unique, so we use the collada ID.
|
||||
if (!pNode->mID.empty())
|
||||
|
@ -1935,5 +1949,6 @@ std::string ColladaLoader::FindNameForNode( const Collada::Node* pNode)
|
|||
return format() << "$ColladaAutoName$_" << mNodeNameCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_DAE_IMPORTER
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
@ -2362,7 +2362,7 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
|
|||
if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) {
|
||||
if (pPrimType == Prim_Lines) {
|
||||
// HACK: We just fix this number since SketchUp 15.3.331 writes the wrong 'count' for 'lines'
|
||||
ReportWarning( "Expected different index count in <p> element, %d instead of %d.", indices.size(), expectedPointCount * numOffsets);
|
||||
ReportWarning( "Expected different index count in <p> element, %zu instead of %zu.", indices.size(), expectedPointCount * numOffsets);
|
||||
pNumPrimitives = (indices.size() / numOffsets) / 2;
|
||||
} else
|
||||
ThrowException( "Expected different index count in <p> element.");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
@ -166,8 +166,9 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) {
|
|||
for( size_t a = 0; a < pMesh->mNumVertices; ++a)
|
||||
{
|
||||
pMesh->mVertices[a].z *= -1.0f;
|
||||
if( pMesh->HasNormals())
|
||||
if (pMesh->HasNormals()) {
|
||||
pMesh->mNormals[a].z *= -1.0f;
|
||||
}
|
||||
if( pMesh->HasTangentsAndBitangents())
|
||||
{
|
||||
pMesh->mTangents[a].z *= -1.0f;
|
||||
|
@ -175,6 +176,23 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) {
|
|||
}
|
||||
}
|
||||
|
||||
// mirror anim meshes positions, normals and stuff along the Z axis
|
||||
for (size_t m = 0; m < pMesh->mNumAnimMeshes; ++m)
|
||||
{
|
||||
for (size_t a = 0; a < pMesh->mAnimMeshes[m]->mNumVertices; ++a)
|
||||
{
|
||||
pMesh->mAnimMeshes[m]->mVertices[a].z *= -1.0f;
|
||||
if (pMesh->mAnimMeshes[m]->HasNormals()) {
|
||||
pMesh->mAnimMeshes[m]->mNormals[a].z *= -1.0f;
|
||||
}
|
||||
if (pMesh->mAnimMeshes[m]->HasTangentsAndBitangents())
|
||||
{
|
||||
pMesh->mAnimMeshes[m]->mTangents[a].z *= -1.0f;
|
||||
pMesh->mAnimMeshes[m]->mBitangents[a].z *= -1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirror offset matrices of all bones
|
||||
for( size_t a = 0; a < pMesh->mNumBones; ++a)
|
||||
{
|
||||
|
@ -346,9 +364,51 @@ void FlipWindingOrderProcess::ProcessMesh( aiMesh* pMesh)
|
|||
for( unsigned int a = 0; a < pMesh->mNumFaces; a++)
|
||||
{
|
||||
aiFace& face = pMesh->mFaces[a];
|
||||
for( unsigned int b = 0; b < face.mNumIndices / 2; b++)
|
||||
for (unsigned int b = 0; b < face.mNumIndices / 2; b++) {
|
||||
std::swap(face.mIndices[b], face.mIndices[face.mNumIndices - 1 - b]);
|
||||
}
|
||||
}
|
||||
|
||||
// invert the order of all components in this mesh anim meshes
|
||||
for (unsigned int m = 0; m < pMesh->mNumAnimMeshes; m++) {
|
||||
aiAnimMesh* animMesh = pMesh->mAnimMeshes[m];
|
||||
unsigned int numVertices = animMesh->mNumVertices;
|
||||
if (animMesh->HasPositions()) {
|
||||
for (unsigned int a = 0; a < numVertices; a++)
|
||||
{
|
||||
std::swap(animMesh->mVertices[a], animMesh->mVertices[numVertices - 1 - a]);
|
||||
}
|
||||
}
|
||||
if (animMesh->HasNormals()) {
|
||||
for (unsigned int a = 0; a < numVertices; a++)
|
||||
{
|
||||
std::swap(animMesh->mNormals[a], animMesh->mNormals[numVertices - 1 - a]);
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++) {
|
||||
if (animMesh->HasTextureCoords(i)) {
|
||||
for (unsigned int a = 0; a < numVertices; a++)
|
||||
{
|
||||
std::swap(animMesh->mTextureCoords[i][a], animMesh->mTextureCoords[i][numVertices - 1 - a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (animMesh->HasTangentsAndBitangents()) {
|
||||
for (unsigned int a = 0; a < numVertices; a++)
|
||||
{
|
||||
std::swap(animMesh->mTangents[a], animMesh->mTangents[numVertices - 1 - a]);
|
||||
std::swap(animMesh->mBitangents[a], animMesh->mBitangents[numVertices - 1 - a]);
|
||||
}
|
||||
}
|
||||
for (unsigned int v = 0; v < AI_MAX_NUMBER_OF_COLOR_SETS; v++) {
|
||||
if (animMesh->HasVertexColors(v)) {
|
||||
for (unsigned int a = 0; a < numVertices; a++)
|
||||
{
|
||||
std::swap(animMesh->mColors[v][a], animMesh->mColors[v][numVertices - 1 - a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_FLIPWINDING_PROCESS
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
@ -76,6 +76,7 @@ bool DefaultIOSystem::Exists( const char* pFile) const
|
|||
#ifdef _WIN32
|
||||
wchar_t fileName16[PATHLIMIT];
|
||||
|
||||
#ifndef WindowsStore
|
||||
bool isUnicode = IsTextUnicode(pFile, static_cast<int>(strlen(pFile)), NULL) != 0;
|
||||
if (isUnicode) {
|
||||
|
||||
|
@ -85,12 +86,15 @@ bool DefaultIOSystem::Exists( const char* pFile) const
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
FILE* file = ::fopen(pFile, "rb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
::fclose(file);
|
||||
#ifndef WindowsStore
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
FILE* file = ::fopen( pFile, "rb");
|
||||
if( !file)
|
||||
|
@ -110,14 +114,18 @@ IOStream* DefaultIOSystem::Open( const char* strFile, const char* strMode)
|
|||
FILE* file;
|
||||
#ifdef _WIN32
|
||||
wchar_t fileName16[PATHLIMIT];
|
||||
#ifndef WindowsStore
|
||||
bool isUnicode = IsTextUnicode(strFile, static_cast<int>(strlen(strFile)), NULL) != 0;
|
||||
if (isUnicode) {
|
||||
MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, strFile, -1, fileName16, PATHLIMIT);
|
||||
std::string mode8(strMode);
|
||||
file = ::_wfopen(fileName16, std::wstring(mode8.begin(), mode8.end()).c_str());
|
||||
} else {
|
||||
#endif
|
||||
file = ::fopen(strFile, strMode);
|
||||
#ifndef WindowsStore
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
file = ::fopen(strFile, strMode);
|
||||
#endif
|
||||
|
@ -158,6 +166,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out)
|
|||
{
|
||||
ai_assert(in && _out);
|
||||
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
||||
#ifndef WindowsStore
|
||||
bool isUnicode = IsTextUnicode(in, static_cast<int>(strlen(in)), NULL) != 0;
|
||||
if (isUnicode) {
|
||||
wchar_t out16[PATHLIMIT];
|
||||
|
@ -175,6 +184,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out)
|
|||
}
|
||||
|
||||
} else {
|
||||
#endif
|
||||
char* ret = :: _fullpath(_out, in, PATHLIMIT);
|
||||
if (!ret) {
|
||||
// preserve the input path, maybe someone else is able to fix
|
||||
|
@ -182,7 +192,9 @@ inline static void MakeAbsolutePath (const char* in, char* _out)
|
|||
ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in));
|
||||
strcpy(_out, in);
|
||||
}
|
||||
#ifndef WindowsStore
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// use realpath
|
||||
char* ret = realpath(in, _out);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -124,22 +124,28 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
|
|||
file.read(reinterpret_cast<char*>(imageContent), imageSize);
|
||||
|
||||
// Enlarging the textures table
|
||||
auto textureId = pScene->mNumTextures++;
|
||||
unsigned int textureId = pScene->mNumTextures++;
|
||||
auto oldTextures = pScene->mTextures;
|
||||
pScene->mTextures = new aiTexture*[pScene->mNumTextures];
|
||||
memmove(pScene->mTextures, oldTextures, sizeof(aiTexture*) * (pScene->mNumTextures - 1u));
|
||||
::memmove(pScene->mTextures, oldTextures, sizeof(aiTexture*) * (pScene->mNumTextures - 1u));
|
||||
|
||||
// Add the new texture
|
||||
auto pTexture = new aiTexture();
|
||||
auto pTexture = new aiTexture;
|
||||
pTexture->mHeight = 0; // Means that this is still compressed
|
||||
pTexture->mWidth = static_cast<uint32_t>(imageSize);
|
||||
pTexture->pcData = imageContent;
|
||||
|
||||
auto extension = path.substr(path.find_last_of('.') + 1u);
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
||||
if (extension == "jpeg") extension = "jpg";
|
||||
strcpy(pTexture->achFormatHint, extension.c_str());
|
||||
if (extension == "jpeg") {
|
||||
extension = "jpg";
|
||||
}
|
||||
|
||||
size_t len = extension.size();
|
||||
if (len > HINTMAXTEXTURELEN -1 ) {
|
||||
len = HINTMAXTEXTURELEN - 1;
|
||||
}
|
||||
::strncpy(pTexture->achFormatHint, extension.c_str(), len);
|
||||
pScene->mTextures[textureId] = pTexture;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -105,8 +105,8 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
|
|||
const Scope& sc = GetRequiredScope(element);
|
||||
|
||||
// find target node
|
||||
const char* whitelist[] = {"Model","NodeAttribute"};
|
||||
const std::vector<const Connection*>& conns = doc.GetConnectionsBySourceSequenced(ID(),whitelist,2);
|
||||
const char* whitelist[] = {"Model","NodeAttribute","Deformer"};
|
||||
const std::vector<const Connection*>& conns = doc.GetConnectionsBySourceSequenced(ID(),whitelist,3);
|
||||
|
||||
for(const Connection* con : conns) {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -276,8 +276,8 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
|
|||
case 'f':
|
||||
case 'd':
|
||||
case 'l':
|
||||
case 'i': {
|
||||
|
||||
case 'i':
|
||||
case 'c': {
|
||||
const uint32_t length = ReadWord(input, cursor, end);
|
||||
const uint32_t encoding = ReadWord(input, cursor, end);
|
||||
|
||||
|
@ -298,6 +298,10 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
|
|||
stride = 8;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
stride = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
ai_assert(false);
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -53,10 +53,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "FBXUtil.h"
|
||||
#include "FBXProperties.h"
|
||||
#include "FBXImporter.h"
|
||||
|
||||
#include <assimp/StringComparison.h>
|
||||
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#include <assimp/CreateAnimMesh.h>
|
||||
|
||||
#include <tuple>
|
||||
#include <memory>
|
||||
#include <iterator>
|
||||
|
@ -188,7 +191,8 @@ void FBXConverter::ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4&
|
|||
std::string old_original_name = original_name;
|
||||
GetUniqueName(old_original_name, original_name);
|
||||
nodes_chain.push_back(new aiNode(original_name));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
original_name = nodes_chain.back()->mName.C_Str();
|
||||
}
|
||||
|
||||
|
@ -236,7 +240,8 @@ void FBXConverter::ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4&
|
|||
|
||||
new_abs_transform *= postnode->mTransformation;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// free the nodes we allocated as we don't need them
|
||||
Util::delete_fun<aiNode> deleter;
|
||||
std::for_each(
|
||||
|
@ -385,9 +390,18 @@ void FBXConverter::ConvertCamera( const Camera& cam, const std::string &orig_nam
|
|||
out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
|
||||
|
||||
//cameras are defined along positive x direction
|
||||
out_camera->mPosition = cam.Position();
|
||||
/*out_camera->mPosition = cam.Position();
|
||||
out_camera->mLookAt = (cam.InterestPosition() - out_camera->mPosition).Normalize();
|
||||
out_camera->mUp = cam.UpVector();
|
||||
out_camera->mUp = cam.UpVector();*/
|
||||
|
||||
out_camera->mPosition = aiVector3D(0.0f);
|
||||
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->mClipPlaneNear = cam.NearPlane();
|
||||
out_camera->mClipPlaneFar = cam.FarPlane();
|
||||
|
||||
out_camera->mHorizontalFOV = AI_DEG_TO_RAD(cam.FieldOfView());
|
||||
out_camera->mClipPlaneNear = cam.NearPlane();
|
||||
|
@ -622,7 +636,8 @@ bool FBXConverter::NeedsComplexTransformationChain( const Model& model )
|
|||
if ((v - all_ones).SquareLength() > zero_epsilon) {
|
||||
return true;
|
||||
}
|
||||
} else if ( ok ) {
|
||||
}
|
||||
else if (ok) {
|
||||
if (v.SquareLength() > zero_epsilon) {
|
||||
return true;
|
||||
}
|
||||
|
@ -720,7 +735,8 @@ void FBXConverter::GenerateTransformationNodeChain( const Model& model, std::vec
|
|||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
if (std::fabs(GeometricScalingInverse[i]) > zero_epsilon) {
|
||||
GeometricScalingInverse[i] = 1.0f / GeometricScaling[i];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
FBXImporter::LogError("cannot invert geometric scaling matrix with a 0.0 scale component");
|
||||
canscale = false;
|
||||
break;
|
||||
|
@ -787,7 +803,8 @@ void FBXConverter::GenerateTransformationNodeChain( const Model& model, std::vec
|
|||
comp == TransformationComp_GeometricTranslationInverse
|
||||
) {
|
||||
post_output_nodes.push_back(nd);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
output_nodes.push_back(nd);
|
||||
}
|
||||
}
|
||||
|
@ -830,17 +847,23 @@ void FBXConverter::SetupNodeMetadata( const Model& model, aiNode& nd )
|
|||
// Interpret the property as a concrete type
|
||||
if (const TypedProperty<bool>* interpreted = prop.second->As<TypedProperty<bool> >()) {
|
||||
data->Set(index++, prop.first, interpreted->Value());
|
||||
} else if ( const TypedProperty<int>* interpreted = prop.second->As<TypedProperty<int> >() ) {
|
||||
}
|
||||
else if (const TypedProperty<int>* interpreted = prop.second->As<TypedProperty<int> >()) {
|
||||
data->Set(index++, prop.first, interpreted->Value());
|
||||
} else if ( const TypedProperty<uint64_t>* interpreted = prop.second->As<TypedProperty<uint64_t> >() ) {
|
||||
}
|
||||
else if (const TypedProperty<uint64_t>* interpreted = prop.second->As<TypedProperty<uint64_t> >()) {
|
||||
data->Set(index++, prop.first, interpreted->Value());
|
||||
} else if ( const TypedProperty<float>* interpreted = prop.second->As<TypedProperty<float> >() ) {
|
||||
}
|
||||
else if (const TypedProperty<float>* interpreted = prop.second->As<TypedProperty<float> >()) {
|
||||
data->Set(index++, prop.first, interpreted->Value());
|
||||
} else if ( const TypedProperty<std::string>* interpreted = prop.second->As<TypedProperty<std::string> >() ) {
|
||||
}
|
||||
else if (const TypedProperty<std::string>* interpreted = prop.second->As<TypedProperty<std::string> >()) {
|
||||
data->Set(index++, prop.first, aiString(interpreted->Value()));
|
||||
} else if ( const TypedProperty<aiVector3D>* interpreted = prop.second->As<TypedProperty<aiVector3D> >() ) {
|
||||
}
|
||||
else if (const TypedProperty<aiVector3D>* interpreted = prop.second->As<TypedProperty<aiVector3D> >()) {
|
||||
data->Set(index++, prop.first, interpreted->Value());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ai_assert(false);
|
||||
}
|
||||
}
|
||||
|
@ -856,10 +879,15 @@ void FBXConverter::ConvertModel( const Model& model, aiNode& nd, const aiMatrix4
|
|||
for (const Geometry* geo : geos) {
|
||||
|
||||
const MeshGeometry* const mesh = dynamic_cast<const MeshGeometry*>(geo);
|
||||
const LineGeometry* const line = dynamic_cast<const LineGeometry*>(geo);
|
||||
if (mesh) {
|
||||
const std::vector<unsigned int>& indices = ConvertMesh(*mesh, model, node_global_transform, nd);
|
||||
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
|
||||
}
|
||||
else if (line) {
|
||||
const std::vector<unsigned int>& indices = ConvertLine(*line, model, node_global_transform, nd);
|
||||
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
|
||||
}
|
||||
else {
|
||||
FBXImporter::LogWarn("ignoring unrecognized geometry: " + geo->Name());
|
||||
}
|
||||
|
@ -908,7 +936,52 @@ std::vector<unsigned int> FBXConverter::ConvertMesh( const MeshGeometry& mesh, c
|
|||
return temp;
|
||||
}
|
||||
|
||||
aiMesh* FBXConverter::SetupEmptyMesh( const MeshGeometry& mesh, aiNode& nd)
|
||||
std::vector<unsigned int> FBXConverter::ConvertLine(const LineGeometry& line, const Model& model,
|
||||
const aiMatrix4x4& node_global_transform, aiNode& nd)
|
||||
{
|
||||
std::vector<unsigned int> temp;
|
||||
|
||||
const std::vector<aiVector3D>& vertices = line.GetVertices();
|
||||
const std::vector<int>& indices = line.GetIndices();
|
||||
if (vertices.empty() || indices.empty()) {
|
||||
FBXImporter::LogWarn("ignoring empty line: " + line.Name());
|
||||
return temp;
|
||||
}
|
||||
|
||||
aiMesh* const out_mesh = SetupEmptyMesh(line, nd);
|
||||
out_mesh->mPrimitiveTypes |= aiPrimitiveType_LINE;
|
||||
|
||||
// copy vertices
|
||||
out_mesh->mNumVertices = static_cast<unsigned int>(vertices.size());
|
||||
out_mesh->mVertices = new aiVector3D[out_mesh->mNumVertices];
|
||||
std::copy(vertices.begin(), vertices.end(), out_mesh->mVertices);
|
||||
|
||||
//Number of line segments (faces) is "Number of Points - Number of Endpoints"
|
||||
//N.B.: Endpoints in FbxLine are denoted by negative indices.
|
||||
//If such an Index is encountered, add 1 and multiply by -1 to get the real index.
|
||||
unsigned int epcount = 0;
|
||||
for (unsigned i = 0; i < indices.size(); i++)
|
||||
{
|
||||
if (indices[i] < 0) epcount++;
|
||||
}
|
||||
unsigned int pcount = indices.size();
|
||||
unsigned int scount = out_mesh->mNumFaces = pcount - epcount;
|
||||
|
||||
aiFace* fac = out_mesh->mFaces = new aiFace[scount]();
|
||||
for (unsigned int i = 0; i < pcount; ++i) {
|
||||
if (indices[i] < 0) continue;
|
||||
aiFace& f = *fac++;
|
||||
f.mNumIndices = 2; //2 == aiPrimitiveType_LINE
|
||||
f.mIndices = new unsigned int[2];
|
||||
f.mIndices[0] = indices[i];
|
||||
int segid = indices[(i + 1 == pcount ? 0 : i + 1)]; //If we have reached he last point, wrap around
|
||||
f.mIndices[1] = (segid < 0 ? (segid + 1)*-1 : segid); //Convert EndPoint Index to normal Index
|
||||
}
|
||||
temp.push_back(static_cast<unsigned int>(meshes.size() - 1));
|
||||
return temp;
|
||||
}
|
||||
|
||||
aiMesh* FBXConverter::SetupEmptyMesh(const Geometry& mesh, aiNode& nd)
|
||||
{
|
||||
aiMesh* const out_mesh = new aiMesh();
|
||||
meshes.push_back(out_mesh);
|
||||
|
@ -943,6 +1016,7 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial( const MeshGeometry& mesh,
|
|||
// copy vertices
|
||||
out_mesh->mNumVertices = static_cast<unsigned int>(vertices.size());
|
||||
out_mesh->mVertices = new aiVector3D[vertices.size()];
|
||||
|
||||
std::copy(vertices.begin(), vertices.end(), out_mesh->mVertices);
|
||||
|
||||
// generate dummy faces
|
||||
|
@ -1055,6 +1129,45 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial( const MeshGeometry& mesh,
|
|||
ConvertWeights(out_mesh, model, mesh, node_global_transform, NO_MATERIAL_SEPARATION);
|
||||
}
|
||||
|
||||
std::vector<aiAnimMesh*> animMeshes;
|
||||
for (const BlendShape* blendShape : mesh.GetBlendShapes()) {
|
||||
for (const BlendShapeChannel* blendShapeChannel : blendShape->BlendShapeChannels()) {
|
||||
const std::vector<const ShapeGeometry*>& shapeGeometries = blendShapeChannel->GetShapeGeometries();
|
||||
for (size_t i = 0; i < shapeGeometries.size(); i++) {
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh);
|
||||
const ShapeGeometry* shapeGeometry = shapeGeometries.at(i);
|
||||
const std::vector<aiVector3D>& vertices = shapeGeometry->GetVertices();
|
||||
const std::vector<aiVector3D>& normals = shapeGeometry->GetNormals();
|
||||
const std::vector<unsigned int>& indices = shapeGeometry->GetIndices();
|
||||
animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name()));
|
||||
for (size_t j = 0; j < indices.size(); j++) {
|
||||
unsigned int index = indices.at(j);
|
||||
aiVector3D vertex = vertices.at(j);
|
||||
aiVector3D normal = normals.at(j);
|
||||
unsigned int count = 0;
|
||||
const unsigned int* outIndices = mesh.ToOutputVertexIndex(index, count);
|
||||
for (unsigned int k = 0; k < count; k++) {
|
||||
unsigned int index = outIndices[k];
|
||||
animMesh->mVertices[index] += vertex;
|
||||
if (animMesh->mNormals != nullptr) {
|
||||
animMesh->mNormals[index] += normal;
|
||||
animMesh->mNormals[index].NormalizeSafe();
|
||||
}
|
||||
}
|
||||
}
|
||||
animMesh->mWeight = shapeGeometries.size() > 1 ? blendShapeChannel->DeformPercent() / 100.0f : 1.0f;
|
||||
animMeshes.push_back(animMesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
const size_t numAnimMeshes = animMeshes.size();
|
||||
if (numAnimMeshes > 0) {
|
||||
out_mesh->mNumAnimMeshes = static_cast<unsigned int>(numAnimMeshes);
|
||||
out_mesh->mAnimMeshes = new aiAnimMesh*[numAnimMeshes];
|
||||
for (size_t i = 0; i < numAnimMeshes; i++) {
|
||||
out_mesh->mAnimMeshes[i] = animMeshes.at(i);
|
||||
}
|
||||
}
|
||||
return static_cast<unsigned int>(meshes.size() - 1);
|
||||
}
|
||||
|
||||
|
@ -1187,8 +1300,7 @@ unsigned int FBXConverter::ConvertMeshMultiMaterial( const MeshGeometry& mesh, c
|
|||
unsigned int cursor = 0, in_cursor = 0;
|
||||
|
||||
itf = faces.begin();
|
||||
for ( MatIndexArray::const_iterator it = mindices.begin(),
|
||||
end = mindices.end(); it != end; ++it, ++itf )
|
||||
for (MatIndexArray::const_iterator it = mindices.begin(), end = mindices.end(); it != end; ++it, ++itf)
|
||||
{
|
||||
const unsigned int pcount = *itf;
|
||||
if ((*it) != index) {
|
||||
|
@ -1471,6 +1583,7 @@ unsigned int FBXConverter::ConvertMaterial( const Material& material, const Mesh
|
|||
|
||||
// shading stuff and colors
|
||||
SetShadingPropertiesCommon(out_mat, props);
|
||||
SetShadingPropertiesRaw( out_mat, props, material.Textures(), mesh );
|
||||
|
||||
// texture assignments
|
||||
SetTextureProperties(out_mat, material.Textures(), mesh);
|
||||
|
@ -1559,7 +1672,8 @@ void FBXConverter::TrySetTextureProperties( aiMaterial* out_mat, const TextureMa
|
|||
}
|
||||
|
||||
const Texture* const tex = (*it).second;
|
||||
if ( tex != nullptr ) {
|
||||
if (tex != 0)
|
||||
{
|
||||
aiString path = GetTexturePath(tex);
|
||||
out_mat->AddProperty(&path, _AI_MATKEY_TEXTURE_BASE, target, 0);
|
||||
|
||||
|
@ -1793,28 +1907,40 @@ void FBXConverter::SetTextureProperties( aiMaterial* out_mat, const TextureMap&
|
|||
{
|
||||
TrySetTextureProperties(out_mat, textures, "DiffuseColor", aiTextureType_DIFFUSE, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "AmbientColor", aiTextureType_AMBIENT, mesh);
|
||||
TrySetTextureProperties( out_mat, textures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh );
|
||||
TrySetTextureProperties(out_mat, textures, "EmissiveColor", aiTextureType_EMISSIVE, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "SpecularColor", aiTextureType_SPECULAR, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "SpecularFactor", aiTextureType_SPECULAR, mesh);
|
||||
TrySetTextureProperties( out_mat, textures, "TransparencyFactor", aiTextureType_OPACITY, mesh );
|
||||
TrySetTextureProperties(out_mat, textures, "TransparentColor", aiTextureType_OPACITY, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "ReflectionColor", aiTextureType_REFLECTION, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "NormalMap", aiTextureType_NORMALS, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "Bump", aiTextureType_HEIGHT, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "ShininessExponent", aiTextureType_SHININESS, mesh);
|
||||
TrySetTextureProperties( out_mat, textures, "TransparencyFactor", aiTextureType_OPACITY, mesh );
|
||||
TrySetTextureProperties( out_mat, textures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh );
|
||||
//Maya counterparts
|
||||
TrySetTextureProperties(out_mat, textures, "Maya|DiffuseTexture", aiTextureType_DIFFUSE, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "Maya|NormalTexture", aiTextureType_NORMALS, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "Maya|SpecularTexture", aiTextureType_SPECULAR, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "Maya|FalloffTexture", aiTextureType_OPACITY, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "Maya|ReflectionMapTexture", aiTextureType_REFLECTION, mesh);
|
||||
}
|
||||
|
||||
void FBXConverter::SetTextureProperties(aiMaterial* out_mat, const LayeredTextureMap& layeredTextures, const MeshGeometry* const mesh)
|
||||
{
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "DiffuseColor", aiTextureType_DIFFUSE, mesh);
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "AmbientColor", aiTextureType_AMBIENT, mesh);
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh );
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "EmissiveColor", aiTextureType_EMISSIVE, mesh);
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "SpecularColor", aiTextureType_SPECULAR, mesh);
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "SpecularFactor", aiTextureType_SPECULAR, mesh);
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "TransparencyFactor", aiTextureType_OPACITY, mesh );
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "TransparentColor", aiTextureType_OPACITY, mesh);
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "ReflectionColor", aiTextureType_REFLECTION, mesh);
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh);
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "NormalMap", aiTextureType_NORMALS, mesh);
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "Bump", aiTextureType_HEIGHT, mesh);
|
||||
TrySetTextureProperties(out_mat, layeredTextures, "ShininessExponent", aiTextureType_SHININESS, mesh);
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh );
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "TransparencyFactor", aiTextureType_OPACITY, mesh );
|
||||
}
|
||||
|
||||
aiColor3D FBXConverter::GetColorPropertyFactored(const PropertyTable& props, const std::string& colorName,
|
||||
|
@ -1960,6 +2086,180 @@ void FBXConverter::SetShadingPropertiesCommon( aiMaterial* out_mat, const Proper
|
|||
}
|
||||
|
||||
|
||||
void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTable& props, const TextureMap& textures, const MeshGeometry* const mesh)
|
||||
{
|
||||
// Add all the unparsed properties with a "$raw." prefix
|
||||
|
||||
const std::string prefix = "$raw.";
|
||||
|
||||
for (const DirectPropertyMap::value_type& prop : props.GetUnparsedProperties()) {
|
||||
|
||||
std::string name = prefix + prop.first;
|
||||
|
||||
if (const TypedProperty<aiVector3D>* interpreted = prop.second->As<TypedProperty<aiVector3D> >())
|
||||
{
|
||||
out_mat->AddProperty(&interpreted->Value(), 1, name.c_str(), 0, 0);
|
||||
}
|
||||
else if (const TypedProperty<aiColor3D>* interpreted = prop.second->As<TypedProperty<aiColor3D> >())
|
||||
{
|
||||
out_mat->AddProperty(&interpreted->Value(), 1, name.c_str(), 0, 0);
|
||||
}
|
||||
else if (const TypedProperty<aiColor4D>* interpreted = prop.second->As<TypedProperty<aiColor4D> >())
|
||||
{
|
||||
out_mat->AddProperty(&interpreted->Value(), 1, name.c_str(), 0, 0);
|
||||
}
|
||||
else if (const TypedProperty<float>* interpreted = prop.second->As<TypedProperty<float> >())
|
||||
{
|
||||
out_mat->AddProperty(&interpreted->Value(), 1, name.c_str(), 0, 0);
|
||||
}
|
||||
else if (const TypedProperty<int>* interpreted = prop.second->As<TypedProperty<int> >())
|
||||
{
|
||||
out_mat->AddProperty(&interpreted->Value(), 1, name.c_str(), 0, 0);
|
||||
}
|
||||
else if (const TypedProperty<bool>* interpreted = prop.second->As<TypedProperty<bool> >())
|
||||
{
|
||||
int value = interpreted->Value() ? 1 : 0;
|
||||
out_mat->AddProperty(&value, 1, name.c_str(), 0, 0);
|
||||
}
|
||||
else if (const TypedProperty<std::string>* interpreted = prop.second->As<TypedProperty<std::string> >())
|
||||
{
|
||||
const aiString value = aiString(interpreted->Value());
|
||||
out_mat->AddProperty(&value, name.c_str(), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the textures' properties
|
||||
|
||||
for (TextureMap::const_iterator it = textures.begin(); it != textures.end(); it++) {
|
||||
|
||||
std::string name = prefix + it->first;
|
||||
|
||||
const Texture* const tex = (*it).second;
|
||||
if (tex != nullptr)
|
||||
{
|
||||
aiString path;
|
||||
path.Set(tex->RelativeFilename());
|
||||
|
||||
const Video* media = tex->Media();
|
||||
if (media != nullptr && media->ContentLength() > 0) {
|
||||
unsigned int index;
|
||||
|
||||
VideoMap::const_iterator it = textures_converted.find(media);
|
||||
if (it != textures_converted.end()) {
|
||||
index = (*it).second;
|
||||
}
|
||||
else {
|
||||
index = ConvertVideo(*media);
|
||||
textures_converted[media] = index;
|
||||
}
|
||||
|
||||
// setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture)
|
||||
path.data[0] = '*';
|
||||
path.length = 1 + ASSIMP_itoa10(path.data + 1, MAXLEN - 1, index);
|
||||
}
|
||||
|
||||
out_mat->AddProperty(&path, (name + "|file").c_str(), aiTextureType_UNKNOWN, 0);
|
||||
|
||||
aiUVTransform uvTrafo;
|
||||
// XXX handle all kinds of UV transformations
|
||||
uvTrafo.mScaling = tex->UVScaling();
|
||||
uvTrafo.mTranslation = tex->UVTranslation();
|
||||
out_mat->AddProperty(&uvTrafo, 1, (name + "|uvtrafo").c_str(), aiTextureType_UNKNOWN, 0);
|
||||
|
||||
int uvIndex = 0;
|
||||
|
||||
bool uvFound = false;
|
||||
const std::string& uvSet = PropertyGet<std::string>(tex->Props(), "UVSet", uvFound);
|
||||
if (uvFound) {
|
||||
// "default" is the name which usually appears in the FbxFileTexture template
|
||||
if (uvSet != "default" && uvSet.length()) {
|
||||
// this is a bit awkward - we need to find a mesh that uses this
|
||||
// material and scan its UV channels for the given UV name because
|
||||
// assimp references UV channels by index, not by name.
|
||||
|
||||
// XXX: the case that UV channels may appear in different orders
|
||||
// in meshes is unhandled. A possible solution would be to sort
|
||||
// the UV channels alphabetically, but this would have the side
|
||||
// effect that the primary (first) UV channel would sometimes
|
||||
// be moved, causing trouble when users read only the first
|
||||
// UV channel and ignore UV channel assignments altogether.
|
||||
|
||||
std::vector<aiMaterial*>::iterator materialIt = std::find(materials.begin(), materials.end(), out_mat);
|
||||
const unsigned int matIndex = static_cast<unsigned int>(std::distance(materials.begin(), materialIt));
|
||||
|
||||
uvIndex = -1;
|
||||
if (!mesh)
|
||||
{
|
||||
for (const MeshMap::value_type& v : meshes_converted) {
|
||||
const MeshGeometry* const mesh = dynamic_cast<const MeshGeometry*>(v.first);
|
||||
if (!mesh) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const MatIndexArray& mats = mesh->GetMaterialIndices();
|
||||
if (std::find(mats.begin(), mats.end(), matIndex) == mats.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int index = -1;
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||
if (mesh->GetTextureCoords(i).empty()) {
|
||||
break;
|
||||
}
|
||||
const std::string& name = mesh->GetTextureCoordChannelName(i);
|
||||
if (name == uvSet) {
|
||||
index = static_cast<int>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == -1) {
|
||||
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (uvIndex == -1) {
|
||||
uvIndex = index;
|
||||
}
|
||||
else {
|
||||
FBXImporter::LogWarn("the UV channel named " + uvSet + " appears at different positions in meshes, results will be wrong");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = -1;
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||
if (mesh->GetTextureCoords(i).empty()) {
|
||||
break;
|
||||
}
|
||||
const std::string& name = mesh->GetTextureCoordChannelName(i);
|
||||
if (name == uvSet) {
|
||||
index = static_cast<int>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == -1) {
|
||||
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
|
||||
}
|
||||
|
||||
if (uvIndex == -1) {
|
||||
uvIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
if (uvIndex == -1) {
|
||||
FBXImporter::LogWarn("failed to resolve UV channel " + uvSet + ", using first UV channel");
|
||||
uvIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out_mat->AddProperty(&uvIndex, 1, (name + "|uvwsrc").c_str(), aiTextureType_UNKNOWN, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double FBXConverter::FrameRateToDouble(FileGlobalSettings::FrameRate fp, double customFPSVal) {
|
||||
switch (fp) {
|
||||
case FileGlobalSettings::FrameRate_DEFAULT:
|
||||
|
@ -2039,6 +2339,16 @@ std::string FBXConverter::FixNodeName( const std::string& name ) {
|
|||
return name;
|
||||
}
|
||||
|
||||
std::string FBXConverter::FixAnimMeshName(const std::string& name) {
|
||||
if (name.length()) {
|
||||
size_t indexOf = name.find_first_of("::");
|
||||
if (indexOf != std::string::npos && indexOf < name.size() - 2) {
|
||||
return name.substr(indexOf + 2);
|
||||
}
|
||||
}
|
||||
return name.length() ? name : "AnimMesh";
|
||||
}
|
||||
|
||||
void FBXConverter::ConvertAnimationStack(const AnimationStack& st)
|
||||
{
|
||||
const AnimationLayerList& layers = st.Layers();
|
||||
|
@ -2071,26 +2381,28 @@ void FBXConverter::ConvertAnimationStack( const AnimationStack& st )
|
|||
const char* prop_whitelist[] = {
|
||||
"Lcl Scaling",
|
||||
"Lcl Rotation",
|
||||
"Lcl Translation"
|
||||
"Lcl Translation",
|
||||
"DeformPercent"
|
||||
};
|
||||
|
||||
std::map<std::string, morphAnimData*> morphAnimDatas;
|
||||
|
||||
for (const AnimationLayer* layer : layers) {
|
||||
ai_assert(layer);
|
||||
|
||||
const AnimationCurveNodeList& nodes = layer->Nodes( prop_whitelist, 3 );
|
||||
const AnimationCurveNodeList& nodes = layer->Nodes(prop_whitelist, 4);
|
||||
for (const AnimationCurveNode* node : nodes) {
|
||||
ai_assert(node);
|
||||
|
||||
const Model* const model = dynamic_cast<const Model*>(node->Target());
|
||||
// this can happen - it could also be a NodeAttribute (i.e. for camera animations)
|
||||
if ( !model ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (model) {
|
||||
const std::string& name = FixNodeName(model->Name());
|
||||
node_map[name].push_back(node);
|
||||
|
||||
layer_map[node] = layer;
|
||||
continue;
|
||||
}
|
||||
const BlendShapeChannel* const bsc = dynamic_cast<const BlendShapeChannel*>(node->Target());
|
||||
if (bsc) {
|
||||
ProcessMorphAnimDatas(&morphAnimDatas, bsc, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2126,12 +2438,42 @@ void FBXConverter::ConvertAnimationStack( const AnimationStack& st )
|
|||
throw;
|
||||
}
|
||||
|
||||
if (node_anims.size() || morphAnimDatas.size()) {
|
||||
if (node_anims.size()) {
|
||||
anim->mChannels = new aiNodeAnim*[node_anims.size()]();
|
||||
anim->mNumChannels = static_cast<unsigned int>(node_anims.size());
|
||||
|
||||
std::swap_ranges(node_anims.begin(), node_anims.end(), anim->mChannels);
|
||||
}
|
||||
if (morphAnimDatas.size()) {
|
||||
unsigned int numMorphMeshChannels = static_cast<unsigned int>(morphAnimDatas.size());
|
||||
anim->mMorphMeshChannels = new aiMeshMorphAnim*[numMorphMeshChannels];
|
||||
anim->mNumMorphMeshChannels = numMorphMeshChannels;
|
||||
unsigned int i = 0;
|
||||
for (auto morphAnimIt : morphAnimDatas) {
|
||||
morphAnimData* animData = morphAnimIt.second;
|
||||
unsigned int numKeys = static_cast<unsigned int>(animData->size());
|
||||
aiMeshMorphAnim* meshMorphAnim = new aiMeshMorphAnim();
|
||||
meshMorphAnim->mName.Set(morphAnimIt.first);
|
||||
meshMorphAnim->mNumKeys = numKeys;
|
||||
meshMorphAnim->mKeys = new aiMeshMorphKey[numKeys];
|
||||
unsigned int j = 0;
|
||||
for (auto animIt : *animData) {
|
||||
morphKeyData* keyData = animIt.second;
|
||||
unsigned int numValuesAndWeights = static_cast<unsigned int>(keyData->values.size());
|
||||
meshMorphAnim->mKeys[j].mNumValuesAndWeights = numValuesAndWeights;
|
||||
meshMorphAnim->mKeys[j].mValues = new unsigned int[numValuesAndWeights];
|
||||
meshMorphAnim->mKeys[j].mWeights = new double[numValuesAndWeights];
|
||||
meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first) * anim_fps;
|
||||
for (unsigned int k = 0; k < numValuesAndWeights; k++) {
|
||||
meshMorphAnim->mKeys[j].mValues[k] = keyData->values.at(k);
|
||||
meshMorphAnim->mKeys[j].mWeights[k] = keyData->weights.at(k);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
anim->mMorphMeshChannels[i++] = meshMorphAnim;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// empty animations would fail validation, so drop them
|
||||
delete anim;
|
||||
|
@ -2146,13 +2488,22 @@ void FBXConverter::ConvertAnimationStack( const AnimationStack& st )
|
|||
// adjust relative timing for animation
|
||||
for (unsigned int c = 0; c < anim->mNumChannels; c++) {
|
||||
aiNodeAnim* channel = anim->mChannels[c];
|
||||
for ( uint32_t i = 0; i < channel->mNumPositionKeys; i++ )
|
||||
for (uint32_t i = 0; i < channel->mNumPositionKeys; i++) {
|
||||
channel->mPositionKeys[i].mTime -= start_time_fps;
|
||||
for ( uint32_t i = 0; i < channel->mNumRotationKeys; i++ )
|
||||
}
|
||||
for (uint32_t i = 0; i < channel->mNumRotationKeys; i++) {
|
||||
channel->mRotationKeys[i].mTime -= start_time_fps;
|
||||
for ( uint32_t i = 0; i < channel->mNumScalingKeys; i++ )
|
||||
}
|
||||
for (uint32_t i = 0; i < channel->mNumScalingKeys; i++) {
|
||||
channel->mScalingKeys[i].mTime -= start_time_fps;
|
||||
}
|
||||
}
|
||||
for (unsigned int c = 0; c < anim->mNumMorphMeshChannels; c++) {
|
||||
aiMeshMorphAnim* channel = anim->mMorphMeshChannels[c];
|
||||
for (uint32_t i = 0; i < channel->mNumKeys; i++) {
|
||||
channel->mKeys[i].mTime -= start_time_fps;
|
||||
}
|
||||
}
|
||||
|
||||
// for some mysterious reason, mDuration is simply the maximum key -- the
|
||||
// validator always assumes animations to start at zero.
|
||||
|
@ -2160,6 +2511,68 @@ void FBXConverter::ConvertAnimationStack( const AnimationStack& st )
|
|||
anim->mTicksPerSecond = anim_fps;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void FBXConverter::ProcessMorphAnimDatas(std::map<std::string, morphAnimData*>* morphAnimDatas, const BlendShapeChannel* bsc, const AnimationCurveNode* node) {
|
||||
std::vector<const Connection*> bscConnections = doc.GetConnectionsBySourceSequenced(bsc->ID(), "Deformer");
|
||||
for (const Connection* bscConnection : bscConnections) {
|
||||
auto bs = dynamic_cast<const BlendShape*>(bscConnection->DestinationObject());
|
||||
if (bs) {
|
||||
auto channelIt = std::find(bs->BlendShapeChannels().begin(), bs->BlendShapeChannels().end(), bsc);
|
||||
if (channelIt != bs->BlendShapeChannels().end()) {
|
||||
auto channelIndex = static_cast<unsigned int>(std::distance(bs->BlendShapeChannels().begin(), channelIt));
|
||||
std::vector<const Connection*> bsConnections = doc.GetConnectionsBySourceSequenced(bs->ID(), "Geometry");
|
||||
for (const Connection* bsConnection : bsConnections) {
|
||||
auto geo = dynamic_cast<const Geometry*>(bsConnection->DestinationObject());
|
||||
if (geo) {
|
||||
std::vector<const Connection*> geoConnections = doc.GetConnectionsBySourceSequenced(geo->ID(), "Model");
|
||||
for (const Connection* geoConnection : geoConnections) {
|
||||
auto model = dynamic_cast<const Model*>(geoConnection->DestinationObject());
|
||||
if (model) {
|
||||
auto geoIt = std::find(model->GetGeometry().begin(), model->GetGeometry().end(), geo);
|
||||
auto geoIndex = static_cast<unsigned int>(std::distance(model->GetGeometry().begin(), geoIt));
|
||||
auto name = aiString(FixNodeName(model->Name() + "*"));
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + name.length, MAXLEN - 1, geoIndex);
|
||||
morphAnimData* animData;
|
||||
auto animIt = morphAnimDatas->find(name.C_Str());
|
||||
if (animIt == morphAnimDatas->end()) {
|
||||
animData = new morphAnimData();
|
||||
morphAnimDatas->insert(std::make_pair(name.C_Str(), animData));
|
||||
}
|
||||
else {
|
||||
animData = animIt->second;
|
||||
}
|
||||
for (std::pair<std::string, const AnimationCurve*> curvesIt : node->Curves()) {
|
||||
if (curvesIt.first == "d|DeformPercent") {
|
||||
const AnimationCurve* animationCurve = curvesIt.second;
|
||||
const KeyTimeList& keys = animationCurve->GetKeys();
|
||||
const KeyValueList& values = animationCurve->GetValues();
|
||||
unsigned int k = 0;
|
||||
for (auto key : keys) {
|
||||
morphKeyData* keyData;
|
||||
auto keyIt = animData->find(key);
|
||||
if (keyIt == animData->end()) {
|
||||
keyData = new morphKeyData();
|
||||
animData->insert(std::make_pair(key, keyData));
|
||||
}
|
||||
else {
|
||||
keyData = keyIt->second;
|
||||
}
|
||||
keyData->values.push_back(channelIndex);
|
||||
keyData->weights.push_back(values.at(k) / 100.0f);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#ifdef ASSIMP_BUILD_DEBUG
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// sanity check whether the input is ok
|
||||
|
@ -2415,6 +2828,7 @@ void FBXConverter::GenerateNodeAnimations( std::vector<aiNodeAnim*>& node_anims,
|
|||
node_anim_chain_bits[fixed_name] = flags;
|
||||
}
|
||||
|
||||
|
||||
bool FBXConverter::IsRedundantAnimationData(const Model& target,
|
||||
TransformationComp comp,
|
||||
const std::vector<const AnimationCurveNode*>& curves) {
|
||||
|
@ -3019,10 +3433,22 @@ void FBXConverter::ConvertGlobalSettings() {
|
|||
return;
|
||||
}
|
||||
|
||||
out->mMetaData = aiMetadata::Alloc(1);
|
||||
unsigned int index(0);
|
||||
const double unitScalFactor(doc.GlobalSettings().UnitScaleFactor());
|
||||
out->mMetaData->Set(index, "UnitScaleFactor", unitScalFactor);
|
||||
out->mMetaData = aiMetadata::Alloc(15);
|
||||
out->mMetaData->Set(0, "UpAxis", doc.GlobalSettings().UpAxis());
|
||||
out->mMetaData->Set(1, "UpAxisSign", doc.GlobalSettings().UpAxisSign());
|
||||
out->mMetaData->Set(2, "FrontAxis", doc.GlobalSettings().FrontAxis());
|
||||
out->mMetaData->Set(3, "FrontAxisSign", doc.GlobalSettings().FrontAxisSign());
|
||||
out->mMetaData->Set(4, "CoordAxis", doc.GlobalSettings().CoordAxis());
|
||||
out->mMetaData->Set(5, "CoordAxisSign", doc.GlobalSettings().CoordAxisSign());
|
||||
out->mMetaData->Set(6, "OriginalUpAxis", doc.GlobalSettings().OriginalUpAxis());
|
||||
out->mMetaData->Set(7, "OriginalUpAxisSign", doc.GlobalSettings().OriginalUpAxisSign());
|
||||
out->mMetaData->Set(8, "UnitScaleFactor", (double)doc.GlobalSettings().UnitScaleFactor());
|
||||
out->mMetaData->Set(9, "OriginalUnitScaleFactor", doc.GlobalSettings().OriginalUnitScaleFactor());
|
||||
out->mMetaData->Set(10, "AmbientColor", doc.GlobalSettings().AmbientColor());
|
||||
out->mMetaData->Set(11, "FrameRate", (int)doc.GlobalSettings().TimeMode());
|
||||
out->mMetaData->Set(12, "TimeSpanStart", doc.GlobalSettings().TimeSpanStart());
|
||||
out->mMetaData->Set(13, "TimeSpanStop", doc.GlobalSettings().TimeSpanStop());
|
||||
out->mMetaData->Set(14, "CustomFrameRate", doc.GlobalSettings().CustomFrameRate());
|
||||
}
|
||||
|
||||
void FBXConverter::TransferDataToScene()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -63,6 +63,12 @@ struct aiScene;
|
|||
struct aiNode;
|
||||
struct aiMaterial;
|
||||
|
||||
struct morphKeyData {
|
||||
std::vector<unsigned int> values;
|
||||
std::vector<float> weights;
|
||||
};
|
||||
typedef std::map<int64_t, morphKeyData*> morphAnimData;
|
||||
|
||||
namespace Assimp {
|
||||
namespace FBX {
|
||||
|
||||
|
@ -175,7 +181,11 @@ private:
|
|||
const aiMatrix4x4& node_global_transform, aiNode& nd);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
aiMesh* SetupEmptyMesh(const MeshGeometry& mesh, aiNode& nd);
|
||||
std::vector<unsigned int> ConvertLine(const LineGeometry& line, const Model& model,
|
||||
const aiMatrix4x4& node_global_transform, aiNode& nd);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
aiMesh* SetupEmptyMesh(const Geometry& mesh, aiNode& nd);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
unsigned int ConvertMeshSingleMaterial(const MeshGeometry& mesh, const Model& model,
|
||||
|
@ -258,6 +268,7 @@ private:
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SetShadingPropertiesCommon(aiMaterial* out_mat, const PropertyTable& props);
|
||||
void SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTable& props, const TextureMap& textures, const MeshGeometry* const mesh);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// get the number of fps for a FrameRate enumerated value
|
||||
|
@ -272,6 +283,7 @@ private:
|
|||
// the function is guaranteed to provide consistent results over multiple invocations
|
||||
// UNLESS RenameNode() is called for a particular node name.
|
||||
std::string FixNodeName(const std::string& name);
|
||||
std::string FixAnimMeshName(const std::string& name);
|
||||
|
||||
typedef std::map<const AnimationCurveNode*, const AnimationLayer*> LayerMap;
|
||||
|
||||
|
@ -281,6 +293,9 @@ private:
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
void ConvertAnimationStack(const AnimationStack& st);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ProcessMorphAnimDatas(std::map<std::string, morphAnimData*>* morphAnimDatas, const BlendShapeChannel* bsc, const AnimationCurveNode* node);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void GenerateNodeAnimations(std::vector<aiNodeAnim*>& node_anims,
|
||||
const std::string& fixed_name,
|
||||
|
@ -415,6 +430,7 @@ private:
|
|||
std::vector<aiCamera*> cameras;
|
||||
std::vector<aiTexture*> textures;
|
||||
|
||||
|
||||
typedef std::map<const Material*, unsigned int> MaterialMap;
|
||||
MaterialMap materials_converted;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "FBXParser.h"
|
||||
#include "FBXDocument.h"
|
||||
#include "FBXMeshGeometry.h"
|
||||
#include "FBXImporter.h"
|
||||
#include "FBXDocumentUtil.h"
|
||||
|
||||
|
@ -158,9 +159,55 @@ Skin::~Skin()
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BlendShape::BlendShape(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Deformer(id, element, doc, name)
|
||||
{
|
||||
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(), "Deformer");
|
||||
blendShapeChannels.reserve(conns.size());
|
||||
for (const Connection* con : conns) {
|
||||
const BlendShapeChannel* const bspc = ProcessSimpleConnection<BlendShapeChannel>(*con, false, "BlendShapeChannel -> BlendShape", element);
|
||||
if (bspc) {
|
||||
blendShapeChannels.push_back(bspc);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BlendShape::~BlendShape()
|
||||
{
|
||||
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BlendShapeChannel::BlendShapeChannel(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Deformer(id, element, doc, name)
|
||||
{
|
||||
const Scope& sc = GetRequiredScope(element);
|
||||
const Element* const DeformPercent = sc["DeformPercent"];
|
||||
if (DeformPercent) {
|
||||
percent = ParseTokenAsFloat(GetRequiredToken(*DeformPercent, 0));
|
||||
}
|
||||
const Element* const FullWeights = sc["FullWeights"];
|
||||
if (FullWeights) {
|
||||
ParseVectorDataArray(fullWeights, *FullWeights);
|
||||
}
|
||||
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(), "Geometry");
|
||||
shapeGeometries.reserve(conns.size());
|
||||
for (const Connection* con : conns) {
|
||||
const ShapeGeometry* const sg = ProcessSimpleConnection<ShapeGeometry>(*con, false, "Shape -> BlendShapeChannel", element);
|
||||
if (sg) {
|
||||
shapeGeometries.push_back(sg);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BlendShapeChannel::~BlendShapeChannel()
|
||||
{
|
||||
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue