pull/1811/head
commit
affedc139e
|
@ -1,6 +1,7 @@
|
||||||
# Open Asset Import Library (assimp)
|
# Open Asset Import Library (assimp)
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Copyright (c) 2006-2017, assimp team
|
# Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use of this software in source and binary forms,
|
# Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -213,7 +214,9 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
||||||
ELSEIF(MSVC)
|
ELSEIF(MSVC)
|
||||||
# enable multi-core compilation with MSVC
|
# enable multi-core compilation with MSVC
|
||||||
add_compile_options(/MP)
|
add_compile_options(/MP)
|
||||||
|
if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
|
||||||
|
add_compile_options( /bigobj )
|
||||||
|
endif()
|
||||||
# disable "elements of array '' will be default initialized" warning on MSVC2013
|
# disable "elements of array '' will be default initialized" warning on MSVC2013
|
||||||
IF(MSVC12)
|
IF(MSVC12)
|
||||||
add_compile_options(/wd4351)
|
add_compile_options(/wd4351)
|
||||||
|
|
|
@ -120,7 +120,7 @@ Take a look into the `INSTALL` file. Our build system is CMake, if you used CMak
|
||||||
* [Pascal](port/AssimpPascal/Readme.md)
|
* [Pascal](port/AssimpPascal/Readme.md)
|
||||||
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
|
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
|
||||||
* [Unity 3d Plugin](https://www.assetstore.unity3d.com/en/#!/content/91777)
|
* [Unity 3d Plugin](https://www.assetstore.unity3d.com/en/#!/content/91777)
|
||||||
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (currently supported obj, ply, stl, collada, md2)
|
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status))
|
||||||
|
|
||||||
### Other tools ###
|
### Other tools ###
|
||||||
[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.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -127,9 +128,8 @@ void Discreet3DSImporter::ReplaceDefaultMaterial()
|
||||||
if (cnt && idx == mScene->mMaterials.size())
|
if (cnt && idx == mScene->mMaterials.size())
|
||||||
{
|
{
|
||||||
// We need to create our own default material
|
// We need to create our own default material
|
||||||
D3DS::Material sMat;
|
D3DS::Material sMat("%%%DEFAULT");
|
||||||
sMat.mDiffuse = aiColor3D(0.3f,0.3f,0.3f);
|
sMat.mDiffuse = aiColor3D(0.3f,0.3f,0.3f);
|
||||||
sMat.mName = "%%%DEFAULT";
|
|
||||||
mScene->mMaterials.push_back(sMat);
|
mScene->mMaterials.push_back(sMat);
|
||||||
|
|
||||||
DefaultLogger::get()->info("3DS: Generating default material");
|
DefaultLogger::get()->info("3DS: Generating default material");
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
119
code/3DSHelper.h
119
code/3DSHelper.h
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -370,9 +371,14 @@ struct Texture
|
||||||
/** Helper structure representing a 3ds material */
|
/** Helper structure representing a 3ds material */
|
||||||
struct Material
|
struct Material
|
||||||
{
|
{
|
||||||
//! Default constructor. Builds a default name for the material
|
//! Default constructor has been deleted
|
||||||
Material()
|
Material() = delete;
|
||||||
: mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black
|
|
||||||
|
|
||||||
|
//! Constructor with explicit name
|
||||||
|
explicit Material(const std::string &name)
|
||||||
|
: mName(name)
|
||||||
|
, mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black
|
||||||
, mSpecularExponent ( ai_real( 0.0 ) )
|
, mSpecularExponent ( ai_real( 0.0 ) )
|
||||||
, mShininessStrength ( ai_real( 1.0 ) )
|
, mShininessStrength ( ai_real( 1.0 ) )
|
||||||
, mShading(Discreet3DS::Gouraud)
|
, mShading(Discreet3DS::Gouraud)
|
||||||
|
@ -380,13 +386,70 @@ struct Material
|
||||||
, mBumpHeight ( ai_real( 1.0 ) )
|
, mBumpHeight ( ai_real( 1.0 ) )
|
||||||
, mTwoSided (false)
|
, mTwoSided (false)
|
||||||
{
|
{
|
||||||
static int iCnt = 0;
|
|
||||||
|
|
||||||
char szTemp[128];
|
|
||||||
ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
|
||||||
mName = szTemp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Material(const Material &other) = default;
|
||||||
|
Material &operator=(const Material &other) = default;
|
||||||
|
|
||||||
|
|
||||||
|
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||||
|
Material(Material &&other)
|
||||||
|
: mName(std::move(other.mName))
|
||||||
|
, mDiffuse(std::move(other.mDiffuse))
|
||||||
|
, mSpecularExponent(std::move(other.mSpecularExponent))
|
||||||
|
, mShininessStrength(std::move(other.mShininessStrength))
|
||||||
|
, mSpecular(std::move(other.mSpecular))
|
||||||
|
, mAmbient(std::move(other.mAmbient))
|
||||||
|
, mShading(std::move(other.mShading))
|
||||||
|
, mTransparency(std::move(other.mTransparency))
|
||||||
|
, sTexDiffuse(std::move(other.sTexDiffuse))
|
||||||
|
, sTexOpacity(std::move(other.sTexOpacity))
|
||||||
|
, sTexSpecular(std::move(other.sTexSpecular))
|
||||||
|
, sTexReflective(std::move(other.sTexReflective))
|
||||||
|
, sTexBump(std::move(other.sTexBump))
|
||||||
|
, sTexEmissive(std::move(other.sTexEmissive))
|
||||||
|
, sTexShininess(std::move(other.sTexShininess))
|
||||||
|
, mBumpHeight(std::move(other.mBumpHeight))
|
||||||
|
, mEmissive(std::move(other.mEmissive))
|
||||||
|
, sTexAmbient(std::move(other.sTexAmbient))
|
||||||
|
, mTwoSided(std::move(other.mTwoSided))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Material &operator=(Material &&other) {
|
||||||
|
if (this == &other) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
mName = std::move(other.mName);
|
||||||
|
mDiffuse = std::move(other.mDiffuse);
|
||||||
|
mSpecularExponent = std::move(other.mSpecularExponent);
|
||||||
|
mShininessStrength = std::move(other.mShininessStrength),
|
||||||
|
mSpecular = std::move(other.mSpecular);
|
||||||
|
mAmbient = std::move(other.mAmbient);
|
||||||
|
mShading = std::move(other.mShading);
|
||||||
|
mTransparency = std::move(other.mTransparency);
|
||||||
|
sTexDiffuse = std::move(other.sTexDiffuse);
|
||||||
|
sTexOpacity = std::move(other.sTexOpacity);
|
||||||
|
sTexSpecular = std::move(other.sTexSpecular);
|
||||||
|
sTexReflective = std::move(other.sTexReflective);
|
||||||
|
sTexBump = std::move(other.sTexBump);
|
||||||
|
sTexEmissive = std::move(other.sTexEmissive);
|
||||||
|
sTexShininess = std::move(other.sTexShininess);
|
||||||
|
mBumpHeight = std::move(other.mBumpHeight);
|
||||||
|
mEmissive = std::move(other.mEmissive);
|
||||||
|
sTexAmbient = std::move(other.sTexAmbient);
|
||||||
|
mTwoSided = std::move(other.mTwoSided);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
~Material() {}
|
||||||
|
|
||||||
|
|
||||||
//! Name of the material
|
//! Name of the material
|
||||||
std::string mName;
|
std::string mName;
|
||||||
//! Diffuse color of the material
|
//! Diffuse color of the material
|
||||||
|
@ -432,17 +495,16 @@ struct Material
|
||||||
/** Helper structure to represent a 3ds file mesh */
|
/** Helper structure to represent a 3ds file mesh */
|
||||||
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
|
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
|
||||||
{
|
{
|
||||||
//! Default constructor
|
//! Default constructor has been deleted
|
||||||
Mesh()
|
Mesh() = delete;
|
||||||
{
|
|
||||||
static int iCnt = 0;
|
|
||||||
|
|
||||||
// Generate a default name for the mesh
|
//! Constructor with explicit name
|
||||||
char szTemp[128];
|
explicit Mesh(const std::string &name)
|
||||||
ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
: mName(name)
|
||||||
mName = szTemp;
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Name of the mesh
|
//! Name of the mesh
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
|
@ -488,25 +550,22 @@ struct aiFloatKey
|
||||||
/** Helper structure to represent a 3ds file node */
|
/** Helper structure to represent a 3ds file node */
|
||||||
struct Node
|
struct Node
|
||||||
{
|
{
|
||||||
Node():
|
Node() = delete;
|
||||||
mParent(NULL)
|
|
||||||
, mInstanceNumber(0)
|
explicit Node(const std::string &name)
|
||||||
, mHierarchyPos (0)
|
: mParent(NULL)
|
||||||
, mHierarchyIndex (0)
|
, mName(name)
|
||||||
, mInstanceCount (1)
|
, mInstanceNumber(0)
|
||||||
|
, mHierarchyPos (0)
|
||||||
|
, mHierarchyIndex (0)
|
||||||
|
, mInstanceCount (1)
|
||||||
{
|
{
|
||||||
static int iCnt = 0;
|
|
||||||
|
|
||||||
// Generate a default name for the node
|
|
||||||
char szTemp[128];
|
|
||||||
::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
|
||||||
mName = szTemp;
|
|
||||||
|
|
||||||
aRotationKeys.reserve (20);
|
aRotationKeys.reserve (20);
|
||||||
aPositionKeys.reserve (20);
|
aPositionKeys.reserve (20);
|
||||||
aScalingKeys.reserve (20);
|
aScalingKeys.reserve (20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
~Node()
|
~Node()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < mChildren.size();++i)
|
for (unsigned int i = 0; i < mChildren.size();++i)
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -105,29 +106,31 @@ static const aiImporterDesc desc = {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
Discreet3DSImporter::Discreet3DSImporter()
|
Discreet3DSImporter::Discreet3DSImporter()
|
||||||
: stream(),
|
: stream()
|
||||||
mLastNodeIndex(),
|
, mLastNodeIndex()
|
||||||
mCurrentNode(),
|
, mCurrentNode()
|
||||||
mRootNode(),
|
, mRootNode()
|
||||||
mScene(),
|
, mScene()
|
||||||
mMasterScale(),
|
, mMasterScale()
|
||||||
bHasBG(),
|
, bHasBG()
|
||||||
bIsPrj()
|
, bIsPrj() {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
Discreet3DSImporter::~Discreet3DSImporter()
|
Discreet3DSImporter::~Discreet3DSImporter() {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||||
{
|
|
||||||
std::string extension = GetExtension(pFile);
|
std::string extension = GetExtension(pFile);
|
||||||
if(extension == "3ds" || extension == "prj" ) {
|
if(extension == "3ds" || extension == "prj" ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extension.length() || checkSig) {
|
if (!extension.length() || checkSig) {
|
||||||
uint16_t token[3];
|
uint16_t token[3];
|
||||||
token[0] = 0x4d4d;
|
token[0] = 0x4d4d;
|
||||||
|
@ -170,7 +173,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// Initialize members
|
// Initialize members
|
||||||
mLastNodeIndex = -1;
|
mLastNodeIndex = -1;
|
||||||
mCurrentNode = new D3DS::Node();
|
mCurrentNode = new D3DS::Node("UNNAMED");
|
||||||
mRootNode = mCurrentNode;
|
mRootNode = mCurrentNode;
|
||||||
mRootNode->mHierarchyPos = -1;
|
mRootNode->mHierarchyPos = -1;
|
||||||
mRootNode->mHierarchyIndex = -1;
|
mRootNode->mHierarchyIndex = -1;
|
||||||
|
@ -209,7 +212,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
ConvertScene(pScene);
|
ConvertScene(pScene);
|
||||||
|
|
||||||
// Generate the node graph for the scene. This is a little bit
|
// Generate the node graph for the scene. This is a little bit
|
||||||
// tricky since we'll need to split some meshes into submeshes
|
// tricky since we'll need to split some meshes into sub-meshes
|
||||||
GenerateNodeGraph(pScene);
|
GenerateNodeGraph(pScene);
|
||||||
|
|
||||||
// Now apply the master scaling factor to the scene
|
// Now apply the master scaling factor to the scene
|
||||||
|
@ -346,7 +349,7 @@ void Discreet3DSImporter::ParseObjectChunk()
|
||||||
case Discreet3DS::CHUNK_MAT_MATERIAL:
|
case Discreet3DS::CHUNK_MAT_MATERIAL:
|
||||||
|
|
||||||
// Add a new material to the list
|
// Add a new material to the list
|
||||||
mScene->mMaterials.push_back(D3DS::Material());
|
mScene->mMaterials.push_back(D3DS::Material(std::string("UNNAMED_" + std::to_string(mScene->mMaterials.size()))));
|
||||||
ParseMaterialChunk();
|
ParseMaterialChunk();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -402,11 +405,7 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num)
|
||||||
case Discreet3DS::CHUNK_TRIMESH:
|
case Discreet3DS::CHUNK_TRIMESH:
|
||||||
{
|
{
|
||||||
// this starts a new triangle mesh
|
// this starts a new triangle mesh
|
||||||
mScene->mMeshes.push_back(D3DS::Mesh());
|
mScene->mMeshes.push_back(D3DS::Mesh(std::string(name, num)));
|
||||||
D3DS::Mesh& m = mScene->mMeshes.back();
|
|
||||||
|
|
||||||
// Setup the name of the mesh
|
|
||||||
m.mName = std::string(name, num);
|
|
||||||
|
|
||||||
// Read mesh chunks
|
// Read mesh chunks
|
||||||
ParseMeshChunk();
|
ParseMeshChunk();
|
||||||
|
@ -690,8 +689,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
|
||||||
pcNode->mInstanceCount++;
|
pcNode->mInstanceCount++;
|
||||||
instanceNumber = pcNode->mInstanceCount;
|
instanceNumber = pcNode->mInstanceCount;
|
||||||
}
|
}
|
||||||
pcNode = new D3DS::Node();
|
pcNode = new D3DS::Node(name);
|
||||||
pcNode->mName = name;
|
|
||||||
pcNode->mInstanceNumber = instanceNumber;
|
pcNode->mInstanceNumber = instanceNumber;
|
||||||
|
|
||||||
// There are two unknown values which we can safely ignore
|
// There are two unknown values which we can safely ignore
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -83,11 +84,11 @@ static const aiImporterDesc desc = {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
ASEImporter::ASEImporter()
|
ASEImporter::ASEImporter()
|
||||||
: mParser(),
|
: mParser()
|
||||||
mBuffer(),
|
, mBuffer()
|
||||||
pcScene(),
|
, pcScene()
|
||||||
configRecomputeNormals(),
|
, configRecomputeNormals()
|
||||||
noSkeletonMesh()
|
, noSkeletonMesh()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -276,14 +277,13 @@ void ASEImporter::GenerateDefaultMaterial()
|
||||||
}
|
}
|
||||||
if (bHas || mParser->m_vMaterials.empty()) {
|
if (bHas || mParser->m_vMaterials.empty()) {
|
||||||
// add a simple material without submaterials to the parser's list
|
// add a simple material without submaterials to the parser's list
|
||||||
mParser->m_vMaterials.push_back ( ASE::Material() );
|
mParser->m_vMaterials.push_back ( ASE::Material(AI_DEFAULT_MATERIAL_NAME) );
|
||||||
ASE::Material& mat = mParser->m_vMaterials.back();
|
ASE::Material& mat = mParser->m_vMaterials.back();
|
||||||
|
|
||||||
mat.mDiffuse = aiColor3D(0.6f,0.6f,0.6f);
|
mat.mDiffuse = aiColor3D(0.6f,0.6f,0.6f);
|
||||||
mat.mSpecular = aiColor3D(1.0f,1.0f,1.0f);
|
mat.mSpecular = aiColor3D(1.0f,1.0f,1.0f);
|
||||||
mat.mAmbient = aiColor3D(0.05f,0.05f,0.05f);
|
mat.mAmbient = aiColor3D(0.05f,0.05f,0.05f);
|
||||||
mat.mShading = Discreet3DS::Gouraud;
|
mat.mShading = Discreet3DS::Gouraud;
|
||||||
mat.mName = AI_DEFAULT_MATERIAL_NAME;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ void ASEImporter::AddNodes (const std::vector<BaseNode*>& nodes,
|
||||||
node->mTransformation = mParentAdjust*snode->mTransform;
|
node->mTransformation = mParentAdjust*snode->mTransform;
|
||||||
|
|
||||||
// Add sub nodes - prevent stack overflow due to recursive parenting
|
// Add sub nodes - prevent stack overflow due to recursive parenting
|
||||||
if (node->mName != node->mParent->mName) {
|
if (node->mName != node->mParent->mName && node->mName != node->mParent->mParent->mName ) {
|
||||||
AddNodes(nodes,node,node->mName.data,snode->mTransform);
|
AddNodes(nodes,node,node->mName.data,snode->mTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -292,7 +293,7 @@ void Parser::Parse()
|
||||||
if (TokenMatch(filePtr,"GEOMOBJECT",10))
|
if (TokenMatch(filePtr,"GEOMOBJECT",10))
|
||||||
|
|
||||||
{
|
{
|
||||||
m_vMeshes.push_back(Mesh());
|
m_vMeshes.push_back(Mesh("UNNAMED"));
|
||||||
ParseLV1ObjectBlock(m_vMeshes.back());
|
ParseLV1ObjectBlock(m_vMeshes.back());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -308,14 +309,14 @@ void Parser::Parse()
|
||||||
if (TokenMatch(filePtr,"LIGHTOBJECT",11))
|
if (TokenMatch(filePtr,"LIGHTOBJECT",11))
|
||||||
|
|
||||||
{
|
{
|
||||||
m_vLights.push_back(Light());
|
m_vLights.push_back(Light("UNNAMED"));
|
||||||
ParseLV1ObjectBlock(m_vLights.back());
|
ParseLV1ObjectBlock(m_vLights.back());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// camera object
|
// camera object
|
||||||
if (TokenMatch(filePtr,"CAMERAOBJECT",12))
|
if (TokenMatch(filePtr,"CAMERAOBJECT",12))
|
||||||
{
|
{
|
||||||
m_vCameras.push_back(Camera());
|
m_vCameras.push_back(Camera("UNNAMED"));
|
||||||
ParseLV1ObjectBlock(m_vCameras.back());
|
ParseLV1ObjectBlock(m_vCameras.back());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +529,7 @@ void Parser::ParseLV1MaterialListBlock()
|
||||||
ParseLV4MeshLong(iMaterialCount);
|
ParseLV4MeshLong(iMaterialCount);
|
||||||
|
|
||||||
// now allocate enough storage to hold all materials
|
// now allocate enough storage to hold all materials
|
||||||
m_vMaterials.resize(iOldMaterialCount+iMaterialCount);
|
m_vMaterials.resize(iOldMaterialCount+iMaterialCount, Material("INVALID"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (TokenMatch(filePtr,"MATERIAL",8))
|
if (TokenMatch(filePtr,"MATERIAL",8))
|
||||||
|
@ -706,7 +707,7 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
|
||||||
ParseLV4MeshLong(iNumSubMaterials);
|
ParseLV4MeshLong(iNumSubMaterials);
|
||||||
|
|
||||||
// allocate enough storage
|
// allocate enough storage
|
||||||
mat.avSubMaterials.resize(iNumSubMaterials);
|
mat.avSubMaterials.resize(iNumSubMaterials, Material("INVALID SUBMATERIAL"));
|
||||||
}
|
}
|
||||||
// submaterial chunks
|
// submaterial chunks
|
||||||
if (TokenMatch(filePtr,"SUBMATERIAL",11))
|
if (TokenMatch(filePtr,"SUBMATERIAL",11))
|
||||||
|
@ -1553,7 +1554,7 @@ void Parser::ParseLV3MeshWeightsBlock(ASE::Mesh& mesh)
|
||||||
void Parser::ParseLV4MeshBones(unsigned int iNumBones,ASE::Mesh& mesh)
|
void Parser::ParseLV4MeshBones(unsigned int iNumBones,ASE::Mesh& mesh)
|
||||||
{
|
{
|
||||||
AI_ASE_PARSER_INIT();
|
AI_ASE_PARSER_INIT();
|
||||||
mesh.mBones.resize(iNumBones);
|
mesh.mBones.resize(iNumBones, Bone("UNNAMED"));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ('*' == *filePtr)
|
if ('*' == *filePtr)
|
||||||
|
|
135
code/ASEParser.h
135
code/ASEParser.h
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -67,10 +68,53 @@ using namespace D3DS;
|
||||||
/** Helper structure representing an ASE material */
|
/** Helper structure representing an ASE material */
|
||||||
struct Material : public D3DS::Material
|
struct Material : public D3DS::Material
|
||||||
{
|
{
|
||||||
//! Default constructor
|
//! Default constructor has been deleted
|
||||||
Material() : pcInstance(NULL), bNeed (false)
|
Material() = delete;
|
||||||
|
|
||||||
|
|
||||||
|
//! Constructor with explicit name
|
||||||
|
explicit Material(const std::string &name)
|
||||||
|
: D3DS::Material(name)
|
||||||
|
, pcInstance(NULL)
|
||||||
|
, bNeed (false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Material(const Material &other) = default;
|
||||||
|
Material &operator=(const Material &other) = default;
|
||||||
|
|
||||||
|
|
||||||
|
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||||
|
Material(Material &&other)
|
||||||
|
: D3DS::Material(std::move(other))
|
||||||
|
, avSubMaterials(std::move(other.avSubMaterials))
|
||||||
|
, pcInstance(std::move(other.pcInstance))
|
||||||
|
, bNeed(std::move(other.bNeed))
|
||||||
|
{
|
||||||
|
other.pcInstance = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Material &operator=(Material &&other) {
|
||||||
|
if (this == &other) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
D3DS::Material::operator=(std::move(other));
|
||||||
|
|
||||||
|
avSubMaterials = std::move(other.avSubMaterials);
|
||||||
|
pcInstance = std::move(other.pcInstance);
|
||||||
|
bNeed = std::move(other.bNeed);
|
||||||
|
|
||||||
|
other.pcInstance = nullptr;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
~Material() {}
|
||||||
|
|
||||||
|
|
||||||
//! Contains all sub materials of this material
|
//! Contains all sub materials of this material
|
||||||
std::vector<Material> avSubMaterials;
|
std::vector<Material> avSubMaterials;
|
||||||
|
|
||||||
|
@ -125,15 +169,7 @@ struct Face : public FaceWithSmoothingGroup
|
||||||
struct Bone
|
struct Bone
|
||||||
{
|
{
|
||||||
//! Constructor
|
//! Constructor
|
||||||
Bone()
|
Bone() = delete;
|
||||||
{
|
|
||||||
static int iCnt = 0;
|
|
||||||
|
|
||||||
// Generate a default name for the bone
|
|
||||||
char szTemp[128];
|
|
||||||
::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
|
||||||
mName = szTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Construction from an existing name
|
//! Construction from an existing name
|
||||||
explicit Bone( const std::string& name)
|
explicit Bone( const std::string& name)
|
||||||
|
@ -213,22 +249,19 @@ struct BaseNode
|
||||||
{
|
{
|
||||||
enum Type {Light, Camera, Mesh, Dummy} mType;
|
enum Type {Light, Camera, Mesh, Dummy} mType;
|
||||||
|
|
||||||
//! Constructor. Creates a default name for the node
|
|
||||||
explicit BaseNode(Type _mType)
|
|
||||||
: mType (_mType)
|
|
||||||
, mProcessed (false)
|
|
||||||
{
|
|
||||||
// generate a default name for the node
|
|
||||||
static int iCnt = 0;
|
|
||||||
char szTemp[128]; // should be sufficiently large
|
|
||||||
::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
|
||||||
mName = szTemp;
|
|
||||||
|
|
||||||
|
//! Construction from an existing name
|
||||||
|
BaseNode(Type _mType, const std::string &name)
|
||||||
|
: mType (_mType)
|
||||||
|
, mName (name)
|
||||||
|
, mProcessed (false)
|
||||||
|
{
|
||||||
// Set mTargetPosition to qnan
|
// Set mTargetPosition to qnan
|
||||||
const ai_real qnan = get_qnan();
|
const ai_real qnan = get_qnan();
|
||||||
mTargetPosition.x = qnan;
|
mTargetPosition.x = qnan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Name of the mesh
|
//! Name of the mesh
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
|
@ -260,19 +293,22 @@ struct BaseNode
|
||||||
/** Helper structure to represent an ASE file mesh */
|
/** Helper structure to represent an ASE file mesh */
|
||||||
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode
|
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode
|
||||||
{
|
{
|
||||||
//! Constructor.
|
//! Default constructor has been deleted
|
||||||
Mesh()
|
Mesh() = delete;
|
||||||
: BaseNode (BaseNode::Mesh)
|
|
||||||
, bSkip (false)
|
|
||||||
|
//! Construction from an existing name
|
||||||
|
explicit Mesh(const std::string &name)
|
||||||
|
: BaseNode (BaseNode::Mesh, name)
|
||||||
|
, iMaterialIndex(Face::DEFAULT_MATINDEX)
|
||||||
|
, bSkip (false)
|
||||||
{
|
{
|
||||||
// use 2 texture vertex components by default
|
// use 2 texture vertex components by default
|
||||||
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||||
this->mNumUVComponents[c] = 2;
|
this->mNumUVComponents[c] = 2;
|
||||||
|
|
||||||
// setup the default material index by default
|
|
||||||
iMaterialIndex = Face::DEFAULT_MATINDEX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! List of all texture coordinate sets
|
//! List of all texture coordinate sets
|
||||||
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
|
||||||
|
@ -307,17 +343,21 @@ struct Light : public BaseNode
|
||||||
DIRECTIONAL
|
DIRECTIONAL
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Constructor.
|
//! Default constructor has been deleted
|
||||||
Light()
|
Light() = delete;
|
||||||
: BaseNode (BaseNode::Light)
|
|
||||||
, mLightType (OMNI)
|
//! Construction from an existing name
|
||||||
, mColor (1.f,1.f,1.f)
|
explicit Light(const std::string &name)
|
||||||
, mIntensity (1.f) // light is white by default
|
: BaseNode (BaseNode::Light, name)
|
||||||
, mAngle (45.f)
|
, mLightType (OMNI)
|
||||||
, mFalloff (0.f)
|
, mColor (1.f,1.f,1.f)
|
||||||
|
, mIntensity (1.f) // light is white by default
|
||||||
|
, mAngle (45.f)
|
||||||
|
, mFalloff (0.f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LightType mLightType;
|
LightType mLightType;
|
||||||
aiColor3D mColor;
|
aiColor3D mColor;
|
||||||
ai_real mIntensity;
|
ai_real mIntensity;
|
||||||
|
@ -335,16 +375,21 @@ struct Camera : public BaseNode
|
||||||
TARGET
|
TARGET
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Constructor
|
//! Default constructor has been deleted
|
||||||
Camera()
|
Camera() = delete;
|
||||||
: BaseNode (BaseNode::Camera)
|
|
||||||
, mFOV (0.75f) // in radians
|
|
||||||
, mNear (0.1f)
|
//! Construction from an existing name
|
||||||
, mFar (1000.f) // could be zero
|
explicit Camera(const std::string &name)
|
||||||
, mCameraType (FREE)
|
: BaseNode (BaseNode::Camera, name)
|
||||||
|
, mFOV (0.75f) // in radians
|
||||||
|
, mNear (0.1f)
|
||||||
|
, mFar (1000.f) // could be zero
|
||||||
|
, mCameraType (FREE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ai_real mFOV, mNear, mFar;
|
ai_real mFOV, mNear, mFar;
|
||||||
CameraType mCameraType;
|
CameraType mCameraType;
|
||||||
};
|
};
|
||||||
|
@ -355,7 +400,7 @@ struct Dummy : public BaseNode
|
||||||
{
|
{
|
||||||
//! Constructor
|
//! Constructor
|
||||||
Dummy()
|
Dummy()
|
||||||
: BaseNode (BaseNode::Dummy)
|
: BaseNode (BaseNode::Dummy, "DUMMY")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -41,6 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @file AssbinExporter.cpp
|
/** @file AssbinExporter.cpp
|
||||||
* ASSBIN exporter main code
|
* ASSBIN exporter main code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||||
|
|
||||||
#include "assbin_chunks.h"
|
#include "assbin_chunks.h"
|
||||||
#include <assimp/version.h>
|
#include <assimp/version.h>
|
||||||
#include <assimp/IOStream.hpp>
|
#include <assimp/IOStream.hpp>
|
||||||
|
@ -57,10 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
|
||||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -41,6 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @file AssxmlExporter.cpp
|
/** @file AssxmlExporter.cpp
|
||||||
* ASSXML exporter main code
|
* ASSXML exporter main code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <assimp/version.h>
|
#include <assimp/version.h>
|
||||||
#include "ProcessHelper.h"
|
#include "ProcessHelper.h"
|
||||||
|
@ -57,9 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
|
||||||
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -83,7 +84,10 @@ class BVHLoader : public BaseImporter
|
||||||
std::vector<ChannelType> mChannels;
|
std::vector<ChannelType> mChannels;
|
||||||
std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames
|
std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames
|
||||||
|
|
||||||
Node() { }
|
Node()
|
||||||
|
: mNode(nullptr)
|
||||||
|
{ }
|
||||||
|
|
||||||
explicit Node( const aiNode* pNode) : mNode( pNode) { }
|
explicit Node( const aiNode* pNode) : mNode( pNode) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -156,9 +157,6 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
|
||||||
// read 200 characters from the file
|
// read 200 characters from the file
|
||||||
std::unique_ptr<char[]> _buffer (new char[searchBytes+1 /* for the '\0' */]);
|
std::unique_ptr<char[]> _buffer (new char[searchBytes+1 /* for the '\0' */]);
|
||||||
char* buffer = _buffer.get();
|
char* buffer = _buffer.get();
|
||||||
if( NULL == buffer ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t read = pStream->Read(buffer,1,searchBytes);
|
const size_t read = pStream->Read(buffer,1,searchBytes);
|
||||||
if( !read ) {
|
if( !read ) {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -84,7 +85,8 @@ namespace Assimp {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline std::size_t Copy(uint8_t* data, T& field) {
|
inline
|
||||||
|
std::size_t Copy(uint8_t* data, const T &field) {
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
T field_swapped=AI_BE(field);
|
T field_swapped=AI_BE(field);
|
||||||
std::memcpy(data, &field_swapped, sizeof(field)); return sizeof(field);
|
std::memcpy(data, &field_swapped, sizeof(field)); return sizeof(field);
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -57,12 +58,11 @@ using namespace Assimp::Formatter;
|
||||||
|
|
||||||
static bool match4(StreamReaderAny& stream, const char* string) {
|
static bool match4(StreamReaderAny& stream, const char* string) {
|
||||||
ai_assert( nullptr != string );
|
ai_assert( nullptr != string );
|
||||||
char tmp[] = {
|
char tmp[4];
|
||||||
(const char)(stream).GetI1(),
|
tmp[ 0 ] = ( stream ).GetI1();
|
||||||
(const char)(stream).GetI1(),
|
tmp[ 1 ] = ( stream ).GetI1();
|
||||||
(const char)(stream).GetI1(),
|
tmp[ 2 ] = ( stream ).GetI1();
|
||||||
(const char)(stream).GetI1()
|
tmp[ 3 ] = ( stream ).GetI1();
|
||||||
};
|
|
||||||
return (tmp[0]==string[0] && tmp[1]==string[1] && tmp[2]==string[2] && tmp[3]==string[3]);
|
return (tmp[0]==string[0] && tmp[1]==string[1] && tmp[2]==string[2] && tmp[3]==string[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -121,9 +122,11 @@ namespace Blender {
|
||||||
# pragma warning(disable:4351)
|
# pragma warning(disable:4351)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// As counter-intuitive as it may seem, a comparator must return false for equal values.
|
||||||
|
// The C++ standard defines and expects this behavior: true if lhs < rhs, false otherwise.
|
||||||
struct ObjectCompare {
|
struct ObjectCompare {
|
||||||
bool operator() (const Object* left, const Object* right) const {
|
bool operator() (const Object* left, const Object* right) const {
|
||||||
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
|
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) < 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,9 +145,11 @@ namespace Blender {
|
||||||
, db(db)
|
, db(db)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
// As counter-intuitive as it may seem, a comparator must return false for equal values.
|
||||||
|
// The C++ standard defines and expects this behavior: true if lhs < rhs, false otherwise.
|
||||||
struct ObjectCompare {
|
struct ObjectCompare {
|
||||||
bool operator() (const Object* left, const Object* right) const {
|
bool operator() (const Object* left, const Object* right) const {
|
||||||
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
|
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) < 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -153,14 +154,6 @@ void BlenderImporter::SetupProperties(const Importer* /*pImp*/)
|
||||||
// nothing to be done for the moment
|
// nothing to be done for the moment
|
||||||
}
|
}
|
||||||
|
|
||||||
struct free_it {
|
|
||||||
free_it(void* free) : free(free) {}
|
|
||||||
~free_it() {
|
|
||||||
::free(this->free);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* free;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
|
@ -168,8 +161,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene* pScene, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
#ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
|
#ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
|
||||||
Bytef* dest = NULL;
|
std::vector<Bytef> uncompressed;
|
||||||
free_it free_it_really(dest);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,6 +209,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
size_t total = 0l;
|
size_t total = 0l;
|
||||||
|
|
||||||
|
// TODO: be smarter about this, decompress directly into heap buffer
|
||||||
// and decompress the data .... do 1k chunks in the hope that we won't kill the stack
|
// and decompress the data .... do 1k chunks in the hope that we won't kill the stack
|
||||||
#define MYBLOCK 1024
|
#define MYBLOCK 1024
|
||||||
Bytef block[MYBLOCK];
|
Bytef block[MYBLOCK];
|
||||||
|
@ -231,8 +224,8 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
const size_t have = MYBLOCK - zstream.avail_out;
|
const size_t have = MYBLOCK - zstream.avail_out;
|
||||||
total += have;
|
total += have;
|
||||||
dest = reinterpret_cast<Bytef*>( realloc(dest,total) );
|
uncompressed.resize(total);
|
||||||
memcpy(dest + total - have,block,have);
|
memcpy(uncompressed.data() + total - have,block,have);
|
||||||
}
|
}
|
||||||
while (ret != Z_STREAM_END);
|
while (ret != Z_STREAM_END);
|
||||||
|
|
||||||
|
@ -240,7 +233,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
||||||
inflateEnd(&zstream);
|
inflateEnd(&zstream);
|
||||||
|
|
||||||
// replace the input stream with a memory stream
|
// replace the input stream with a memory stream
|
||||||
stream.reset(new MemoryIOStream(reinterpret_cast<uint8_t*>(dest),total));
|
stream.reset(new MemoryIOStream(reinterpret_cast<uint8_t*>(uncompressed.data()),total));
|
||||||
|
|
||||||
// .. and retry
|
// .. and retry
|
||||||
stream->Read(magic,7,1);
|
stream->Read(magic,7,1);
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
# Open Asset Import Library (assimp)
|
# Open Asset Import Library (assimp)
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006-2017, assimp team
|
# Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -135,7 +136,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
||||||
TextFileToBuffer(file.get(),mBuffer2);
|
TextFileToBuffer(file.get(),mBuffer2);
|
||||||
const char* buffer = &mBuffer2[0];
|
const char* buffer = &mBuffer2[0];
|
||||||
|
|
||||||
aiAnimation* anim = new aiAnimation();
|
std::unique_ptr<aiAnimation> anim(new aiAnimation());
|
||||||
int first = 0, last = 0x00ffffff;
|
int first = 0, last = 0x00ffffff;
|
||||||
|
|
||||||
// now process the file and look out for '$' sections
|
// now process the file and look out for '$' sections
|
||||||
|
@ -293,8 +294,8 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// Store the one and only animation in the scene
|
// Store the one and only animation in the scene
|
||||||
pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations=1];
|
pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations=1];
|
||||||
pScene->mAnimations[0] = anim;
|
|
||||||
anim->mName.Set("$CSM_MasterAnim");
|
anim->mName.Set("$CSM_MasterAnim");
|
||||||
|
pScene->mAnimations[0] = anim.release();
|
||||||
|
|
||||||
// mark the scene as incomplete and run SkeletonMeshBuilder on it
|
// mark the scene as incomplete and run SkeletonMeshBuilder on it
|
||||||
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
|
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "D3MFOpcPackage.h"
|
#include "D3MFOpcPackage.h"
|
||||||
#include <contrib/unzip/unzip.h>
|
#include <unzip.h>
|
||||||
#include <assimp/irrXMLWrapper.h>
|
#include <assimp/irrXMLWrapper.h>
|
||||||
#include "3MFXmlTags.h"
|
#include "3MFXmlTags.h"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ 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 <contrib/unzip/unzip.h>
|
#include <unzip.h>
|
||||||
#include "3MFXmlTags.h"
|
#include "3MFXmlTags.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -66,7 +67,6 @@ namespace FBX {
|
||||||
|
|
||||||
using namespace Util;
|
using namespace Util;
|
||||||
|
|
||||||
|
|
||||||
#define MAGIC_NODE_TAG "_$AssimpFbx$"
|
#define MAGIC_NODE_TAG "_$AssimpFbx$"
|
||||||
|
|
||||||
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000L
|
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000L
|
||||||
|
@ -74,379 +74,11 @@ using namespace Util;
|
||||||
// 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 */
|
|
||||||
class Converter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* The different parts that make up the final local transformation of a fbx-node
|
|
||||||
*/
|
|
||||||
enum TransformationComp
|
|
||||||
{
|
|
||||||
TransformationComp_Translation = 0,
|
|
||||||
TransformationComp_RotationOffset,
|
|
||||||
TransformationComp_RotationPivot,
|
|
||||||
TransformationComp_PreRotation,
|
|
||||||
TransformationComp_Rotation,
|
|
||||||
TransformationComp_PostRotation,
|
|
||||||
TransformationComp_RotationPivotInverse,
|
|
||||||
TransformationComp_ScalingOffset,
|
|
||||||
TransformationComp_ScalingPivot,
|
|
||||||
TransformationComp_Scaling,
|
|
||||||
TransformationComp_ScalingPivotInverse,
|
|
||||||
TransformationComp_GeometricTranslation,
|
|
||||||
TransformationComp_GeometricRotation,
|
|
||||||
TransformationComp_GeometricScaling,
|
|
||||||
|
|
||||||
TransformationComp_MAXIMUM
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
Converter( aiScene* out, const Document& doc );
|
|
||||||
~Converter();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// find scene root and trigger recursive scene conversion
|
|
||||||
void ConvertRootNode();
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// collect and assign child nodes
|
|
||||||
void ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform = aiMatrix4x4() );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertLights( const Model& model );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertCameras( const Model& model );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertLight( const Model& model, const Light& light );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertCamera( const Model& model, const Camera& cam );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// this returns unified names usable within assimp identifiers (i.e. no space characters -
|
|
||||||
// while these would be allowed, they are a potential trouble spot so better not use them).
|
|
||||||
const char* NameTransformationComp( TransformationComp comp );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// note: this returns the REAL fbx property names
|
|
||||||
const char* NameTransformationCompProperty( TransformationComp comp );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
aiVector3D TransformationCompDefaultValue( TransformationComp comp );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void GetRotationMatrix( Model::RotOrder mode, const aiVector3D& rotation, aiMatrix4x4& out );
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* checks if a node has more than just scaling, rotation and translation components
|
|
||||||
*/
|
|
||||||
bool NeedsComplexTransformationChain( const Model& model );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// note: name must be a FixNodeName() result
|
|
||||||
std::string NameTransformationChainNode( const std::string& name, TransformationComp comp );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* note: memory for output_nodes will be managed by the caller
|
|
||||||
*/
|
|
||||||
void GenerateTransformationNodeChain( const Model& model, std::vector<aiNode*>& output_nodes );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void SetupNodeMetadata( const Model& model, aiNode& nd );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertModel( const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// MeshGeometry -> aiMesh, return mesh index + 1 or 0 if the conversion failed
|
|
||||||
std::vector<unsigned int> ConvertMesh( const MeshGeometry& mesh, const Model& model,
|
|
||||||
const aiMatrix4x4& node_global_transform );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
aiMesh* SetupEmptyMesh( const MeshGeometry& mesh );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
unsigned int ConvertMeshSingleMaterial( const MeshGeometry& mesh, const Model& model,
|
|
||||||
const aiMatrix4x4& node_global_transform );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
std::vector<unsigned int> ConvertMeshMultiMaterial( const MeshGeometry& mesh, const Model& model,
|
|
||||||
const aiMatrix4x4& node_global_transform );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
unsigned int ConvertMeshMultiMaterial( const MeshGeometry& mesh, const Model& model,
|
|
||||||
MatIndexArray::value_type index,
|
|
||||||
const aiMatrix4x4& node_global_transform );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
static const unsigned int NO_MATERIAL_SEPARATION = /* std::numeric_limits<unsigned int>::max() */
|
|
||||||
static_cast<unsigned int>(-1);
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* - if materialIndex == NO_MATERIAL_SEPARATION, materials are not taken into
|
|
||||||
* account when determining which weights to include.
|
|
||||||
* - outputVertStartIndices is only used when a material index is specified, it gives for
|
|
||||||
* each output vertex the DOM index it maps to.
|
|
||||||
*/
|
|
||||||
void ConvertWeights( aiMesh* out, const Model& model, const MeshGeometry& geo,
|
|
||||||
const aiMatrix4x4& node_global_transform = aiMatrix4x4(),
|
|
||||||
unsigned int materialIndex = NO_MATERIAL_SEPARATION,
|
|
||||||
std::vector<unsigned int>* outputVertStartIndices = NULL );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertCluster( std::vector<aiBone*>& bones, const Model& /*model*/, const Cluster& cl,
|
|
||||||
std::vector<size_t>& out_indices,
|
|
||||||
std::vector<size_t>& index_out_indices,
|
|
||||||
std::vector<size_t>& count_out_indices,
|
|
||||||
const aiMatrix4x4& node_global_transform );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertMaterialForMesh( aiMesh* out, const Model& model, const MeshGeometry& geo,
|
|
||||||
MatIndexArray::value_type materialIndex );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
unsigned int GetDefaultMaterial();
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Material -> aiMaterial
|
|
||||||
unsigned int ConvertMaterial( const Material& material, const MeshGeometry* const mesh );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Video -> aiTexture
|
|
||||||
unsigned int ConvertVideo( const Video& video );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void TrySetTextureProperties( aiMaterial* out_mat, const TextureMap& textures,
|
|
||||||
const std::string& propName,
|
|
||||||
aiTextureType target, const MeshGeometry* const mesh );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void TrySetTextureProperties( aiMaterial* out_mat, const LayeredTextureMap& layeredTextures,
|
|
||||||
const std::string& propName,
|
|
||||||
aiTextureType target, const MeshGeometry* const mesh );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void SetTextureProperties( aiMaterial* out_mat, const TextureMap& textures, const MeshGeometry* const mesh );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void SetTextureProperties( aiMaterial* out_mat, const LayeredTextureMap& layeredTextures, const MeshGeometry* const mesh );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
aiColor3D GetColorPropertyFromMaterial( const PropertyTable& props, const std::string& baseName,
|
|
||||||
bool& result );
|
|
||||||
aiColor3D GetColorPropertyFactored( const PropertyTable& props, const std::string& colorName,
|
|
||||||
const std::string& factorName, bool& result, bool useTemplate=true );
|
|
||||||
aiColor3D GetColorProperty( const PropertyTable& props, const std::string& colorName,
|
|
||||||
bool& result, bool useTemplate=true );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void SetShadingPropertiesCommon( aiMaterial* out_mat, const PropertyTable& props );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// get the number of fps for a FrameRate enumerated value
|
|
||||||
static double FrameRateToDouble( FileGlobalSettings::FrameRate fp, double customFPSVal = -1.0 );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// convert animation data to aiAnimation et al
|
|
||||||
void ConvertAnimations();
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// rename a node already partially converted. fixed_name is a string previously returned by
|
|
||||||
// FixNodeName, new_name specifies the string FixNodeName should return on all further invocations
|
|
||||||
// which would previously have returned the old value.
|
|
||||||
//
|
|
||||||
// this also updates names in node animations, cameras and light sources and is thus slow.
|
|
||||||
//
|
|
||||||
// NOTE: the caller is responsible for ensuring that the new name is unique and does
|
|
||||||
// not collide with any other identifiers. The best way to ensure this is to only
|
|
||||||
// append to the old name, which is guaranteed to match these requirements.
|
|
||||||
void RenameNode( const std::string& fixed_name, const std::string& new_name );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// takes a fbx node name and returns the identifier to be used in the assimp output scene.
|
|
||||||
// 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 );
|
|
||||||
|
|
||||||
typedef std::map<const AnimationCurveNode*, const AnimationLayer*> LayerMap;
|
|
||||||
|
|
||||||
// XXX: better use multi_map ..
|
|
||||||
typedef std::map<std::string, std::vector<const AnimationCurveNode*> > NodeMap;
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertAnimationStack( const AnimationStack& st );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void GenerateNodeAnimations( std::vector<aiNodeAnim*>& node_anims,
|
|
||||||
const std::string& fixed_name,
|
|
||||||
const std::vector<const AnimationCurveNode*>& curves,
|
|
||||||
const LayerMap& layer_map,
|
|
||||||
int64_t start, int64_t stop,
|
|
||||||
double& max_time,
|
|
||||||
double& min_time );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
bool IsRedundantAnimationData( const Model& target,
|
|
||||||
TransformationComp comp,
|
|
||||||
const std::vector<const AnimationCurveNode*>& curves );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
aiNodeAnim* GenerateRotationNodeAnim( const std::string& name,
|
|
||||||
const Model& target,
|
|
||||||
const std::vector<const AnimationCurveNode*>& curves,
|
|
||||||
const LayerMap& layer_map,
|
|
||||||
int64_t start, int64_t stop,
|
|
||||||
double& max_time,
|
|
||||||
double& min_time );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
aiNodeAnim* GenerateScalingNodeAnim( const std::string& name,
|
|
||||||
const Model& /*target*/,
|
|
||||||
const std::vector<const AnimationCurveNode*>& curves,
|
|
||||||
const LayerMap& layer_map,
|
|
||||||
int64_t start, int64_t stop,
|
|
||||||
double& max_time,
|
|
||||||
double& min_time );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
aiNodeAnim* GenerateTranslationNodeAnim( const std::string& name,
|
|
||||||
const Model& /*target*/,
|
|
||||||
const std::vector<const AnimationCurveNode*>& curves,
|
|
||||||
const LayerMap& layer_map,
|
|
||||||
int64_t start, int64_t stop,
|
|
||||||
double& max_time,
|
|
||||||
double& min_time,
|
|
||||||
bool inverse = false );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// generate node anim, extracting only Rotation, Scaling and Translation from the given chain
|
|
||||||
aiNodeAnim* GenerateSimpleNodeAnim( const std::string& name,
|
|
||||||
const Model& target,
|
|
||||||
NodeMap::const_iterator chain[ TransformationComp_MAXIMUM ],
|
|
||||||
NodeMap::const_iterator iter_end,
|
|
||||||
const LayerMap& layer_map,
|
|
||||||
int64_t start, int64_t stop,
|
|
||||||
double& max_time,
|
|
||||||
double& min_time,
|
|
||||||
bool reverse_order = false );
|
|
||||||
|
|
||||||
// key (time), value, mapto (component index)
|
|
||||||
typedef std::tuple<std::shared_ptr<KeyTimeList>, std::shared_ptr<KeyValueList>, unsigned int > KeyFrameList;
|
|
||||||
typedef std::vector<KeyFrameList> KeyFrameListList;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
KeyFrameListList GetKeyframeList( const std::vector<const AnimationCurveNode*>& nodes, int64_t start, int64_t stop );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
KeyTimeList GetKeyTimeList( const KeyFrameListList& inputs );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void InterpolateKeys( aiVectorKey* valOut, const KeyTimeList& keys, const KeyFrameListList& inputs,
|
|
||||||
const aiVector3D& def_value,
|
|
||||||
double& max_time,
|
|
||||||
double& min_time );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void InterpolateKeys( aiQuatKey* valOut, const KeyTimeList& keys, const KeyFrameListList& inputs,
|
|
||||||
const aiVector3D& def_value,
|
|
||||||
double& maxTime,
|
|
||||||
double& minTime,
|
|
||||||
Model::RotOrder order );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertTransformOrder_TRStoSRT( aiQuatKey* out_quat, aiVectorKey* out_scale,
|
|
||||||
aiVectorKey* out_translation,
|
|
||||||
const KeyFrameListList& scaling,
|
|
||||||
const KeyFrameListList& translation,
|
|
||||||
const KeyFrameListList& rotation,
|
|
||||||
const KeyTimeList& times,
|
|
||||||
double& maxTime,
|
|
||||||
double& minTime,
|
|
||||||
Model::RotOrder order,
|
|
||||||
const aiVector3D& def_scale,
|
|
||||||
const aiVector3D& def_translate,
|
|
||||||
const aiVector3D& def_rotation );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// euler xyz -> quat
|
|
||||||
aiQuaternion EulerToQuaternion( const aiVector3D& rot, Model::RotOrder order );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertScaleKeys( aiNodeAnim* na, const std::vector<const AnimationCurveNode*>& nodes, const LayerMap& /*layers*/,
|
|
||||||
int64_t start, int64_t stop,
|
|
||||||
double& maxTime,
|
|
||||||
double& minTime );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertTranslationKeys( aiNodeAnim* na, const std::vector<const AnimationCurveNode*>& nodes,
|
|
||||||
const LayerMap& /*layers*/,
|
|
||||||
int64_t start, int64_t stop,
|
|
||||||
double& maxTime,
|
|
||||||
double& minTime );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void ConvertRotationKeys( aiNodeAnim* na, const std::vector<const AnimationCurveNode*>& nodes,
|
|
||||||
const LayerMap& /*layers*/,
|
|
||||||
int64_t start, int64_t stop,
|
|
||||||
double& maxTime,
|
|
||||||
double& minTime,
|
|
||||||
Model::RotOrder order );
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// copy generated meshes, animations, lights, cameras and textures to the output scene
|
|
||||||
void TransferDataToScene();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// 0: not assigned yet, others: index is value - 1
|
|
||||||
unsigned int defaultMaterialIndex;
|
|
||||||
|
|
||||||
std::vector<aiMesh*> meshes;
|
|
||||||
std::vector<aiMaterial*> materials;
|
|
||||||
std::vector<aiAnimation*> animations;
|
|
||||||
std::vector<aiLight*> lights;
|
|
||||||
std::vector<aiCamera*> cameras;
|
|
||||||
std::vector<aiTexture*> textures;
|
|
||||||
|
|
||||||
typedef std::map<const Material*, unsigned int> MaterialMap;
|
|
||||||
MaterialMap materials_converted;
|
|
||||||
|
|
||||||
typedef std::map<const Video*, unsigned int> VideoMap;
|
|
||||||
VideoMap textures_converted;
|
|
||||||
|
|
||||||
typedef std::map<const Geometry*, std::vector<unsigned int> > MeshMap;
|
|
||||||
MeshMap meshes_converted;
|
|
||||||
|
|
||||||
// fixed node name -> which trafo chain components have animations?
|
|
||||||
typedef std::map<std::string, unsigned int> NodeAnimBitMap;
|
|
||||||
NodeAnimBitMap node_anim_chain_bits;
|
|
||||||
|
|
||||||
// name -> has had its prefix_stripped?
|
|
||||||
typedef std::map<std::string, bool> NodeNameMap;
|
|
||||||
NodeNameMap node_names;
|
|
||||||
|
|
||||||
typedef std::map<std::string, std::string> NameNameMap;
|
|
||||||
NameNameMap renamed_nodes;
|
|
||||||
|
|
||||||
double anim_fps;
|
|
||||||
|
|
||||||
aiScene* const out;
|
|
||||||
const FBX::Document& doc;
|
|
||||||
};
|
|
||||||
|
|
||||||
Converter::Converter( aiScene* out, const Document& doc )
|
Converter::Converter( aiScene* out, const Document& doc )
|
||||||
: defaultMaterialIndex()
|
: defaultMaterialIndex()
|
||||||
, out( out )
|
, out( out )
|
||||||
, doc( doc )
|
, doc( doc ) {
|
||||||
{
|
|
||||||
// animations need to be converted first since this will
|
// animations need to be converted first since this will
|
||||||
// populate the node_anim_chain_bits map, which is needed
|
// populate the node_anim_chain_bits map, which is needed
|
||||||
// to determine which nodes need to be generated.
|
// to determine which nodes need to be generated.
|
||||||
|
@ -472,6 +104,7 @@ Converter::Converter( aiScene* out, const Document& doc )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConvertGlobalSettings();
|
||||||
TransferDataToScene();
|
TransferDataToScene();
|
||||||
|
|
||||||
// if we didn't read any meshes set the AI_SCENE_FLAGS_INCOMPLETE
|
// if we didn't read any meshes set the AI_SCENE_FLAGS_INCOMPLETE
|
||||||
|
@ -483,8 +116,7 @@ Converter::Converter( aiScene* out, const Document& doc )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Converter::~Converter()
|
Converter::~Converter() {
|
||||||
{
|
|
||||||
std::for_each( meshes.begin(), meshes.end(), Util::delete_fun<aiMesh>() );
|
std::for_each( meshes.begin(), meshes.end(), Util::delete_fun<aiMesh>() );
|
||||||
std::for_each( materials.begin(), materials.end(), Util::delete_fun<aiMaterial>() );
|
std::for_each( materials.begin(), materials.end(), Util::delete_fun<aiMaterial>() );
|
||||||
std::for_each( animations.begin(), animations.end(), Util::delete_fun<aiAnimation>() );
|
std::for_each( animations.begin(), animations.end(), Util::delete_fun<aiAnimation>() );
|
||||||
|
@ -493,8 +125,7 @@ Converter::~Converter()
|
||||||
std::for_each( textures.begin(), textures.end(), Util::delete_fun<aiTexture>() );
|
std::for_each( textures.begin(), textures.end(), Util::delete_fun<aiTexture>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Converter::ConvertRootNode()
|
void Converter::ConvertRootNode() {
|
||||||
{
|
|
||||||
out->mRootNode = new aiNode();
|
out->mRootNode = new aiNode();
|
||||||
out->mRootNode->mName.Set( "RootNode" );
|
out->mRootNode->mName.Set( "RootNode" );
|
||||||
|
|
||||||
|
@ -721,10 +352,12 @@ 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();
|
||||||
|
|
||||||
//cameras are defined along positive x direction
|
//cameras are defined along positive x direction
|
||||||
out_camera->mPosition = aiVector3D(0.0f);
|
out_camera->mPosition = cam.Position();
|
||||||
out_camera->mLookAt = aiVector3D(1.0f, 0.0f, 0.0f);
|
out_camera->mLookAt = ( cam.InterestPosition() - out_camera->mPosition ).Normalize();
|
||||||
out_camera->mUp = aiVector3D(0.0f, 1.0f, 0.0f);
|
out_camera->mUp = cam.UpVector();
|
||||||
|
|
||||||
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->mClipPlaneNear = cam.NearPlane();
|
||||||
out_camera->mClipPlaneFar = cam.FarPlane();
|
out_camera->mClipPlaneFar = cam.FarPlane();
|
||||||
|
@ -1497,14 +1130,14 @@ unsigned int Converter::ConvertMeshMultiMaterial( const MeshGeometry& mesh, cons
|
||||||
out_mesh->mBitangents[ cursor ] = ( *binormals )[ in_cursor ];
|
out_mesh->mBitangents[ cursor ] = ( *binormals )[ in_cursor ];
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < num_uvs; ++i ) {
|
for ( unsigned int j = 0; j < num_uvs; ++j ) {
|
||||||
const std::vector<aiVector2D>& uvs = mesh.GetTextureCoords( i );
|
const std::vector<aiVector2D>& uvs = mesh.GetTextureCoords( j );
|
||||||
out_mesh->mTextureCoords[ i ][ cursor ] = aiVector3D( uvs[ in_cursor ].x, uvs[ in_cursor ].y, 0.0f );
|
out_mesh->mTextureCoords[ j ][ cursor ] = aiVector3D( uvs[ in_cursor ].x, uvs[ in_cursor ].y, 0.0f );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < num_vcs; ++i ) {
|
for ( unsigned int j = 0; j < num_vcs; ++j ) {
|
||||||
const std::vector<aiColor4D>& cols = mesh.GetVertexColors( i );
|
const std::vector<aiColor4D>& cols = mesh.GetVertexColors( j );
|
||||||
out_mesh->mColors[ i ][ cursor ] = cols[ in_cursor ];
|
out_mesh->mColors[ j ][ cursor ] = cols[ in_cursor ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3341,8 +2974,20 @@ void Converter::ConvertRotationKeys( aiNodeAnim* na, const std::vector<const Ani
|
||||||
|
|
||||||
na->mNumRotationKeys = static_cast<unsigned int>( keys.size() );
|
na->mNumRotationKeys = static_cast<unsigned int>( keys.size() );
|
||||||
na->mRotationKeys = new aiQuatKey[ keys.size() ];
|
na->mRotationKeys = new aiQuatKey[ keys.size() ];
|
||||||
if ( keys.size() > 0 )
|
if (!keys.empty()) {
|
||||||
InterpolateKeys( na->mRotationKeys, keys, inputs, aiVector3D( 0.0f, 0.0f, 0.0f ), maxTime, minTime, order );
|
InterpolateKeys(na->mRotationKeys, keys, inputs, aiVector3D(0.0f, 0.0f, 0.0f), maxTime, minTime, order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Converter::ConvertGlobalSettings() {
|
||||||
|
if (nullptr == out) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
out->mMetaData = aiMetadata::Alloc(1);
|
||||||
|
unsigned int index(0);
|
||||||
|
const double unitScalFactor(doc.GlobalSettings().UnitScaleFactor());
|
||||||
|
out->mMetaData->Set(index, "UnitScaleFactor", unitScalFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Converter::TransferDataToScene()
|
void Converter::TransferDataToScene()
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -45,7 +46,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef INCLUDED_AI_FBX_CONVERTER_H
|
#ifndef INCLUDED_AI_FBX_CONVERTER_H
|
||||||
#define INCLUDED_AI_FBX_CONVERTER_H
|
#define INCLUDED_AI_FBX_CONVERTER_H
|
||||||
|
|
||||||
|
#include "FBXParser.h"
|
||||||
|
#include "FBXMeshGeometry.h"
|
||||||
|
#include "FBXDocument.h"
|
||||||
|
#include "FBXUtil.h"
|
||||||
|
#include "FBXProperties.h"
|
||||||
|
#include "FBXImporter.h"
|
||||||
|
#include <assimp/anim.h>
|
||||||
|
#include <assimp/material.h>
|
||||||
|
#include <assimp/light.h>
|
||||||
|
#include <assimp/texture.h>
|
||||||
|
#include <assimp/camera.h>
|
||||||
|
#include <assimp/StringComparison.h>
|
||||||
|
|
||||||
struct aiScene;
|
struct aiScene;
|
||||||
|
struct aiNode;
|
||||||
|
struct aiMaterial;
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace FBX {
|
namespace FBX {
|
||||||
|
@ -59,6 +75,373 @@ class Document;
|
||||||
*/
|
*/
|
||||||
void ConvertToAssimpScene(aiScene* out, const Document& doc);
|
void ConvertToAssimpScene(aiScene* out, const Document& doc);
|
||||||
|
|
||||||
|
/** Dummy class to encapsulate the conversion process */
|
||||||
|
class Converter {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The different parts that make up the final local transformation of a fbx-node
|
||||||
|
*/
|
||||||
|
enum TransformationComp {
|
||||||
|
TransformationComp_Translation = 0,
|
||||||
|
TransformationComp_RotationOffset,
|
||||||
|
TransformationComp_RotationPivot,
|
||||||
|
TransformationComp_PreRotation,
|
||||||
|
TransformationComp_Rotation,
|
||||||
|
TransformationComp_PostRotation,
|
||||||
|
TransformationComp_RotationPivotInverse,
|
||||||
|
TransformationComp_ScalingOffset,
|
||||||
|
TransformationComp_ScalingPivot,
|
||||||
|
TransformationComp_Scaling,
|
||||||
|
TransformationComp_ScalingPivotInverse,
|
||||||
|
TransformationComp_GeometricTranslation,
|
||||||
|
TransformationComp_GeometricRotation,
|
||||||
|
TransformationComp_GeometricScaling,
|
||||||
|
|
||||||
|
TransformationComp_MAXIMUM
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
Converter(aiScene* out, const Document& doc);
|
||||||
|
~Converter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// find scene root and trigger recursive scene conversion
|
||||||
|
void ConvertRootNode();
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// collect and assign child nodes
|
||||||
|
void ConvertNodes(uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform = aiMatrix4x4());
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertLights(const Model& model);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertCameras(const Model& model);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertLight(const Model& model, const Light& light);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertCamera(const Model& model, const Camera& cam);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// this returns unified names usable within assimp identifiers (i.e. no space characters -
|
||||||
|
// while these would be allowed, they are a potential trouble spot so better not use them).
|
||||||
|
const char* NameTransformationComp(TransformationComp comp);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// note: this returns the REAL fbx property names
|
||||||
|
const char* NameTransformationCompProperty(TransformationComp comp);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiVector3D TransformationCompDefaultValue(TransformationComp comp);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void GetRotationMatrix(Model::RotOrder mode, const aiVector3D& rotation, aiMatrix4x4& out);
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* checks if a node has more than just scaling, rotation and translation components
|
||||||
|
*/
|
||||||
|
bool NeedsComplexTransformationChain(const Model& model);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// note: name must be a FixNodeName() result
|
||||||
|
std::string NameTransformationChainNode(const std::string& name, TransformationComp comp);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* note: memory for output_nodes will be managed by the caller
|
||||||
|
*/
|
||||||
|
void GenerateTransformationNodeChain(const Model& model, std::vector<aiNode*>& output_nodes);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void SetupNodeMetadata(const Model& model, aiNode& nd);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertModel(const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// MeshGeometry -> aiMesh, return mesh index + 1 or 0 if the conversion failed
|
||||||
|
std::vector<unsigned int> ConvertMesh(const MeshGeometry& mesh, const Model& model,
|
||||||
|
const aiMatrix4x4& node_global_transform);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiMesh* SetupEmptyMesh(const MeshGeometry& mesh);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
unsigned int ConvertMeshSingleMaterial(const MeshGeometry& mesh, const Model& model,
|
||||||
|
const aiMatrix4x4& node_global_transform);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<unsigned int> ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model,
|
||||||
|
const aiMatrix4x4& node_global_transform);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
unsigned int ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model,
|
||||||
|
MatIndexArray::value_type index,
|
||||||
|
const aiMatrix4x4& node_global_transform);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const unsigned int NO_MATERIAL_SEPARATION = /* std::numeric_limits<unsigned int>::max() */
|
||||||
|
static_cast<unsigned int>(-1);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* - if materialIndex == NO_MATERIAL_SEPARATION, materials are not taken into
|
||||||
|
* account when determining which weights to include.
|
||||||
|
* - outputVertStartIndices is only used when a material index is specified, it gives for
|
||||||
|
* each output vertex the DOM index it maps to.
|
||||||
|
*/
|
||||||
|
void ConvertWeights(aiMesh* out, const Model& model, const MeshGeometry& geo,
|
||||||
|
const aiMatrix4x4& node_global_transform = aiMatrix4x4(),
|
||||||
|
unsigned int materialIndex = NO_MATERIAL_SEPARATION,
|
||||||
|
std::vector<unsigned int>* outputVertStartIndices = NULL);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertCluster(std::vector<aiBone*>& bones, const Model& /*model*/, const Cluster& cl,
|
||||||
|
std::vector<size_t>& out_indices,
|
||||||
|
std::vector<size_t>& index_out_indices,
|
||||||
|
std::vector<size_t>& count_out_indices,
|
||||||
|
const aiMatrix4x4& node_global_transform);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertMaterialForMesh(aiMesh* out, const Model& model, const MeshGeometry& geo,
|
||||||
|
MatIndexArray::value_type materialIndex);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
unsigned int GetDefaultMaterial();
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Material -> aiMaterial
|
||||||
|
unsigned int ConvertMaterial(const Material& material, const MeshGeometry* const mesh);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Video -> aiTexture
|
||||||
|
unsigned int ConvertVideo(const Video& video);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void TrySetTextureProperties(aiMaterial* out_mat, const TextureMap& textures,
|
||||||
|
const std::string& propName,
|
||||||
|
aiTextureType target, const MeshGeometry* const mesh);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void TrySetTextureProperties(aiMaterial* out_mat, const LayeredTextureMap& layeredTextures,
|
||||||
|
const std::string& propName,
|
||||||
|
aiTextureType target, const MeshGeometry* const mesh);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void SetTextureProperties(aiMaterial* out_mat, const TextureMap& textures, const MeshGeometry* const mesh);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void SetTextureProperties(aiMaterial* out_mat, const LayeredTextureMap& layeredTextures, const MeshGeometry* const mesh);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiColor3D GetColorPropertyFromMaterial(const PropertyTable& props, const std::string& baseName,
|
||||||
|
bool& result);
|
||||||
|
aiColor3D GetColorPropertyFactored(const PropertyTable& props, const std::string& colorName,
|
||||||
|
const std::string& factorName, bool& result, bool useTemplate = true);
|
||||||
|
aiColor3D GetColorProperty(const PropertyTable& props, const std::string& colorName,
|
||||||
|
bool& result, bool useTemplate = true);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void SetShadingPropertiesCommon(aiMaterial* out_mat, const PropertyTable& props);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// get the number of fps for a FrameRate enumerated value
|
||||||
|
static double FrameRateToDouble(FileGlobalSettings::FrameRate fp, double customFPSVal = -1.0);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// convert animation data to aiAnimation et al
|
||||||
|
void ConvertAnimations();
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// rename a node already partially converted. fixed_name is a string previously returned by
|
||||||
|
// FixNodeName, new_name specifies the string FixNodeName should return on all further invocations
|
||||||
|
// which would previously have returned the old value.
|
||||||
|
//
|
||||||
|
// this also updates names in node animations, cameras and light sources and is thus slow.
|
||||||
|
//
|
||||||
|
// NOTE: the caller is responsible for ensuring that the new name is unique and does
|
||||||
|
// not collide with any other identifiers. The best way to ensure this is to only
|
||||||
|
// append to the old name, which is guaranteed to match these requirements.
|
||||||
|
void RenameNode(const std::string& fixed_name, const std::string& new_name);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// takes a fbx node name and returns the identifier to be used in the assimp output scene.
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
typedef std::map<const AnimationCurveNode*, const AnimationLayer*> LayerMap;
|
||||||
|
|
||||||
|
// XXX: better use multi_map ..
|
||||||
|
typedef std::map<std::string, std::vector<const AnimationCurveNode*> > NodeMap;
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertAnimationStack(const AnimationStack& st);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void GenerateNodeAnimations(std::vector<aiNodeAnim*>& node_anims,
|
||||||
|
const std::string& fixed_name,
|
||||||
|
const std::vector<const AnimationCurveNode*>& curves,
|
||||||
|
const LayerMap& layer_map,
|
||||||
|
int64_t start, int64_t stop,
|
||||||
|
double& max_time,
|
||||||
|
double& min_time);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
bool IsRedundantAnimationData(const Model& target,
|
||||||
|
TransformationComp comp,
|
||||||
|
const std::vector<const AnimationCurveNode*>& curves);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiNodeAnim* GenerateRotationNodeAnim(const std::string& name,
|
||||||
|
const Model& target,
|
||||||
|
const std::vector<const AnimationCurveNode*>& curves,
|
||||||
|
const LayerMap& layer_map,
|
||||||
|
int64_t start, int64_t stop,
|
||||||
|
double& max_time,
|
||||||
|
double& min_time);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiNodeAnim* GenerateScalingNodeAnim(const std::string& name,
|
||||||
|
const Model& /*target*/,
|
||||||
|
const std::vector<const AnimationCurveNode*>& curves,
|
||||||
|
const LayerMap& layer_map,
|
||||||
|
int64_t start, int64_t stop,
|
||||||
|
double& max_time,
|
||||||
|
double& min_time);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiNodeAnim* GenerateTranslationNodeAnim(const std::string& name,
|
||||||
|
const Model& /*target*/,
|
||||||
|
const std::vector<const AnimationCurveNode*>& curves,
|
||||||
|
const LayerMap& layer_map,
|
||||||
|
int64_t start, int64_t stop,
|
||||||
|
double& max_time,
|
||||||
|
double& min_time,
|
||||||
|
bool inverse = false);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// generate node anim, extracting only Rotation, Scaling and Translation from the given chain
|
||||||
|
aiNodeAnim* GenerateSimpleNodeAnim(const std::string& name,
|
||||||
|
const Model& target,
|
||||||
|
NodeMap::const_iterator chain[TransformationComp_MAXIMUM],
|
||||||
|
NodeMap::const_iterator iter_end,
|
||||||
|
const LayerMap& layer_map,
|
||||||
|
int64_t start, int64_t stop,
|
||||||
|
double& max_time,
|
||||||
|
double& min_time,
|
||||||
|
bool reverse_order = false);
|
||||||
|
|
||||||
|
// key (time), value, mapto (component index)
|
||||||
|
typedef std::tuple<std::shared_ptr<KeyTimeList>, std::shared_ptr<KeyValueList>, unsigned int > KeyFrameList;
|
||||||
|
typedef std::vector<KeyFrameList> KeyFrameListList;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
KeyFrameListList GetKeyframeList(const std::vector<const AnimationCurveNode*>& nodes, int64_t start, int64_t stop);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
KeyTimeList GetKeyTimeList(const KeyFrameListList& inputs);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void InterpolateKeys(aiVectorKey* valOut, const KeyTimeList& keys, const KeyFrameListList& inputs,
|
||||||
|
const aiVector3D& def_value,
|
||||||
|
double& max_time,
|
||||||
|
double& min_time);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void InterpolateKeys(aiQuatKey* valOut, const KeyTimeList& keys, const KeyFrameListList& inputs,
|
||||||
|
const aiVector3D& def_value,
|
||||||
|
double& maxTime,
|
||||||
|
double& minTime,
|
||||||
|
Model::RotOrder order);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertTransformOrder_TRStoSRT(aiQuatKey* out_quat, aiVectorKey* out_scale,
|
||||||
|
aiVectorKey* out_translation,
|
||||||
|
const KeyFrameListList& scaling,
|
||||||
|
const KeyFrameListList& translation,
|
||||||
|
const KeyFrameListList& rotation,
|
||||||
|
const KeyTimeList& times,
|
||||||
|
double& maxTime,
|
||||||
|
double& minTime,
|
||||||
|
Model::RotOrder order,
|
||||||
|
const aiVector3D& def_scale,
|
||||||
|
const aiVector3D& def_translate,
|
||||||
|
const aiVector3D& def_rotation);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// euler xyz -> quat
|
||||||
|
aiQuaternion EulerToQuaternion(const aiVector3D& rot, Model::RotOrder order);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertScaleKeys(aiNodeAnim* na, const std::vector<const AnimationCurveNode*>& nodes, const LayerMap& /*layers*/,
|
||||||
|
int64_t start, int64_t stop,
|
||||||
|
double& maxTime,
|
||||||
|
double& minTime);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertTranslationKeys(aiNodeAnim* na, const std::vector<const AnimationCurveNode*>& nodes,
|
||||||
|
const LayerMap& /*layers*/,
|
||||||
|
int64_t start, int64_t stop,
|
||||||
|
double& maxTime,
|
||||||
|
double& minTime);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ConvertRotationKeys(aiNodeAnim* na, const std::vector<const AnimationCurveNode*>& nodes,
|
||||||
|
const LayerMap& /*layers*/,
|
||||||
|
int64_t start, int64_t stop,
|
||||||
|
double& maxTime,
|
||||||
|
double& minTime,
|
||||||
|
Model::RotOrder order);
|
||||||
|
|
||||||
|
void ConvertGlobalSettings();
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// copy generated meshes, animations, lights, cameras and textures to the output scene
|
||||||
|
void TransferDataToScene();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// 0: not assigned yet, others: index is value - 1
|
||||||
|
unsigned int defaultMaterialIndex;
|
||||||
|
|
||||||
|
std::vector<aiMesh*> meshes;
|
||||||
|
std::vector<aiMaterial*> materials;
|
||||||
|
std::vector<aiAnimation*> animations;
|
||||||
|
std::vector<aiLight*> lights;
|
||||||
|
std::vector<aiCamera*> cameras;
|
||||||
|
std::vector<aiTexture*> textures;
|
||||||
|
|
||||||
|
typedef std::map<const Material*, unsigned int> MaterialMap;
|
||||||
|
MaterialMap materials_converted;
|
||||||
|
|
||||||
|
typedef std::map<const Video*, unsigned int> VideoMap;
|
||||||
|
VideoMap textures_converted;
|
||||||
|
|
||||||
|
typedef std::map<const Geometry*, std::vector<unsigned int> > MeshMap;
|
||||||
|
MeshMap meshes_converted;
|
||||||
|
|
||||||
|
// fixed node name -> which trafo chain components have animations?
|
||||||
|
typedef std::map<std::string, unsigned int> NodeAnimBitMap;
|
||||||
|
NodeAnimBitMap node_anim_chain_bits;
|
||||||
|
|
||||||
|
// name -> has had its prefix_stripped?
|
||||||
|
typedef std::map<std::string, bool> NodeNameMap;
|
||||||
|
NodeNameMap node_names;
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::string> NameNameMap;
|
||||||
|
NameNameMap renamed_nodes;
|
||||||
|
|
||||||
|
double anim_fps;
|
||||||
|
|
||||||
|
aiScene* const out;
|
||||||
|
const FBX::Document& doc;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -344,14 +345,15 @@ void Document::ReadGlobalSettings()
|
||||||
{
|
{
|
||||||
const Scope& sc = parser.GetRootScope();
|
const Scope& sc = parser.GetRootScope();
|
||||||
const Element* const ehead = sc["GlobalSettings"];
|
const Element* const ehead = sc["GlobalSettings"];
|
||||||
if(!ehead || !ehead->Compound()) {
|
if ( nullptr == ehead || !ehead->Compound() ) {
|
||||||
DOMWarning("no GlobalSettings dictionary found");
|
DOMWarning( "no GlobalSettings dictionary found" );
|
||||||
|
|
||||||
globals.reset(new FileGlobalSettings(*this, std::make_shared<const PropertyTable>()));
|
globals.reset(new FileGlobalSettings(*this, std::make_shared<const PropertyTable>()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const PropertyTable> props = GetPropertyTable(*this, "", *ehead, *ehead->Compound(), true);
|
std::shared_ptr<const PropertyTable> props = GetPropertyTable( *this, "", *ehead, *ehead->Compound(), true );
|
||||||
|
|
||||||
|
//double v = PropertyGet<float>( *props.get(), std::string("UnitScaleFactor"), 1.0 );
|
||||||
|
|
||||||
if(!props) {
|
if(!props) {
|
||||||
DOMError("GlobalSettings dictionary contains no property table");
|
DOMError("GlobalSettings dictionary contains no property table");
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -999,8 +1000,7 @@ typedef std::multimap<uint64_t, const Connection*> ConnectionMap;
|
||||||
|
|
||||||
/** DOM class for global document settings, a single instance per document can
|
/** DOM class for global document settings, a single instance per document can
|
||||||
* be accessed via Document.Globals(). */
|
* be accessed via Document.Globals(). */
|
||||||
class FileGlobalSettings
|
class FileGlobalSettings {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FileGlobalSettings(const Document& doc, std::shared_ptr<const PropertyTable> props);
|
FileGlobalSettings(const Document& doc, std::shared_ptr<const PropertyTable> props);
|
||||||
~FileGlobalSettings();
|
~FileGlobalSettings();
|
||||||
|
@ -1022,8 +1022,8 @@ public:
|
||||||
fbx_simple_property(CoordAxisSign, int, 1)
|
fbx_simple_property(CoordAxisSign, int, 1)
|
||||||
fbx_simple_property(OriginalUpAxis, int, 0)
|
fbx_simple_property(OriginalUpAxis, int, 0)
|
||||||
fbx_simple_property(OriginalUpAxisSign, int, 1)
|
fbx_simple_property(OriginalUpAxisSign, int, 1)
|
||||||
fbx_simple_property(UnitScaleFactor, double, 1)
|
fbx_simple_property(UnitScaleFactor, float, 1)
|
||||||
fbx_simple_property(OriginalUnitScaleFactor, double, 1)
|
fbx_simple_property(OriginalUnitScaleFactor, float, 1)
|
||||||
fbx_simple_property(AmbientColor, aiVector3D, aiVector3D(0,0,0))
|
fbx_simple_property(AmbientColor, aiVector3D, aiVector3D(0,0,0))
|
||||||
fbx_simple_property(DefaultCamera, std::string, "")
|
fbx_simple_property(DefaultCamera, std::string, "")
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ inline const T* ProcessSimpleConnection(const Connection& con,
|
||||||
|
|
||||||
const Object* const ob = con.SourceObject();
|
const Object* const ob = con.SourceObject();
|
||||||
if(!ob) {
|
if(!ob) {
|
||||||
DOMWarning("failed to read source object for incoming" + std::string(name) +
|
DOMWarning("failed to read source object for incoming " + std::string(name) +
|
||||||
" link, ignoring",
|
" link, ignoring",
|
||||||
&element);
|
&element);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2017, assimp team
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -140,8 +141,7 @@ void FBXImporter::SetupProperties(const Importer* pImp)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// 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, aiScene* pScene, IOSystem* pIOHandler)
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
|
||||||
{
|
{
|
||||||
std::unique_ptr<IOStream> stream(pIOHandler->Open(pFile,"rb"));
|
std::unique_ptr<IOStream> stream(pIOHandler->Open(pFile,"rb"));
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue