Merge branch 'master' into improve-msvc-switches
commit
790203ee9d
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
name: Bug report
|
name: Bug report
|
||||||
about: Create a report to help us improve
|
about: Create a report to help us improve
|
||||||
title: ''
|
title: 'Bug:'
|
||||||
labels: ''
|
labels: 'Bug'
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -23,16 +23,10 @@ A clear and concise description of what you expected to happen.
|
||||||
**Screenshots**
|
**Screenshots**
|
||||||
If applicable, add screenshots to help explain your problem.
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
**Desktop (please complete the following information):**
|
**Platform (please complete the following information):**
|
||||||
- OS: [e.g. iOS]
|
- OS: [e.g. iOS]
|
||||||
- Browser [e.g. chrome, safari]
|
- Browser [e.g. chrome, safari]
|
||||||
- Version [e.g. 22]
|
- Version [e.g. 22]
|
||||||
|
|
||||||
**Smartphone (please complete the following information):**
|
|
||||||
- Device: [e.g. iPhone6]
|
|
||||||
- OS: [e.g. iOS8.1]
|
|
||||||
- Browser [e.g. stock browser, safari]
|
|
||||||
- Version [e.g. 22]
|
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context about the problem here.
|
Add any other context about the problem here.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name: Feature request
|
name: Feature request
|
||||||
about: Suggest an idea for this project
|
about: Suggest an idea for this project
|
||||||
title: ''
|
title: ''
|
||||||
labels: ''
|
labels: 'Feature-Request'
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
name: Technical debt
|
||||||
|
about: Create a report to help us to fix and detect tech debts
|
||||||
|
title: ''
|
||||||
|
labels: 'Techdebt'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the technical debt**
|
||||||
|
A clear and concise description of what the tech debt is about.
|
||||||
|
|
||||||
|
**Better solution**
|
||||||
|
A clear and concise description of what you would expect.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS: [e.g. iOS]
|
||||||
|
- Browser [e.g. chrome, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
|
@ -336,9 +336,9 @@ INCLUDE (FindPkgMacros)
|
||||||
INCLUDE (PrecompiledHeader)
|
INCLUDE (PrecompiledHeader)
|
||||||
|
|
||||||
# Set Assimp project output directory variables.
|
# Set Assimp project output directory variables.
|
||||||
SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for runtime output files")
|
||||||
SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for library output files")
|
||||||
SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
|
SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE STRING "Path for archive output files")
|
||||||
|
|
||||||
# Macro used to set the output directories of a target to the
|
# Macro used to set the output directories of a target to the
|
||||||
# respective Assimp output directories.
|
# respective Assimp output directories.
|
||||||
|
@ -529,12 +529,12 @@ ENDIF()
|
||||||
MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER )
|
MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER )
|
||||||
|
|
||||||
SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL
|
SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL
|
||||||
"Build the C4D importer, which relies on the non-free Melange SDK."
|
"Build the C4D importer, which relies on the non-free Cineware SDK."
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||||
IF ( MSVC )
|
IF ( MSVC )
|
||||||
SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/includes")
|
SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/includes")
|
||||||
|
|
||||||
# pick the correct prebuilt library
|
# pick the correct prebuilt library
|
||||||
IF(MSVC15)
|
IF(MSVC15)
|
||||||
|
@ -553,22 +553,23 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||||
)
|
)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/libraries/win")
|
SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/libraries/win")
|
||||||
|
|
||||||
SET(C4D_DEBUG_LIBRARIES
|
SET(C4D_DEBUG_LIBRARIES
|
||||||
"${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_debug.lib"
|
"${C4D_LIB_BASE_PATH}/cinewarelib${C4D_LIB_POSTFIX}/cinewarelib_debug.lib"
|
||||||
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib"
|
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib"
|
||||||
)
|
)
|
||||||
SET(C4D_RELEASE_LIBRARIES
|
SET(C4D_RELEASE_LIBRARIES
|
||||||
"${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_release.lib"
|
"${C4D_LIB_BASE_PATH}/cinewarelib${C4D_LIB_POSTFIX}/cinewarelib_release.lib"
|
||||||
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_release.lib"
|
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_release.lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
# winsock and winmm are necessary dependencies of melange (this is undocumented, but true.)
|
# winsock and winmm are necessary (and undocumented) dependencies of Cineware SDK because
|
||||||
|
# it can be used to communicate with a running Cinema 4D instance
|
||||||
SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib)
|
SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib)
|
||||||
ELSE ()
|
ELSE ()
|
||||||
MESSAGE( FATAL_ERROR
|
MESSAGE( FATAL_ERROR
|
||||||
"C4D is currently only available on Windows with melange SDK installed in contrib/Melange"
|
"C4D is currently only available on Windows with Cineware SDK installed in contrib/Cineware"
|
||||||
)
|
)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ELSE ()
|
ELSE ()
|
||||||
|
|
|
@ -8,10 +8,10 @@ A library to import and export various 3d-model-formats including scene-post-pro
|
||||||
<img alt="Coverity Scan Build Status"
|
<img alt="Coverity Scan Build Status"
|
||||||
src="https://scan.coverity.com/projects/5607/badge.svg"/>
|
src="https://scan.coverity.com/projects/5607/badge.svg"/>
|
||||||
</a>
|
</a>
|
||||||
|
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9973693b7bdd4543b07084d5d9cf4745)](https://www.codacy.com/gh/assimp/assimp/dashboard?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
|
||||||
[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
|
[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
|
||||||
[![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
|
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
|
||||||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5be56faac64f46fc941ac890fb4febef)](https://www.codacy.com/app/kimkulling/assimp?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
|
|
||||||
[![Total alerts](https://img.shields.io/lgtm/alerts/g/assimp/assimp.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/assimp/assimp/alerts/)
|
[![Total alerts](https://img.shields.io/lgtm/alerts/g/assimp/assimp.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/assimp/assimp/alerts/)
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file.
|
||||||
* [.NET](https://bitbucket.org/Starnick/assimpnet/src/master/)
|
* [.NET](https://bitbucket.org/Starnick/assimpnet/src/master/)
|
||||||
* [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://ricardoreis.net/trilib-2/)
|
||||||
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status))
|
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status))
|
||||||
* [HAXE-Port](https://github.com/longde123/assimp-haxe) The Assimp-HAXE-port.
|
* [HAXE-Port](https://github.com/longde123/assimp-haxe) The Assimp-HAXE-port.
|
||||||
* [Rust](https://github.com/jkvargas/russimp)
|
* [Rust](https://github.com/jkvargas/russimp)
|
||||||
|
@ -68,7 +68,7 @@ The source code is organized in the following way:
|
||||||
|
|
||||||
code/Common The base implementation for importers and the infrastructure
|
code/Common The base implementation for importers and the infrastructure
|
||||||
code/PostProcessing The post-processing steps
|
code/PostProcessing The post-processing steps
|
||||||
code/<FormatName> Implementation for import and export for the format
|
code/AssetLib/<FormatName> Implementation for import and export for the format
|
||||||
|
|
||||||
### Where to get help ###
|
### Where to get help ###
|
||||||
For more information, visit [our website](http://assimp.org/). Or check out the `./doc`- folder, which contains the official documentation in HTML format.
|
For more information, visit [our website](http://assimp.org/). Or check out the `./doc`- folder, which contains the official documentation in HTML format.
|
||||||
|
|
|
@ -69,7 +69,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() {
|
||||||
for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) {
|
for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) {
|
||||||
std::string s = mScene->mMaterials[i].mName;
|
std::string s = mScene->mMaterials[i].mName;
|
||||||
for (std::string::iterator it = s.begin(); it != s.end(); ++it) {
|
for (std::string::iterator it = s.begin(); it != s.end(); ++it) {
|
||||||
*it = static_cast<char>(::tolower(*it));
|
*it = static_cast<char>(::tolower(static_cast<unsigned char>(*it)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::string::npos == s.find("default")) continue;
|
if (std::string::npos == s.find("default")) continue;
|
||||||
|
@ -212,7 +212,7 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material &oldMat,
|
||||||
mat.AddProperty(&tex, AI_MATKEY_GLOBAL_BACKGROUND_IMAGE);
|
mat.AddProperty(&tex, AI_MATKEY_GLOBAL_BACKGROUND_IMAGE);
|
||||||
|
|
||||||
// Be sure this is only done for the first material
|
// Be sure this is only done for the first material
|
||||||
mBackgroundImage = std::string("");
|
mBackgroundImage = std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
// At first add the base ambient color of the scene to the material
|
// At first add the base ambient color of the scene to the material
|
||||||
|
|
|
@ -102,13 +102,14 @@ private:
|
||||||
// preserves the mesh's given name if it has one. |index| is the index
|
// preserves the mesh's given name if it has one. |index| is the index
|
||||||
// of the mesh in |aiScene::mMeshes|.
|
// of the mesh in |aiScene::mMeshes|.
|
||||||
std::string GetMeshName(const aiMesh &mesh, unsigned int index, const aiNode &node) {
|
std::string GetMeshName(const aiMesh &mesh, unsigned int index, const aiNode &node) {
|
||||||
static const std::string underscore = "_";
|
static const char underscore = '_';
|
||||||
char postfix[10] = { 0 };
|
char postfix[10] = { 0 };
|
||||||
ASSIMP_itoa10(postfix, index);
|
ASSIMP_itoa10(postfix, index);
|
||||||
|
|
||||||
std::string result = node.mName.C_Str();
|
std::string result = node.mName.C_Str();
|
||||||
if (mesh.mName.length > 0) {
|
if (mesh.mName.length > 0) {
|
||||||
result += underscore + mesh.mName.C_Str();
|
result += underscore;
|
||||||
|
result += mesh.mName.C_Str();
|
||||||
}
|
}
|
||||||
return result + underscore + postfix;
|
return result + underscore + postfix;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +379,7 @@ void Discreet3DSExporter::WriteTexture(const aiMaterial &mat, aiTextureType type
|
||||||
|
|
||||||
// TODO: handle embedded textures properly
|
// TODO: handle embedded textures properly
|
||||||
if (path.data[0] == '*') {
|
if (path.data[0] == '*') {
|
||||||
ASSIMP_LOG_ERROR("Ignoring embedded texture for export: " + std::string(path.C_Str()));
|
ASSIMP_LOG_ERROR("Ignoring embedded texture for export: ", path.C_Str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,20 +61,10 @@ namespace D3DS {
|
||||||
#include <assimp/Compiler/pushpack1.h>
|
#include <assimp/Compiler/pushpack1.h>
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Discreet3DS class: Helper class for loading 3ds files. Defines chunks
|
/** Defines chunks and data structures.
|
||||||
* and data structures.
|
|
||||||
*/
|
*/
|
||||||
class Discreet3DS {
|
namespace Discreet3DS {
|
||||||
private:
|
|
||||||
Discreet3DS() AI_NO_EXCEPT {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
~Discreet3DS() {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
//! data structure for a single chunk in a .3ds file
|
//! data structure for a single chunk in a .3ds file
|
||||||
struct Chunk {
|
struct Chunk {
|
||||||
uint16_t Flag;
|
uint16_t Flag;
|
||||||
|
@ -314,7 +304,7 @@ public:
|
||||||
// camera sub-chunks
|
// camera sub-chunks
|
||||||
CHUNK_CAM_RANGES = 0x4720
|
CHUNK_CAM_RANGES = 0x4720
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure representing a 3ds mesh face */
|
/** Helper structure representing a 3ds mesh face */
|
||||||
|
|
|
@ -143,7 +143,13 @@ void Discreet3DSImporter::SetupProperties(const Importer * /*pImp*/) {
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void Discreet3DSImporter::InternReadFile(const std::string &pFile,
|
void Discreet3DSImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene *pScene, IOSystem *pIOHandler) {
|
aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
StreamReaderLE theStream(pIOHandler->Open(pFile, "rb"));
|
|
||||||
|
auto theFile = pIOHandler->Open(pFile, "rb");
|
||||||
|
if (!theFile) {
|
||||||
|
throw DeadlyImportError("3DS: Could not open ", pFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamReaderLE theStream(theFile);
|
||||||
|
|
||||||
// We should have at least one chunk
|
// We should have at least one chunk
|
||||||
if (theStream.GetRemainingSize() < 16) {
|
if (theStream.GetRemainingSize() < 16) {
|
||||||
|
@ -164,7 +170,7 @@ void Discreet3DSImporter::InternReadFile(const std::string &pFile,
|
||||||
mRootNode->mHierarchyIndex = -1;
|
mRootNode->mHierarchyIndex = -1;
|
||||||
mRootNode->mParent = nullptr;
|
mRootNode->mParent = nullptr;
|
||||||
mMasterScale = 1.0f;
|
mMasterScale = 1.0f;
|
||||||
mBackgroundImage = "";
|
mBackgroundImage = std::string();
|
||||||
bHasBG = false;
|
bHasBG = false;
|
||||||
bIsPrj = false;
|
bIsPrj = false;
|
||||||
|
|
||||||
|
@ -299,7 +305,7 @@ void Discreet3DSImporter::ParseEditorChunk() {
|
||||||
// print the version number
|
// print the version number
|
||||||
char buff[10];
|
char buff[10];
|
||||||
ASSIMP_itoa10(buff, stream->GetI2());
|
ASSIMP_itoa10(buff, stream->GetI2());
|
||||||
ASSIMP_LOG_INFO_F(std::string("3DS file format version: "), buff);
|
ASSIMP_LOG_INFO("3DS file format version: ", buff);
|
||||||
} break;
|
} break;
|
||||||
};
|
};
|
||||||
ASSIMP_3DS_END_CHUNK();
|
ASSIMP_3DS_END_CHUNK();
|
||||||
|
@ -928,7 +934,7 @@ void Discreet3DSImporter::ParseFaceChunk() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0xcdcdcdcd == idx) {
|
if (0xcdcdcdcd == idx) {
|
||||||
ASSIMP_LOG_ERROR_F("3DS: Unknown material: ", sz);
|
ASSIMP_LOG_ERROR("3DS: Unknown material: ", sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now continue and read all material indices
|
// Now continue and read all material indices
|
||||||
|
@ -981,9 +987,9 @@ void Discreet3DSImporter::ParseMeshChunk() {
|
||||||
mMesh.mMat.a3 = stream->GetF4();
|
mMesh.mMat.a3 = stream->GetF4();
|
||||||
mMesh.mMat.b3 = stream->GetF4();
|
mMesh.mMat.b3 = stream->GetF4();
|
||||||
mMesh.mMat.c3 = stream->GetF4();
|
mMesh.mMat.c3 = stream->GetF4();
|
||||||
mMesh.mMat.d1 = stream->GetF4();
|
mMesh.mMat.a4 = stream->GetF4();
|
||||||
mMesh.mMat.d2 = stream->GetF4();
|
mMesh.mMat.b4 = stream->GetF4();
|
||||||
mMesh.mMat.d3 = stream->GetF4();
|
mMesh.mMat.c4 = stream->GetF4();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Discreet3DS::CHUNK_MAPLIST: {
|
case Discreet3DS::CHUNK_MAPLIST: {
|
||||||
|
|
|
@ -44,63 +44,66 @@ namespace Assimp {
|
||||||
namespace D3MF {
|
namespace D3MF {
|
||||||
|
|
||||||
namespace XmlTag {
|
namespace XmlTag {
|
||||||
|
// Root tag
|
||||||
|
const char* const RootTag = "3MF";
|
||||||
|
|
||||||
// Meta-data
|
// Meta-data
|
||||||
static const std::string meta = "metadata";
|
const char* const meta = "metadata";
|
||||||
static const std::string meta_name = "name";
|
const char* const meta_name = "name";
|
||||||
|
|
||||||
// Model-data specific tags
|
// Model-data specific tags
|
||||||
static const std::string model = "model";
|
const char* const model = "model";
|
||||||
static const std::string model_unit = "unit";
|
const char* const model_unit = "unit";
|
||||||
static const std::string metadata = "metadata";
|
const char* const metadata = "metadata";
|
||||||
static const std::string resources = "resources";
|
const char* const resources = "resources";
|
||||||
static const std::string object = "object";
|
const char* const object = "object";
|
||||||
static const std::string mesh = "mesh";
|
const char* const mesh = "mesh";
|
||||||
static const std::string components = "components";
|
const char* const components = "components";
|
||||||
static const std::string component = "component";
|
const char* const component = "component";
|
||||||
static const std::string vertices = "vertices";
|
const char* const vertices = "vertices";
|
||||||
static const std::string vertex = "vertex";
|
const char* const vertex = "vertex";
|
||||||
static const std::string triangles = "triangles";
|
const char* const triangles = "triangles";
|
||||||
static const std::string triangle = "triangle";
|
const char* const triangle = "triangle";
|
||||||
static const std::string x = "x";
|
const char* const x = "x";
|
||||||
static const std::string y = "y";
|
const char* const y = "y";
|
||||||
static const std::string z = "z";
|
const char* const z = "z";
|
||||||
static const std::string v1 = "v1";
|
const char* const v1 = "v1";
|
||||||
static const std::string v2 = "v2";
|
const char* const v2 = "v2";
|
||||||
static const std::string v3 = "v3";
|
const char* const v3 = "v3";
|
||||||
static const std::string id = "id";
|
const char* const id = "id";
|
||||||
static const std::string pid = "pid";
|
const char* const pid = "pid";
|
||||||
static const std::string pindex = "pindex";
|
const char* const pindex = "pindex";
|
||||||
static const std::string p1 = "p1";
|
const char* const p1 = "p1";
|
||||||
static const std::string name = "name";
|
const char* const name = "name";
|
||||||
static const std::string type = "type";
|
const char* const type = "type";
|
||||||
static const std::string build = "build";
|
const char* const build = "build";
|
||||||
static const std::string item = "item";
|
const char* const item = "item";
|
||||||
static const std::string objectid = "objectid";
|
const char* const objectid = "objectid";
|
||||||
static const std::string transform = "transform";
|
const char* const transform = "transform";
|
||||||
|
|
||||||
// Material definitions
|
// Material definitions
|
||||||
static const std::string basematerials = "basematerials";
|
const char* const basematerials = "basematerials";
|
||||||
static const std::string basematerials_id = "id";
|
const char* const basematerials_id = "id";
|
||||||
static const std::string basematerials_base = "base";
|
const char* const basematerials_base = "base";
|
||||||
static const std::string basematerials_name = "name";
|
const char* const basematerials_name = "name";
|
||||||
static const std::string basematerials_displaycolor = "displaycolor";
|
const char* const basematerials_displaycolor = "displaycolor";
|
||||||
|
|
||||||
// Meta info tags
|
// Meta info tags
|
||||||
static const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml";
|
const char* const CONTENT_TYPES_ARCHIVE = "[Content_Types].xml";
|
||||||
static const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels";
|
const char* const ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels";
|
||||||
static const std::string SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
|
const char* const SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
|
||||||
static const std::string SCHEMA_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
const char* const SCHEMA_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
||||||
static const std::string RELS_RELATIONSHIP_CONTAINER = "Relationships";
|
const char* const RELS_RELATIONSHIP_CONTAINER = "Relationships";
|
||||||
static const std::string RELS_RELATIONSHIP_NODE = "Relationship";
|
const char* const RELS_RELATIONSHIP_NODE = "Relationship";
|
||||||
static const std::string RELS_ATTRIB_TARGET = "Target";
|
const char* const RELS_ATTRIB_TARGET = "Target";
|
||||||
static const std::string RELS_ATTRIB_TYPE = "Type";
|
const char* const RELS_ATTRIB_TYPE = "Type";
|
||||||
static const std::string RELS_ATTRIB_ID = "Id";
|
const char* const RELS_ATTRIB_ID = "Id";
|
||||||
static const std::string PACKAGE_START_PART_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel";
|
const char* const PACKAGE_START_PART_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel";
|
||||||
static const std::string PACKAGE_PRINT_TICKET_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket";
|
const char* const PACKAGE_PRINT_TICKET_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket";
|
||||||
static const std::string PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture";
|
const char* const PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture";
|
||||||
static const std::string PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
const char* const PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
||||||
static const std::string PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
|
const char* const PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace D3MF
|
} // Namespace D3MF
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
|
@ -307,18 +307,26 @@ void D3MFExporter::writeMesh(aiMesh *mesh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mModelOutput << "<" << XmlTag::mesh << ">" << std::endl;
|
mModelOutput << "<"
|
||||||
mModelOutput << "<" << XmlTag::vertices << ">" << std::endl;
|
<< XmlTag::mesh
|
||||||
|
<< ">" << "\n";
|
||||||
|
mModelOutput << "<"
|
||||||
|
<< XmlTag::vertices
|
||||||
|
<< ">" << "\n";
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
||||||
writeVertex(mesh->mVertices[i]);
|
writeVertex(mesh->mVertices[i]);
|
||||||
}
|
}
|
||||||
mModelOutput << "</" << XmlTag::vertices << ">" << std::endl;
|
mModelOutput << "</"
|
||||||
|
<< XmlTag::vertices << ">"
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
const unsigned int matIdx(mesh->mMaterialIndex);
|
const unsigned int matIdx(mesh->mMaterialIndex);
|
||||||
|
|
||||||
writeFaces(mesh, matIdx);
|
writeFaces(mesh, matIdx);
|
||||||
|
|
||||||
mModelOutput << "</" << XmlTag::mesh << ">" << std::endl;
|
mModelOutput << "</"
|
||||||
|
<< XmlTag::mesh << ">"
|
||||||
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFExporter::writeVertex(const aiVector3D &pos) {
|
void D3MFExporter::writeVertex(const aiVector3D &pos) {
|
||||||
|
@ -334,27 +342,34 @@ void D3MFExporter::writeFaces(aiMesh *mesh, unsigned int matIdx) {
|
||||||
if (!mesh->HasFaces()) {
|
if (!mesh->HasFaces()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mModelOutput << "<" << XmlTag::triangles << ">" << std::endl;
|
mModelOutput << "<"
|
||||||
|
<< XmlTag::triangles << ">"
|
||||||
|
<< "\n";
|
||||||
for (unsigned int i = 0; i < mesh->mNumFaces; ++i) {
|
for (unsigned int i = 0; i < mesh->mNumFaces; ++i) {
|
||||||
aiFace ¤tFace = mesh->mFaces[i];
|
aiFace ¤tFace = mesh->mFaces[i];
|
||||||
mModelOutput << "<" << XmlTag::triangle << " v1=\"" << currentFace.mIndices[0] << "\" v2=\""
|
mModelOutput << "<" << XmlTag::triangle << " v1=\"" << currentFace.mIndices[0] << "\" v2=\""
|
||||||
<< currentFace.mIndices[1] << "\" v3=\"" << currentFace.mIndices[2]
|
<< currentFace.mIndices[1] << "\" v3=\"" << currentFace.mIndices[2]
|
||||||
<< "\" pid=\"1\" p1=\"" + ai_to_string(matIdx) + "\" />";
|
<< "\" pid=\"1\" p1=\"" + ai_to_string(matIdx) + "\" />";
|
||||||
mModelOutput << std::endl;
|
mModelOutput << "\n";
|
||||||
}
|
}
|
||||||
mModelOutput << "</" << XmlTag::triangles << ">";
|
mModelOutput << "</"
|
||||||
mModelOutput << std::endl;
|
<< XmlTag::triangles
|
||||||
|
<< ">";
|
||||||
|
mModelOutput << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFExporter::writeBuild() {
|
void D3MFExporter::writeBuild() {
|
||||||
mModelOutput << "<" << XmlTag::build << ">" << std::endl;
|
mModelOutput << "<"
|
||||||
|
<< XmlTag::build
|
||||||
|
<< ">"
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
for (size_t i = 0; i < mBuildItems.size(); ++i) {
|
for (size_t i = 0; i < mBuildItems.size(); ++i) {
|
||||||
mModelOutput << "<" << XmlTag::item << " objectid=\"" << i + 2 << "\"/>";
|
mModelOutput << "<" << XmlTag::item << " objectid=\"" << i + 2 << "\"/>";
|
||||||
mModelOutput << std::endl;
|
mModelOutput << "\n";
|
||||||
}
|
}
|
||||||
mModelOutput << "</" << XmlTag::build << ">";
|
mModelOutput << "</" << XmlTag::build << ">";
|
||||||
mModelOutput << std::endl;
|
mModelOutput << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFExporter::zipContentType(const std::string &filename) {
|
void D3MFExporter::zipContentType(const std::string &filename) {
|
||||||
|
|
|
@ -42,6 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
|
||||||
|
|
||||||
#include "D3MFImporter.h"
|
#include "D3MFImporter.h"
|
||||||
|
#include "3MFXmlTags.h"
|
||||||
|
#include "D3MFOpcPackage.h"
|
||||||
|
|
||||||
#include <assimp/StringComparison.h>
|
#include <assimp/StringComparison.h>
|
||||||
#include <assimp/StringUtils.h>
|
#include <assimp/StringUtils.h>
|
||||||
|
@ -51,17 +53,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
#include <assimp/fast_atof.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "3MFXmlTags.h"
|
|
||||||
#include "D3MFOpcPackage.h"
|
|
||||||
#include <assimp/fast_atof.h>
|
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace D3MF {
|
namespace D3MF {
|
||||||
|
@ -72,32 +72,39 @@ enum class ResourceType {
|
||||||
RT_Unknown
|
RT_Unknown
|
||||||
}; // To be extended with other resource types (eg. material extension resources like Texture2d, Texture2dGroup...)
|
}; // To be extended with other resource types (eg. material extension resources like Texture2d, Texture2dGroup...)
|
||||||
|
|
||||||
class Resource
|
class Resource {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Resource(int id) :
|
|
||||||
mId(id) {}
|
|
||||||
|
|
||||||
virtual ~Resource() {}
|
|
||||||
|
|
||||||
int mId;
|
int mId;
|
||||||
|
|
||||||
virtual ResourceType getType() {
|
Resource(int id) :
|
||||||
|
mId(id) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~Resource() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ResourceType getType() const {
|
||||||
return ResourceType::RT_Unknown;
|
return ResourceType::RT_Unknown;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class BaseMaterials : public Resource {
|
class BaseMaterials : public Resource {
|
||||||
public:
|
public:
|
||||||
BaseMaterials(int id) :
|
|
||||||
Resource(id),
|
|
||||||
mMaterials(),
|
|
||||||
mMaterialIndex() {}
|
|
||||||
|
|
||||||
std::vector<aiMaterial *> mMaterials;
|
std::vector<aiMaterial *> mMaterials;
|
||||||
std::vector<unsigned int> mMaterialIndex;
|
std::vector<unsigned int> mMaterialIndex;
|
||||||
|
|
||||||
virtual ResourceType getType() {
|
BaseMaterials(int id) :
|
||||||
|
Resource(id),
|
||||||
|
mMaterials(),
|
||||||
|
mMaterialIndex() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
~BaseMaterials() = default;
|
||||||
|
|
||||||
|
ResourceType getType() const override {
|
||||||
return ResourceType::RT_BaseMaterials;
|
return ResourceType::RT_BaseMaterials;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -109,24 +116,26 @@ struct Component {
|
||||||
|
|
||||||
class Object : public Resource {
|
class Object : public Resource {
|
||||||
public:
|
public:
|
||||||
std::vector<aiMesh*> mMeshes;
|
std::vector<aiMesh *> mMeshes;
|
||||||
std::vector<unsigned int> mMeshIndex;
|
std::vector<unsigned int> mMeshIndex;
|
||||||
std::vector<Component> mComponents;
|
std::vector<Component> mComponents;
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
Object(int id) :
|
Object(int id) :
|
||||||
Resource(id),
|
Resource(id),
|
||||||
mName(std::string("Object_") + ai_to_string(id)) {}
|
mName(std::string("Object_") + ai_to_string(id)) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
virtual ResourceType getType() {
|
~Object() = default;
|
||||||
|
|
||||||
|
ResourceType getType() const override {
|
||||||
return ResourceType::RT_Object;
|
return ResourceType::RT_Object;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class XmlSerializer {
|
class XmlSerializer {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
XmlSerializer(XmlParser *xmlParser) :
|
XmlSerializer(XmlParser *xmlParser) :
|
||||||
mResourcesDictionnary(),
|
mResourcesDictionnary(),
|
||||||
mMaterialCount(0),
|
mMaterialCount(0),
|
||||||
|
@ -136,7 +145,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
~XmlSerializer() {
|
~XmlSerializer() {
|
||||||
for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); it++) {
|
for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it ) {
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,28 +155,28 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scene->mRootNode = new aiNode("3MF");
|
scene->mRootNode = new aiNode(XmlTag::RootTag);
|
||||||
|
|
||||||
XmlNode node = mXmlParser->getRootNode().child("model");
|
XmlNode node = mXmlParser->getRootNode().child(XmlTag::model);
|
||||||
if (node.empty()) {
|
if (node.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XmlNode resNode = node.child("resources");
|
XmlNode resNode = node.child(XmlTag::resources);
|
||||||
for (XmlNode currentNode = resNode.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
for (auto ¤tNode : resNode.children()) {
|
||||||
const std::string ¤tNodeName = currentNode.name();
|
const std::string currentNodeName = currentNode.name();
|
||||||
if (currentNodeName == D3MF::XmlTag::object) {
|
if (currentNodeName == XmlTag::object) {
|
||||||
ReadObject(currentNode);;
|
ReadObject(currentNode);
|
||||||
} else if (currentNodeName == D3MF::XmlTag::basematerials) {
|
} else if (currentNodeName == XmlTag::basematerials) {
|
||||||
ReadBaseMaterials(currentNode);
|
ReadBaseMaterials(currentNode);
|
||||||
} else if (currentNodeName == D3MF::XmlTag::meta) {
|
} else if (currentNodeName == XmlTag::meta) {
|
||||||
ReadMetadata(currentNode);
|
ReadMetadata(currentNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNode buildNode = node.child("build");
|
XmlNode buildNode = node.child(XmlTag::build);
|
||||||
for (XmlNode currentNode = buildNode.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
for (auto ¤tNode : buildNode.children()) {
|
||||||
const std::string ¤tNodeName = currentNode.name();
|
const std::string currentNodeName = currentNode.name();
|
||||||
if (currentNodeName == D3MF::XmlTag::item) {
|
if (currentNodeName == XmlTag::item) {
|
||||||
int objectId = -1;
|
int objectId = -1;
|
||||||
std::string transformationMatrixStr;
|
std::string transformationMatrixStr;
|
||||||
aiMatrix4x4 transformationMatrix;
|
aiMatrix4x4 transformationMatrix;
|
||||||
|
@ -186,10 +195,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// import the metadata
|
// import the metadata
|
||||||
if (!mMetaData.empty()) {
|
if (!mMetaData.empty()) {
|
||||||
const size_t numMeta(mMetaData.size());
|
const size_t numMeta = mMetaData.size();
|
||||||
scene->mMetaData = aiMetadata::Alloc(static_cast<unsigned int>(numMeta));
|
scene->mMetaData = aiMetadata::Alloc(static_cast<unsigned int>(numMeta));
|
||||||
for (size_t i = 0; i < numMeta; ++i) {
|
for (size_t i = 0; i < numMeta; ++i) {
|
||||||
aiString val(mMetaData[i].value);
|
aiString val(mMetaData[i].value);
|
||||||
|
@ -201,9 +209,10 @@ public:
|
||||||
scene->mNumMeshes = static_cast<unsigned int>(mMeshCount);
|
scene->mNumMeshes = static_cast<unsigned int>(mMeshCount);
|
||||||
if (scene->mNumMeshes != 0) {
|
if (scene->mNumMeshes != 0) {
|
||||||
scene->mMeshes = new aiMesh *[scene->mNumMeshes]();
|
scene->mMeshes = new aiMesh *[scene->mNumMeshes]();
|
||||||
for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); it++) {
|
for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it) {
|
||||||
if (it->second->getType() == ResourceType::RT_Object) {
|
if (it->second->getType() == ResourceType::RT_Object) {
|
||||||
Object *obj = static_cast<Object*>(it->second);
|
Object *obj = static_cast<Object *>(it->second);
|
||||||
|
ai_assert(nullptr != obj);
|
||||||
for (unsigned int i = 0; i < obj->mMeshes.size(); ++i) {
|
for (unsigned int i = 0; i < obj->mMeshes.size(); ++i) {
|
||||||
scene->mMeshes[obj->mMeshIndex[i]] = obj->mMeshes[i];
|
scene->mMeshes[obj->mMeshIndex[i]] = obj->mMeshes[i];
|
||||||
}
|
}
|
||||||
|
@ -211,12 +220,11 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// import the materials
|
// import the materials
|
||||||
scene->mNumMaterials = static_cast<unsigned int>(mMaterialCount);
|
scene->mNumMaterials = mMaterialCount;
|
||||||
if (scene->mNumMaterials != 0) {
|
if (scene->mNumMaterials != 0) {
|
||||||
scene->mMaterials = new aiMaterial *[scene->mNumMaterials];
|
scene->mMaterials = new aiMaterial *[scene->mNumMaterials];
|
||||||
for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); it++) {
|
for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it) {
|
||||||
if (it->second->getType() == ResourceType::RT_BaseMaterials) {
|
if (it->second->getType() == ResourceType::RT_BaseMaterials) {
|
||||||
BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
|
BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
|
||||||
for (unsigned int i = 0; i < baseMaterials->mMaterials.size(); ++i) {
|
for (unsigned int i = 0; i < baseMaterials->mMaterials.size(); ++i) {
|
||||||
|
@ -228,35 +236,36 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void addObjectToNode(aiNode *parent, Object *obj, aiMatrix4x4 nodeTransform) {
|
||||||
|
ai_assert(nullptr != obj);
|
||||||
|
|
||||||
void addObjectToNode(aiNode* parent, Object* obj, aiMatrix4x4 nodeTransform) {
|
|
||||||
aiNode *sceneNode = new aiNode(obj->mName);
|
aiNode *sceneNode = new aiNode(obj->mName);
|
||||||
sceneNode->mNumMeshes = static_cast<unsigned int>(obj->mMeshes.size());
|
sceneNode->mNumMeshes = static_cast<unsigned int>(obj->mMeshes.size());
|
||||||
sceneNode->mMeshes = new unsigned int[sceneNode->mNumMeshes];
|
sceneNode->mMeshes = new unsigned int[sceneNode->mNumMeshes];
|
||||||
std::copy(obj->mMeshIndex.begin(), obj->mMeshIndex.end(), sceneNode->mMeshes);
|
std::copy(obj->mMeshIndex.begin(), obj->mMeshIndex.end(), sceneNode->mMeshes);
|
||||||
|
|
||||||
sceneNode->mTransformation = nodeTransform;
|
sceneNode->mTransformation = nodeTransform;
|
||||||
|
if (nullptr != parent) {
|
||||||
parent->addChildren(1, &sceneNode);
|
parent->addChildren(1, &sceneNode);
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < obj->mComponents.size(); ++i) {
|
for (size_t i = 0; i < obj->mComponents.size(); ++i) {
|
||||||
Component c = obj->mComponents[i];
|
Component c = obj->mComponents[i];
|
||||||
auto it = mResourcesDictionnary.find(c.mObjectId);
|
auto it = mResourcesDictionnary.find(c.mObjectId);
|
||||||
if (it != mResourcesDictionnary.end() && it->second->getType() == ResourceType::RT_Object) {
|
if (it != mResourcesDictionnary.end() && it->second->getType() == ResourceType::RT_Object) {
|
||||||
addObjectToNode(sceneNode, static_cast<Object*>(it->second), c.mTransformation);
|
addObjectToNode(sceneNode, static_cast<Object *>(it->second), c.mTransformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getNodeAttribute(const XmlNode& node, const std::string& attribute, std::string& value) {
|
bool getNodeAttribute(const XmlNode &node, const std::string &attribute, std::string &value) {
|
||||||
pugi::xml_attribute objectAttribute = node.attribute(attribute.c_str());
|
pugi::xml_attribute objectAttribute = node.attribute(attribute.c_str());
|
||||||
if (!objectAttribute.empty()) {
|
if (!objectAttribute.empty()) {
|
||||||
value = objectAttribute.as_string();
|
value = objectAttribute.as_string();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getNodeAttribute(const XmlNode &node, const std::string &attribute, int &value) {
|
bool getNodeAttribute(const XmlNode &node, const std::string &attribute, int &value) {
|
||||||
|
@ -265,9 +274,9 @@ private:
|
||||||
if (ret) {
|
if (ret) {
|
||||||
value = std::atoi(strValue.c_str());
|
value = std::atoi(strValue.c_str());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMatrix4x4 parseTransformMatrix(std::string matrixStr) {
|
aiMatrix4x4 parseTransformMatrix(std::string matrixStr) {
|
||||||
|
@ -287,7 +296,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentNumber.size() > 0) {
|
if (currentNumber.size() > 0) {
|
||||||
float f = std::stof(currentNumber);
|
const float f = std::stof(currentNumber);
|
||||||
numbers.push_back(f);
|
numbers.push_back(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,29 +320,26 @@ private:
|
||||||
transformMatrix.b4 = numbers[10];
|
transformMatrix.b4 = numbers[10];
|
||||||
transformMatrix.c4 = numbers[11];
|
transformMatrix.c4 = numbers[11];
|
||||||
transformMatrix.d4 = 1;
|
transformMatrix.d4 = 1;
|
||||||
|
|
||||||
return transformMatrix;
|
return transformMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadObject(XmlNode &node) {
|
void ReadObject(XmlNode &node) {
|
||||||
int id = -1, pid = -1, pindex = -1;
|
int id = -1, pid = -1, pindex = -1;
|
||||||
bool hasId = getNodeAttribute(node, D3MF::XmlTag::id, id);
|
bool hasId = getNodeAttribute(node, XmlTag::id, id);
|
||||||
//bool hasType = getNodeAttribute(node, D3MF::XmlTag::type, type); not used currently
|
bool hasPid = getNodeAttribute(node, XmlTag::pid, pid);
|
||||||
bool hasPid = getNodeAttribute(node, D3MF::XmlTag::pid, pid);
|
bool hasPindex = getNodeAttribute(node, XmlTag::pindex, pindex);
|
||||||
bool hasPindex = getNodeAttribute(node, D3MF::XmlTag::pindex, pindex);
|
|
||||||
|
|
||||||
std::string idStr = ai_to_string(id);
|
|
||||||
|
|
||||||
if (!hasId) {
|
if (!hasId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *obj = new Object(id);
|
Object *obj = new Object(id);
|
||||||
|
|
||||||
for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
for (XmlNode ¤tNode : node.children()) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
if (currentName == D3MF::XmlTag::mesh) {
|
if (currentName == D3MF::XmlTag::mesh) {
|
||||||
auto mesh = ReadMesh(currentNode);
|
auto mesh = ReadMesh(currentNode);
|
||||||
mesh->mName.Set(idStr);
|
mesh->mName.Set(ai_to_string(id));
|
||||||
|
|
||||||
if (hasPid) {
|
if (hasPid) {
|
||||||
auto it = mResourcesDictionnary.find(pid);
|
auto it = mResourcesDictionnary.find(pid);
|
||||||
|
@ -347,8 +353,9 @@ private:
|
||||||
obj->mMeshIndex.push_back(mMeshCount);
|
obj->mMeshIndex.push_back(mMeshCount);
|
||||||
mMeshCount++;
|
mMeshCount++;
|
||||||
} else if (currentName == D3MF::XmlTag::components) {
|
} else if (currentName == D3MF::XmlTag::components) {
|
||||||
for (XmlNode currentSubNode = currentNode.first_child(); currentSubNode; currentSubNode = currentSubNode.next_sibling()) {
|
for (XmlNode ¤tSubNode : currentNode.children()) {
|
||||||
if (currentSubNode.name() == D3MF::XmlTag::component) {
|
const std::string subNodeName = currentSubNode.name();
|
||||||
|
if (subNodeName == D3MF::XmlTag::component) {
|
||||||
int objectId = -1;
|
int objectId = -1;
|
||||||
std::string componentTransformStr;
|
std::string componentTransformStr;
|
||||||
aiMatrix4x4 componentTransform;
|
aiMatrix4x4 componentTransform;
|
||||||
|
@ -356,12 +363,13 @@ private:
|
||||||
componentTransform = parseTransformMatrix(componentTransformStr);
|
componentTransform = parseTransformMatrix(componentTransformStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getNodeAttribute(currentSubNode, D3MF::XmlTag::objectid, objectId))
|
if (getNodeAttribute(currentSubNode, D3MF::XmlTag::objectid, objectId)) {
|
||||||
obj->mComponents.push_back({ objectId, componentTransform });
|
obj->mComponents.push_back({ objectId, componentTransform });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mResourcesDictionnary.insert(std::make_pair(id, obj));
|
mResourcesDictionnary.insert(std::make_pair(id, obj));
|
||||||
}
|
}
|
||||||
|
@ -369,21 +377,20 @@ private:
|
||||||
aiMesh *ReadMesh(XmlNode &node) {
|
aiMesh *ReadMesh(XmlNode &node) {
|
||||||
aiMesh *mesh = new aiMesh();
|
aiMesh *mesh = new aiMesh();
|
||||||
|
|
||||||
for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
for (XmlNode ¤tNode : node.children()) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string currentName = currentNode.name();
|
||||||
if (currentName == D3MF::XmlTag::vertices) {
|
if (currentName == XmlTag::vertices) {
|
||||||
ImportVertices(currentNode, mesh);
|
ImportVertices(currentNode, mesh);
|
||||||
} else if (currentName == D3MF::XmlTag::triangles) {
|
} else if (currentName == XmlTag::triangles) {
|
||||||
ImportTriangles(currentNode, mesh);
|
ImportTriangles(currentNode, mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadMetadata(XmlNode &node) {
|
void ReadMetadata(XmlNode &node) {
|
||||||
pugi::xml_attribute attribute = node.attribute(D3MF::XmlTag::meta_name.c_str());
|
pugi::xml_attribute attribute = node.attribute(D3MF::XmlTag::meta_name);
|
||||||
const std::string name = attribute.as_string();
|
const std::string name = attribute.as_string();
|
||||||
const std::string value = node.value();
|
const std::string value = node.value();
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
|
@ -398,9 +405,9 @@ private:
|
||||||
|
|
||||||
void ImportVertices(XmlNode &node, aiMesh *mesh) {
|
void ImportVertices(XmlNode &node, aiMesh *mesh) {
|
||||||
std::vector<aiVector3D> vertices;
|
std::vector<aiVector3D> vertices;
|
||||||
for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
for (XmlNode ¤tNode : node.children()) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string currentName = currentNode.name();
|
||||||
if (currentName == D3MF::XmlTag::vertex) {
|
if (currentName == XmlTag::vertex) {
|
||||||
vertices.push_back(ReadVertex(currentNode));
|
vertices.push_back(ReadVertex(currentNode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,29 +419,28 @@ private:
|
||||||
|
|
||||||
aiVector3D ReadVertex(XmlNode &node) {
|
aiVector3D ReadVertex(XmlNode &node) {
|
||||||
aiVector3D vertex;
|
aiVector3D vertex;
|
||||||
vertex.x = ai_strtof(node.attribute(D3MF::XmlTag::x.c_str()).as_string(), nullptr);
|
vertex.x = ai_strtof(node.attribute(XmlTag::x).as_string(), nullptr);
|
||||||
vertex.y = ai_strtof(node.attribute(D3MF::XmlTag::y.c_str()).as_string(), nullptr);
|
vertex.y = ai_strtof(node.attribute(XmlTag::y).as_string(), nullptr);
|
||||||
vertex.z = ai_strtof(node.attribute(D3MF::XmlTag::z.c_str()).as_string(), nullptr);
|
vertex.z = ai_strtof(node.attribute(XmlTag::z).as_string(), nullptr);
|
||||||
|
|
||||||
return vertex;
|
return vertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportTriangles(XmlNode &node, aiMesh *mesh) {
|
void ImportTriangles(XmlNode &node, aiMesh *mesh) {
|
||||||
std::vector<aiFace> faces;
|
std::vector<aiFace> faces;
|
||||||
for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
for (XmlNode ¤tNode : node.children()) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string currentName = currentNode.name();
|
||||||
if (currentName == D3MF::XmlTag::triangle) {
|
if (currentName == XmlTag::triangle) {
|
||||||
aiFace face = ReadTriangle(currentNode);
|
aiFace face = ReadTriangle(currentNode);
|
||||||
faces.push_back(face);
|
faces.push_back(face);
|
||||||
|
|
||||||
int pid = 0, p1;
|
int pid = 0, p1 = 0;
|
||||||
bool hasPid = getNodeAttribute(currentNode, D3MF::XmlTag::pid, pid);
|
bool hasPid = getNodeAttribute(currentNode, D3MF::XmlTag::pid, pid);
|
||||||
bool hasP1 = getNodeAttribute(currentNode, D3MF::XmlTag::p1, p1);
|
bool hasP1 = getNodeAttribute(currentNode, D3MF::XmlTag::p1, p1);
|
||||||
|
|
||||||
if (hasPid && hasP1) {
|
if (hasPid && hasP1) {
|
||||||
auto it = mResourcesDictionnary.find(pid);
|
auto it = mResourcesDictionnary.find(pid);
|
||||||
if (it != mResourcesDictionnary.end())
|
if (it != mResourcesDictionnary.end()) {
|
||||||
{
|
|
||||||
if (it->second->getType() == ResourceType::RT_BaseMaterials) {
|
if (it->second->getType() == ResourceType::RT_BaseMaterials) {
|
||||||
BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
|
BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
|
||||||
mesh->mMaterialIndex = baseMaterials->mMaterialIndex[p1];
|
mesh->mMaterialIndex = baseMaterials->mMaterialIndex[p1];
|
||||||
|
@ -457,9 +463,9 @@ private:
|
||||||
|
|
||||||
face.mNumIndices = 3;
|
face.mNumIndices = 3;
|
||||||
face.mIndices = new unsigned int[face.mNumIndices];
|
face.mIndices = new unsigned int[face.mNumIndices];
|
||||||
face.mIndices[0] = static_cast<unsigned int>(std::atoi(node.attribute(D3MF::XmlTag::v1.c_str()).as_string()));
|
face.mIndices[0] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v1).as_string()));
|
||||||
face.mIndices[1] = static_cast<unsigned int>(std::atoi(node.attribute(D3MF::XmlTag::v2.c_str()).as_string()));
|
face.mIndices[1] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v2).as_string()));
|
||||||
face.mIndices[2] = static_cast<unsigned int>(std::atoi(node.attribute(D3MF::XmlTag::v3.c_str()).as_string()));
|
face.mIndices[2] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v3).as_string()));
|
||||||
|
|
||||||
return face;
|
return face;
|
||||||
}
|
}
|
||||||
|
@ -467,14 +473,14 @@ private:
|
||||||
void ReadBaseMaterials(XmlNode &node) {
|
void ReadBaseMaterials(XmlNode &node) {
|
||||||
int id = -1;
|
int id = -1;
|
||||||
if (getNodeAttribute(node, D3MF::XmlTag::basematerials_id, id)) {
|
if (getNodeAttribute(node, D3MF::XmlTag::basematerials_id, id)) {
|
||||||
BaseMaterials* baseMaterials = new BaseMaterials(id);
|
BaseMaterials *baseMaterials = new BaseMaterials(id);
|
||||||
|
|
||||||
for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling())
|
for (XmlNode ¤tNode : node.children()) {
|
||||||
{
|
const std::string currentName = currentNode.name();
|
||||||
if (currentNode.name() == D3MF::XmlTag::basematerials_base) {
|
if (currentName == XmlTag::basematerials_base) {
|
||||||
baseMaterials->mMaterialIndex.push_back(mMaterialCount);
|
baseMaterials->mMaterialIndex.push_back(mMaterialCount);
|
||||||
baseMaterials->mMaterials.push_back(readMaterialDef(currentNode, id));
|
baseMaterials->mMaterials.push_back(readMaterialDef(currentNode, id));
|
||||||
mMaterialCount++;
|
++mMaterialCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +494,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
//format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
|
//format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
|
||||||
const size_t len(strlen(color));
|
const size_t len = strlen(color);
|
||||||
if (9 != len && 7 != len) {
|
if (9 != len && 7 != len) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +523,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void assignDiffuseColor(XmlNode &node, aiMaterial *mat) {
|
void assignDiffuseColor(XmlNode &node, aiMaterial *mat) {
|
||||||
const char *color = node.attribute(D3MF::XmlTag::basematerials_displaycolor.c_str()).as_string();
|
const char *color = node.attribute(XmlTag::basematerials_displaycolor).as_string();
|
||||||
aiColor4D diffuse;
|
aiColor4D diffuse;
|
||||||
if (parseColor(color, diffuse)) {
|
if (parseColor(color, diffuse)) {
|
||||||
mat->AddProperty<aiColor4D>(&diffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
mat->AddProperty<aiColor4D>(&diffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||||
|
@ -531,7 +537,7 @@ private:
|
||||||
bool hasName = getNodeAttribute(node, D3MF::XmlTag::basematerials_name, name);
|
bool hasName = getNodeAttribute(node, D3MF::XmlTag::basematerials_name, name);
|
||||||
|
|
||||||
std::string stdMaterialName;
|
std::string stdMaterialName;
|
||||||
std::string strId(ai_to_string(basematerialsId));
|
const std::string strId(ai_to_string(basematerialsId));
|
||||||
stdMaterialName += "id";
|
stdMaterialName += "id";
|
||||||
stdMaterialName += strId;
|
stdMaterialName += strId;
|
||||||
stdMaterialName += "_";
|
stdMaterialName += "_";
|
||||||
|
@ -556,13 +562,15 @@ private:
|
||||||
std::string value;
|
std::string value;
|
||||||
};
|
};
|
||||||
std::vector<MetaEntry> mMetaData;
|
std::vector<MetaEntry> mMetaData;
|
||||||
std::map<unsigned int, Resource*> mResourcesDictionnary;
|
std::map<unsigned int, Resource *> mResourcesDictionnary;
|
||||||
unsigned int mMaterialCount, mMeshCount;
|
unsigned int mMaterialCount, mMeshCount;
|
||||||
XmlParser *mXmlParser;
|
XmlParser *mXmlParser;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace D3MF
|
} //namespace D3MF
|
||||||
|
|
||||||
|
using namespace D3MF;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static const aiImporterDesc desc = {
|
||||||
"3mf Importer",
|
"3mf Importer",
|
||||||
"",
|
"",
|
||||||
|
@ -596,7 +604,7 @@ bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bo
|
||||||
if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) {
|
if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
D3MF::D3MFOpcPackage opcPackage(pIOHandler, filename);
|
D3MFOpcPackage opcPackage(pIOHandler, filename);
|
||||||
return opcPackage.validate();
|
return opcPackage.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,11 +620,11 @@ const aiImporterDesc *D3MFImporter::GetInfo() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFImporter::InternReadFile(const std::string &filename, aiScene *pScene, IOSystem *pIOHandler) {
|
void D3MFImporter::InternReadFile(const std::string &filename, aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
D3MF::D3MFOpcPackage opcPackage(pIOHandler, filename);
|
D3MFOpcPackage opcPackage(pIOHandler, filename);
|
||||||
|
|
||||||
XmlParser xmlParser;
|
XmlParser xmlParser;
|
||||||
if (xmlParser.parse(opcPackage.RootStream())) {
|
if (xmlParser.parse(opcPackage.RootStream())) {
|
||||||
D3MF::XmlSerializer xmlSerializer(&xmlParser);
|
XmlSerializer xmlSerializer(&xmlParser);
|
||||||
xmlSerializer.ImportXml(pScene);
|
xmlSerializer.ImportXml(pScene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
/// @brief The 3MF-importer class.
|
||||||
class D3MFImporter : public BaseImporter {
|
class D3MFImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
// BaseImporter interface
|
|
||||||
D3MFImporter();
|
D3MFImporter();
|
||||||
~D3MFImporter();
|
~D3MFImporter();
|
||||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const;
|
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const;
|
||||||
|
|
|
@ -103,9 +103,9 @@ public:
|
||||||
std::string name = currentNode.name();
|
std::string name = currentNode.name();
|
||||||
if (name == "Relationship") {
|
if (name == "Relationship") {
|
||||||
OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship());
|
OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship());
|
||||||
relPtr->id = currentNode.attribute(XmlTag::RELS_ATTRIB_ID.c_str()).as_string();
|
relPtr->id = currentNode.attribute(XmlTag::RELS_ATTRIB_ID).as_string();
|
||||||
relPtr->type = currentNode.attribute(XmlTag::RELS_ATTRIB_TYPE.c_str()).as_string();
|
relPtr->type = currentNode.attribute(XmlTag::RELS_ATTRIB_TYPE).as_string();
|
||||||
relPtr->target = currentNode.attribute(XmlTag::RELS_ATTRIB_TARGET.c_str()).as_string();
|
relPtr->target = currentNode.attribute(XmlTag::RELS_ATTRIB_TARGET).as_string();
|
||||||
if (validateRels(relPtr)) {
|
if (validateRels(relPtr)) {
|
||||||
m_relationShips.push_back(relPtr);
|
m_relationShips.push_back(relPtr);
|
||||||
}
|
}
|
||||||
|
@ -160,9 +160,9 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem *pIOHandler, const std::string &rFile) :
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) {
|
} else if (file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) {
|
||||||
ASSIMP_LOG_WARN_F("Ignored file of unsupported type CONTENT_TYPES_ARCHIVES", file);
|
ASSIMP_LOG_WARN("Ignored file of unsupported type CONTENT_TYPES_ARCHIVES", file);
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN_F("Ignored file of unknown type: ", file);
|
ASSIMP_LOG_WARN("Ignored file of unknown type: ", file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ bool D3MFOpcPackage::validate() {
|
||||||
std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream *stream) {
|
std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream *stream) {
|
||||||
XmlParser xmlParser;
|
XmlParser xmlParser;
|
||||||
if (!xmlParser.parse(stream)) {
|
if (!xmlParser.parse(stream)) {
|
||||||
return "";
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
OpcPackageRelationshipReader reader(xmlParser);
|
OpcPackageRelationshipReader reader(xmlParser);
|
||||||
|
|
|
@ -116,7 +116,7 @@ inline const char *TAcCheckedLoadFloatArray(const char *buffer, const char *name
|
||||||
buffer = AcSkipToNextToken(buffer);
|
buffer = AcSkipToNextToken(buffer);
|
||||||
if (0 != name_length) {
|
if (0 != name_length) {
|
||||||
if (0 != strncmp(buffer, name, name_length) || !IsSpace(buffer[name_length])) {
|
if (0 != strncmp(buffer, name, name_length) || !IsSpace(buffer[name_length])) {
|
||||||
ASSIMP_LOG_ERROR("AC3D: Unexpexted token. " + std::string(name) + " was expected.");
|
ASSIMP_LOG_ERROR("AC3D: Unexpected token. ", name, " was expected.");
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
buffer += name_length + 1;
|
buffer += name_length + 1;
|
||||||
|
@ -492,7 +492,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Coerce unknowns to a polygon and warn
|
// Coerce unknowns to a polygon and warn
|
||||||
ASSIMP_LOG_WARN_F("AC3D: The type flag of a surface is unknown: ", (*it).flags);
|
ASSIMP_LOG_WARN("AC3D: The type flag of a surface is unknown: ", (*it).flags);
|
||||||
(*it).flags &= ~(Surface::Mask);
|
(*it).flags &= ~(Surface::Mask);
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
||||||
if (object.subDiv) {
|
if (object.subDiv) {
|
||||||
if (configEvalSubdivision) {
|
if (configEvalSubdivision) {
|
||||||
std::unique_ptr<Subdivider> div(Subdivider::Create(Subdivider::CATMULL_CLARKE));
|
std::unique_ptr<Subdivider> div(Subdivider::Create(Subdivider::CATMULL_CLARKE));
|
||||||
ASSIMP_LOG_INFO("AC3D: Evaluating subdivision surface: " + object.name);
|
ASSIMP_LOG_INFO("AC3D: Evaluating subdivision surface: ", object.name);
|
||||||
|
|
||||||
std::vector<aiMesh *> cpy(meshes.size() - oldm, nullptr);
|
std::vector<aiMesh *> cpy(meshes.size() - oldm, nullptr);
|
||||||
div->Subdivide(&meshes[oldm], cpy.size(), &cpy.front(), object.subDiv, true);
|
div->Subdivide(&meshes[oldm], cpy.size(), &cpy.front(), object.subDiv, true);
|
||||||
|
@ -698,7 +698,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
||||||
|
|
||||||
// previous meshes are deleted vy Subdivide().
|
// previous meshes are deleted vy Subdivide().
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_INFO("AC3D: Letting the subdivision surface untouched due to my configuration: " + object.name);
|
ASSIMP_LOG_INFO("AC3D: Letting the subdivision surface untouched due to my configuration: ", object.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -782,7 +782,7 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
|
||||||
unsigned int version = HexDigitToDecimal(buffer[4]);
|
unsigned int version = HexDigitToDecimal(buffer[4]);
|
||||||
char msg[3];
|
char msg[3];
|
||||||
ASSIMP_itoa10(msg, 3, version);
|
ASSIMP_itoa10(msg, 3, version);
|
||||||
ASSIMP_LOG_INFO_F("AC3D file format version: ", msg);
|
ASSIMP_LOG_INFO("AC3D file format version: ", msg);
|
||||||
|
|
||||||
std::vector<Material> materials;
|
std::vector<Material> materials;
|
||||||
materials.reserve(5);
|
materials.reserve(5);
|
||||||
|
|
|
@ -123,9 +123,9 @@ public:
|
||||||
struct Object {
|
struct Object {
|
||||||
Object() :
|
Object() :
|
||||||
type(World),
|
type(World),
|
||||||
name(""),
|
name(),
|
||||||
children(),
|
children(),
|
||||||
texture(""),
|
texture(),
|
||||||
texRepeat(1.f, 1.f),
|
texRepeat(1.f, 1.f),
|
||||||
texOffset(0.0f, 0.0f),
|
texOffset(0.0f, 0.0f),
|
||||||
rotation(),
|
rotation(),
|
||||||
|
|
|
@ -205,7 +205,7 @@ void AMFImporter::ParseHelper_FixTruncatedFloatString(const char *pInStr, std::s
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ParseHelper_Decode_Base64_IsBase64(const char pChar) {
|
static bool ParseHelper_Decode_Base64_IsBase64(const char pChar) {
|
||||||
return (isalnum(pChar) || (pChar == '+') || (pChar == '/'));
|
return (isalnum((unsigned char)pChar) || (pChar == '+') || (pChar == '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMFImporter::ParseHelper_Decode_Base64(const std::string &pInputBase64, std::vector<uint8_t> &pOutputData) const {
|
void AMFImporter::ParseHelper_Decode_Base64(const std::string &pInputBase64, std::vector<uint8_t> &pOutputData) const {
|
||||||
|
@ -268,7 +268,8 @@ void AMFImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) {
|
||||||
mXmlParser = new XmlParser();
|
mXmlParser = new XmlParser();
|
||||||
if (!mXmlParser->parse(file.get())) {
|
if (!mXmlParser->parse(file.get())) {
|
||||||
delete mXmlParser;
|
delete mXmlParser;
|
||||||
throw DeadlyImportError("Failed to create XML reader for file" + pFile + ".");
|
mXmlParser = nullptr;
|
||||||
|
throw DeadlyImportError("Failed to create XML reader for file ", pFile, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start reading, search for root tag <amf>
|
// Start reading, search for root tag <amf>
|
||||||
|
@ -517,10 +518,6 @@ bool AMFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool p
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMFImporter::GetExtensionList(std::set<std::string> &pExtensionList) {
|
|
||||||
pExtensionList.insert("amf");
|
|
||||||
}
|
|
||||||
|
|
||||||
const aiImporterDesc *AMFImporter::GetInfo() const {
|
const aiImporterDesc *AMFImporter::GetInfo() const {
|
||||||
return &Description;
|
return &Description;
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,7 +277,6 @@ public:
|
||||||
void ParseHelper_Node_Enter(AMFNodeElementBase *child);
|
void ParseHelper_Node_Enter(AMFNodeElementBase *child);
|
||||||
void ParseHelper_Node_Exit();
|
void ParseHelper_Node_Exit();
|
||||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const;
|
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const;
|
||||||
void GetExtensionList(std::set<std::string> &pExtensionList);
|
|
||||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler);
|
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler);
|
||||||
const aiImporterDesc *GetInfo() const;
|
const aiImporterDesc *GetInfo() const;
|
||||||
bool Find_NodeElement(const std::string &pID, const AMFNodeElementBase::EType pType, AMFNodeElementBase **pNodeElement) const;
|
bool Find_NodeElement(const std::string &pID, const AMFNodeElementBase::EType pType, AMFNodeElementBase **pNodeElement) const;
|
||||||
|
|
|
@ -428,10 +428,10 @@ void AMFImporter::Postprocess_BuildMeshSet(const AMFMesh &pNodeElement, const st
|
||||||
|
|
||||||
if (pBiggerThan != nullptr) {
|
if (pBiggerThan != nullptr) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
const size_t biggerThan = *pBiggerThan;
|
||||||
for (const SComplexFace &face : pFaceList) {
|
for (const SComplexFace &face : pFaceList) {
|
||||||
for (size_t idx_vert = 0; idx_vert < face.Face.mNumIndices; idx_vert++) {
|
for (size_t idx_vert = 0; idx_vert < face.Face.mNumIndices; idx_vert++) {
|
||||||
if (face.Face.mIndices[idx_vert] > *pBiggerThan) {
|
if (face.Face.mIndices[idx_vert] > biggerThan) {
|
||||||
rv = face.Face.mIndices[idx_vert];
|
rv = face.Face.mIndices[idx_vert];
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -614,7 +614,7 @@ void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes,
|
||||||
node->mNumChildren++;
|
node->mNumChildren++;
|
||||||
|
|
||||||
// What we did is so great, it is at least worth a debug message
|
// What we did is so great, it is at least worth a debug message
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG("ASE: Generating separate target node (" + snode->mName + ")");
|
ASSIMP_LOG_VERBOSE_DEBUG("ASE: Generating separate target node (", snode->mName, ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -498,6 +498,12 @@ void Parser::ParseLV1MaterialListBlock() {
|
||||||
ParseLV2MaterialBlock(sMat);
|
ParseLV2MaterialBlock(sMat);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if( iDepth == 1 ){
|
||||||
|
// CRUDE HACK: support missing brace after "Ascii Scene Exporter v2.51"
|
||||||
|
LogWarning("Missing closing brace in material list");
|
||||||
|
--filePtr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
AI_ASE_HANDLE_TOP_LEVEL_SECTION();
|
AI_ASE_HANDLE_TOP_LEVEL_SECTION();
|
||||||
}
|
}
|
||||||
|
@ -671,7 +677,7 @@ void Parser::ParseLV3MapBlock(Texture &map) {
|
||||||
if (!ParseString(temp, "*MAP_CLASS"))
|
if (!ParseString(temp, "*MAP_CLASS"))
|
||||||
SkipToNextToken();
|
SkipToNextToken();
|
||||||
if (temp != "Bitmap" && temp != "Normal Bump") {
|
if (temp != "Bitmap" && temp != "Normal Bump") {
|
||||||
ASSIMP_LOG_WARN_F("ASE: Skipping unknown map type: ", temp);
|
ASSIMP_LOG_WARN("ASE: Skipping unknown map type: ", temp);
|
||||||
parsePath = false;
|
parsePath = false;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -685,7 +691,7 @@ void Parser::ParseLV3MapBlock(Texture &map) {
|
||||||
// Files with 'None' as map name are produced by
|
// Files with 'None' as map name are produced by
|
||||||
// an Maja to ASE exporter which name I forgot ..
|
// an Maja to ASE exporter which name I forgot ..
|
||||||
ASSIMP_LOG_WARN("ASE: Skipping invalid map entry");
|
ASSIMP_LOG_WARN("ASE: Skipping invalid map entry");
|
||||||
map.mMapName = "";
|
map.mMapName = std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -1119,7 +1125,7 @@ void Parser::ParseLV2NodeTransformBlock(ASE::BaseNode &mesh) {
|
||||||
"this is no spot light or target camera");
|
"this is no spot light or target camera");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_ERROR("ASE: Unknown node transformation: " + temp);
|
ASSIMP_LOG_ERROR("ASE: Unknown node transformation: ", temp);
|
||||||
// mode = 0
|
// mode = 0
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -671,7 +671,7 @@ void AssbinImporter::ReadBinaryScene(IOStream *stream, aiScene *scene) {
|
||||||
void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
IOStream *stream = pIOHandler->Open(pFile, "rb");
|
IOStream *stream = pIOHandler->Open(pFile, "rb");
|
||||||
if (nullptr == stream) {
|
if (nullptr == stream) {
|
||||||
return;
|
throw DeadlyImportError("ASSBIN: Could not open ", pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// signature
|
// signature
|
||||||
|
|
|
@ -598,8 +598,11 @@ static void WriteDump(const char *pFile, const char *cmd, const aiScene *scene,
|
||||||
if (!mesh->mTextureCoords[a])
|
if (!mesh->mTextureCoords[a])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ioprintf(io, "\t\t<TextureCoords num=\"%u\" set=\"%u\" num_components=\"%u\"> \n", mesh->mNumVertices,
|
ioprintf(io, "\t\t<TextureCoords num=\"%u\" set=\"%u\" name=\"%s\" num_components=\"%u\"> \n",
|
||||||
a, mesh->mNumUVComponents[a]);
|
mesh->mNumVertices,
|
||||||
|
a,
|
||||||
|
mesh->mTextureCoordsNames[a].C_Str(),
|
||||||
|
mesh->mNumUVComponents[a]);
|
||||||
|
|
||||||
if (!shortened) {
|
if (!shortened) {
|
||||||
if (mesh->mNumUVComponents[a] == 3) {
|
if (mesh->mNumUVComponents[a] == 3) {
|
||||||
|
|
|
@ -145,7 +145,7 @@ AI_WONT_RETURN void B3DImporter::Oops() {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
AI_WONT_RETURN void B3DImporter::Fail(string str) {
|
AI_WONT_RETURN void B3DImporter::Fail(string str) {
|
||||||
#ifdef DEBUG_B3D
|
#ifdef DEBUG_B3D
|
||||||
ASSIMP_LOG_ERROR_F("Error in B3D file data: ", str);
|
ASSIMP_LOG_ERROR("Error in B3D file data: ", str);
|
||||||
#endif
|
#endif
|
||||||
throw DeadlyImportError("B3D Importer - error in B3D file data: ", str);
|
throw DeadlyImportError("B3D Importer - error in B3D file data: ", str);
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ string B3DImporter::ReadChunk() {
|
||||||
tag += char(ReadByte());
|
tag += char(ReadByte());
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_B3D
|
#ifdef DEBUG_B3D
|
||||||
ASSIMP_LOG_DEBUG_F("ReadChunk: ", tag);
|
ASSIMP_LOG_DEBUG("ReadChunk: ", tag);
|
||||||
#endif
|
#endif
|
||||||
unsigned sz = (unsigned)ReadInt();
|
unsigned sz = (unsigned)ReadInt();
|
||||||
_stack.push_back(_pos + sz);
|
_stack.push_back(_pos + sz);
|
||||||
|
@ -397,7 +397,7 @@ void B3DImporter::ReadTRIS(int v0) {
|
||||||
matid = 0;
|
matid = 0;
|
||||||
} else if (matid < 0 || matid >= (int)_materials.size()) {
|
} else if (matid < 0 || matid >= (int)_materials.size()) {
|
||||||
#ifdef DEBUG_B3D
|
#ifdef DEBUG_B3D
|
||||||
ASSIMP_LOG_ERROR_F("material id=", matid);
|
ASSIMP_LOG_ERROR("material id=", matid);
|
||||||
#endif
|
#endif
|
||||||
Fail("Bad material id");
|
Fail("Bad material id");
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ void B3DImporter::ReadTRIS(int v0) {
|
||||||
int i2 = ReadInt() + v0;
|
int i2 = ReadInt() + v0;
|
||||||
if (i0 < 0 || i0 >= (int)_vertices.size() || i1 < 0 || i1 >= (int)_vertices.size() || i2 < 0 || i2 >= (int)_vertices.size()) {
|
if (i0 < 0 || i0 >= (int)_vertices.size() || i1 < 0 || i1 >= (int)_vertices.size() || i2 < 0 || i2 >= (int)_vertices.size()) {
|
||||||
#ifdef DEBUG_B3D
|
#ifdef DEBUG_B3D
|
||||||
ASSIMP_LOG_ERROR_F("Bad triangle index: i0=", i0, ", i1=", i1, ", i2=", i2);
|
ASSIMP_LOG_ERROR("Bad triangle index: i0=", i0, ", i1=", i1, ", i2=", i2);
|
||||||
#endif
|
#endif
|
||||||
Fail("Bad triangle index");
|
Fail("Bad triangle index");
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -359,7 +359,7 @@ void BVHLoader::ReadMotion(aiScene * /*pScene*/) {
|
||||||
std::string BVHLoader::GetNextToken() {
|
std::string BVHLoader::GetNextToken() {
|
||||||
// skip any preceding whitespace
|
// skip any preceding whitespace
|
||||||
while (mReader != mBuffer.end()) {
|
while (mReader != mBuffer.end()) {
|
||||||
if (!isspace(*mReader))
|
if (!isspace((unsigned char)*mReader))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// count lines
|
// count lines
|
||||||
|
@ -372,7 +372,7 @@ std::string BVHLoader::GetNextToken() {
|
||||||
// collect all chars till the next whitespace. BVH is easy in respect to that.
|
// collect all chars till the next whitespace. BVH is easy in respect to that.
|
||||||
std::string token;
|
std::string token;
|
||||||
while (mReader != mBuffer.end()) {
|
while (mReader != mBuffer.end()) {
|
||||||
if (isspace(*mReader))
|
if (isspace((unsigned char)*mReader))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
token.push_back(*mReader);
|
token.push_back(*mReader);
|
||||||
|
|
|
@ -198,9 +198,9 @@ void DNAParser::Parse() {
|
||||||
s.size = offset;
|
s.size = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F("BlenderDNA: Got ", dna.structures.size(), " structures with totally ", fields, " fields");
|
ASSIMP_LOG_DEBUG("BlenderDNA: Got ", dna.structures.size(), " structures with totally ", fields, " fields");
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_BLENDER_DEBUG
|
#if ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
dna.DumpToFile();
|
dna.DumpToFile();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ void DNAParser::Parse() {
|
||||||
dna.RegisterConverters();
|
dna.RegisterConverters();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_BLENDER_DEBUG
|
#if ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -237,7 +237,7 @@ void DNA ::DumpToFile() {
|
||||||
|
|
||||||
ASSIMP_LOG_INFO("BlenderDNA: Dumped dna to dna.txt");
|
ASSIMP_LOG_INFO("BlenderDNA: Dumped dna to dna.txt");
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
/*static*/ void DNA ::ExtractArraySize(
|
/*static*/ void DNA ::ExtractArraySize(
|
||||||
|
|
|
@ -59,6 +59,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define ASSIMP_BUILD_BLENDER_DEBUG
|
#define ASSIMP_BUILD_BLENDER_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// set this to non-zero to dump BlenderDNA stuff to dna.txt.
|
||||||
|
// you could set it on the assimp build command line too without touching it here.
|
||||||
|
// !!! please make sure this is set to 0 in the repo !!!
|
||||||
|
#ifndef ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
|
#define ASSIMP_BUILD_BLENDER_DEBUG_DNA 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// #define ASSIMP_BUILD_BLENDER_NO_STATS
|
// #define ASSIMP_BUILD_BLENDER_NO_STATS
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -495,7 +502,7 @@ public:
|
||||||
const Structure &structure,
|
const Structure &structure,
|
||||||
const FileDatabase &db) const;
|
const FileDatabase &db) const;
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_BLENDER_DEBUG
|
#if ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
/** Dump the DNA to a text file. This is for debugging purposes.
|
/** Dump the DNA to a text file. This is for debugging purposes.
|
||||||
* The output file is `dna.txt` in the current working folder*/
|
* The output file is `dna.txt` in the current working folder*/
|
||||||
|
|
|
@ -565,7 +565,7 @@ template <> bool Structure :: ResolvePointer<std::shared_ptr,ElemBase>(std::shar
|
||||||
// this might happen if DNA::RegisterConverters hasn't been called so far
|
// this might happen if DNA::RegisterConverters hasn't been called so far
|
||||||
// or if the target type is not contained in `our` DNA.
|
// or if the target type is not contained in `our` DNA.
|
||||||
out.reset();
|
out.reset();
|
||||||
ASSIMP_LOG_WARN_F( "Failed to find a converter for the `",s.name,"` structure" );
|
ASSIMP_LOG_WARN( "Failed to find a converter for the `",s.name,"` structure" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ using namespace Assimp::Blender;
|
||||||
using namespace Assimp::Formatter;
|
using namespace Assimp::Formatter;
|
||||||
|
|
||||||
static const aiImporterDesc blenderDesc = {
|
static const aiImporterDesc blenderDesc = {
|
||||||
"Blender 3D Importer \nhttp://www.blender3d.org",
|
"Blender 3D Importer (http://www.blender3d.org)",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"No animation support yet",
|
"No animation support yet",
|
||||||
|
@ -132,12 +132,6 @@ bool BlenderImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// List all extensions handled by this loader
|
|
||||||
void BlenderImporter::GetExtensionList(std::set<std::string> &app) {
|
|
||||||
app.insert("blend");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Loader registry entry
|
// Loader registry entry
|
||||||
const aiImporterDesc *BlenderImporter::GetInfo() const {
|
const aiImporterDesc *BlenderImporter::GetInfo() const {
|
||||||
|
@ -241,9 +235,9 @@ void BlenderImporter::InternReadFile(const std::string &pFile,
|
||||||
stream->Read(magic, 3, 1);
|
stream->Read(magic, 3, 1);
|
||||||
magic[3] = '\0';
|
magic[3] = '\0';
|
||||||
|
|
||||||
LogInfo((format(), "Blender version is ", magic[0], ".", magic + 1,
|
LogInfo("Blender version is ", magic[0], ".", magic + 1,
|
||||||
" (64bit: ", file.i64bit ? "true" : "false",
|
" (64bit: ", file.i64bit ? "true" : "false",
|
||||||
", little endian: ", file.little ? "true" : "false", ")"));
|
", little endian: ", file.little ? "true" : "false", ")");
|
||||||
|
|
||||||
ParseBlendFile(file, stream);
|
ParseBlendFile(file, stream);
|
||||||
|
|
||||||
|
@ -316,7 +310,7 @@ void BlenderImporter::ExtractScene(Scene &out, const FileDatabase &file) {
|
||||||
ss.Convert(out, file);
|
ss.Convert(out, file);
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_BLENDER_NO_STATS
|
#ifndef ASSIMP_BUILD_BLENDER_NO_STATS
|
||||||
ASSIMP_LOG_INFO_F(
|
ASSIMP_LOG_INFO(
|
||||||
"(Stats) Fields read: ", file.stats().fields_read,
|
"(Stats) Fields read: ", file.stats().fields_read,
|
||||||
", pointers resolved: ", file.stats().pointers_resolved,
|
", pointers resolved: ", file.stats().pointers_resolved,
|
||||||
", cache hits: ", file.stats().cache_hits,
|
", cache hits: ", file.stats().cache_hits,
|
||||||
|
@ -426,9 +420,9 @@ void BlenderImporter::ResolveImage(aiMaterial *out, const Material *mat, const M
|
||||||
--s;
|
--s;
|
||||||
}
|
}
|
||||||
|
|
||||||
curTex->achFormatHint[0] = s + 1 > e ? '\0' : (char)::tolower(s[1]);
|
curTex->achFormatHint[0] = s + 1 > e ? '\0' : (char)::tolower((unsigned char)s[1]);
|
||||||
curTex->achFormatHint[1] = s + 2 > e ? '\0' : (char)::tolower(s[2]);
|
curTex->achFormatHint[1] = s + 2 > e ? '\0' : (char)::tolower((unsigned char)s[2]);
|
||||||
curTex->achFormatHint[2] = s + 3 > e ? '\0' : (char)::tolower(s[3]);
|
curTex->achFormatHint[2] = s + 3 > e ? '\0' : (char)::tolower((unsigned char)s[3]);
|
||||||
curTex->achFormatHint[3] = '\0';
|
curTex->achFormatHint[3] = '\0';
|
||||||
|
|
||||||
// tex->mHeight = 0;
|
// tex->mHeight = 0;
|
||||||
|
@ -440,7 +434,7 @@ void BlenderImporter::ResolveImage(aiMaterial *out, const Material *mat, const M
|
||||||
|
|
||||||
curTex->pcData = reinterpret_cast<aiTexel *>(ch);
|
curTex->pcData = reinterpret_cast<aiTexel *>(ch);
|
||||||
|
|
||||||
LogInfo("Reading embedded texture, original file was " + std::string(img->name));
|
LogInfo("Reading embedded texture, original file was ", img->name);
|
||||||
} else {
|
} else {
|
||||||
name = aiString(img->name);
|
name = aiString(img->name);
|
||||||
}
|
}
|
||||||
|
@ -522,7 +516,7 @@ void BlenderImporter::ResolveTexture(aiMaterial *out, const Material *mat, const
|
||||||
case Tex::Type_POINTDENSITY:
|
case Tex::Type_POINTDENSITY:
|
||||||
case Tex::Type_VOXELDATA:
|
case Tex::Type_VOXELDATA:
|
||||||
|
|
||||||
LogWarn(std::string("Encountered a texture with an unsupported type: ") + dispnam);
|
LogWarn("Encountered a texture with an unsupported type: ", dispnam);
|
||||||
AddSentinelTexture(out, mat, tex, conv_data);
|
AddSentinelTexture(out, mat, tex, conv_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -758,7 +752,7 @@ void BlenderImporter::CheckActualType(const ElemBase *dt, const char *check) {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void BlenderImporter::NotSupportedObjectType(const Object *obj, const char *type) {
|
void BlenderImporter::NotSupportedObjectType(const Object *obj, const char *type) {
|
||||||
LogWarn((format(), "Object `", obj->id.name, "` - type is unsupported: `", type, "`, skipping"));
|
LogWarn("Object `", obj->id.name, "` - type is unsupported: `", type, "`, skipping");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -110,7 +110,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const aiImporterDesc* GetInfo () const;
|
const aiImporterDesc* GetInfo () const;
|
||||||
void GetExtensionList(std::set<std::string>& app);
|
|
||||||
void SetupProperties(const Importer* pImp);
|
void SetupProperties(const Importer* pImp);
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
||||||
void ParseBlendFile(Blender::FileDatabase& out, std::shared_ptr<IOStream> stream);
|
void ParseBlendFile(Blender::FileDatabase& out, std::shared_ptr<IOStream> stream);
|
||||||
|
|
|
@ -90,7 +90,7 @@ void BlenderModifierShowcase::ApplyModifiers(aiNode &out, ConversionData &conv_d
|
||||||
|
|
||||||
const Structure *s = conv_data.db.dna.Get(cur->dna_type);
|
const Structure *s = conv_data.db.dna.Get(cur->dna_type);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
ASSIMP_LOG_WARN_F("BlendModifier: could not resolve DNA name: ", cur->dna_type);
|
ASSIMP_LOG_WARN("BlendModifier: could not resolve DNA name: ", cur->dna_type);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ void BlenderModifierShowcase::ApplyModifiers(aiNode &out, ConversionData &conv_d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (curgod) {
|
if (curgod) {
|
||||||
ASSIMP_LOG_WARN_F("Couldn't find a handler for modifier: ", dat.name);
|
ASSIMP_LOG_WARN("Couldn't find a handler for modifier: ", dat.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ void BlenderModifierShowcase::ApplyModifiers(aiNode &out, ConversionData &conv_d
|
||||||
// object, we still can't say whether our modifier implementations were
|
// object, we still can't say whether our modifier implementations were
|
||||||
// able to fully do their job.
|
// able to fully do their job.
|
||||||
if (ful) {
|
if (ful) {
|
||||||
ASSIMP_LOG_DEBUG_F("BlendModifier: found handlers for ", cnt, " of ", ful, " modifiers on `", orig_object.id.name,
|
ASSIMP_LOG_DEBUG("BlendModifier: found handlers for ", cnt, " of ", ful, " modifiers on `", orig_object.id.name,
|
||||||
"`, check log messages above for errors");
|
"`, check log messages above for errors");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ void BlenderModifier_Mirror ::DoIt(aiNode &out, ConversionData &conv_data, const
|
||||||
out.mMeshes = nind;
|
out.mMeshes = nind;
|
||||||
out.mNumMeshes *= 2;
|
out.mNumMeshes *= 2;
|
||||||
|
|
||||||
ASSIMP_LOG_INFO_F("BlendModifier: Applied the `Mirror` modifier to `",
|
ASSIMP_LOG_INFO("BlendModifier: Applied the `Mirror` modifier to `",
|
||||||
orig_object.id.name, "`");
|
orig_object.id.name, "`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ void BlenderModifier_Subdivision ::DoIt(aiNode &out, ConversionData &conv_data,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ASSIMP_LOG_WARN_F("BlendModifier: Unrecognized subdivision algorithm: ", mir.subdivType);
|
ASSIMP_LOG_WARN("BlendModifier: Unrecognized subdivision algorithm: ", mir.subdivType);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ void BlenderModifier_Subdivision ::DoIt(aiNode &out, ConversionData &conv_data,
|
||||||
subd->Subdivide(meshes, out.mNumMeshes, tempmeshes.get(), std::max(mir.renderLevels, mir.levels), true);
|
subd->Subdivide(meshes, out.mNumMeshes, tempmeshes.get(), std::max(mir.renderLevels, mir.levels), true);
|
||||||
std::copy(tempmeshes.get(), tempmeshes.get() + out.mNumMeshes, meshes);
|
std::copy(tempmeshes.get(), tempmeshes.get() + out.mNumMeshes, meshes);
|
||||||
|
|
||||||
ASSIMP_LOG_INFO_F("BlendModifier: Applied the `Subdivision` modifier to `",
|
ASSIMP_LOG_INFO("BlendModifier: Applied the `Subdivision` modifier to `",
|
||||||
orig_object.id.name, "`");
|
orig_object.id.name, "`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
const Scene& /*in*/,
|
const Scene& /*in*/,
|
||||||
const Object& /*orig_object*/
|
const Object& /*orig_object*/
|
||||||
) {
|
) {
|
||||||
ASSIMP_LOG_INFO_F("This modifier is not supported, skipping: ",orig_modifier.dna_type );
|
ASSIMP_LOG_INFO("This modifier is not supported, skipping: ",orig_modifier.dna_type );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2021, 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,
|
||||||
|
@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "C4DImporter.h"
|
#include "C4DImporter.h"
|
||||||
#include <assimp/TinyFormatter.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
@ -65,7 +64,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "c4d_file.h"
|
#include "c4d_file.h"
|
||||||
#include "default_alien_overloads.h"
|
#include "default_alien_overloads.h"
|
||||||
|
|
||||||
using namespace melange;
|
namespace {
|
||||||
|
|
||||||
|
aiString aiStringFrom(cineware::String const & cinestring) {
|
||||||
|
aiString result;
|
||||||
|
cinestring.GetCString(result.data, MAXLEN-1);
|
||||||
|
result.length = static_cast<ai_uint32>(cinestring.GetLength());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
using namespace cineware;
|
||||||
|
|
||||||
// overload this function and fill in your own unique data
|
// overload this function and fill in your own unique data
|
||||||
void GetWriterInfo(int &id, String &appname) {
|
void GetWriterInfo(int &id, String &appname) {
|
||||||
|
@ -73,9 +84,6 @@ void GetWriterInfo(int &id, String &appname) {
|
||||||
appname = "Open Asset Import Library";
|
appname = "Open Asset Import Library";
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
using namespace Assimp::Formatter;
|
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
template<> const char* LogFunctions<C4DImporter>::Prefix() {
|
template<> const char* LogFunctions<C4DImporter>::Prefix() {
|
||||||
static auto prefix = "C4D: ";
|
static auto prefix = "C4D: ";
|
||||||
|
@ -97,17 +105,6 @@ static const aiImporterDesc desc = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
C4DImporter::C4DImporter()
|
|
||||||
: BaseImporter() {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
C4DImporter::~C4DImporter() {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool C4DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
bool C4DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||||
const std::string& extension = GetExtension(pFile);
|
const std::string& extension = GetExtension(pFile);
|
||||||
|
@ -125,11 +122,6 @@ const aiImporterDesc* C4DImporter::GetInfo () const {
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void C4DImporter::SetupProperties(const Importer* /*pImp*/) {
|
|
||||||
// nothing to be done for the moment
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
|
@ -199,8 +191,8 @@ void C4DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
bool C4DImporter::ReadShader(aiMaterial* out, BaseShader* shader) {
|
||||||
// based on Melange sample code (C4DImportExport.cpp)
|
// based on Cineware sample code (C4DImportExport.cpp)
|
||||||
while(shader) {
|
while(shader) {
|
||||||
if(shader->GetType() == Xlayer) {
|
if(shader->GetType() == Xlayer) {
|
||||||
BaseContainer* container = shader->GetDataInstance();
|
BaseContainer* container = shader->GetDataInstance();
|
||||||
|
@ -242,13 +234,11 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
||||||
lsl = lsl->GetNext();
|
lsl = lsl->GetNext();
|
||||||
}
|
}
|
||||||
} else if ( shader->GetType() == Xbitmap ) {
|
} else if ( shader->GetType() == Xbitmap ) {
|
||||||
aiString path;
|
auto const path = aiStringFrom(shader->GetFileName().GetString());
|
||||||
shader->GetFileName().GetString().GetCString(path.data, MAXLEN-1);
|
|
||||||
path.length = ::strlen(path.data);
|
|
||||||
out->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
out->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LogWarn("ignoring shader type: " + std::string(GetObjectTypeName(shader->GetType())));
|
LogWarn("ignoring shader type: ", GetObjectTypeName(shader->GetType()));
|
||||||
}
|
}
|
||||||
shader = shader->GetNext();
|
shader = shader->GetNext();
|
||||||
}
|
}
|
||||||
|
@ -257,18 +247,15 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void C4DImporter::ReadMaterials(melange::BaseMaterial* mat) {
|
void C4DImporter::ReadMaterials(BaseMaterial* mat) {
|
||||||
// based on Melange sample code
|
// based on Cineware sample code
|
||||||
while (mat) {
|
while (mat) {
|
||||||
const String& name = mat->GetName();
|
|
||||||
if (mat->GetType() == Mmaterial) {
|
if (mat->GetType() == Mmaterial) {
|
||||||
aiMaterial* out = new aiMaterial();
|
aiMaterial* out = new aiMaterial();
|
||||||
material_mapping[mat] = static_cast<unsigned int>(materials.size());
|
material_mapping[mat] = static_cast<unsigned int>(materials.size());
|
||||||
materials.push_back(out);
|
materials.push_back(out);
|
||||||
|
|
||||||
aiString ai_name;
|
auto const ai_name = aiStringFrom(mat->GetName());
|
||||||
name.GetCString(ai_name.data, MAXLEN-1);
|
|
||||||
ai_name.length = ::strlen(ai_name.data);
|
|
||||||
out->AddProperty(&ai_name, AI_MATKEY_NAME);
|
out->AddProperty(&ai_name, AI_MATKEY_NAME);
|
||||||
|
|
||||||
Material& m = dynamic_cast<Material&>(*mat);
|
Material& m = dynamic_cast<Material&>(*mat);
|
||||||
|
@ -294,7 +281,7 @@ void C4DImporter::ReadMaterials(melange::BaseMaterial* mat) {
|
||||||
ReadShader(out, shader);
|
ReadShader(out, shader);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogWarn("ignoring plugin material: " + std::string(GetObjectTypeName(mat->GetType())));
|
LogWarn("ignoring plugin material: ", GetObjectTypeName(mat->GetType()));
|
||||||
}
|
}
|
||||||
mat = mat->GetNext();
|
mat = mat->GetNext();
|
||||||
}
|
}
|
||||||
|
@ -305,19 +292,15 @@ void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent) {
|
||||||
ai_assert(parent != nullptr );
|
ai_assert(parent != nullptr );
|
||||||
std::vector<aiNode*> nodes;
|
std::vector<aiNode*> nodes;
|
||||||
|
|
||||||
// based on Melange sample code
|
// based on Cineware sample code
|
||||||
while (object) {
|
while (object) {
|
||||||
const String& name = object->GetName();
|
|
||||||
const LONG type = object->GetType();
|
const LONG type = object->GetType();
|
||||||
const Matrix& ml = object->GetMl();
|
const Matrix& ml = object->GetMl();
|
||||||
|
|
||||||
aiString string;
|
|
||||||
name.GetCString(string.data, MAXLEN-1);
|
|
||||||
string.length = ::strlen(string.data);
|
|
||||||
aiNode* const nd = new aiNode();
|
aiNode* const nd = new aiNode();
|
||||||
|
|
||||||
nd->mParent = parent;
|
nd->mParent = parent;
|
||||||
nd->mName = string;
|
nd->mName = aiStringFrom(object->GetName());
|
||||||
|
|
||||||
nd->mTransformation.a1 = ml.v1.x;
|
nd->mTransformation.a1 = ml.v1.x;
|
||||||
nd->mTransformation.b1 = ml.v1.y;
|
nd->mTransformation.b1 = ml.v1.y;
|
||||||
|
@ -352,7 +335,7 @@ void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent) {
|
||||||
meshes.push_back(mesh);
|
meshes.push_back(mesh);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogWarn("ignoring object: " + std::string(GetObjectTypeName(type)));
|
LogWarn("ignoring object: ", GetObjectTypeName(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
RecurseHierarchy(object->GetDown(), nd);
|
RecurseHierarchy(object->GetDown(), nd);
|
||||||
|
@ -370,7 +353,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
|
||||||
ai_assert(object != nullptr);
|
ai_assert(object != nullptr);
|
||||||
ai_assert( object->GetType() == Opolygon );
|
ai_assert( object->GetType() == Opolygon );
|
||||||
|
|
||||||
// based on Melange sample code
|
// based on Cineware sample code
|
||||||
PolygonObject* const polyObject = dynamic_cast<PolygonObject*>(object);
|
PolygonObject* const polyObject = dynamic_cast<PolygonObject*>(object);
|
||||||
ai_assert(polyObject != nullptr);
|
ai_assert(polyObject != nullptr);
|
||||||
|
|
||||||
|
@ -618,4 +601,3 @@ unsigned int C4DImporter::ResolveMaterial(PolygonObject* obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_C4D_IMPORTER
|
#endif // ASSIMP_BUILD_NO_C4D_IMPORTER
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2021, 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,
|
||||||
|
@ -56,8 +56,8 @@ struct aiMaterial;
|
||||||
|
|
||||||
struct aiImporterDesc;
|
struct aiImporterDesc;
|
||||||
|
|
||||||
namespace melange {
|
namespace cineware {
|
||||||
class BaseObject; // c4d_file.h
|
class BaseObject;
|
||||||
class PolygonObject;
|
class PolygonObject;
|
||||||
class BaseMaterial;
|
class BaseMaterial;
|
||||||
class BaseShader;
|
class BaseShader;
|
||||||
|
@ -71,43 +71,34 @@ namespace Assimp {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
/** Importer class to load Cinema4D files using the Melange library to be obtained from
|
/** Importer class to load Cinema4D files using the Cineware library to be obtained from
|
||||||
* www.plugincafe.com
|
* https://developers.maxon.net
|
||||||
*
|
*
|
||||||
* Note that Melange is not free software. */
|
* Note that Cineware is not free software. */
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
class C4DImporter : public BaseImporter, public LogFunctions<C4DImporter> {
|
class C4DImporter : public BaseImporter, public LogFunctions<C4DImporter> {
|
||||||
public:
|
public:
|
||||||
C4DImporter();
|
bool CanRead( const std::string& pFile, IOSystem*, bool checkSig) const override;
|
||||||
~C4DImporter();
|
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
|
||||||
bool checkSig) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// --------------------
|
const aiImporterDesc* GetInfo () const override;
|
||||||
const aiImporterDesc* GetInfo () const;
|
|
||||||
|
|
||||||
// --------------------
|
void InternReadFile( const std::string& pFile, aiScene*, IOSystem* ) override;
|
||||||
void SetupProperties(const Importer* pImp);
|
|
||||||
|
|
||||||
// --------------------
|
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
|
||||||
IOSystem* pIOHandler);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void ReadMaterials(melange::BaseMaterial* mat);
|
void ReadMaterials(cineware::BaseMaterial* mat);
|
||||||
void RecurseHierarchy(melange::BaseObject* object, aiNode* parent);
|
void RecurseHierarchy(cineware::BaseObject* object, aiNode* parent);
|
||||||
aiMesh* ReadMesh(melange::BaseObject* object);
|
aiMesh* ReadMesh(cineware::BaseObject* object);
|
||||||
unsigned int ResolveMaterial(melange::PolygonObject* obj);
|
unsigned int ResolveMaterial(cineware::PolygonObject* obj);
|
||||||
|
|
||||||
bool ReadShader(aiMaterial* out, melange::BaseShader* shader);
|
bool ReadShader(aiMaterial* out, cineware::BaseShader* shader);
|
||||||
|
|
||||||
std::vector<aiMesh*> meshes;
|
std::vector<aiMesh*> meshes;
|
||||||
std::vector<aiMaterial*> materials;
|
std::vector<aiMaterial*> materials;
|
||||||
|
|
||||||
typedef std::map<melange::BaseMaterial*, unsigned int> MaterialMap;
|
typedef std::map<cineware::BaseMaterial*, unsigned int> MaterialMap;
|
||||||
MaterialMap material_mapping;
|
MaterialMap material_mapping;
|
||||||
|
|
||||||
}; // !class C4DImporter
|
}; // !class C4DImporter
|
||||||
|
|
|
@ -137,7 +137,13 @@ void COBImporter::SetupProperties(const Importer * /*pImp*/) {
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void COBImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
void COBImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
COB::Scene scene;
|
COB::Scene scene;
|
||||||
std::unique_ptr<StreamReaderLE> stream(new StreamReaderLE(pIOHandler->Open(pFile, "rb")));
|
|
||||||
|
auto file = pIOHandler->Open(pFile, "rb");
|
||||||
|
if (!file) {
|
||||||
|
ThrowException("Could not open " + pFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<StreamReaderLE> stream(new StreamReaderLE(file));
|
||||||
|
|
||||||
// check header
|
// check header
|
||||||
char head[32];
|
char head[32];
|
||||||
|
@ -146,7 +152,7 @@ void COBImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
ThrowException("Could not found magic id: `Caligari`");
|
ThrowException("Could not found magic id: `Caligari`");
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_INFO_F("File format tag: ", std::string(head + 9, 6));
|
ASSIMP_LOG_INFO("File format tag: ", std::string(head + 9, 6));
|
||||||
if (head[16] != 'L') {
|
if (head[16] != 'L') {
|
||||||
ThrowException("File is big-endian, which is not supported");
|
ThrowException("File is big-endian, which is not supported");
|
||||||
}
|
}
|
||||||
|
@ -295,8 +301,7 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi
|
||||||
}
|
}
|
||||||
std::unique_ptr<const Material> defmat;
|
std::unique_ptr<const Material> defmat;
|
||||||
if (!min) {
|
if (!min) {
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG(format() << "Could not resolve material index "
|
ASSIMP_LOG_VERBOSE_DEBUG("Could not resolve material index ", reflist.first, " - creating default material for this slot");
|
||||||
<< reflist.first << " - creating default material for this slot");
|
|
||||||
|
|
||||||
defmat.reset(min = new Material());
|
defmat.reset(min = new Material());
|
||||||
}
|
}
|
||||||
|
@ -521,7 +526,7 @@ void COBImporter::ReadMat1_Ascii(Scene &out, LineSplitter &splitter, const Chunk
|
||||||
|
|
||||||
++splitter;
|
++splitter;
|
||||||
if (!splitter.match_start("mat# ")) {
|
if (!splitter.match_start("mat# ")) {
|
||||||
ASSIMP_LOG_WARN_F("Expected `mat#` line in `Mat1` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Expected `mat#` line in `Mat1` chunk ", nfo.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,7 +538,7 @@ void COBImporter::ReadMat1_Ascii(Scene &out, LineSplitter &splitter, const Chunk
|
||||||
++splitter;
|
++splitter;
|
||||||
|
|
||||||
if (!splitter.match_start("shader: ")) {
|
if (!splitter.match_start("shader: ")) {
|
||||||
ASSIMP_LOG_WARN_F("Expected `mat#` line in `Mat1` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Expected `mat#` line in `Mat1` chunk ", nfo.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string shader = std::string(splitter[1]);
|
std::string shader = std::string(splitter[1]);
|
||||||
|
@ -544,12 +549,12 @@ void COBImporter::ReadMat1_Ascii(Scene &out, LineSplitter &splitter, const Chunk
|
||||||
} else if (shader == "phong") {
|
} else if (shader == "phong") {
|
||||||
mat.shader = Material::PHONG;
|
mat.shader = Material::PHONG;
|
||||||
} else if (shader != "flat") {
|
} else if (shader != "flat") {
|
||||||
ASSIMP_LOG_WARN_F("Unknown value for `shader` in `Mat1` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Unknown value for `shader` in `Mat1` chunk ", nfo.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
++splitter;
|
++splitter;
|
||||||
if (!splitter.match_start("rgb ")) {
|
if (!splitter.match_start("rgb ")) {
|
||||||
ASSIMP_LOG_WARN_F("Expected `rgb` line in `Mat1` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Expected `rgb` line in `Mat1` chunk ", nfo.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *rgb = splitter[1];
|
const char *rgb = splitter[1];
|
||||||
|
@ -557,7 +562,7 @@ void COBImporter::ReadMat1_Ascii(Scene &out, LineSplitter &splitter, const Chunk
|
||||||
|
|
||||||
++splitter;
|
++splitter;
|
||||||
if (!splitter.match_start("alpha ")) {
|
if (!splitter.match_start("alpha ")) {
|
||||||
ASSIMP_LOG_WARN_F("Expected `alpha` line in `Mat1` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Expected `alpha` line in `Mat1` chunk ", nfo.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *tokens[10];
|
const char *tokens[10];
|
||||||
|
@ -577,7 +582,7 @@ void COBImporter::ReadUnit_Ascii(Scene &out, LineSplitter &splitter, const Chunk
|
||||||
}
|
}
|
||||||
++splitter;
|
++splitter;
|
||||||
if (!splitter.match_start("Units ")) {
|
if (!splitter.match_start("Units ")) {
|
||||||
ASSIMP_LOG_WARN_F("Expected `Units` line in `Unit` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Expected `Units` line in `Unit` chunk ", nfo.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,12 +593,12 @@ void COBImporter::ReadUnit_Ascii(Scene &out, LineSplitter &splitter, const Chunk
|
||||||
const unsigned int t = strtoul10(splitter[1]);
|
const unsigned int t = strtoul10(splitter[1]);
|
||||||
|
|
||||||
nd->unit_scale = t >= sizeof(units) / sizeof(units[0]) ? (
|
nd->unit_scale = t >= sizeof(units) / sizeof(units[0]) ? (
|
||||||
ASSIMP_LOG_WARN_F(t, " is not a valid value for `Units` attribute in `Unit chunk` ", nfo.id), 1.f) :
|
ASSIMP_LOG_WARN(t, " is not a valid value for `Units` attribute in `Unit chunk` ", nfo.id), 1.f) :
|
||||||
units[t];
|
units[t];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSIMP_LOG_WARN_F("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
|
ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -622,13 +627,13 @@ void COBImporter::ReadLght_Ascii(Scene &out, LineSplitter &splitter, const Chunk
|
||||||
} else if (splitter.match_start("Spot ")) {
|
} else if (splitter.match_start("Spot ")) {
|
||||||
msh.ltype = Light::SPOT;
|
msh.ltype = Light::SPOT;
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN_F("Unknown kind of light source in `Lght` chunk ", nfo.id, " : ", *splitter);
|
ASSIMP_LOG_WARN("Unknown kind of light source in `Lght` chunk ", nfo.id, " : ", *splitter);
|
||||||
msh.ltype = Light::SPOT;
|
msh.ltype = Light::SPOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
++splitter;
|
++splitter;
|
||||||
if (!splitter.match_start("color ")) {
|
if (!splitter.match_start("color ")) {
|
||||||
ASSIMP_LOG_WARN_F("Expected `color` line in `Lght` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Expected `color` line in `Lght` chunk ", nfo.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *rgb = splitter[1];
|
const char *rgb = splitter[1];
|
||||||
|
@ -636,14 +641,14 @@ void COBImporter::ReadLght_Ascii(Scene &out, LineSplitter &splitter, const Chunk
|
||||||
|
|
||||||
SkipSpaces(&rgb);
|
SkipSpaces(&rgb);
|
||||||
if (strncmp(rgb, "cone angle", 10) != 0) {
|
if (strncmp(rgb, "cone angle", 10) != 0) {
|
||||||
ASSIMP_LOG_WARN_F("Expected `cone angle` entity in `color` line in `Lght` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Expected `cone angle` entity in `color` line in `Lght` chunk ", nfo.id);
|
||||||
}
|
}
|
||||||
SkipSpaces(rgb + 10, &rgb);
|
SkipSpaces(rgb + 10, &rgb);
|
||||||
msh.angle = fast_atof(&rgb);
|
msh.angle = fast_atof(&rgb);
|
||||||
|
|
||||||
SkipSpaces(&rgb);
|
SkipSpaces(&rgb);
|
||||||
if (strncmp(rgb, "inner angle", 11) != 0) {
|
if (strncmp(rgb, "inner angle", 11) != 0) {
|
||||||
ASSIMP_LOG_WARN_F("Expected `inner angle` entity in `color` line in `Lght` chunk ", nfo.id);
|
ASSIMP_LOG_WARN("Expected `inner angle` entity in `color` line in `Lght` chunk ", nfo.id);
|
||||||
}
|
}
|
||||||
SkipSpaces(rgb + 11, &rgb);
|
SkipSpaces(rgb + 11, &rgb);
|
||||||
msh.inner_angle = fast_atof(&rgb);
|
msh.inner_angle = fast_atof(&rgb);
|
||||||
|
@ -1027,7 +1032,7 @@ void COBImporter::ReadMat1_Binary(COB::Scene &out, StreamReaderLE &reader, const
|
||||||
mat.type = Material::METAL;
|
mat.type = Material::METAL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSIMP_LOG_ERROR_F("Unrecognized shader type in `Mat1` chunk with id ", nfo.id);
|
ASSIMP_LOG_ERROR("Unrecognized shader type in `Mat1` chunk with id ", nfo.id);
|
||||||
mat.type = Material::FLAT;
|
mat.type = Material::FLAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,7 +1047,7 @@ void COBImporter::ReadMat1_Binary(COB::Scene &out, StreamReaderLE &reader, const
|
||||||
mat.autofacet = Material::SMOOTH;
|
mat.autofacet = Material::SMOOTH;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSIMP_LOG_ERROR_F("Unrecognized faceting mode in `Mat1` chunk with id ", nfo.id);
|
ASSIMP_LOG_ERROR("Unrecognized faceting mode in `Mat1` chunk with id ", nfo.id);
|
||||||
mat.autofacet = Material::FACETED;
|
mat.autofacet = Material::FACETED;
|
||||||
}
|
}
|
||||||
mat.autofacet_angle = static_cast<float>(reader.GetI1());
|
mat.autofacet_angle = static_cast<float>(reader.GetI1());
|
||||||
|
@ -1170,13 +1175,13 @@ void COBImporter::ReadUnit_Binary(COB::Scene &out, StreamReaderLE &reader, const
|
||||||
if (nd->id == nfo.parent_id) {
|
if (nd->id == nfo.parent_id) {
|
||||||
const unsigned int t = reader.GetI2();
|
const unsigned int t = reader.GetI2();
|
||||||
nd->unit_scale = t >= sizeof(units) / sizeof(units[0]) ? (
|
nd->unit_scale = t >= sizeof(units) / sizeof(units[0]) ? (
|
||||||
ASSIMP_LOG_WARN_F(t, " is not a valid value for `Units` attribute in `Unit chunk` ", nfo.id), 1.f) :
|
ASSIMP_LOG_WARN(t, " is not a valid value for `Units` attribute in `Unit chunk` ", nfo.id), 1.f) :
|
||||||
units[t];
|
units[t];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSIMP_LOG_WARN_F("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
|
ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_COB_IMPORTER
|
#endif // ASSIMP_BUILD_NO_COB_IMPORTER
|
||||||
|
|
|
@ -75,7 +75,7 @@ static const aiImporterDesc desc = {
|
||||||
3,
|
3,
|
||||||
1,
|
1,
|
||||||
5,
|
5,
|
||||||
"dae zae"
|
"dae xml zae"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float kMillisecondsFromSeconds = 1000.f;
|
static const float kMillisecondsFromSeconds = 1000.f;
|
||||||
|
@ -317,7 +317,7 @@ void ColladaLoader::ResolveNodeInstances(const ColladaParser &pParser, const Nod
|
||||||
nd = FindNode(pParser.mRootNode, nodeInst.mNode);
|
nd = FindNode(pParser.mRootNode, nodeInst.mNode);
|
||||||
}
|
}
|
||||||
if (nullptr == nd) {
|
if (nullptr == nd) {
|
||||||
ASSIMP_LOG_ERROR_F("Collada: Unable to resolve reference to instanced node ", nodeInst.mNode);
|
ASSIMP_LOG_ERROR("Collada: Unable to resolve reference to instanced node ", nodeInst.mNode);
|
||||||
} else {
|
} else {
|
||||||
// attach this node to the list of children
|
// attach this node to the list of children
|
||||||
resolved.push_back(nd);
|
resolved.push_back(nd);
|
||||||
|
@ -347,7 +347,7 @@ void ColladaLoader::BuildLightsForNode(const ColladaParser &pParser, const Node
|
||||||
// find the referred light
|
// find the referred light
|
||||||
ColladaParser::LightLibrary::const_iterator srcLightIt = pParser.mLightLibrary.find(lid.mLight);
|
ColladaParser::LightLibrary::const_iterator srcLightIt = pParser.mLightLibrary.find(lid.mLight);
|
||||||
if (srcLightIt == pParser.mLightLibrary.end()) {
|
if (srcLightIt == pParser.mLightLibrary.end()) {
|
||||||
ASSIMP_LOG_WARN_F("Collada: Unable to find light for ID \"", lid.mLight, "\". Skipping.");
|
ASSIMP_LOG_WARN("Collada: Unable to find light for ID \"", lid.mLight, "\". Skipping.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const Collada::Light *srcLight = &srcLightIt->second;
|
const Collada::Light *srcLight = &srcLightIt->second;
|
||||||
|
@ -412,7 +412,7 @@ void ColladaLoader::BuildCamerasForNode(const ColladaParser &pParser, const Node
|
||||||
// find the referred light
|
// find the referred light
|
||||||
ColladaParser::CameraLibrary::const_iterator srcCameraIt = pParser.mCameraLibrary.find(cid.mCamera);
|
ColladaParser::CameraLibrary::const_iterator srcCameraIt = pParser.mCameraLibrary.find(cid.mCamera);
|
||||||
if (srcCameraIt == pParser.mCameraLibrary.end()) {
|
if (srcCameraIt == pParser.mCameraLibrary.end()) {
|
||||||
ASSIMP_LOG_WARN_F("Collada: Unable to find camera for ID \"", cid.mCamera, "\". Skipping.");
|
ASSIMP_LOG_WARN("Collada: Unable to find camera for ID \"", cid.mCamera, "\". Skipping.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const Collada::Camera *srcCamera = &srcCameraIt->second;
|
const Collada::Camera *srcCamera = &srcCameraIt->second;
|
||||||
|
@ -486,7 +486,7 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser &pParser, const Node
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullptr == srcMesh) {
|
if (nullptr == srcMesh) {
|
||||||
ASSIMP_LOG_WARN_F("Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping.");
|
ASSIMP_LOG_WARN("Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -511,7 +511,7 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser &pParser, const Node
|
||||||
table = &meshMatIt->second;
|
table = &meshMatIt->second;
|
||||||
meshMaterial = table->mMatName;
|
meshMaterial = table->mMatName;
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN_F("Collada: No material specified for subgroup <", submesh.mMaterial, "> in geometry <",
|
ASSIMP_LOG_WARN("Collada: No material specified for subgroup <", submesh.mMaterial, "> in geometry <",
|
||||||
mid.mMeshOrController, ">.");
|
mid.mMeshOrController, ">.");
|
||||||
if (!mid.mMaterials.empty()) {
|
if (!mid.mMaterials.empty()) {
|
||||||
meshMaterial = mid.mMaterials.begin()->second.mMatName;
|
meshMaterial = mid.mMaterials.begin()->second.mMatName;
|
||||||
|
@ -883,7 +883,7 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Mesh *pSrc
|
||||||
if (nullptr != bnode) {
|
if (nullptr != bnode) {
|
||||||
bone->mName.Set(FindNameForNode(bnode));
|
bone->mName.Set(FindNameForNode(bnode));
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN_F("ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\".");
|
ASSIMP_LOG_WARN("ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
// and insert bone
|
// and insert bone
|
||||||
|
@ -1184,7 +1184,7 @@ void ColladaLoader::CreateAnimation(aiScene *pScene, const ColladaParser &pParse
|
||||||
else if (subElement == "Z")
|
else if (subElement == "Z")
|
||||||
entry.mSubElement = 2;
|
entry.mSubElement = 2;
|
||||||
else
|
else
|
||||||
ASSIMP_LOG_WARN_F("Unknown anim subelement <", subElement, ">. Ignoring");
|
ASSIMP_LOG_WARN("Unknown anim subelement <", subElement, ">. Ignoring");
|
||||||
} else {
|
} else {
|
||||||
// no sub-element following, transformId is remaining string
|
// no sub-element following, transformId is remaining string
|
||||||
entry.mTransformId = srcChannel.mTarget.substr(slashPos + 1);
|
entry.mTransformId = srcChannel.mTarget.substr(slashPos + 1);
|
||||||
|
@ -1241,7 +1241,7 @@ void ColladaLoader::CreateAnimation(aiScene *pScene, const ColladaParser &pParse
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
entry.mTargetId = entry.mTransformId;
|
entry.mTargetId = entry.mTransformId;
|
||||||
entry.mTransformId = "";
|
entry.mTransformId = std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.mChannel = &(*cit);
|
entry.mChannel = &(*cit);
|
||||||
|
@ -1711,7 +1711,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser &pParse
|
||||||
// find the image referred by this name in the image library of the scene
|
// find the image referred by this name in the image library of the scene
|
||||||
ColladaParser::ImageLibrary::const_iterator imIt = pParser.mImageLibrary.find(name);
|
ColladaParser::ImageLibrary::const_iterator imIt = pParser.mImageLibrary.find(name);
|
||||||
if (imIt == pParser.mImageLibrary.end()) {
|
if (imIt == pParser.mImageLibrary.end()) {
|
||||||
ASSIMP_LOG_WARN_F("Collada: Unable to resolve effect texture entry \"", pName, "\", ended up at ID \"", name, "\".");
|
ASSIMP_LOG_WARN("Collada: Unable to resolve effect texture entry \"", pName, "\", ended up at ID \"", name, "\".");
|
||||||
|
|
||||||
//set default texture file name
|
//set default texture file name
|
||||||
result.Set(name + ".jpg");
|
result.Set(name + ".jpg");
|
||||||
|
|
|
@ -71,7 +71,7 @@ static void ReportWarning(const char *msg, ...) {
|
||||||
ai_assert(iLen > 0);
|
ai_assert(iLen > 0);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
ASSIMP_LOG_WARN_F("Validation warning: ", std::string(szBuffer, iLen));
|
ASSIMP_LOG_WARN("Validation warning: ", std::string(szBuffer, iLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVector &key_renaming, size_t &found_index) {
|
static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVector &key_renaming, size_t &found_index) {
|
||||||
|
@ -234,7 +234,7 @@ void ColladaParser::UriDecodePath(aiString &ss) {
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
||||||
#else
|
#else
|
||||||
if (ss.data[0] == '/' && isalpha(ss.data[1]) && ss.data[2] == ':') {
|
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
||||||
#endif
|
#endif
|
||||||
--ss.length;
|
--ss.length;
|
||||||
::memmove(ss.data, ss.data + 1, ss.length);
|
::memmove(ss.data, ss.data + 1, ss.length);
|
||||||
|
@ -623,8 +623,7 @@ void ColladaParser::ReadController(XmlNode &node, Collada::Controller &controlle
|
||||||
controller.mType = Skin;
|
controller.mType = Skin;
|
||||||
controller.mMethod = Normalized;
|
controller.mMethod = Normalized;
|
||||||
|
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
|
|
||||||
|
@ -929,8 +928,7 @@ void ColladaParser::ReadMaterial(XmlNode &node, Collada::Material &pMaterial) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Reads a light entry into the given light
|
// Reads a light entry into the given light
|
||||||
void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
|
void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
|
@ -991,10 +989,8 @@ void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Reads a camera entry into the given light
|
// Reads a camera entry into the given light
|
||||||
void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) {
|
void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) {
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
|
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
if (currentName == "orthographic") {
|
if (currentName == "orthographic") {
|
||||||
|
@ -1050,11 +1046,10 @@ void ColladaParser::ReadEffect(XmlNode &node, Collada::Effect &pEffect) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Reads an COMMON effect profile
|
// Reads an COMMON effect profile
|
||||||
void ColladaParser::ReadEffectProfileCommon(XmlNode &node, Collada::Effect &pEffect) {
|
void ColladaParser::ReadEffectProfileCommon(XmlNode &node, Collada::Effect &pEffect) {
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string currentName = currentNode.name();
|
||||||
if (currentName == "newparam") {
|
if (currentName == "newparam") {
|
||||||
// save ID
|
// save ID
|
||||||
std::string sid = currentNode.attribute("sid").as_string();
|
std::string sid = currentNode.attribute("sid").as_string();
|
||||||
|
@ -1145,10 +1140,9 @@ void ColladaParser::ReadSamplerProperties(XmlNode &node, Sampler &out) {
|
||||||
if (node.empty()) {
|
if (node.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XmlNodeIterator xmlIt(node);
|
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
|
||||||
|
|
||||||
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
// MAYA extensions
|
// MAYA extensions
|
||||||
|
@ -1208,10 +1202,9 @@ void ColladaParser::ReadEffectColor(XmlNode &node, aiColor4D &pColor, Sampler &p
|
||||||
if (node.empty()) {
|
if (node.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XmlNodeIterator xmlIt(node);
|
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
|
||||||
|
|
||||||
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
if (currentName == "color") {
|
if (currentName == "color") {
|
||||||
|
@ -1273,8 +1266,7 @@ void ColladaParser::ReadEffectParam(XmlNode &node, Collada::EffectParam &pParam)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
|
@ -1360,8 +1352,7 @@ void ColladaParser::ReadMesh(XmlNode &node, Mesh &pMesh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
|
@ -1386,8 +1377,7 @@ void ColladaParser::ReadSource(XmlNode &node) {
|
||||||
|
|
||||||
std::string sourceID;
|
std::string sourceID;
|
||||||
XmlParser::getStdStrAttribute(node, "id", sourceID);
|
XmlParser::getStdStrAttribute(node, "id", sourceID);
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
|
@ -1490,8 +1480,7 @@ void ColladaParser::ReadAccessor(XmlNode &node, const std::string &pID) {
|
||||||
acc.mSource = source.c_str() + 1; // ignore the leading '#'
|
acc.mSource = source.c_str() + 1; // ignore the leading '#'
|
||||||
acc.mSize = 0; // gets incremented with every param
|
acc.mSize = 0; // gets incremented with every param
|
||||||
|
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
|
@ -1608,8 +1597,7 @@ void ColladaParser::ReadIndexData(XmlNode &node, Mesh &pMesh) {
|
||||||
ai_assert(primType != Prim_Invalid);
|
ai_assert(primType != Prim_Invalid);
|
||||||
|
|
||||||
// also a number of <input> elements, but in addition a <p> primitive collection and probably index counts for all primitives
|
// also a number of <input> elements, but in addition a <p> primitive collection and probably index counts for all primitives
|
||||||
XmlNodeIterator xmlIt(node);
|
XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
|
||||||
xmlIt.collectChildrenPreOrder(node);
|
|
||||||
XmlNode currentNode;
|
XmlNode currentNode;
|
||||||
while (xmlIt.getNext(currentNode)) {
|
while (xmlIt.getNext(currentNode)) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
|
@ -2400,7 +2388,7 @@ Collada::InputType ColladaParser::GetTypeForSemantic(const std::string &semantic
|
||||||
else if (semantic == "TANGENT" || semantic == "TEXTANGENT")
|
else if (semantic == "TANGENT" || semantic == "TEXTANGENT")
|
||||||
return IT_Tangent;
|
return IT_Tangent;
|
||||||
|
|
||||||
ASSIMP_LOG_WARN_F("Unknown vertex input type \"", semantic, "\". Ignoring.");
|
ASSIMP_LOG_WARN("Unknown vertex input type \"", semantic, "\". Ignoring.");
|
||||||
return IT_Invalid;
|
return IT_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ public:
|
||||||
for(;splitter->length() && splitter->at(0) != '}'; splitter++, cnt++);
|
for(;splitter->length() && splitter->at(0) != '}'; splitter++, cnt++);
|
||||||
|
|
||||||
splitter++;
|
splitter++;
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG((Formatter::format("DXF: skipped over control group ("),cnt," lines)"));
|
ASSIMP_LOG_VERBOSE_DEBUG("DXF: skipped over control group (",cnt," lines)");
|
||||||
}
|
}
|
||||||
} catch(std::logic_error&) {
|
} catch(std::logic_error&) {
|
||||||
ai_assert(!splitter);
|
ai_assert(!splitter);
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2021, assimp team
|
Copyright (c) 2006-2021, 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,
|
||||||
|
@ -63,11 +61,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
// AutoCAD Binary DXF<CR><LF><SUB><NULL>
|
// AutoCAD Binary DXF<CR><LF><SUB><NULL>
|
||||||
const std::string AI_DXF_BINARY_IDENT = std::string("AutoCAD Binary DXF\r\n\x1a\0");
|
static constexpr char AI_DXF_BINARY_IDENT[] = "AutoCAD Binary DXF\r\n\x1a";
|
||||||
const size_t AI_DXF_BINARY_IDENT_LEN = 24u;
|
static constexpr size_t AI_DXF_BINARY_IDENT_LEN = sizeof AI_DXF_BINARY_IDENT;
|
||||||
|
|
||||||
// default vertex color that all uncolored vertices will receive
|
// default vertex color that all uncolored vertices will receive
|
||||||
const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
|
static const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
|
||||||
|
|
||||||
// color indices for DXF - 16 are supported, the table is
|
// color indices for DXF - 16 are supported, the table is
|
||||||
// taken directly from the DXF spec.
|
// taken directly from the DXF spec.
|
||||||
|
@ -156,10 +154,10 @@ void DXFImporter::InternReadFile( const std::string& filename, aiScene* pScene,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether this is a binary DXF file - we can't read binary DXF files :-(
|
// Check whether this is a binary DXF file - we can't read binary DXF files :-(
|
||||||
char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0};
|
char buff[AI_DXF_BINARY_IDENT_LEN] = {0};
|
||||||
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
|
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
|
||||||
|
|
||||||
if (0 == strncmp(AI_DXF_BINARY_IDENT.c_str(),buff,AI_DXF_BINARY_IDENT_LEN)) {
|
if (0 == memcmp(AI_DXF_BINARY_IDENT,buff,AI_DXF_BINARY_IDENT_LEN)) {
|
||||||
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
|
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +200,7 @@ void DXFImporter::InternReadFile( const std::string& filename, aiScene* pScene,
|
||||||
|
|
||||||
// comments
|
// comments
|
||||||
else if (reader.Is(999)) {
|
else if (reader.Is(999)) {
|
||||||
ASSIMP_LOG_INFO_F("DXF Comment: ", reader.Value());
|
ASSIMP_LOG_INFO("DXF Comment: ", reader.Value());
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't read past the official EOF sign
|
// don't read past the official EOF sign
|
||||||
|
@ -241,7 +239,7 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount);
|
ASSIMP_LOG_VERBOSE_DEBUG("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! output.blocks.size() ) {
|
if (! output.blocks.size() ) {
|
||||||
|
@ -372,7 +370,7 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
|
||||||
// first check if the referenced blocks exists ...
|
// first check if the referenced blocks exists ...
|
||||||
const DXF::BlockMap::const_iterator it = blocks_by_name.find(insert.name);
|
const DXF::BlockMap::const_iterator it = blocks_by_name.find(insert.name);
|
||||||
if (it == blocks_by_name.end()) {
|
if (it == blocks_by_name.end()) {
|
||||||
ASSIMP_LOG_ERROR_F("DXF: Failed to resolve block reference: ", insert.name,"; skipping" );
|
ASSIMP_LOG_ERROR("DXF: Failed to resolve block reference: ", insert.name,"; skipping" );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +471,7 @@ void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) {
|
||||||
++reader;
|
++reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("DXF: got ", output.blocks.size()," entries in BLOCKS" );
|
ASSIMP_LOG_VERBOSE_DEBUG("DXF: got ", output.blocks.size()," entries in BLOCKS" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -549,7 +547,7 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output)
|
||||||
++reader;
|
++reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F( "DXF: got ", block.lines.size()," polylines and ", block.insertions.size(),
|
ASSIMP_LOG_VERBOSE_DEBUG( "DXF: got ", block.lines.size()," polylines and ", block.insertions.size(),
|
||||||
" inserted blocks in ENTITIES" );
|
" inserted blocks in ENTITIES" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +652,7 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (vguess && line.positions.size() != vguess) {
|
if (vguess && line.positions.size() != vguess) {
|
||||||
ASSIMP_LOG_WARN_F("DXF: unexpected vertex count in polymesh: ",
|
ASSIMP_LOG_WARN("DXF: unexpected vertex count in polymesh: ",
|
||||||
line.positions.size(),", expected ", vguess );
|
line.positions.size(),", expected ", vguess );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,7 +668,7 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
|
||||||
// to set the 71 and 72 fields, respectively, to valid values.
|
// to set the 71 and 72 fields, respectively, to valid values.
|
||||||
// So just fire a warning.
|
// So just fire a warning.
|
||||||
if (iguess && line.counts.size() != iguess) {
|
if (iguess && line.counts.size() != iguess) {
|
||||||
ASSIMP_LOG_WARN_F( "DXF: unexpected face count in polymesh: ", line.counts.size(),", expected ", iguess );
|
ASSIMP_LOG_WARN( "DXF: unexpected face count in polymesh: ", line.counts.size(),", expected ", iguess );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!line.indices.size() && !line.counts.size()) {
|
else if (!line.indices.size() && !line.counts.size()) {
|
||||||
|
|
|
@ -459,7 +459,7 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length)
|
||||||
/*Result ignored*/ ReadByte(input, cursor, input + length);
|
/*Result ignored*/ ReadByte(input, cursor, input + length);
|
||||||
/*Result ignored*/ ReadByte(input, cursor, input + length);
|
/*Result ignored*/ ReadByte(input, cursor, input + length);
|
||||||
const uint32_t version = ReadWord(input, cursor, input + length);
|
const uint32_t version = ReadWord(input, cursor, input + length);
|
||||||
ASSIMP_LOG_DEBUG_F("FBX version: ", version);
|
ASSIMP_LOG_DEBUG("FBX version: ", version);
|
||||||
const bool is64bits = version >= 7500;
|
const bool is64bits = version >= 7500;
|
||||||
const char *end = input + length;
|
const char *end = input + length;
|
||||||
try
|
try
|
||||||
|
|
|
@ -811,7 +811,7 @@ bool FBXConverter::GenerateTransformationNodeChain(const Model &model, const std
|
||||||
// we need to generate a full node chain to accommodate for assimp's
|
// we need to generate a full node chain to accommodate for assimp's
|
||||||
// lack to express pivots and offsets.
|
// lack to express pivots and offsets.
|
||||||
if ((chainBits & chainMaskComplex) && doc.Settings().preservePivots) {
|
if ((chainBits & chainMaskComplex) && doc.Settings().preservePivots) {
|
||||||
FBXImporter::LogInfo("generating full transformation chain for node: " + name);
|
FBXImporter::LogInfo("generating full transformation chain for node: ", name);
|
||||||
|
|
||||||
// query the anim_chain_bits dictionary to find out which chain elements
|
// query the anim_chain_bits dictionary to find out which chain elements
|
||||||
// have associated node animation channels. These can not be dropped
|
// have associated node animation channels. These can not be dropped
|
||||||
|
@ -918,7 +918,7 @@ void FBXConverter::ConvertModel(const Model &model, aiNode *parent, aiNode *root
|
||||||
const std::vector<unsigned int> &indices = ConvertLine(*line, root_node);
|
const std::vector<unsigned int> &indices = ConvertLine(*line, root_node);
|
||||||
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
|
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
|
||||||
} else {
|
} else {
|
||||||
FBXImporter::LogWarn("ignoring unrecognized geometry: " + geo->Name());
|
FBXImporter::LogWarn("ignoring unrecognized geometry: ", geo->Name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,7 +944,7 @@ FBXConverter::ConvertMesh(const MeshGeometry &mesh, const Model &model, aiNode *
|
||||||
const std::vector<aiVector3D> &vertices = mesh.GetVertices();
|
const std::vector<aiVector3D> &vertices = mesh.GetVertices();
|
||||||
const std::vector<unsigned int> &faces = mesh.GetFaceIndexCounts();
|
const std::vector<unsigned int> &faces = mesh.GetFaceIndexCounts();
|
||||||
if (vertices.empty() || faces.empty()) {
|
if (vertices.empty() || faces.empty()) {
|
||||||
FBXImporter::LogWarn("ignoring empty geometry: " + mesh.Name());
|
FBXImporter::LogWarn("ignoring empty geometry: ", mesh.Name());
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,7 +971,7 @@ std::vector<unsigned int> FBXConverter::ConvertLine(const LineGeometry &line, ai
|
||||||
const std::vector<aiVector3D> &vertices = line.GetVertices();
|
const std::vector<aiVector3D> &vertices = line.GetVertices();
|
||||||
const std::vector<int> &indices = line.GetIndices();
|
const std::vector<int> &indices = line.GetIndices();
|
||||||
if (vertices.empty() || indices.empty()) {
|
if (vertices.empty() || indices.empty()) {
|
||||||
FBXImporter::LogWarn("ignoring empty line: " + line.Name());
|
FBXImporter::LogWarn("ignoring empty line: ", line.Name());
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1126,6 +1126,8 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
|
||||||
*out_uv++ = aiVector3D(v.x, v.y, 0.0f);
|
*out_uv++ = aiVector3D(v.x, v.y, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out_mesh->mTextureCoordsNames[i] = mesh.GetTextureCoordChannelName(i);
|
||||||
|
|
||||||
out_mesh->mNumUVComponents[i] = 2;
|
out_mesh->mNumUVComponents[i] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1542,10 +1544,10 @@ void FBXConverter::ConvertCluster(std::vector<aiBone *> &local_mesh_bones, const
|
||||||
aiBone *bone = nullptr;
|
aiBone *bone = nullptr;
|
||||||
|
|
||||||
if (bone_map.count(deformer_name)) {
|
if (bone_map.count(deformer_name)) {
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("retrieved bone from lookup ", bone_name.C_Str(), ". Deformer:", deformer_name);
|
ASSIMP_LOG_VERBOSE_DEBUG("retrieved bone from lookup ", bone_name.C_Str(), ". Deformer:", deformer_name);
|
||||||
bone = bone_map[deformer_name];
|
bone = bone_map[deformer_name];
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("created new bone ", bone_name.C_Str(), ". Deformer: ", deformer_name);
|
ASSIMP_LOG_VERBOSE_DEBUG("created new bone ", bone_name.C_Str(), ". Deformer: ", deformer_name);
|
||||||
bone = new aiBone();
|
bone = new aiBone();
|
||||||
bone->mName = bone_name;
|
bone->mName = bone_name;
|
||||||
|
|
||||||
|
@ -1591,7 +1593,7 @@ void FBXConverter::ConvertCluster(std::vector<aiBone *> &local_mesh_bones, const
|
||||||
bone_map.insert(std::pair<const std::string, aiBone *>(deformer_name, bone));
|
bone_map.insert(std::pair<const std::string, aiBone *>(deformer_name, bone));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F("bone research: Indicies size: ", out_indices.size());
|
ASSIMP_LOG_DEBUG("bone research: Indicies size: ", out_indices.size());
|
||||||
|
|
||||||
// lookup must be populated in case something goes wrong
|
// lookup must be populated in case something goes wrong
|
||||||
// this also allocates bones to mesh instance outside
|
// this also allocates bones to mesh instance outside
|
||||||
|
@ -1815,14 +1817,14 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const TextureMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
|
FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
uvIndex = index;
|
uvIndex = index;
|
||||||
} else {
|
} else {
|
||||||
FBXImporter::LogWarn("the UV channel named " + uvSet +
|
FBXImporter::LogWarn("the UV channel named ", uvSet,
|
||||||
" appears at different positions in meshes, results will be wrong");
|
" appears at different positions in meshes, results will be wrong");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1839,7 +1841,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const TextureMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
|
FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
|
@ -1848,7 +1850,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const TextureMap
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
FBXImporter::LogWarn("failed to resolve UV channel " + uvSet + ", using first UV channel");
|
FBXImporter::LogWarn("failed to resolve UV channel ", uvSet, ", using first UV channel");
|
||||||
uvIndex = 0;
|
uvIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1934,14 +1936,14 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const LayeredTex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
|
FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
uvIndex = index;
|
uvIndex = index;
|
||||||
} else {
|
} else {
|
||||||
FBXImporter::LogWarn("the UV channel named " + uvSet +
|
FBXImporter::LogWarn("the UV channel named ", uvSet,
|
||||||
" appears at different positions in meshes, results will be wrong");
|
" appears at different positions in meshes, results will be wrong");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1958,7 +1960,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const LayeredTex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
|
FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
|
@ -1967,7 +1969,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const LayeredTex
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
FBXImporter::LogWarn("failed to resolve UV channel " + uvSet + ", using first UV channel");
|
FBXImporter::LogWarn("failed to resolve UV channel ", uvSet, ", using first UV channel");
|
||||||
uvIndex = 0;
|
uvIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2126,6 +2128,11 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
|
||||||
const aiColor3D &Emissive = GetColorPropertyFromMaterial(props, "Emissive", ok);
|
const aiColor3D &Emissive = GetColorPropertyFromMaterial(props, "Emissive", ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
out_mat->AddProperty(&Emissive, 1, AI_MATKEY_COLOR_EMISSIVE);
|
out_mat->AddProperty(&Emissive, 1, AI_MATKEY_COLOR_EMISSIVE);
|
||||||
|
} else {
|
||||||
|
const aiColor3D &emissiveColor = GetColorPropertyFromMaterial(props, "Maya|emissive", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&emissiveColor, 1, AI_MATKEY_COLOR_EMISSIVE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const aiColor3D &Ambient = GetColorPropertyFromMaterial(props, "Ambient", ok);
|
const aiColor3D &Ambient = GetColorPropertyFromMaterial(props, "Ambient", ok);
|
||||||
|
@ -2207,6 +2214,52 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
|
||||||
if (ok) {
|
if (ok) {
|
||||||
out_mat->AddProperty(&DispFactor, 1, "$mat.displacementscaling", 0, 0);
|
out_mat->AddProperty(&DispFactor, 1, "$mat.displacementscaling", 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PBR material information
|
||||||
|
const aiColor3D &baseColor = GetColorPropertyFromMaterial(props, "Maya|base_color", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&baseColor, 1, AI_MATKEY_BASE_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float useColorMap = PropertyGet<float>(props, "Maya|use_color_map", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&useColorMap, 1, AI_MATKEY_USE_COLOR_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float useMetallicMap = PropertyGet<float>(props, "Maya|use_metallic_map", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&useMetallicMap, 1, AI_MATKEY_USE_METALLIC_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float metallicFactor = PropertyGet<float>(props, "Maya|metallic", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&metallicFactor, 1, AI_MATKEY_METALLIC_FACTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float useRoughnessMap = PropertyGet<float>(props, "Maya|use_roughness_map", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&useRoughnessMap, 1, AI_MATKEY_USE_ROUGHNESS_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float roughnessFactor = PropertyGet<float>(props, "Maya|roughness", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&roughnessFactor, 1, AI_MATKEY_ROUGHNESS_FACTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float useEmissiveMap = PropertyGet<float>(props, "Maya|use_emissive_map", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&useEmissiveMap, 1, AI_MATKEY_USE_EMISSIVE_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float emissiveIntensity = PropertyGet<float>(props, "Maya|emissive_intensity", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&emissiveIntensity, 1, AI_MATKEY_EMISSIVE_INTENSITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float useAOMap = PropertyGet<float>(props, "Maya|use_ao_map", ok);
|
||||||
|
if (ok) {
|
||||||
|
out_mat->AddProperty(&useAOMap, 1, AI_MATKEY_USE_AO_MAP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTable &props, const TextureMap &_textures, const MeshGeometry *const mesh) {
|
void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTable &props, const TextureMap &_textures, const MeshGeometry *const mesh) {
|
||||||
|
@ -2319,14 +2372,14 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
|
FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
uvIndex = index;
|
uvIndex = index;
|
||||||
} else {
|
} else {
|
||||||
FBXImporter::LogWarn("the UV channel named " + uvSet + " appears at different positions in meshes, results will be wrong");
|
FBXImporter::LogWarn("the UV channel named ", uvSet, " appears at different positions in meshes, results will be wrong");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2342,7 +2395,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
|
FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
|
@ -2351,7 +2404,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndex == -1) {
|
if (uvIndex == -1) {
|
||||||
FBXImporter::LogWarn("failed to resolve UV channel " + uvSet + ", using first UV channel");
|
FBXImporter::LogWarn("failed to resolve UV channel ", uvSet, ", using first UV channel");
|
||||||
uvIndex = 0;
|
uvIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2574,7 +2627,7 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
|
||||||
// empty animations would fail validation, so drop them
|
// empty animations would fail validation, so drop them
|
||||||
delete anim;
|
delete anim;
|
||||||
animations.pop_back();
|
animations.pop_back();
|
||||||
FBXImporter::LogInfo("ignoring empty AnimationStack (using IK?): " + name);
|
FBXImporter::LogInfo("ignoring empty AnimationStack (using IK?): ", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2707,13 +2760,13 @@ void FBXConverter::GenerateNodeAnimations(std::vector<aiNodeAnim *> &node_anims,
|
||||||
ai_assert(node);
|
ai_assert(node);
|
||||||
|
|
||||||
if (node->TargetProperty().empty()) {
|
if (node->TargetProperty().empty()) {
|
||||||
FBXImporter::LogWarn("target property for animation curve not set: " + node->Name());
|
FBXImporter::LogWarn("target property for animation curve not set: ", node->Name());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
curve_node = node;
|
curve_node = node;
|
||||||
if (node->Curves().empty()) {
|
if (node->Curves().empty()) {
|
||||||
FBXImporter::LogWarn("no animation curves assigned to AnimationCurveNode: " + node->Name());
|
FBXImporter::LogWarn("no animation curves assigned to AnimationCurveNode: ", node->Name());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2748,7 +2801,7 @@ void FBXConverter::GenerateNodeAnimations(std::vector<aiNodeAnim *> &node_anims,
|
||||||
if (doc.Settings().optimizeEmptyAnimationCurves &&
|
if (doc.Settings().optimizeEmptyAnimationCurves &&
|
||||||
IsRedundantAnimationData(target, comp, (chain[i]->second))) {
|
IsRedundantAnimationData(target, comp, (chain[i]->second))) {
|
||||||
|
|
||||||
FBXImporter::LogVerboseDebug("dropping redundant animation channel for node " + target.Name());
|
FBXImporter::LogVerboseDebug("dropping redundant animation channel for node ", target.Name());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ void Document::ReadHeader() {
|
||||||
|
|
||||||
const Scope& shead = *ehead->Compound();
|
const Scope& shead = *ehead->Compound();
|
||||||
fbxVersion = ParseTokenAsInt(GetRequiredToken(GetRequiredElement(shead,"FBXVersion",ehead),0));
|
fbxVersion = ParseTokenAsInt(GetRequiredToken(GetRequiredElement(shead,"FBXVersion",ehead),0));
|
||||||
ASSIMP_LOG_DEBUG_F("FBX Version: ", fbxVersion);
|
ASSIMP_LOG_DEBUG("FBX Version: ", fbxVersion);
|
||||||
|
|
||||||
// While we may have some success with newer files, we don't support
|
// While we may have some success with newer files, we don't support
|
||||||
// the older 6.n fbx format
|
// the older 6.n fbx format
|
||||||
|
|
|
@ -79,7 +79,7 @@ void DOMError(const std::string& message, const Element* element /*= nullptr*/)
|
||||||
void DOMWarning(const std::string& message, const Token& token)
|
void DOMWarning(const std::string& message, const Token& token)
|
||||||
{
|
{
|
||||||
if(DefaultLogger::get()) {
|
if(DefaultLogger::get()) {
|
||||||
ASSIMP_LOG_WARN_F("FBX-DOM", Util::GetTokenText(&token), message);
|
ASSIMP_LOG_WARN("FBX-DOM", Util::GetTokenText(&token), message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ void DOMWarning(const std::string& message, const Element* element /*= nullptr*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(DefaultLogger::get()) {
|
if(DefaultLogger::get()) {
|
||||||
ASSIMP_LOG_WARN("FBX-DOM: " + message);
|
ASSIMP_LOG_WARN("FBX-DOM: ", message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -541,10 +541,17 @@ void FBXExporter::WriteReferences ()
|
||||||
// (before any actual data is written)
|
// (before any actual data is written)
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
size_t count_nodes(const aiNode* n) {
|
size_t count_nodes(const aiNode* n, const aiNode* root) {
|
||||||
size_t count = 1;
|
size_t count;
|
||||||
|
if (n == root) {
|
||||||
|
count = n->mNumMeshes; // (not counting root node)
|
||||||
|
} else if (n->mNumMeshes > 1) {
|
||||||
|
count = n->mNumMeshes + 1;
|
||||||
|
} else {
|
||||||
|
count = 1;
|
||||||
|
}
|
||||||
for (size_t i = 0; i < n->mNumChildren; ++i) {
|
for (size_t i = 0; i < n->mNumChildren; ++i) {
|
||||||
count += count_nodes(n->mChildren[i]);
|
count += count_nodes(n->mChildren[i], root);
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -714,7 +721,7 @@ void FBXExporter::WriteDefinitions ()
|
||||||
|
|
||||||
// Model / FbxNode
|
// Model / FbxNode
|
||||||
// <~~ node hierarchy
|
// <~~ node hierarchy
|
||||||
count = int32_t(count_nodes(mScene->mRootNode)) - 1; // (not counting root node)
|
count = int32_t(count_nodes(mScene->mRootNode, mScene->mRootNode));
|
||||||
if (count) {
|
if (count) {
|
||||||
n = FBX::Node("ObjectType", "Model");
|
n = FBX::Node("ObjectType", "Model");
|
||||||
n.AddChild("Count", count);
|
n.AddChild("Count", count);
|
||||||
|
@ -1789,13 +1796,13 @@ void FBXExporter::WriteObjects ()
|
||||||
blendchannel_uid, blendshape_name + FBX::SEPARATOR + "SubDeformer", "BlendShapeChannel"
|
blendchannel_uid, blendshape_name + FBX::SEPARATOR + "SubDeformer", "BlendShapeChannel"
|
||||||
);
|
);
|
||||||
sdnode.AddChild("Version", int32_t(100));
|
sdnode.AddChild("Version", int32_t(100));
|
||||||
sdnode.AddChild("DeformPercent", int32_t(100));
|
sdnode.AddChild("DeformPercent", float_t(0.0));
|
||||||
FBX::Node p("Properties70");
|
FBX::Node p("Properties70");
|
||||||
p.AddP70numberA("DeformPercent", 100.);
|
p.AddP70numberA("DeformPercent", 0.0);
|
||||||
sdnode.AddChild(p);
|
sdnode.AddChild(p);
|
||||||
// TODO: Normally just one weight per channel, adding stub for later development
|
// TODO: Normally just one weight per channel, adding stub for later development
|
||||||
std::vector<float>fFullWeights;
|
std::vector<float>fFullWeights;
|
||||||
fFullWeights.push_back(0.);
|
fFullWeights.push_back(100.);
|
||||||
sdnode.AddChild("FullWeights", fFullWeights);
|
sdnode.AddChild("FullWeights", fFullWeights);
|
||||||
sdnode.Dump(outstream, binary, indent);
|
sdnode.Dump(outstream, binary, indent);
|
||||||
|
|
||||||
|
@ -2625,17 +2632,14 @@ void FBXExporter::WriteModelNodes(
|
||||||
],
|
],
|
||||||
new_node_uid
|
new_node_uid
|
||||||
);
|
);
|
||||||
// write model node
|
|
||||||
FBX::Node m("Model");
|
aiNode new_node;
|
||||||
// take name from mesh name, if it exists
|
// take name from mesh name, if it exists
|
||||||
std::string name = mScene->mMeshes[node->mMeshes[i]]->mName.C_Str();
|
new_node.mName = mScene->mMeshes[node->mMeshes[i]]->mName;
|
||||||
name += FBX::SEPARATOR + "Model";
|
// write model node
|
||||||
m.AddProperties(new_node_uid, name, "Mesh");
|
WriteModelNode(
|
||||||
m.AddChild("Version", int32_t(232));
|
outstream, binary, &new_node, new_node_uid, "Mesh", std::vector<std::pair<std::string,aiVector3D>>()
|
||||||
FBX::Node p("Properties70");
|
);
|
||||||
p.AddP70enum("InheritType", 1);
|
|
||||||
m.AddChild(p);
|
|
||||||
m.Dump(outstream, binary, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
|
||||||
|
|
||||||
// lower-case shading because Blender (for example) writes "Phong"
|
// lower-case shading because Blender (for example) writes "Phong"
|
||||||
for (size_t i = 0; i < shading.length(); ++i) {
|
for (size_t i = 0; i < shading.length(); ++i) {
|
||||||
shading[i] = static_cast<char>(tolower(shading[i]));
|
shading[i] = static_cast<char>(tolower(static_cast<unsigned char>(shading[i])));
|
||||||
}
|
}
|
||||||
std::string templateName;
|
std::string templateName;
|
||||||
if(shading == "phong") {
|
if(shading == "phong") {
|
||||||
|
@ -352,7 +352,7 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std
|
||||||
}
|
}
|
||||||
} catch (const runtime_error& runtimeError) {
|
} catch (const runtime_error& runtimeError) {
|
||||||
//we don't need the content data for contents that has already been loaded
|
//we don't need the content data for contents that has already been loaded
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Caught exception in FBXMaterial (likely because content was already loaded): ",
|
ASSIMP_LOG_VERBOSE_DEBUG("Caught exception in FBXMaterial (likely because content was already loaded): ",
|
||||||
runtimeError.what());
|
runtimeError.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,8 +307,8 @@ void MeshGeometry::ReadLayerElement(const Scope& layerElement)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FBXImporter::LogError(Formatter::format("failed to resolve vertex layer element: ")
|
FBXImporter::LogError("failed to resolve vertex layer element: ",
|
||||||
<< type << ", index: " << typedIndex);
|
type, ", index: ", typedIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -324,13 +324,13 @@ void MeshGeometry::ReadVertexData(const std::string& type, int index, const Scop
|
||||||
|
|
||||||
if (type == "LayerElementUV") {
|
if (type == "LayerElementUV") {
|
||||||
if(index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
if(index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||||
FBXImporter::LogError(Formatter::format("ignoring UV layer, maximum number of UV channels exceeded: ")
|
FBXImporter::LogError("ignoring UV layer, maximum number of UV channels exceeded: ",
|
||||||
<< index << " (limit is " << AI_MAX_NUMBER_OF_TEXTURECOORDS << ")" );
|
index, " (limit is ", AI_MAX_NUMBER_OF_TEXTURECOORDS, ")" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Element* Name = source["Name"];
|
const Element* Name = source["Name"];
|
||||||
m_uvNames[index] = "";
|
m_uvNames[index] = std::string();
|
||||||
if(Name) {
|
if(Name) {
|
||||||
m_uvNames[index] = ParseTokenAsString(GetRequiredToken(*Name,0));
|
m_uvNames[index] = ParseTokenAsString(GetRequiredToken(*Name,0));
|
||||||
}
|
}
|
||||||
|
@ -402,8 +402,8 @@ void MeshGeometry::ReadVertexData(const std::string& type, int index, const Scop
|
||||||
}
|
}
|
||||||
else if (type == "LayerElementColor") {
|
else if (type == "LayerElementColor") {
|
||||||
if(index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
|
if(index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
|
||||||
FBXImporter::LogError(Formatter::format("ignoring vertex color layer, maximum number of color sets exceeded: ")
|
FBXImporter::LogError("ignoring vertex color layer, maximum number of color sets exceeded: ",
|
||||||
<< index << " (limit is " << AI_MAX_NUMBER_OF_COLOR_SETS << ")" );
|
index, " (limit is ", AI_MAX_NUMBER_OF_COLOR_SETS, ")" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,8 +449,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
||||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||||
|
|
||||||
if (tempData.size() != mapping_offsets.size()) {
|
if (tempData.size() != mapping_offsets.size()) {
|
||||||
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
|
FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ",
|
||||||
<< tempData.size() << ", expected " << mapping_offsets.size());
|
tempData.size(), ", expected ", mapping_offsets.size());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,8 +470,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
||||||
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
||||||
|
|
||||||
if (uvIndices.size() != vertex_count) {
|
if (uvIndices.size() != vertex_count) {
|
||||||
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
|
FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ",
|
||||||
<< uvIndices.size() << ", expected " << vertex_count);
|
uvIndices.size(), ", expected ", vertex_count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,8 +493,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
||||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||||
|
|
||||||
if (tempData.size() != vertex_count) {
|
if (tempData.size() != vertex_count) {
|
||||||
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygon mapping: ")
|
FBXImporter::LogError("length of input data unexpected for ByPolygon mapping: ",
|
||||||
<< tempData.size() << ", expected " << vertex_count
|
tempData.size(), ", expected ", vertex_count
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -509,14 +509,14 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
||||||
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
||||||
|
|
||||||
if (uvIndices.size() > vertex_count) {
|
if (uvIndices.size() > vertex_count) {
|
||||||
FBXImporter::LogWarn(Formatter::format("trimming length of input array for ByPolygonVertex mapping: ")
|
FBXImporter::LogWarn("trimming length of input array for ByPolygonVertex mapping: ",
|
||||||
<< uvIndices.size() << ", expected " << vertex_count);
|
uvIndices.size(), ", expected ", vertex_count);
|
||||||
uvIndices.resize(vertex_count);
|
uvIndices.resize(vertex_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvIndices.size() != vertex_count) {
|
if (uvIndices.size() != vertex_count) {
|
||||||
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ")
|
FBXImporter::LogError("length of input data unexpected for ByPolygonVertex mapping: ",
|
||||||
<< uvIndices.size() << ", expected " << vertex_count);
|
uvIndices.size(), ", expected ", vertex_count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,8 +537,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FBXImporter::LogError(Formatter::format("ignoring vertex data channel, access type not implemented: ")
|
FBXImporter::LogError("ignoring vertex data channel, access type not implemented: ",
|
||||||
<< MappingInformationType << "," << ReferenceInformationType);
|
MappingInformationType, ",", ReferenceInformationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,15 +604,15 @@ void MeshGeometry::ReadVertexDataTangents(std::vector<aiVector3D>& tangents_out,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static const std::string BinormalIndexToken = "BinormalIndex";
|
static const char * BinormalIndexToken = "BinormalIndex";
|
||||||
static const std::string BinormalsIndexToken = "BinormalsIndex";
|
static const char * BinormalsIndexToken = "BinormalsIndex";
|
||||||
|
|
||||||
void MeshGeometry::ReadVertexDataBinormals(std::vector<aiVector3D>& binormals_out, const Scope& source,
|
void MeshGeometry::ReadVertexDataBinormals(std::vector<aiVector3D>& binormals_out, const Scope& source,
|
||||||
const std::string& MappingInformationType,
|
const std::string& MappingInformationType,
|
||||||
const std::string& ReferenceInformationType)
|
const std::string& ReferenceInformationType)
|
||||||
{
|
{
|
||||||
const char * str = source.Elements().count( "Binormals" ) > 0 ? "Binormals" : "Binormal";
|
const char * str = source.Elements().count( "Binormals" ) > 0 ? "Binormals" : "Binormal";
|
||||||
const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken.c_str() : BinormalIndexToken.c_str();
|
const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken : BinormalIndexToken;
|
||||||
ResolveVertexDataArray(binormals_out,source,MappingInformationType,ReferenceInformationType,
|
ResolveVertexDataArray(binormals_out,source,MappingInformationType,ReferenceInformationType,
|
||||||
str,
|
str,
|
||||||
strIdx,
|
strIdx,
|
||||||
|
@ -642,10 +642,10 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
|
||||||
if (MappingInformationType == "AllSame") {
|
if (MappingInformationType == "AllSame") {
|
||||||
// easy - same material for all faces
|
// easy - same material for all faces
|
||||||
if (materials_out.empty()) {
|
if (materials_out.empty()) {
|
||||||
FBXImporter::LogError(Formatter::format("expected material index, ignoring"));
|
FBXImporter::LogError("expected material index, ignoring");
|
||||||
return;
|
return;
|
||||||
} else if (materials_out.size() > 1) {
|
} else if (materials_out.size() > 1) {
|
||||||
FBXImporter::LogWarn(Formatter::format("expected only a single material index, ignoring all except the first one"));
|
FBXImporter::LogWarn("expected only a single material index, ignoring all except the first one");
|
||||||
materials_out.clear();
|
materials_out.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,14 +655,14 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
|
||||||
materials_out.resize(face_count);
|
materials_out.resize(face_count);
|
||||||
|
|
||||||
if(materials_out.size() != face_count) {
|
if(materials_out.size() != face_count) {
|
||||||
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygon mapping: ")
|
FBXImporter::LogError("length of input data unexpected for ByPolygon mapping: ",
|
||||||
<< materials_out.size() << ", expected " << face_count
|
materials_out.size(), ", expected ", face_count
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FBXImporter::LogError(Formatter::format("ignoring material assignments, access type not implemented: ")
|
FBXImporter::LogError("ignoring material assignments, access type not implemented: ",
|
||||||
<< MappingInformationType << "," << ReferenceInformationType);
|
MappingInformationType, ",", ReferenceInformationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -462,7 +462,7 @@ std::string ParseTokenAsString(const Token& t, const char*& err_out)
|
||||||
|
|
||||||
if (t.Type() != TokenType_DATA) {
|
if (t.Type() != TokenType_DATA) {
|
||||||
err_out = "expected TOK_DATA token";
|
err_out = "expected TOK_DATA token";
|
||||||
return "";
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(t.IsBinary())
|
if(t.IsBinary())
|
||||||
|
@ -470,7 +470,7 @@ std::string ParseTokenAsString(const Token& t, const char*& err_out)
|
||||||
const char* data = t.begin();
|
const char* data = t.begin();
|
||||||
if (data[0] != 'S') {
|
if (data[0] != 'S') {
|
||||||
err_out = "failed to parse S(tring), unexpected data type (binary)";
|
err_out = "failed to parse S(tring), unexpected data type (binary)";
|
||||||
return "";
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
// read string length
|
// read string length
|
||||||
|
@ -484,13 +484,13 @@ std::string ParseTokenAsString(const Token& t, const char*& err_out)
|
||||||
const size_t length = static_cast<size_t>(t.end() - t.begin());
|
const size_t length = static_cast<size_t>(t.end() - t.begin());
|
||||||
if(length < 2) {
|
if(length < 2) {
|
||||||
err_out = "token is too short to hold a string";
|
err_out = "token is too short to hold a string";
|
||||||
return "";
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* s = t.begin(), *e = t.end() - 1;
|
const char* s = t.begin(), *e = t.end() - 1;
|
||||||
if (*s != '\"' || *e != '\"') {
|
if (*s != '\"' || *e != '\"') {
|
||||||
err_out = "expected double quoted string";
|
err_out = "expected double quoted string";
|
||||||
return "";
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string(s+1,length-2);
|
return std::string(s+1,length-2);
|
||||||
|
|
|
@ -131,7 +131,7 @@ Property* ReadTypedProperty(const Element& element)
|
||||||
ParseTokenAsFloat(*tok[6]))
|
ParseTokenAsFloat(*tok[6]))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
|
else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"float") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
|
||||||
checkTokenCount(tok, 5);
|
checkTokenCount(tok, 5);
|
||||||
return new TypedProperty<float>(ParseTokenAsFloat(*tok[4]));
|
return new TypedProperty<float>(ParseTokenAsFloat(*tok[4]));
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ std::string PeekPropertyName(const Element& element)
|
||||||
ai_assert(element.KeyToken().StringContents() == "P");
|
ai_assert(element.KeyToken().StringContents() == "P");
|
||||||
const TokenList& tok = element.Tokens();
|
const TokenList& tok = element.Tokens();
|
||||||
if(tok.size() < 4) {
|
if(tok.size() < 4) {
|
||||||
return "";
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ParseTokenAsString(*tok[0]);
|
return ParseTokenAsString(*tok[0]);
|
||||||
|
|
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "AssetLib/HMP/HMPLoader.h"
|
#include "AssetLib/HMP/HMPLoader.h"
|
||||||
#include "AssetLib/MD2/MD2FileData.h"
|
#include "AssetLib/MD2/MD2FileData.h"
|
||||||
|
|
||||||
|
#include <assimp/StringUtils.h>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/importerdesc.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
@ -151,12 +152,7 @@ void HMPImporter::InternReadFile(const std::string &pFile,
|
||||||
InternReadFile_HMP7();
|
InternReadFile_HMP7();
|
||||||
} else {
|
} else {
|
||||||
// Print the magic word to the logger
|
// Print the magic word to the logger
|
||||||
char szBuffer[5];
|
std::string szBuffer = ai_str_toprintable((const char *)&iMagic, sizeof(iMagic));
|
||||||
szBuffer[0] = ((char *)&iMagic)[0];
|
|
||||||
szBuffer[1] = ((char *)&iMagic)[1];
|
|
||||||
szBuffer[2] = ((char *)&iMagic)[2];
|
|
||||||
szBuffer[3] = ((char *)&iMagic)[3];
|
|
||||||
szBuffer[4] = '\0';
|
|
||||||
|
|
||||||
delete[] mBuffer;
|
delete[] mBuffer;
|
||||||
mBuffer = nullptr;
|
mBuffer = nullptr;
|
||||||
|
|
|
@ -715,7 +715,7 @@ void ProcessBoolean(const Schema_2x3::IfcBooleanResult &boolean, TempMesh &resul
|
||||||
// DIFFERENCE
|
// DIFFERENCE
|
||||||
if (const Schema_2x3::IfcBooleanResult *const clip = boolean.ToPtr<Schema_2x3::IfcBooleanResult>()) {
|
if (const Schema_2x3::IfcBooleanResult *const clip = boolean.ToPtr<Schema_2x3::IfcBooleanResult>()) {
|
||||||
if (clip->Operator != "DIFFERENCE") {
|
if (clip->Operator != "DIFFERENCE") {
|
||||||
IFCImporter::LogWarn("encountered unsupported boolean operator: " + (std::string)clip->Operator);
|
IFCImporter::LogWarn("encountered unsupported boolean operator: ", (std::string)clip->Operator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,7 +756,7 @@ void ProcessBoolean(const Schema_2x3::IfcBooleanResult &boolean, TempMesh &resul
|
||||||
ProcessBooleanExtrudedAreaSolidDifference(as, result, first_operand, conv);
|
ProcessBooleanExtrudedAreaSolidDifference(as, result, first_operand, conv);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IFCImporter::LogWarn("skipping unknown IfcBooleanResult entity, type is " + boolean.GetClassName());
|
IFCImporter::LogWarn("skipping unknown IfcBooleanResult entity, type is ", boolean.GetClassName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ void ProcessConnectedFaceSet(const Schema_2x3::IfcConnectedFaceSet& fset, TempMe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IFCImporter::LogWarn("skipping unknown IfcFaceBound entity, type is " + bound.Bound->GetClassName());
|
IFCImporter::LogWarn("skipping unknown IfcFaceBound entity, type is ", bound.Bound->GetClassName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,7 +729,7 @@ void ProcessSweptAreaSolid(const Schema_2x3::IfcSweptAreaSolid& swept, TempMesh&
|
||||||
ProcessRevolvedAreaSolid(*rev,meshout,conv);
|
ProcessRevolvedAreaSolid(*rev,meshout,conv);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IFCImporter::LogWarn("skipping unknown IfcSweptAreaSolid entity, type is " + swept.GetClassName());
|
IFCImporter::LogWarn("skipping unknown IfcSweptAreaSolid entity, type is ", swept.GetClassName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,7 +781,7 @@ bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo, unsigned
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IFCImporter::LogWarn("skipping unknown IfcGeometricRepresentationItem entity, type is " + geo.GetClassName());
|
IFCImporter::LogWarn("skipping unknown IfcGeometricRepresentationItem entity, type is ", geo.GetClassName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ static const aiImporterDesc desc = {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"ifc ifczip stp"
|
"ifc ifczip step stp"
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -243,12 +243,12 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DefaultLogger::isNullLogger()) {
|
if (!DefaultLogger::isNullLogger()) {
|
||||||
LogDebug("File schema is \'" + head.fileSchema + '\'');
|
LogDebug("File schema is \'", head.fileSchema, '\'');
|
||||||
if (head.timestamp.length()) {
|
if (head.timestamp.length()) {
|
||||||
LogDebug("Timestamp \'" + head.timestamp + '\'');
|
LogDebug("Timestamp \'", head.timestamp, '\'');
|
||||||
}
|
}
|
||||||
if (head.app.length()) {
|
if (head.app.length()) {
|
||||||
LogDebug("Application/Exporter identline is \'" + head.app + '\'');
|
LogDebug("Application/Exporter identline is \'", head.app, '\'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
// this must be last because objects are evaluated lazily as we process them
|
// this must be last because objects are evaluated lazily as we process them
|
||||||
if (!DefaultLogger::isNullLogger()) {
|
if (!DefaultLogger::isNullLogger()) {
|
||||||
LogDebug((Formatter::format(), "STEP: evaluated ", db->GetEvaluatedObjectCount(), " object records"));
|
LogDebug("STEP: evaluated ", db->GetEvaluatedObjectCount(), " object records");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ void ResolveObjectPlacement(aiMatrix4x4 &m, const Schema_2x3::IfcObjectPlacement
|
||||||
m = tmpM * m;
|
m = tmpM * m;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IFCImporter::LogWarn("skipping unknown IfcObjectPlacement entity, type is " + place.GetClassName());
|
IFCImporter::LogWarn("skipping unknown IfcObjectPlacement entity, type is ", place.GetClassName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ bool ProcessMappedItem(const Schema_2x3::IfcMappedItem &mapped, aiNode *nd_src,
|
||||||
bool got = false;
|
bool got = false;
|
||||||
for (const Schema_2x3::IfcRepresentationItem &item : repr.Items) {
|
for (const Schema_2x3::IfcRepresentationItem &item : repr.Items) {
|
||||||
if (!ProcessRepresentationItem(item, localmatid, meshes, conv)) {
|
if (!ProcessRepresentationItem(item, localmatid, meshes, conv)) {
|
||||||
IFCImporter::LogWarn("skipping mapped entity of type " + item.GetClassName() + ", no representations could be generated");
|
IFCImporter::LogWarn("skipping mapped entity of type ", item.GetClassName(), ", no representations could be generated");
|
||||||
} else
|
} else
|
||||||
got = true;
|
got = true;
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ typedef std::map<std::string, std::string> Metadata;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void ProcessMetadata(const Schema_2x3::ListOf<Schema_2x3::Lazy<Schema_2x3::IfcProperty>, 1, 0> &set, ConversionData &conv, Metadata &properties,
|
void ProcessMetadata(const Schema_2x3::ListOf<Schema_2x3::Lazy<Schema_2x3::IfcProperty>, 1, 0> &set, ConversionData &conv, Metadata &properties,
|
||||||
const std::string &prefix = "",
|
const std::string &prefix = std::string(),
|
||||||
unsigned int nest = 0) {
|
unsigned int nest = 0) {
|
||||||
for (const Schema_2x3::IfcProperty &property : set) {
|
for (const Schema_2x3::IfcProperty &property : set) {
|
||||||
const std::string &key = prefix.length() > 0 ? (prefix + "." + property.Name) : property.Name;
|
const std::string &key = prefix.length() > 0 ? (prefix + "." + property.Name) : property.Name;
|
||||||
|
@ -618,7 +618,7 @@ void ProcessMetadata(const Schema_2x3::ListOf<Schema_2x3::Lazy<Schema_2x3::IfcPr
|
||||||
ProcessMetadata(complexProp->HasProperties, conv, properties, key, nest + 1);
|
ProcessMetadata(complexProp->HasProperties, conv, properties, key, nest + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
properties[key] = "";
|
properties[key] = std::string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -856,7 +856,7 @@ void ProcessSpatialStructures(ConversionData &conv) {
|
||||||
if (!prod) {
|
if (!prod) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IFCImporter::LogVerboseDebug("looking at spatial structure `" + (prod->Name ? prod->Name.Get() : "unnamed") + "`" + (prod->ObjectType ? " which is of type " + prod->ObjectType.Get() : ""));
|
IFCImporter::LogVerboseDebug("looking at spatial structure `", (prod->Name ? prod->Name.Get() : "unnamed"), "`", (prod->ObjectType ? " which is of type " + prod->ObjectType.Get() : ""));
|
||||||
|
|
||||||
// the primary sites are referenced by an IFCRELAGGREGATES element which assigns them to the IFCPRODUCT
|
// the primary sites are referenced by an IFCRELAGGREGATES element which assigns them to the IFCPRODUCT
|
||||||
const STEP::DB::RefMap &refs = conv.db.GetRefs();
|
const STEP::DB::RefMap &refs = conv.db.GetRefs();
|
||||||
|
|
|
@ -64,7 +64,7 @@ static int ConvertShadingMode(const std::string& name) {
|
||||||
else if (name == "PHONG") {
|
else if (name == "PHONG") {
|
||||||
return aiShadingMode_Phong;
|
return aiShadingMode_Phong;
|
||||||
}
|
}
|
||||||
IFCImporter::LogWarn("shading mode "+name+" not recognized by Assimp, using Phong instead");
|
IFCImporter::LogWarn("shading mode ", name, " not recognized by Assimp, using Phong instead");
|
||||||
return aiShadingMode_Phong;
|
return aiShadingMode_Phong;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ unsigned int ProcessMaterials(uint64_t id, unsigned int prevMatId, ConversionDat
|
||||||
// not found, create new material
|
// not found, create new material
|
||||||
const std::string side = static_cast<std::string>(surf->Side);
|
const std::string side = static_cast<std::string>(surf->Side);
|
||||||
if( side != "BOTH" ) {
|
if( side != "BOTH" ) {
|
||||||
IFCImporter::LogWarn("ignoring surface side marker on IFC::IfcSurfaceStyle: " + side);
|
IFCImporter::LogWarn("ignoring surface side marker on IFC::IfcSurfaceStyle: ", side);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<aiMaterial> mat(new aiMaterial());
|
std::unique_ptr<aiMaterial> mat(new aiMaterial());
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool ProcessCurve(const Schema_2x3::IfcCurve& curve, TempMesh& meshout, Convers
|
||||||
{
|
{
|
||||||
std::unique_ptr<const Curve> cv(Curve::Convert(curve,conv));
|
std::unique_ptr<const Curve> cv(Curve::Convert(curve,conv));
|
||||||
if (!cv) {
|
if (!cv) {
|
||||||
IFCImporter::LogWarn("skipping unknown IfcCurve entity, type is " + curve.GetClassName());
|
IFCImporter::LogWarn("skipping unknown IfcCurve entity, type is ", curve.GetClassName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ bool ProcessCurve(const Schema_2x3::IfcCurve& curve, TempMesh& meshout, Convers
|
||||||
bc->SampleDiscrete(meshout);
|
bc->SampleDiscrete(meshout);
|
||||||
}
|
}
|
||||||
catch(const CurveError& cv) {
|
catch(const CurveError& cv) {
|
||||||
IFCImporter::LogError(cv.mStr + " (error occurred while processing curve)");
|
IFCImporter::LogError(cv.mStr, " (error occurred while processing curve)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
meshout.mVertcnt.push_back(static_cast<unsigned int>(meshout.mVerts.size()));
|
meshout.mVertcnt.push_back(static_cast<unsigned int>(meshout.mVerts.size()));
|
||||||
|
@ -152,7 +152,7 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
|
||||||
meshout.mVertcnt.push_back(12);
|
meshout.mVertcnt.push_back(12);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IFCImporter::LogWarn("skipping unknown IfcParameterizedProfileDef entity, type is " + def.GetClassName());
|
IFCImporter::LogWarn("skipping unknown IfcParameterizedProfileDef entity, type is ", def.GetClassName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ bool ProcessProfile(const Schema_2x3::IfcProfileDef& prof, TempMesh& meshout, Co
|
||||||
ProcessParametrizedProfile(*cparam,meshout,conv);
|
ProcessParametrizedProfile(*cparam,meshout,conv);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IFCImporter::LogWarn("skipping unknown IfcProfileDef entity, type is " + prof.GetClassName());
|
IFCImporter::LogWarn("skipping unknown IfcProfileDef entity, type is ", prof.GetClassName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
meshout.RemoveAdjacentDuplicates();
|
meshout.RemoveAdjacentDuplicates();
|
||||||
|
|
|
@ -506,7 +506,7 @@ IfcFloat ConvertSIPrefix(const std::string& prefix)
|
||||||
return 1e-18f;
|
return 1e-18f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IFCImporter::LogError("Unrecognized SI prefix: " + prefix);
|
IFCImporter::LogError("Unrecognized SI prefix: ", prefix);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -639,7 +639,7 @@ void IRRImporter::GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene,
|
||||||
// graph we're currently building
|
// graph we're currently building
|
||||||
aiScene *localScene = batch.GetImport(root->id);
|
aiScene *localScene = batch.GetImport(root->id);
|
||||||
if (!localScene) {
|
if (!localScene) {
|
||||||
ASSIMP_LOG_ERROR("IRR: Unable to load external file: " + root->meshPath);
|
ASSIMP_LOG_ERROR("IRR: Unable to load external file: ", root->meshPath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
attach.push_back(AttachmentInfo(localScene, rootOut));
|
attach.push_back(AttachmentInfo(localScene, rootOut));
|
||||||
|
@ -859,13 +859,13 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if (file.get() == nullptr) {
|
if (file.get() == nullptr) {
|
||||||
throw DeadlyImportError("Failed to open IRR file " + pFile + "");
|
throw DeadlyImportError("Failed to open IRR file ", pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the irrXML parser
|
// Construct the irrXML parser
|
||||||
XmlParser st;
|
XmlParser st;
|
||||||
if (!st.parse( file.get() )) {
|
if (!st.parse( file.get() )) {
|
||||||
return;
|
throw DeadlyImportError("XML parse error while loading IRR file ", pFile);
|
||||||
}
|
}
|
||||||
pugi::xml_node rootElement = st.getRootNode();
|
pugi::xml_node rootElement = st.getRootNode();
|
||||||
|
|
||||||
|
@ -963,7 +963,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
ASSIMP_LOG_ERROR("IRR: Billboards are not supported by Assimp");
|
ASSIMP_LOG_ERROR("IRR: Billboards are not supported by Assimp");
|
||||||
nd = new Node(Node::DUMMY);
|
nd = new Node(Node::DUMMY);
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN("IRR: Found unknown node: " + std::string(attrib.name()));
|
ASSIMP_LOG_WARN("IRR: Found unknown node: ", attrib.name());
|
||||||
|
|
||||||
/* We skip the contents of nodes we don't know.
|
/* We skip the contents of nodes we don't know.
|
||||||
* We parse the transformation and all animators
|
* We parse the transformation and all animators
|
||||||
|
@ -1181,7 +1181,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
lights.pop_back();
|
lights.pop_back();
|
||||||
curNode->type = Node::DUMMY;
|
curNode->type = Node::DUMMY;
|
||||||
|
|
||||||
ASSIMP_LOG_ERROR("Ignoring light of unknown type: " + prop.value);
|
ASSIMP_LOG_ERROR("Ignoring light of unknown type: ", prop.value);
|
||||||
}
|
}
|
||||||
} else if ((prop.name == "Mesh" && Node::MESH == curNode->type) ||
|
} else if ((prop.name == "Mesh" && Node::MESH == curNode->type) ||
|
||||||
Node::ANIMMESH == curNode->type) {
|
Node::ANIMMESH == curNode->type) {
|
||||||
|
@ -1225,7 +1225,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
} else if (prop.value == "followSpline") {
|
} else if (prop.value == "followSpline") {
|
||||||
curAnim->type = Animator::FOLLOW_SPLINE;
|
curAnim->type = Animator::FOLLOW_SPLINE;
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN("IRR: Ignoring unknown animator: " + prop.value);
|
ASSIMP_LOG_WARN("IRR: Ignoring unknown animator: ", prop.value);
|
||||||
|
|
||||||
curAnim->type = Animator::UNKNOWN;
|
curAnim->type = Animator::UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,12 +135,12 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if (file.get() == NULL)
|
if (file.get() == NULL)
|
||||||
throw DeadlyImportError("Failed to open IRRMESH file " + pFile + "");
|
throw DeadlyImportError("Failed to open IRRMESH file ", pFile);
|
||||||
|
|
||||||
// Construct the irrXML parser
|
// Construct the irrXML parser
|
||||||
XmlParser parser;
|
XmlParser parser;
|
||||||
if (!parser.parse( file.get() )) {
|
if (!parser.parse( file.get() )) {
|
||||||
return;
|
throw DeadlyImportError("XML parse error while loading IRRMESH file ", pFile);
|
||||||
}
|
}
|
||||||
XmlNode root = parser.getRootNode();
|
XmlNode root = parser.getRootNode();
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags) {
|
||||||
prop.value == "parallaxmap_trans_add") {
|
prop.value == "parallaxmap_trans_add") {
|
||||||
matFlags = AI_IRRMESH_MAT_normalmap_ta;
|
matFlags = AI_IRRMESH_MAT_normalmap_ta;
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN("IRRMat: Unrecognized material type: " + prop.value);
|
ASSIMP_LOG_WARN("IRRMat: Unrecognized material type: ", prop.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// procedural or gradient, not supported
|
// procedural or gradient, not supported
|
||||||
ASSIMP_LOG_ERROR_F("LWOB: Unsupported legacy texture: ", type);
|
ASSIMP_LOG_ERROR("LWOB: Unsupported legacy texture: ", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
|
|
|
@ -502,7 +502,7 @@ struct Surface {
|
||||||
Surface() :
|
Surface() :
|
||||||
mColor(0.78431f, 0.78431f, 0.78431f), bDoubleSided(false), mDiffuseValue(1.f), mSpecularValue(0.f), mTransparency(0.f), mGlossiness(0.4f), mLuminosity(0.f), mColorHighlights(0.f), mMaximumSmoothAngle(0.f) // 0 == not specified, no smoothing
|
mColor(0.78431f, 0.78431f, 0.78431f), bDoubleSided(false), mDiffuseValue(1.f), mSpecularValue(0.f), mTransparency(0.f), mGlossiness(0.4f), mLuminosity(0.f), mColorHighlights(0.f), mMaximumSmoothAngle(0.f) // 0 == not specified, no smoothing
|
||||||
,
|
,
|
||||||
mVCMap(""),
|
mVCMap(),
|
||||||
mVCMapType(AI_LWO_RGBA),
|
mVCMapType(AI_LWO_RGBA),
|
||||||
mIOR(1.f) // vakuum
|
mIOR(1.f) // vakuum
|
||||||
,
|
,
|
||||||
|
|
|
@ -961,7 +961,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AI_LWO_TXUV:
|
case AI_LWO_TXUV:
|
||||||
if (dims != 2) {
|
if (dims != 2) {
|
||||||
ASSIMP_LOG_WARN("LWO2: Skipping UV channel \'" + name + "\' with !2 components");
|
ASSIMP_LOG_WARN("LWO2: Skipping UV channel \'", name, "\' with !2 components");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base = FindEntry(mCurLayer->mUVChannels, name, perPoly);
|
base = FindEntry(mCurLayer->mUVChannels, name, perPoly);
|
||||||
|
@ -969,7 +969,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
|
||||||
case AI_LWO_WGHT:
|
case AI_LWO_WGHT:
|
||||||
case AI_LWO_MNVW:
|
case AI_LWO_MNVW:
|
||||||
if (dims != 1) {
|
if (dims != 1) {
|
||||||
ASSIMP_LOG_WARN("LWO2: Skipping Weight Channel \'" + name + "\' with !1 components");
|
ASSIMP_LOG_WARN("LWO2: Skipping Weight Channel \'", name, "\' with !1 components");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base = FindEntry((type == AI_LWO_WGHT ? mCurLayer->mWeightChannels : mCurLayer->mSWeightChannels), name, perPoly);
|
base = FindEntry((type == AI_LWO_WGHT ? mCurLayer->mWeightChannels : mCurLayer->mSWeightChannels), name, perPoly);
|
||||||
|
@ -977,7 +977,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
|
||||||
case AI_LWO_RGB:
|
case AI_LWO_RGB:
|
||||||
case AI_LWO_RGBA:
|
case AI_LWO_RGBA:
|
||||||
if (dims != 3 && dims != 4) {
|
if (dims != 3 && dims != 4) {
|
||||||
ASSIMP_LOG_WARN("LWO2: Skipping Color Map \'" + name + "\' with a dimension > 4 or < 3");
|
ASSIMP_LOG_WARN("LWO2: Skipping Color Map \'", name, "\' with a dimension > 4 or < 3");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base = FindEntry(mCurLayer->mVColorChannels, name, perPoly);
|
base = FindEntry(mCurLayer->mVColorChannels, name, perPoly);
|
||||||
|
@ -1006,7 +1006,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
|
||||||
if (name == "APS.Level") {
|
if (name == "APS.Level") {
|
||||||
// XXX handle this (seems to be subdivision-related).
|
// XXX handle this (seems to be subdivision-related).
|
||||||
}
|
}
|
||||||
ASSIMP_LOG_WARN_F("LWO2: Skipping unknown VMAP/VMAD channel \'", name, "\'");
|
ASSIMP_LOG_WARN("LWO2: Skipping unknown VMAP/VMAD channel \'", name, "\'");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
base->Allocate((unsigned int)mCurLayer->mTempPoints.size());
|
base->Allocate((unsigned int)mCurLayer->mTempPoints.size());
|
||||||
|
@ -1026,7 +1026,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
|
||||||
|
|
||||||
unsigned int idx = ReadVSizedIntLWO2(mFileBuffer) + mCurLayer->mPointIDXOfs;
|
unsigned int idx = ReadVSizedIntLWO2(mFileBuffer) + mCurLayer->mPointIDXOfs;
|
||||||
if (idx >= numPoints) {
|
if (idx >= numPoints) {
|
||||||
ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAP/VMAD entry \'", name, "\', vertex index is out of range");
|
ASSIMP_LOG_WARN("LWO2: Failure evaluating VMAP/VMAD entry \'", name, "\', vertex index is out of range");
|
||||||
mFileBuffer += base->dims << 2u;
|
mFileBuffer += base->dims << 2u;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1036,7 +1036,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
|
||||||
// we have already a VMAP entry for this vertex - thus
|
// we have already a VMAP entry for this vertex - thus
|
||||||
// we need to duplicate the corresponding polygon.
|
// we need to duplicate the corresponding polygon.
|
||||||
if (polyIdx >= numFaces) {
|
if (polyIdx >= numFaces) {
|
||||||
ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAD entry \'", name, "\', polygon index is out of range");
|
ASSIMP_LOG_WARN("LWO2: Failure evaluating VMAD entry \'", name, "\', polygon index is out of range");
|
||||||
mFileBuffer += base->dims << 2u;
|
mFileBuffer += base->dims << 2u;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1076,7 +1076,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
|
||||||
CreateNewEntry(mCurLayer->mNormals, srcIdx);
|
CreateNewEntry(mCurLayer->mNormals, srcIdx);
|
||||||
}
|
}
|
||||||
if (!had) {
|
if (!had) {
|
||||||
ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAD entry \'", name, "\', vertex index wasn't found in that polygon");
|
ASSIMP_LOG_WARN("LWO2: Failure evaluating VMAD entry \'", name, "\', vertex index wasn't found in that polygon");
|
||||||
ai_assert(had);
|
ai_assert(had);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ void LWOImporter::ConvertMaterial(const LWO::Surface &surf, aiMaterial *pcMat) {
|
||||||
m = aiShadingMode_Fresnel;
|
m = aiShadingMode_Fresnel;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN_F("LWO2: Unknown surface shader: ", shader.functionName);
|
ASSIMP_LOG_WARN("LWO2: Unknown surface shader: ", shader.functionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (surf.mMaximumSmoothAngle <= 0.0)
|
if (surf.mMaximumSmoothAngle <= 0.0)
|
||||||
|
@ -711,7 +711,7 @@ void LWOImporter::LoadLWO2Surface(unsigned int size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (derived.size()) {
|
if (derived.size()) {
|
||||||
ASSIMP_LOG_WARN("LWO2: Unable to find source surface: " + derived);
|
ASSIMP_LOG_WARN("LWO2: Unable to find source surface: ", derived);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,7 @@ void LWSImporter::BuildGraph(aiNode *nd, LWS::NodeDesc &src, std::vector<Attachm
|
||||||
if (src.path.length()) {
|
if (src.path.length()) {
|
||||||
obj = batch.GetImport(src.id);
|
obj = batch.GetImport(src.id);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
ASSIMP_LOG_ERROR("LWS: Failed to read external file " + src.path);
|
ASSIMP_LOG_ERROR("LWS: Failed to read external file ", src.path);
|
||||||
} else {
|
} else {
|
||||||
if (obj->mRootNode->mNumChildren == 1) {
|
if (obj->mRootNode->mNumChildren == 1) {
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
// get file format version and print to log
|
// get file format version and print to log
|
||||||
++it;
|
++it;
|
||||||
unsigned int version = strtoul10((*it).tokens[0].c_str());
|
unsigned int version = strtoul10((*it).tokens[0].c_str());
|
||||||
ASSIMP_LOG_INFO("LWS file format version is " + (*it).tokens[0]);
|
ASSIMP_LOG_INFO("LWS file format version is ", (*it).tokens[0]);
|
||||||
first = 0.;
|
first = 0.;
|
||||||
last = 60.;
|
last = 60.;
|
||||||
fps = 25.; // seems to be a good default frame rate
|
fps = 25.; // seems to be a good default frame rate
|
||||||
|
|
|
@ -88,7 +88,7 @@ struct NodeDesc {
|
||||||
id(),
|
id(),
|
||||||
number(0),
|
number(0),
|
||||||
parent(0),
|
parent(0),
|
||||||
name(""),
|
name(),
|
||||||
isPivotSet(false),
|
isPivotSet(false),
|
||||||
lightColor(1.f, 1.f, 1.f),
|
lightColor(1.f, 1.f, 1.f),
|
||||||
lightIntensity(1.f),
|
lightIntensity(1.f),
|
||||||
|
|
|
@ -294,21 +294,17 @@ void ExportSceneM3D(
|
||||||
// Worker function for exporting a scene to ASCII A3D.
|
// Worker function for exporting a scene to ASCII A3D.
|
||||||
// Prototyped and registered in Exporter.cpp
|
// Prototyped and registered in Exporter.cpp
|
||||||
void ExportSceneM3DA(
|
void ExportSceneM3DA(
|
||||||
const char *,
|
const char *pFile,
|
||||||
IOSystem *,
|
IOSystem *pIOSystem,
|
||||||
const aiScene *,
|
const aiScene *pScene,
|
||||||
const ExportProperties *
|
const ExportProperties *pProperties
|
||||||
|
|
||||||
) {
|
) {
|
||||||
#ifdef M3D_ASCII
|
|
||||||
// initialize the exporter
|
// initialize the exporter
|
||||||
M3DExporter exporter(pScene, pProperties);
|
M3DExporter exporter(pScene, pProperties);
|
||||||
|
|
||||||
// perform ascii export
|
// perform ascii export
|
||||||
exporter.doExport(pFile, pIOSystem, true);
|
exporter.doExport(pFile, pIOSystem, true);
|
||||||
#else
|
|
||||||
throw DeadlyExportError("Assimp configured without M3D_ASCII support");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -95,11 +95,7 @@ static const aiImporterDesc desc = {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
#ifdef M3D_ASCII
|
|
||||||
"m3d a3d"
|
"m3d a3d"
|
||||||
#else
|
|
||||||
"m3d"
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -119,9 +115,7 @@ bool M3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
const std::string extension = GetExtension(pFile);
|
const std::string extension = GetExtension(pFile);
|
||||||
|
|
||||||
if (extension == "m3d"
|
if (extension == "m3d"
|
||||||
#ifdef M3D_ASCII
|
|
||||||
|| extension == "a3d"
|
|| extension == "a3d"
|
||||||
#endif
|
|
||||||
)
|
)
|
||||||
return true;
|
return true;
|
||||||
else if (!extension.length() || checkSig) {
|
else if (!extension.length() || checkSig) {
|
||||||
|
@ -137,13 +131,11 @@ bool M3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<IOStream> pStream(pIOHandler->Open(pFile, "rb"));
|
std::unique_ptr<IOStream> pStream(pIOHandler->Open(pFile, "rb"));
|
||||||
unsigned char data[4];
|
unsigned char data[4];
|
||||||
if (4 != pStream->Read(data, 1, 4)) {
|
if (!pStream || 4 != pStream->Read(data, 1, 4)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !memcmp(data, "3DMO", 4) /* bin */
|
return !memcmp(data, "3DMO", 4) /* bin */
|
||||||
#ifdef M3D_ASCII
|
|
||||||
|| !memcmp(data, "3dmo", 4) /* ASCII */
|
|| !memcmp(data, "3dmo", 4) /* ASCII */
|
||||||
#endif
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -176,12 +168,10 @@ void M3DImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSys
|
||||||
if (!memcmp(buffer.data(), "3DMO", 4) && memcmp(buffer.data() + 4, &fileSize, 4)) {
|
if (!memcmp(buffer.data(), "3DMO", 4) && memcmp(buffer.data() + 4, &fileSize, 4)) {
|
||||||
throw DeadlyImportError("Bad binary header in file ", file, ".");
|
throw DeadlyImportError("Bad binary header in file ", file, ".");
|
||||||
}
|
}
|
||||||
#ifdef M3D_ASCII
|
|
||||||
// make sure there's a terminator zero character, as input must be ASCIIZ
|
// make sure there's a terminator zero character, as input must be ASCIIZ
|
||||||
if (!memcmp(buffer.data(), "3dmo", 4)) {
|
if (!memcmp(buffer.data(), "3dmo", 4)) {
|
||||||
buffer.push_back(0);
|
buffer.push_back(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get the path for external assets
|
// Get the path for external assets
|
||||||
std::string folderName("./");
|
std::string folderName("./");
|
||||||
|
@ -194,7 +184,7 @@ void M3DImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSys
|
||||||
}
|
}
|
||||||
|
|
||||||
//DefaultLogger::create("/dev/stderr", Logger::VERBOSE);
|
//DefaultLogger::create("/dev/stderr", Logger::VERBOSE);
|
||||||
ASSIMP_LOG_DEBUG_F("M3D: loading ", file);
|
ASSIMP_LOG_DEBUG("M3D: loading ", file);
|
||||||
|
|
||||||
// let the C SDK do the hard work for us
|
// let the C SDK do the hard work for us
|
||||||
M3DWrapper m3d(pIOHandler, buffer);
|
M3DWrapper m3d(pIOHandler, buffer);
|
||||||
|
@ -210,7 +200,7 @@ void M3DImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSys
|
||||||
pScene->mRootNode->mNumChildren = 0;
|
pScene->mRootNode->mNumChildren = 0;
|
||||||
mScene = pScene;
|
mScene = pScene;
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG("M3D: root node " + m3d.Name());
|
ASSIMP_LOG_DEBUG("M3D: root node ", m3d.Name());
|
||||||
|
|
||||||
// now we just have to fill up the Assimp structures in pScene
|
// now we just have to fill up the Assimp structures in pScene
|
||||||
importMaterials(m3d);
|
importMaterials(m3d);
|
||||||
|
@ -240,7 +230,7 @@ void M3DImporter::importMaterials(const M3DWrapper &m3d) {
|
||||||
mScene->mNumMaterials = m3d->nummaterial + 1;
|
mScene->mNumMaterials = m3d->nummaterial + 1;
|
||||||
mScene->mMaterials = new aiMaterial *[mScene->mNumMaterials];
|
mScene->mMaterials = new aiMaterial *[mScene->mNumMaterials];
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F("M3D: importMaterials ", mScene->mNumMaterials);
|
ASSIMP_LOG_DEBUG("M3D: importMaterials ", mScene->mNumMaterials);
|
||||||
|
|
||||||
// add a default material as first
|
// add a default material as first
|
||||||
aiMaterial *mat = new aiMaterial;
|
aiMaterial *mat = new aiMaterial;
|
||||||
|
@ -335,7 +325,7 @@ void M3DImporter::importTextures(const M3DWrapper &m3d) {
|
||||||
ai_assert(m3d);
|
ai_assert(m3d);
|
||||||
|
|
||||||
mScene->mNumTextures = m3d->numtexture;
|
mScene->mNumTextures = m3d->numtexture;
|
||||||
ASSIMP_LOG_DEBUG_F("M3D: importTextures ", mScene->mNumTextures);
|
ASSIMP_LOG_DEBUG("M3D: importTextures ", mScene->mNumTextures);
|
||||||
|
|
||||||
if (!m3d->numtexture || !m3d->texture) {
|
if (!m3d->numtexture || !m3d->texture) {
|
||||||
return;
|
return;
|
||||||
|
@ -390,7 +380,7 @@ void M3DImporter::importTextures(const M3DWrapper &m3d) {
|
||||||
// individually. In assimp there're per mesh vertex and UV lists, and they must be
|
// individually. In assimp there're per mesh vertex and UV lists, and they must be
|
||||||
// indexed simultaneously.
|
// indexed simultaneously.
|
||||||
void M3DImporter::importMeshes(const M3DWrapper &m3d) {
|
void M3DImporter::importMeshes(const M3DWrapper &m3d) {
|
||||||
ASSIMP_LOG_DEBUG_F("M3D: importMeshes ", m3d->numface);
|
ASSIMP_LOG_DEBUG("M3D: importMeshes ", m3d->numface);
|
||||||
|
|
||||||
if (!m3d->numface || !m3d->face || !m3d->numvertex || !m3d->vertex) {
|
if (!m3d->numface || !m3d->face || !m3d->numvertex || !m3d->vertex) {
|
||||||
return;
|
return;
|
||||||
|
@ -509,7 +499,7 @@ void M3DImporter::importBones(const M3DWrapper &m3d, unsigned int parentid, aiNo
|
||||||
ai_assert(mScene != nullptr);
|
ai_assert(mScene != nullptr);
|
||||||
ai_assert(m3d);
|
ai_assert(m3d);
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F("M3D: importBones ", m3d->numbone, " parentid ", (int)parentid);
|
ASSIMP_LOG_DEBUG("M3D: importBones ", m3d->numbone, " parentid ", (int)parentid);
|
||||||
|
|
||||||
if (!m3d->numbone || !m3d->bone) {
|
if (!m3d->numbone || !m3d->bone) {
|
||||||
return;
|
return;
|
||||||
|
@ -550,7 +540,7 @@ void M3DImporter::importAnimations(const M3DWrapper &m3d) {
|
||||||
|
|
||||||
mScene->mNumAnimations = m3d->numaction;
|
mScene->mNumAnimations = m3d->numaction;
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F("M3D: importAnimations ", mScene->mNumAnimations);
|
ASSIMP_LOG_DEBUG("M3D: importAnimations ", mScene->mNumAnimations);
|
||||||
|
|
||||||
if (!m3d->numaction || !m3d->action || !m3d->numbone || !m3d->bone || !m3d->vertex) {
|
if (!m3d->numaction || !m3d->action || !m3d->numbone || !m3d->bone || !m3d->vertex) {
|
||||||
return;
|
return;
|
||||||
|
@ -713,7 +703,7 @@ void M3DImporter::populateMesh(const M3DWrapper &m3d, aiMesh *pMesh, std::vector
|
||||||
ai_assert(vertexids != nullptr);
|
ai_assert(vertexids != nullptr);
|
||||||
ai_assert(m3d);
|
ai_assert(m3d);
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F("M3D: populateMesh numvertices ", vertices->size(), " numfaces ", faces->size(),
|
ASSIMP_LOG_DEBUG("M3D: populateMesh numvertices ", vertices->size(), " numfaces ", faces->size(),
|
||||||
" numnormals ", normals->size(), " numtexcoord ", texcoords->size(), " numbones ", m3d->numbone);
|
" numnormals ", normals->size(), " numtexcoord ", texcoords->size(), " numbones ", m3d->numbone);
|
||||||
|
|
||||||
if (vertices->size() && faces->size()) {
|
if (vertices->size() && faces->size()) {
|
||||||
|
|
|
@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Assimp specific M3D configuration. Comment out these defines to remove functionality
|
// Assimp specific M3D configuration. Comment out these defines to remove functionality
|
||||||
//#define ASSIMP_USE_M3D_READFILECB
|
//#define ASSIMP_USE_M3D_READFILECB
|
||||||
//#define M3D_ASCII
|
|
||||||
|
|
||||||
#include "m3d.h"
|
#include "m3d.h"
|
||||||
|
|
||||||
|
|
|
@ -231,14 +231,9 @@ enum {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t format;
|
uint8_t format;
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
#ifdef M3D_ASCII
|
|
||||||
#define M3D_PROPERTYDEF(f, i, n) \
|
#define M3D_PROPERTYDEF(f, i, n) \
|
||||||
{ (f), (i), (char *)(n) }
|
{ (f), (i), (char *)(n) }
|
||||||
char *key;
|
char *key;
|
||||||
#else
|
|
||||||
#define M3D_PROPERTYDEF(f, i, n) \
|
|
||||||
{ (f), (i) }
|
|
||||||
#endif
|
|
||||||
} m3dpd_t;
|
} m3dpd_t;
|
||||||
|
|
||||||
/* material property types */
|
/* material property types */
|
||||||
|
@ -376,18 +371,11 @@ enum {
|
||||||
|
|
||||||
#define M3D_CMDMAXARG 8 /* if you increase this, add more arguments to the macro below */
|
#define M3D_CMDMAXARG 8 /* if you increase this, add more arguments to the macro below */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#ifdef M3D_ASCII
|
|
||||||
#define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \
|
#define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \
|
||||||
{ \
|
{ \
|
||||||
(char *)(n), (p), { (a), (b), (c), (d), (e), (f), (g), (h) } \
|
(char *)(n), (p), { (a), (b), (c), (d), (e), (f), (g), (h) } \
|
||||||
}
|
}
|
||||||
char *key;
|
char *key;
|
||||||
#else
|
|
||||||
#define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \
|
|
||||||
{ \
|
|
||||||
(p), { (a), (b), (c), (d), (e), (f), (g), (h) } \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
uint8_t p;
|
uint8_t p;
|
||||||
uint8_t a[M3D_CMDMAXARG];
|
uint8_t a[M3D_CMDMAXARG];
|
||||||
} m3dcd_t;
|
} m3dcd_t;
|
||||||
|
@ -2059,15 +2047,13 @@ unsigned char *_m3dstbi_zlib_compress(unsigned char *data, int data_len, int *ou
|
||||||
|
|
||||||
#define M3D_CHUNKMAGIC(m, a, b, c, d) ((m)[0] == (a) && (m)[1] == (b) && (m)[2] == (c) && (m)[3] == (d))
|
#define M3D_CHUNKMAGIC(m, a, b, c, d) ((m)[0] == (a) && (m)[1] == (b) && (m)[2] == (c) && (m)[3] == (d))
|
||||||
|
|
||||||
#ifdef M3D_ASCII
|
|
||||||
#include <locale.h> /* sprintf and strtod cares about number locale */
|
#include <locale.h> /* sprintf and strtod cares about number locale */
|
||||||
#include <stdio.h> /* get sprintf */
|
#include <stdio.h> /* get sprintf */
|
||||||
#endif
|
|
||||||
#ifdef M3D_PROFILING
|
#ifdef M3D_PROFILING
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(M3D_NOIMPORTER) && defined(M3D_ASCII)
|
#if !defined(M3D_NOIMPORTER)
|
||||||
/* helper functions for the ASCII parser */
|
/* helper functions for the ASCII parser */
|
||||||
static char *_m3d_findarg(char *s) {
|
static char *_m3d_findarg(char *s) {
|
||||||
while (s && *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n')
|
while (s && *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n')
|
||||||
|
@ -2118,7 +2104,7 @@ static char *_m3d_getfloat(char *s, M3D_FLOAT *ret) {
|
||||||
return _m3d_findarg(e);
|
return _m3d_findarg(e);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !defined(M3D_NODUP) && (!defined(M3D_NOIMPORTER) || defined(M3D_ASCII) || defined(M3D_EXPORTER))
|
#if !defined(M3D_NODUP) && (!defined(M3D_NOIMPORTER) || defined(M3D_EXPORTER))
|
||||||
/* helper function to create safe strings */
|
/* helper function to create safe strings */
|
||||||
char *_m3d_safestr(char *in, int morelines) {
|
char *_m3d_safestr(char *in, int morelines) {
|
||||||
char *out, *o, *i = in;
|
char *out, *o, *i = in;
|
||||||
|
@ -2426,21 +2412,17 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
|
||||||
#ifndef M3D_NOWEIGHTS
|
#ifndef M3D_NOWEIGHTS
|
||||||
m3ds_t *sk;
|
m3ds_t *sk;
|
||||||
#endif
|
#endif
|
||||||
#ifdef M3D_ASCII
|
|
||||||
m3ds_t s;
|
m3ds_t s;
|
||||||
M3D_INDEX bi[M3D_BONEMAXLEVEL + 1], level;
|
M3D_INDEX bi[M3D_BONEMAXLEVEL + 1], level;
|
||||||
const char *ol;
|
const char *ol;
|
||||||
char *ptr, *pe, *fn;
|
char *ptr, *pe, *fn;
|
||||||
#endif
|
|
||||||
#ifdef M3D_PROFILING
|
#ifdef M3D_PROFILING
|
||||||
struct timeval tv0, tv1, tvd;
|
struct timeval tv0, tv1, tvd;
|
||||||
gettimeofday(&tv0, NULL);
|
gettimeofday(&tv0, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!data || (!M3D_CHUNKMAGIC(data, '3', 'D', 'M', 'O')
|
if (!data || (!M3D_CHUNKMAGIC(data, '3', 'D', 'M', 'O')
|
||||||
#ifdef M3D_ASCII
|
|
||||||
&& !M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')
|
&& !M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')
|
||||||
#endif
|
|
||||||
))
|
))
|
||||||
return NULL;
|
return NULL;
|
||||||
model = (m3d_t *)M3D_MALLOC(sizeof(m3d_t));
|
model = (m3d_t *)M3D_MALLOC(sizeof(m3d_t));
|
||||||
|
@ -2457,7 +2439,6 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
|
||||||
model->texture = mtllib->texture;
|
model->texture = mtllib->texture;
|
||||||
model->flags |= M3D_FLG_MTLLIB;
|
model->flags |= M3D_FLG_MTLLIB;
|
||||||
}
|
}
|
||||||
#ifdef M3D_ASCII
|
|
||||||
/* ASCII variant? */
|
/* ASCII variant? */
|
||||||
if (M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')) {
|
if (M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')) {
|
||||||
model->errcode = M3D_ERR_BADFILE;
|
model->errcode = M3D_ERR_BADFILE;
|
||||||
|
@ -3034,7 +3015,6 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
|
||||||
setlocale(LC_NUMERIC, ol);
|
setlocale(LC_NUMERIC, ol);
|
||||||
goto postprocess;
|
goto postprocess;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Binary variant */
|
/* Binary variant */
|
||||||
if (!M3D_CHUNKMAGIC(data + 8, 'H', 'E', 'A', 'D')) {
|
if (!M3D_CHUNKMAGIC(data + 8, 'H', 'E', 'A', 'D')) {
|
||||||
buff = (unsigned char *)stbi_zlib_decode_malloc_guesssize_headerflag((const char *)data + 8, ((m3dchunk_t *)data)->length - 8,
|
buff = (unsigned char *)stbi_zlib_decode_malloc_guesssize_headerflag((const char *)data + 8, ((m3dchunk_t *)data)->length - 8,
|
||||||
|
@ -3698,9 +3678,7 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* calculate normals, normalize skin weights, create bone/vertex cross-references and calculate transform matrices */
|
/* calculate normals, normalize skin weights, create bone/vertex cross-references and calculate transform matrices */
|
||||||
#ifdef M3D_ASCII
|
|
||||||
postprocess:
|
postprocess:
|
||||||
#endif
|
|
||||||
if (model) {
|
if (model) {
|
||||||
M3D_LOG("Post-process");
|
M3D_LOG("Post-process");
|
||||||
#ifdef M3D_PROFILING
|
#ifdef M3D_PROFILING
|
||||||
|
@ -3989,7 +3967,6 @@ void m3d_free(m3d_t *model) {
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
if (!model) return;
|
if (!model) return;
|
||||||
#ifdef M3D_ASCII
|
|
||||||
/* if model imported from ASCII, we have to free all strings as well */
|
/* if model imported from ASCII, we have to free all strings as well */
|
||||||
if (model->flags & M3D_FLG_FREESTR) {
|
if (model->flags & M3D_FLG_FREESTR) {
|
||||||
if (model->name) M3D_FREE(model->name);
|
if (model->name) M3D_FREE(model->name);
|
||||||
|
@ -4047,7 +4024,6 @@ void m3d_free(m3d_t *model) {
|
||||||
if (model->preview.data)
|
if (model->preview.data)
|
||||||
M3D_FREE(model->preview.data);
|
M3D_FREE(model->preview.data);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (model->flags & M3D_FLG_FREERAW) M3D_FREE(model->raw);
|
if (model->flags & M3D_FLG_FREERAW) M3D_FREE(model->raw);
|
||||||
|
|
||||||
if (model->tmap) M3D_FREE(model->tmap);
|
if (model->tmap) M3D_FREE(model->tmap);
|
||||||
|
@ -4315,7 +4291,6 @@ static void _m3d_round(int quality, m3dv_t *src, m3dv_t *dst) {
|
||||||
if (dst->w == (M3D_FLOAT)-0.0) dst->w = (M3D_FLOAT)0.0;
|
if (dst->w == (M3D_FLOAT)-0.0) dst->w = (M3D_FLOAT)0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef M3D_ASCII
|
|
||||||
/* add a bone to ascii output */
|
/* add a bone to ascii output */
|
||||||
static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX parent, uint32_t level, M3D_INDEX *vrtxidx) {
|
static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX parent, uint32_t level, M3D_INDEX *vrtxidx) {
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
|
@ -4334,16 +4309,13 @@ static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to encode an in-memory model into on storage Model 3D format
|
* Function to encode an in-memory model into on storage Model 3D format
|
||||||
*/
|
*/
|
||||||
unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size) {
|
unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size) {
|
||||||
#ifdef M3D_ASCII
|
|
||||||
const char *ol;
|
const char *ol;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
#endif
|
|
||||||
char vc_s, vi_s, si_s, ci_s, ti_s, bi_s, nb_s, sk_s, fc_s, hi_s, fi_s;
|
char vc_s, vi_s, si_s, ci_s, ti_s, bi_s, nb_s, sk_s, fc_s, hi_s, fi_s;
|
||||||
char *sn = NULL, *sl = NULL, *sa = NULL, *sd = NULL;
|
char *sn = NULL, *sl = NULL, *sa = NULL, *sd = NULL;
|
||||||
unsigned char *out = NULL, *z = NULL, weights[M3D_NUMBONE], *norm = NULL;
|
unsigned char *out = NULL, *z = NULL, weights[M3D_NUMBONE], *norm = NULL;
|
||||||
|
@ -4369,9 +4341,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
model->errcode = M3D_SUCCESS;
|
model->errcode = M3D_SUCCESS;
|
||||||
#ifdef M3D_ASCII
|
|
||||||
if (flags & M3D_EXP_ASCII) quality = M3D_EXP_DOUBLE;
|
if (flags & M3D_EXP_ASCII) quality = M3D_EXP_DOUBLE;
|
||||||
#endif
|
|
||||||
vrtxidx = (M3D_INDEX *)M3D_MALLOC(model->numvertex * sizeof(M3D_INDEX));
|
vrtxidx = (M3D_INDEX *)M3D_MALLOC(model->numvertex * sizeof(M3D_INDEX));
|
||||||
if (!vrtxidx) goto memerr;
|
if (!vrtxidx) goto memerr;
|
||||||
memset(vrtxidx, 255, model->numvertex * sizeof(M3D_INDEX));
|
memset(vrtxidx, 255, model->numvertex * sizeof(M3D_INDEX));
|
||||||
|
@ -4800,7 +4770,6 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
}
|
}
|
||||||
|
|
||||||
M3D_LOG("Serializing model");
|
M3D_LOG("Serializing model");
|
||||||
#ifdef M3D_ASCII
|
|
||||||
if (flags & M3D_EXP_ASCII) {
|
if (flags & M3D_EXP_ASCII) {
|
||||||
/* use CRLF to make model creators on Win happy... */
|
/* use CRLF to make model creators on Win happy... */
|
||||||
sd = _m3d_safestr(model->desc, 1);
|
sd = _m3d_safestr(model->desc, 1);
|
||||||
|
@ -5073,7 +5042,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
ptr += sprintf(ptr, "\r\n");
|
ptr += sprintf(ptr, "\r\n");
|
||||||
}
|
}
|
||||||
/* mathematical shapes face */
|
/* mathematical shapes face */
|
||||||
if (model->numshape !(flags & M3D_EXP_NOFACE)) {
|
if (model->numshape && (!(flags & M3D_EXP_NOFACE))) {
|
||||||
for (j = 0; j < model->numshape; j++) {
|
for (j = 0; j < model->numshape; j++) {
|
||||||
sn = _m3d_safestr(model->shape[j].name, 0);
|
sn = _m3d_safestr(model->shape[j].name, 0);
|
||||||
if (!sn) {
|
if (!sn) {
|
||||||
|
@ -5287,7 +5256,6 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
if (!out) goto memerr;
|
if (!out) goto memerr;
|
||||||
out[len] = 0;
|
out[len] = 0;
|
||||||
} else
|
} else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* stricly only use LF (newline) in binary */
|
/* stricly only use LF (newline) in binary */
|
||||||
sd = _m3d_safestr(model->desc, 3);
|
sd = _m3d_safestr(model->desc, 3);
|
||||||
|
|
|
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/importerdesc.h>
|
||||||
|
#include <assimp/StringUtils.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -148,46 +149,39 @@ void MD2Importer::ValidateHeader( )
|
||||||
if (m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_BE &&
|
if (m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_BE &&
|
||||||
m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_LE)
|
m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_LE)
|
||||||
{
|
{
|
||||||
char szBuffer[5];
|
throw DeadlyImportError("Invalid MD2 magic word: expected IDP2, found ",
|
||||||
szBuffer[0] = ((char*)&m_pcHeader->magic)[0];
|
ai_str_toprintable((char *)&m_pcHeader->magic, 4));
|
||||||
szBuffer[1] = ((char*)&m_pcHeader->magic)[1];
|
|
||||||
szBuffer[2] = ((char*)&m_pcHeader->magic)[2];
|
|
||||||
szBuffer[3] = ((char*)&m_pcHeader->magic)[3];
|
|
||||||
szBuffer[4] = '\0';
|
|
||||||
|
|
||||||
throw DeadlyImportError("Invalid MD2 magic word: should be IDP2, the "
|
|
||||||
"magic word found is " + std::string(szBuffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check file format version
|
// check file format version
|
||||||
if (m_pcHeader->version != 8)
|
if (m_pcHeader->version != 8)
|
||||||
ASSIMP_LOG_WARN( "Unsupported md2 file version. Continuing happily ...");
|
ASSIMP_LOG_WARN( "Unsupported MD2 file version. Continuing happily ...");
|
||||||
|
|
||||||
// check some values whether they are valid
|
// check some values whether they are valid
|
||||||
if (0 == m_pcHeader->numFrames)
|
if (0 == m_pcHeader->numFrames)
|
||||||
throw DeadlyImportError( "Invalid md2 file: NUM_FRAMES is 0");
|
throw DeadlyImportError( "Invalid MD2 file: NUM_FRAMES is 0");
|
||||||
|
|
||||||
if (m_pcHeader->offsetEnd > (uint32_t)fileSize)
|
if (m_pcHeader->offsetEnd > (uint32_t)fileSize)
|
||||||
throw DeadlyImportError( "Invalid md2 file: File is too small");
|
throw DeadlyImportError( "Invalid MD2 file: File is too small");
|
||||||
|
|
||||||
if (m_pcHeader->numSkins > AI_MAX_ALLOC(MD2::Skin)) {
|
if (m_pcHeader->numSkins > AI_MAX_ALLOC(MD2::Skin)) {
|
||||||
throw DeadlyImportError("Invalid MD2 header: too many skins, would overflow");
|
throw DeadlyImportError("Invalid MD2 header: Too many skins, would overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pcHeader->numVertices > AI_MAX_ALLOC(MD2::Vertex)) {
|
if (m_pcHeader->numVertices > AI_MAX_ALLOC(MD2::Vertex)) {
|
||||||
throw DeadlyImportError("Invalid MD2 header: too many vertices, would overflow");
|
throw DeadlyImportError("Invalid MD2 header: Too many vertices, would overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pcHeader->numTexCoords > AI_MAX_ALLOC(MD2::TexCoord)) {
|
if (m_pcHeader->numTexCoords > AI_MAX_ALLOC(MD2::TexCoord)) {
|
||||||
throw DeadlyImportError("Invalid MD2 header: too many texcoords, would overflow");
|
throw DeadlyImportError("Invalid MD2 header: Too many texcoords, would overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pcHeader->numTriangles > AI_MAX_ALLOC(MD2::Triangle)) {
|
if (m_pcHeader->numTriangles > AI_MAX_ALLOC(MD2::Triangle)) {
|
||||||
throw DeadlyImportError("Invalid MD2 header: too many triangles, would overflow");
|
throw DeadlyImportError("Invalid MD2 header: Too many triangles, would overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pcHeader->numFrames > AI_MAX_ALLOC(MD2::Frame)) {
|
if (m_pcHeader->numFrames > AI_MAX_ALLOC(MD2::Frame)) {
|
||||||
throw DeadlyImportError("Invalid MD2 header: too many frames, would overflow");
|
throw DeadlyImportError("Invalid MD2 header: Too many frames, would overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
// -1 because Frame already contains one
|
// -1 because Frame already contains one
|
||||||
|
@ -199,7 +193,7 @@ void MD2Importer::ValidateHeader( )
|
||||||
m_pcHeader->offsetFrames + m_pcHeader->numFrames * frameSize >= fileSize ||
|
m_pcHeader->offsetFrames + m_pcHeader->numFrames * frameSize >= fileSize ||
|
||||||
m_pcHeader->offsetEnd > fileSize)
|
m_pcHeader->offsetEnd > fileSize)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("Invalid MD2 header: some offsets are outside the file");
|
throw DeadlyImportError("Invalid MD2 header: Some offsets are outside the file");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pcHeader->numSkins > AI_MD2_MAX_SKINS)
|
if (m_pcHeader->numSkins > AI_MD2_MAX_SKINS)
|
||||||
|
@ -210,7 +204,7 @@ void MD2Importer::ValidateHeader( )
|
||||||
ASSIMP_LOG_WARN("The model contains more vertices than Quake 2 supports");
|
ASSIMP_LOG_WARN("The model contains more vertices than Quake 2 supports");
|
||||||
|
|
||||||
if (m_pcHeader->numFrames <= configFrameID )
|
if (m_pcHeader->numFrames <= configFrameID )
|
||||||
throw DeadlyImportError("The requested frame is not existing the file");
|
throw DeadlyImportError("MD2: The requested frame (", configFrameID, ") does not exist in the file");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -433,10 +427,6 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
|
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
|
||||||
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
|
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
|
||||||
|
|
||||||
// flip z and y to become right-handed
|
|
||||||
std::swap((float&)vNormal.z,(float&)vNormal.y);
|
|
||||||
std::swap((float&)vec.z,(float&)vec.y);
|
|
||||||
|
|
||||||
if (m_pcHeader->numTexCoords) {
|
if (m_pcHeader->numTexCoords) {
|
||||||
// validate texture coordinates
|
// validate texture coordinates
|
||||||
iIndex = pcTriangles[i].textureIndices[c];
|
iIndex = pcTriangles[i].textureIndices[c];
|
||||||
|
@ -454,7 +444,15 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iCurrent;
|
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iCurrent;
|
||||||
}
|
}
|
||||||
|
// flip the face order
|
||||||
|
std::swap( pScene->mMeshes[0]->mFaces[i].mIndices[0], pScene->mMeshes[0]->mFaces[i].mIndices[2] );
|
||||||
}
|
}
|
||||||
|
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||||
|
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||||
|
1.f, 0.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 1.f, 0.f,
|
||||||
|
0.f, -1.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_MD2_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_MD2_IMPORTER
|
||||||
|
|
|
@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_MDL_NORMALTABLE_H_INC
|
#define AI_MDL_NORMALTABLE_H_INC
|
||||||
|
|
||||||
|
|
||||||
float g_avNormals[162][3] = {
|
const float g_avNormals[162][3] = {
|
||||||
{ -0.525731f, 0.000000f, 0.850651f },
|
{ -0.525731f, 0.000000f, 0.850651f },
|
||||||
{ -0.442863f, 0.238856f, 0.864188f },
|
{ -0.442863f, 0.238856f, 0.864188f },
|
||||||
{ -0.295242f, 0.000000f, 0.955423f },
|
{ -0.295242f, 0.000000f, 0.955423f },
|
||||||
|
|
|
@ -101,7 +101,7 @@ Q3Shader::BlendFunc StringToBlendFunc(const std::string &m) {
|
||||||
if (m == "GL_ONE_MINUS_DST_COLOR") {
|
if (m == "GL_ONE_MINUS_DST_COLOR") {
|
||||||
return Q3Shader::BLEND_GL_ONE_MINUS_DST_COLOR;
|
return Q3Shader::BLEND_GL_ONE_MINUS_DST_COLOR;
|
||||||
}
|
}
|
||||||
ASSIMP_LOG_ERROR("Q3Shader: Unknown blend function: " + m);
|
ASSIMP_LOG_ERROR("Q3Shader: Unknown blend function: ", m);
|
||||||
return Q3Shader::BLEND_NONE;
|
return Q3Shader::BLEND_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
|
||||||
if (!file.get())
|
if (!file.get())
|
||||||
return false; // if we can't access the file, don't worry and return
|
return false; // if we can't access the file, don't worry and return
|
||||||
|
|
||||||
ASSIMP_LOG_INFO_F("Loading Quake3 shader file ", pFile);
|
ASSIMP_LOG_INFO("Loading Quake3 shader file ", pFile);
|
||||||
|
|
||||||
// read file in memory
|
// read file in memory
|
||||||
const size_t s = file->FileSize();
|
const size_t s = file->FileSize();
|
||||||
|
@ -196,11 +196,11 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
|
||||||
// 'cull' specifies culling behaviour for the model
|
// 'cull' specifies culling behaviour for the model
|
||||||
else if (TokenMatchI(buff, "cull", 4)) {
|
else if (TokenMatchI(buff, "cull", 4)) {
|
||||||
SkipSpaces(&buff);
|
SkipSpaces(&buff);
|
||||||
if (!ASSIMP_strincmp(buff, "back", 4)) {
|
if (!ASSIMP_strincmp(buff, "back", 4)) { // render face's backside, does not function in Q3 engine (bug)
|
||||||
curData->cull = Q3Shader::CULL_CCW;
|
curData->cull = Q3Shader::CULL_CCW;
|
||||||
} else if (!ASSIMP_strincmp(buff, "front", 5)) {
|
} else if (!ASSIMP_strincmp(buff, "front", 5)) { // is not valid keyword in Q3, but occurs in shaders
|
||||||
curData->cull = Q3Shader::CULL_CW;
|
curData->cull = Q3Shader::CULL_CW;
|
||||||
} else if (!ASSIMP_strincmp(buff, "none", 4) || !ASSIMP_strincmp(buff, "disable", 7)) {
|
} else if (!ASSIMP_strincmp(buff, "none", 4) || !ASSIMP_strincmp(buff, "twosided", 8) || !ASSIMP_strincmp(buff, "disable", 7)) {
|
||||||
curData->cull = Q3Shader::CULL_NONE;
|
curData->cull = Q3Shader::CULL_NONE;
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_ERROR("Q3Shader: Unrecognized cull mode");
|
ASSIMP_LOG_ERROR("Q3Shader: Unrecognized cull mode");
|
||||||
|
@ -226,7 +226,7 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io)
|
||||||
if (!file.get())
|
if (!file.get())
|
||||||
return false; // if we can't access the file, don't worry and return
|
return false; // if we can't access the file, don't worry and return
|
||||||
|
|
||||||
ASSIMP_LOG_INFO("Loading Quake3 skin file " + pFile);
|
ASSIMP_LOG_INFO("Loading Quake3 skin file ", pFile);
|
||||||
|
|
||||||
// read file in memory
|
// read file in memory
|
||||||
const size_t s = file->FileSize();
|
const size_t s = file->FileSize();
|
||||||
|
@ -450,6 +450,9 @@ void MD3Importer::SetupProperties(const Importer *pImp) {
|
||||||
// AI_CONFIG_IMPORT_MD3_SKIN_NAME
|
// AI_CONFIG_IMPORT_MD3_SKIN_NAME
|
||||||
configSkinFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SKIN_NAME, "default"));
|
configSkinFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SKIN_NAME, "default"));
|
||||||
|
|
||||||
|
// AI_CONFIG_IMPORT_MD3_LOAD_SHADERS
|
||||||
|
configLoadShaders = (pImp->GetPropertyBool(AI_CONFIG_IMPORT_MD3_LOAD_SHADERS, true));
|
||||||
|
|
||||||
// AI_CONFIG_IMPORT_MD3_SHADER_SRC
|
// AI_CONFIG_IMPORT_MD3_SHADER_SRC
|
||||||
configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC, ""));
|
configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC, ""));
|
||||||
|
|
||||||
|
@ -483,8 +486,9 @@ void MD3Importer::ReadShader(Q3Shader::ShaderData &fill) const {
|
||||||
|
|
||||||
// If no specific dir or file is given, use our default search behaviour
|
// If no specific dir or file is given, use our default search behaviour
|
||||||
if (!configShaderFile.length()) {
|
if (!configShaderFile.length()) {
|
||||||
if (!Q3Shader::LoadShader(fill, path + "..\\..\\..\\scripts\\" + model_file + ".shader", mIOHandler)) {
|
const char sep = mIOHandler->getOsSeparator();
|
||||||
Q3Shader::LoadShader(fill, path + "..\\..\\..\\scripts\\" + filename + ".shader", mIOHandler);
|
if (!Q3Shader::LoadShader(fill, path + ".." + sep + ".." + sep + ".." + sep + "scripts" + sep + model_file + ".shader", mIOHandler)) {
|
||||||
|
Q3Shader::LoadShader(fill, path + ".." + sep + ".." + sep + ".." + sep + "scripts" + sep + filename + ".shader", mIOHandler);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the given string specifies a file, load this file.
|
// If the given string specifies a file, load this file.
|
||||||
|
@ -702,7 +706,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
}
|
}
|
||||||
filename = mFile.substr(s), path = mFile.substr(0, s);
|
filename = mFile.substr(s), path = mFile.substr(0, s);
|
||||||
for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) {
|
for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) {
|
||||||
*it = static_cast<char>(tolower(*it));
|
*it = static_cast<char>(tolower(static_cast<unsigned char>(*it)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load multi-part model file, if necessary
|
// Load multi-part model file, if necessary
|
||||||
|
@ -780,7 +784,9 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
// And check whether we can locate a shader file for this model
|
// And check whether we can locate a shader file for this model
|
||||||
Q3Shader::ShaderData shaders;
|
Q3Shader::ShaderData shaders;
|
||||||
|
if (configLoadShaders){
|
||||||
ReadShader(shaders);
|
ReadShader(shaders);
|
||||||
|
}
|
||||||
|
|
||||||
// Adjust all texture paths in the shader
|
// Adjust all texture paths in the shader
|
||||||
const char *header_name = pcHeader->NAME;
|
const char *header_name = pcHeader->NAME;
|
||||||
|
@ -851,7 +857,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
if (it != skins.textures.end()) {
|
if (it != skins.textures.end()) {
|
||||||
texture_name = &*(_texture_name = (*it).second).begin();
|
texture_name = &*(_texture_name = (*it).second).begin();
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("MD3: Assigning skin texture ", (*it).second, " to surface ", pcSurfaces->NAME);
|
ASSIMP_LOG_VERBOSE_DEBUG("MD3: Assigning skin texture ", (*it).second, " to surface ", pcSurfaces->NAME);
|
||||||
(*it).resolved = true; // mark entry as resolved
|
(*it).resolved = true; // mark entry as resolved
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,8 +868,13 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
std::string convertedPath;
|
std::string convertedPath;
|
||||||
if (texture_name) {
|
if (texture_name) {
|
||||||
|
if (configLoadShaders){
|
||||||
ConvertPath(texture_name, header_name, convertedPath);
|
ConvertPath(texture_name, header_name, convertedPath);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
convertedPath = texture_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Q3Shader::ShaderDataBlock *shader = nullptr;
|
const Q3Shader::ShaderDataBlock *shader = nullptr;
|
||||||
|
|
||||||
|
@ -880,9 +891,9 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
if (dit != shaders.blocks.end()) {
|
if (dit != shaders.blocks.end()) {
|
||||||
// We made it!
|
// We made it!
|
||||||
shader = &*dit;
|
shader = &*dit;
|
||||||
ASSIMP_LOG_INFO("Found shader record for " + without_ext);
|
ASSIMP_LOG_INFO("Found shader record for ", without_ext);
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN("Unable to find shader record for " + without_ext);
|
ASSIMP_LOG_WARN("Unable to find shader record for ", without_ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,8 +996,8 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[index].U;
|
pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[index].U;
|
||||||
pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - pcUVs[index].V;
|
pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - pcUVs[index].V;
|
||||||
}
|
}
|
||||||
// Flip face order if necessary
|
// Flip face order normally, unless shader is backfacing
|
||||||
if (!shader || shader->cull == Q3Shader::CULL_CW) {
|
if (!(shader && shader->cull == Q3Shader::CULL_CCW)) {
|
||||||
std::swap(pcMesh->mFaces[i].mIndices[2], pcMesh->mFaces[i].mIndices[1]);
|
std::swap(pcMesh->mFaces[i].mIndices[2], pcMesh->mFaces[i].mIndices[1]);
|
||||||
}
|
}
|
||||||
++pcTriangles;
|
++pcTriangles;
|
||||||
|
@ -1000,7 +1011,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
if (!DefaultLogger::isNullLogger()) {
|
if (!DefaultLogger::isNullLogger()) {
|
||||||
for (std::list<Q3Shader::SkinData::TextureEntry>::const_iterator it = skins.textures.begin(); it != skins.textures.end(); ++it) {
|
for (std::list<Q3Shader::SkinData::TextureEntry>::const_iterator it = skins.textures.begin(); it != skins.textures.end(); ++it) {
|
||||||
if (!(*it).resolved) {
|
if (!(*it).resolved) {
|
||||||
ASSIMP_LOG_ERROR_F("MD3: Failed to match skin ", (*it).first, " to surface ", (*it).second);
|
ASSIMP_LOG_ERROR("MD3: Failed to match skin ", (*it).first, " to surface ", (*it).second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,6 +297,9 @@ protected:
|
||||||
/** Configuration option: name of skin file to be read */
|
/** Configuration option: name of skin file to be read */
|
||||||
std::string configSkinFile;
|
std::string configSkinFile;
|
||||||
|
|
||||||
|
/** Configuration option: whether to load shaders */
|
||||||
|
bool configLoadShaders;
|
||||||
|
|
||||||
/** Configuration option: name or path of shader */
|
/** Configuration option: name or path of shader */
|
||||||
std::string configShaderFile;
|
std::string configShaderFile;
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ void MD5Importer::LoadMD5MeshFile() {
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if (file.get() == nullptr || !file->FileSize()) {
|
if (file.get() == nullptr || !file->FileSize()) {
|
||||||
ASSIMP_LOG_WARN("Failed to access MD5MESH file: " + filename);
|
ASSIMP_LOG_WARN("Failed to access MD5MESH file: ", filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mHadMD5Mesh = true;
|
mHadMD5Mesh = true;
|
||||||
|
@ -567,7 +567,7 @@ void MD5Importer::LoadMD5AnimFile() {
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if (!file.get() || !file->FileSize()) {
|
if (!file.get() || !file->FileSize()) {
|
||||||
ASSIMP_LOG_WARN("Failed to read MD5ANIM file: " + pFile);
|
ASSIMP_LOG_WARN("Failed to read MD5ANIM file: ", pFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/StringUtils.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -143,16 +144,8 @@ void MDCImporter::ValidateHeader() {
|
||||||
|
|
||||||
if (pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_BE &&
|
if (pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_BE &&
|
||||||
pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_LE) {
|
pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_LE) {
|
||||||
char szBuffer[5];
|
throw DeadlyImportError("Invalid MDC magic word: expected IDPC, found ",
|
||||||
szBuffer[0] = ((char *)&pcHeader->ulIdent)[0];
|
ai_str_toprintable((char *)&pcHeader->ulIdent, 4));
|
||||||
szBuffer[1] = ((char *)&pcHeader->ulIdent)[1];
|
|
||||||
szBuffer[2] = ((char *)&pcHeader->ulIdent)[2];
|
|
||||||
szBuffer[3] = ((char *)&pcHeader->ulIdent)[3];
|
|
||||||
szBuffer[4] = '\0';
|
|
||||||
|
|
||||||
throw DeadlyImportError("Invalid MDC magic word: should be IDPC, the "
|
|
||||||
"magic word found is " +
|
|
||||||
std::string(szBuffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcHeader->ulVersion != AI_MDC_VERSION) {
|
if (pcHeader->ulVersion != AI_MDC_VERSION) {
|
||||||
|
@ -465,6 +458,13 @@ void MDCImporter::InternReadFile(
|
||||||
pcMat->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
pcMat->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||||
|
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||||
|
1.f, 0.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 1.f, 0.f,
|
||||||
|
0.f, -1.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_MDC_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_MDC_IMPORTER
|
||||||
|
|
|
@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define MDC_NORMAL_TABLE_INCLUDED
|
#define MDC_NORMAL_TABLE_INCLUDED
|
||||||
|
|
||||||
/* mdc decoding normal table */
|
/* mdc decoding normal table */
|
||||||
float mdcNormals[ 256 ][ 3 ] =
|
const float mdcNormals[ 256 ][ 3 ] =
|
||||||
{
|
{
|
||||||
{ 1.000000f, 0.000000f, 0.000000f },
|
{ 1.000000f, 0.000000f, 0.000000f },
|
||||||
{ 0.980785f, 0.195090f, 0.000000f },
|
{ 0.980785f, 0.195090f, 0.000000f },
|
||||||
|
|
|
@ -57,6 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#ifdef MDL_HALFLIFE_LOG_WARN_HEADER
|
#ifdef MDL_HALFLIFE_LOG_WARN_HEADER
|
||||||
#undef MDL_HALFLIFE_LOG_WARN_HEADER
|
#undef MDL_HALFLIFE_LOG_WARN_HEADER
|
||||||
|
@ -868,7 +869,7 @@ void HL1MDLLoader::read_meshes() {
|
||||||
scene_mesh->mNormals[v] = bind_pose_normals[pTrivert->normindex];
|
scene_mesh->mNormals[v] = bind_pose_normals[pTrivert->normindex];
|
||||||
scene_mesh->mTextureCoords[0][v] = aiVector3D(
|
scene_mesh->mTextureCoords[0][v] = aiVector3D(
|
||||||
pTrivert->s * texcoords_s_scale,
|
pTrivert->s * texcoords_s_scale,
|
||||||
pTrivert->t * texcoords_t_scale, 0);
|
pTrivert->t * -texcoords_t_scale, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add face and indices.
|
// Add face and indices.
|
||||||
|
@ -879,9 +880,9 @@ void HL1MDLLoader::read_meshes() {
|
||||||
aiFace *face = &scene_mesh->mFaces[f];
|
aiFace *face = &scene_mesh->mFaces[f];
|
||||||
face->mNumIndices = 3;
|
face->mNumIndices = 3;
|
||||||
face->mIndices = new unsigned int[3];
|
face->mIndices = new unsigned int[3];
|
||||||
face->mIndices[0] = mesh_faces[f].v0;
|
face->mIndices[0] = mesh_faces[f].v2;
|
||||||
face->mIndices[1] = mesh_faces[f].v1;
|
face->mIndices[1] = mesh_faces[f].v1;
|
||||||
face->mIndices[2] = mesh_faces[f].v2;
|
face->mIndices[2] = mesh_faces[f].v0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add mesh bones.
|
// Add mesh bones.
|
||||||
|
@ -1342,7 +1343,7 @@ bool HL1MDLLoader::get_num_blend_controllers(const int num_blend_animations, int
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
num_blend_controllers = 0;
|
num_blend_controllers = 0;
|
||||||
ASSIMP_LOG_WARN(MDL_HALFLIFE_LOG_HEADER "Unsupported number of blend animations (" + std::to_string(num_blend_animations) + ")");
|
ASSIMP_LOG_WARN(MDL_HALFLIFE_LOG_HEADER "Unsupported number of blend animations (", num_blend_animations, ")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ void UniqueNameGenerator::make_unique(std::vector<std::string> &names) {
|
||||||
auto generate_unique_name = [&](const std::string &base_name) -> std::string {
|
auto generate_unique_name = [&](const std::string &base_name) -> std::string {
|
||||||
auto *duplicate_info = &names_to_duplicates[base_name];
|
auto *duplicate_info = &names_to_duplicates[base_name];
|
||||||
|
|
||||||
std::string new_name = "";
|
std::string new_name;
|
||||||
|
|
||||||
bool found_identical_name;
|
bool found_identical_name;
|
||||||
bool tried_with_base_name_only = false;
|
bool tried_with_base_name_only = false;
|
||||||
|
|
|
@ -199,6 +199,7 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
const uint32_t iMagicWord = *((uint32_t *)mBuffer);
|
const uint32_t iMagicWord = *((uint32_t *)mBuffer);
|
||||||
|
|
||||||
// Determine the file subtype and call the appropriate member function
|
// Determine the file subtype and call the appropriate member function
|
||||||
|
bool is_half_life = false;
|
||||||
|
|
||||||
// Original Quake1 format
|
// Original Quake1 format
|
||||||
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
||||||
|
@ -240,6 +241,7 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
||||||
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord) {
|
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord) {
|
||||||
iGSFileVersion = 0;
|
iGSFileVersion = 0;
|
||||||
|
is_half_life = true;
|
||||||
|
|
||||||
HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer;
|
HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer;
|
||||||
if (pHeader->version == AI_MDL_HL1_VERSION) {
|
if (pHeader->version == AI_MDL_HL1_VERSION) {
|
||||||
|
@ -252,12 +254,22 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
} else {
|
} else {
|
||||||
// print the magic word to the log file
|
// print the magic word to the log file
|
||||||
throw DeadlyImportError("Unknown MDL subformat ", pFile,
|
throw DeadlyImportError("Unknown MDL subformat ", pFile,
|
||||||
". Magic word (", std::string((char *)&iMagicWord, 4), ") is not known");
|
". Magic word (", ai_str_toprintable((const char *)&iMagicWord, sizeof(iMagicWord)), ") is not known");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_half_life){
|
||||||
|
// Now rotate the whole scene 90 degrees around the z and x axes to convert to internal coordinate system
|
||||||
|
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||||
|
0.f, -1.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 1.f, 0.f,
|
||||||
|
-1.f, 0.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 0.f, 1.f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||||
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
|
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
|
||||||
0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
|
0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
DeleteBufferAndCleanup();
|
DeleteBufferAndCleanup();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ using namespace std;
|
||||||
// Default constructor
|
// Default constructor
|
||||||
MMDImporter::MMDImporter() :
|
MMDImporter::MMDImporter() :
|
||||||
m_Buffer(),
|
m_Buffer(),
|
||||||
m_strAbsPath("") {
|
m_strAbsPath() {
|
||||||
DefaultIOSystem io;
|
DefaultIOSystem io;
|
||||||
m_strAbsPath = io.getOsSeparator();
|
m_strAbsPath = io.getOsSeparator();
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace pmx
|
||||||
std::vector<char> buffer;
|
std::vector<char> buffer;
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
return std::string("");
|
return std::string();
|
||||||
}
|
}
|
||||||
buffer.reserve(size);
|
buffer.reserve(size);
|
||||||
stream->read((char*) buffer.data(), size);
|
stream->read((char*) buffer.data(), size);
|
||||||
|
@ -478,8 +478,7 @@ namespace pmx
|
||||||
|
|
||||||
void PmxSoftBody::Read(std::istream * /*stream*/, PmxSetting * /*setting*/)
|
void PmxSoftBody::Read(std::istream * /*stream*/, PmxSetting * /*setting*/)
|
||||||
{
|
{
|
||||||
std::cerr << "Not Implemented Exception" << std::endl;
|
throw DeadlyImportError("MMD: Soft Body support is not implemented.");
|
||||||
throw DeadlyImportError("MMD: Not Implemented Exception");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PmxModel::Init()
|
void PmxModel::Init()
|
||||||
|
@ -517,14 +516,12 @@ namespace pmx
|
||||||
stream->read((char*) magic, sizeof(char) * 4);
|
stream->read((char*) magic, sizeof(char) * 4);
|
||||||
if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20)
|
if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20)
|
||||||
{
|
{
|
||||||
std::cerr << "invalid magic number." << std::endl;
|
throw DeadlyImportError("MMD: Invalid magic number.");
|
||||||
throw DeadlyImportError("MMD: invalid magic number.");
|
|
||||||
}
|
}
|
||||||
stream->read((char*) &version, sizeof(float));
|
stream->read((char*) &version, sizeof(float));
|
||||||
if (version != 2.0f && version != 2.1f)
|
if (version != 2.0f && version != 2.1f)
|
||||||
{
|
{
|
||||||
std::cerr << "this is not ver2.0 or ver2.1 but " << version << "." << std::endl;
|
throw DeadlyImportError("MMD: Unsupported version (must be 2.0 or 2.1): ", ai_to_string(version));
|
||||||
throw DeadlyImportError("MMD: this is not ver2.0 or ver2.1 but ", ai_to_string(version));
|
|
||||||
}
|
}
|
||||||
this->setting.Read(stream);
|
this->setting.Read(stream);
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,12 @@ void MS3DImporter :: CollectChildJoints(const std::vector<TempJoint>& joints, ai
|
||||||
void MS3DImporter::InternReadFile( const std::string& pFile,
|
void MS3DImporter::InternReadFile( const std::string& pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene* pScene, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
|
|
||||||
|
auto file = pIOHandler->Open(pFile, "rb");
|
||||||
|
if (!file)
|
||||||
|
throw DeadlyImportError("MS3D: Could not open ", pFile);
|
||||||
|
|
||||||
|
StreamReaderLE stream(file);
|
||||||
|
|
||||||
// CanRead() should have done this already
|
// CanRead() should have done this already
|
||||||
char head[10];
|
char head[10];
|
||||||
|
@ -382,7 +387,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& s = std::string(reinterpret_cast<char*>(stream.GetPtr()),len);
|
const std::string& s = std::string(reinterpret_cast<char*>(stream.GetPtr()),len);
|
||||||
ASSIMP_LOG_DEBUG_F("MS3D: Model comment: ", s);
|
ASSIMP_LOG_DEBUG("MS3D: Model comment: ", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stream.GetRemainingSize() > 4 && inrange((stream >> subversion,subversion),1u,3u)) {
|
if(stream.GetRemainingSize() > 4 && inrange((stream >> subversion,subversion),1u,3u)) {
|
||||||
|
|
|
@ -116,7 +116,13 @@ void NDOImporter::SetupProperties(const Importer* /*pImp*/)
|
||||||
void NDOImporter::InternReadFile( const std::string& pFile,
|
void NDOImporter::InternReadFile( const std::string& pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene* pScene, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
StreamReaderBE reader(pIOHandler->Open( pFile, "rb"));
|
|
||||||
|
auto file = pIOHandler->Open( pFile, "rb");
|
||||||
|
if (!file) {
|
||||||
|
throw DeadlyImportError("Nendo: Could not open ", pFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamReaderBE reader(file);
|
||||||
|
|
||||||
// first 9 bytes are nendo file format ("nendo 1.n")
|
// first 9 bytes are nendo file format ("nendo 1.n")
|
||||||
const char* head = (const char*)reader.GetPtr();
|
const char* head = (const char*)reader.GetPtr();
|
||||||
|
@ -141,7 +147,7 @@ void NDOImporter::InternReadFile( const std::string& pFile,
|
||||||
ASSIMP_LOG_INFO("NDO file format is 1.2");
|
ASSIMP_LOG_INFO("NDO file format is 1.2");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ASSIMP_LOG_WARN_F( "Unrecognized nendo file format version, continuing happily ... :", (head+6));
|
ASSIMP_LOG_WARN( "Unrecognized nendo file format version, continuing happily ... :", (head+6));
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.IncPtr(2); /* skip flags */
|
reader.IncPtr(2); /* skip flags */
|
||||||
|
|
|
@ -132,7 +132,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector<ShadingInfo> &output,
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if (!file.get()) {
|
if (!file.get()) {
|
||||||
ASSIMP_LOG_ERROR("NFF2: Unable to open material library " + path + ".");
|
ASSIMP_LOG_ERROR("NFF2: Unable to open material library ", path, ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector<ShadingInfo> &output,
|
||||||
|
|
||||||
// The file should start with the magic sequence "mat"
|
// The file should start with the magic sequence "mat"
|
||||||
if (!TokenMatch(buffer, "mat", 3)) {
|
if (!TokenMatch(buffer, "mat", 3)) {
|
||||||
ASSIMP_LOG_ERROR_F("NFF2: Not a valid material library ", path, ".");
|
ASSIMP_LOG_ERROR("NFF2: Not a valid material library ", path, ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector<ShadingInfo> &output,
|
||||||
|
|
||||||
// 'version' defines the version of the file format
|
// 'version' defines the version of the file format
|
||||||
if (TokenMatch(sz, "version", 7)) {
|
if (TokenMatch(sz, "version", 7)) {
|
||||||
ASSIMP_LOG_INFO_F("NFF (Sense8) material library file format: ", std::string(sz));
|
ASSIMP_LOG_INFO("NFF (Sense8) material library file format: ", std::string(sz));
|
||||||
}
|
}
|
||||||
// 'matdef' starts a new material in the file
|
// 'matdef' starts a new material in the file
|
||||||
else if (TokenMatch(sz, "matdef", 6)) {
|
else if (TokenMatch(sz, "matdef", 6)) {
|
||||||
|
@ -177,7 +177,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector<ShadingInfo> &output,
|
||||||
// check whether we have an active material at the moment
|
// check whether we have an active material at the moment
|
||||||
if (!IsLineEnd(*sz)) {
|
if (!IsLineEnd(*sz)) {
|
||||||
if (!curShader) {
|
if (!curShader) {
|
||||||
ASSIMP_LOG_ERROR_F("NFF2 material library: Found element ", sz, "but there is no active material");
|
ASSIMP_LOG_ERROR("NFF2 material library: Found element ", sz, "but there is no active material");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -277,7 +277,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
|
||||||
while (GetNextLine(buffer, line)) {
|
while (GetNextLine(buffer, line)) {
|
||||||
SkipSpaces(line, &sz);
|
SkipSpaces(line, &sz);
|
||||||
if (TokenMatch(sz, "version", 7)) {
|
if (TokenMatch(sz, "version", 7)) {
|
||||||
ASSIMP_LOG_INFO_F("NFF (Sense8) file format: ", sz);
|
ASSIMP_LOG_INFO("NFF (Sense8) file format: ", sz);
|
||||||
} else if (TokenMatch(sz, "viewpos", 7)) {
|
} else if (TokenMatch(sz, "viewpos", 7)) {
|
||||||
AI_NFF_PARSE_TRIPLE(camPos);
|
AI_NFF_PARSE_TRIPLE(camPos);
|
||||||
hasCam = true;
|
hasCam = true;
|
||||||
|
|
|
@ -556,7 +556,7 @@ void ObjFileParser::getMaterialDesc() {
|
||||||
// This may be the case if the material library is missing. We don't want to lose all
|
// This may be the case if the material library is missing. We don't want to lose all
|
||||||
// materials if that happens, so create a new named material instead of discarding it
|
// materials if that happens, so create a new named material instead of discarding it
|
||||||
// completely.
|
// completely.
|
||||||
ASSIMP_LOG_ERROR("OBJ: failed to locate material " + strName + ", creating new material");
|
ASSIMP_LOG_ERROR("OBJ: failed to locate material ", strName, ", creating new material");
|
||||||
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
||||||
m_pModel->m_pCurrentMaterial->MaterialName.Set(strName);
|
m_pModel->m_pCurrentMaterial->MaterialName.Set(strName);
|
||||||
m_pModel->m_MaterialLib.push_back(strName);
|
m_pModel->m_MaterialLib.push_back(strName);
|
||||||
|
@ -620,12 +620,12 @@ void ObjFileParser::getMaterialLib() {
|
||||||
|
|
||||||
IOStream *pFile = m_pIO->Open(absName);
|
IOStream *pFile = m_pIO->Open(absName);
|
||||||
if (nullptr == pFile) {
|
if (nullptr == pFile) {
|
||||||
ASSIMP_LOG_ERROR("OBJ: Unable to locate material file " + strMatName);
|
ASSIMP_LOG_ERROR("OBJ: Unable to locate material file ", strMatName);
|
||||||
std::string strMatFallbackName = m_originalObjFileName.substr(0, m_originalObjFileName.length() - 3) + "mtl";
|
std::string strMatFallbackName = m_originalObjFileName.substr(0, m_originalObjFileName.length() - 3) + "mtl";
|
||||||
ASSIMP_LOG_INFO("OBJ: Opening fallback material file " + strMatFallbackName);
|
ASSIMP_LOG_INFO("OBJ: Opening fallback material file ", strMatFallbackName);
|
||||||
pFile = m_pIO->Open(strMatFallbackName);
|
pFile = m_pIO->Open(strMatFallbackName);
|
||||||
if (!pFile) {
|
if (!pFile) {
|
||||||
ASSIMP_LOG_ERROR("OBJ: Unable to locate fallback material file " + strMatFallbackName);
|
ASSIMP_LOG_ERROR("OBJ: Unable to locate fallback material file ", strMatFallbackName);
|
||||||
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
|
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -660,7 +660,7 @@ void ObjFileParser::getNewMaterial() {
|
||||||
std::map<std::string, ObjFile::Material *>::iterator it = m_pModel->m_MaterialMap.find(strMat);
|
std::map<std::string, ObjFile::Material *>::iterator it = m_pModel->m_MaterialMap.find(strMat);
|
||||||
if (it == m_pModel->m_MaterialMap.end()) {
|
if (it == m_pModel->m_MaterialMap.end()) {
|
||||||
// Show a warning, if material was not found
|
// Show a warning, if material was not found
|
||||||
ASSIMP_LOG_WARN("OBJ: Unsupported material requested: " + strMat);
|
ASSIMP_LOG_WARN("OBJ: Unsupported material requested: ", strMat);
|
||||||
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
|
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
|
||||||
} else {
|
} else {
|
||||||
// Set new material
|
// Set new material
|
||||||
|
|
|
@ -55,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace Ogre {
|
namespace Ogre {
|
||||||
|
|
||||||
const std::string MESH_VERSION_1_8 = "[MeshSerializer_v1.8]";
|
static constexpr auto MESH_VERSION_1_8 = "[MeshSerializer_v1.8]";
|
||||||
const std::string SKELETON_VERSION_1_8 = "[Serializer_v1.80]";
|
static constexpr auto SKELETON_VERSION_1_8 = "[Serializer_v1.80]";
|
||||||
const std::string SKELETON_VERSION_1_1 = "[Serializer_v1.10]";
|
static constexpr auto SKELETON_VERSION_1_1 = "[Serializer_v1.10]";
|
||||||
|
|
||||||
const unsigned short HEADER_CHUNK_ID = 0x1000;
|
const unsigned short HEADER_CHUNK_ID = 0x1000;
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ uint16_t OgreBinarySerializer::ReadHeader(bool readLen) {
|
||||||
|
|
||||||
#if (OGRE_BINARY_SERIALIZER_DEBUG == 1)
|
#if (OGRE_BINARY_SERIALIZER_DEBUG == 1)
|
||||||
if (id != HEADER_CHUNK_ID) {
|
if (id != HEADER_CHUNK_ID) {
|
||||||
ASSIMP_LOG_DEBUG(Formatter::format() << (assetMode == AM_Mesh ? MeshHeaderToString(static_cast<MeshChunkId>(id)) : SkeletonHeaderToString(static_cast<SkeletonChunkId>(id))));
|
ASSIMP_LOG_DEBUG((assetMode == AM_Mesh ? MeshHeaderToString(static_cast<MeshChunkId>(id)) : SkeletonHeaderToString(static_cast<SkeletonChunkId>(id))));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ void OgreBinarySerializer::RollbackHeader() {
|
||||||
|
|
||||||
void OgreBinarySerializer::SkipBytes(size_t numBytes) {
|
void OgreBinarySerializer::SkipBytes(size_t numBytes) {
|
||||||
#if (OGRE_BINARY_SERIALIZER_DEBUG == 1)
|
#if (OGRE_BINARY_SERIALIZER_DEBUG == 1)
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Skipping ", numBytes, " bytes");
|
ASSIMP_LOG_VERBOSE_DEBUG("Skipping ", numBytes, " bytes");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_reader->IncPtr(numBytes);
|
m_reader->IncPtr(numBytes);
|
||||||
|
@ -208,7 +208,7 @@ void OgreBinarySerializer::ReadMesh(Mesh *mesh) {
|
||||||
mesh->hasSkeletalAnimations = Read<bool>();
|
mesh->hasSkeletalAnimations = Read<bool>();
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG("Reading Mesh");
|
ASSIMP_LOG_VERBOSE_DEBUG("Reading Mesh");
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Skeletal animations: ", mesh->hasSkeletalAnimations ? "true" : "false");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Skeletal animations: ", mesh->hasSkeletalAnimations ? "true" : "false");
|
||||||
|
|
||||||
if (!AtEnd()) {
|
if (!AtEnd()) {
|
||||||
uint16_t id = ReadHeader();
|
uint16_t id = ReadHeader();
|
||||||
|
@ -364,9 +364,9 @@ void OgreBinarySerializer::ReadSubMesh(Mesh *mesh) {
|
||||||
submesh->indexData->faceCount = static_cast<uint32_t>(submesh->indexData->count / 3);
|
submesh->indexData->faceCount = static_cast<uint32_t>(submesh->indexData->count / 3);
|
||||||
submesh->indexData->is32bit = Read<bool>();
|
submesh->indexData->is32bit = Read<bool>();
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Reading SubMesh ", mesh->subMeshes.size());
|
ASSIMP_LOG_VERBOSE_DEBUG("Reading SubMesh ", mesh->subMeshes.size());
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Material: '", submesh->materialRef, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Material: '", submesh->materialRef, "'");
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Uses shared geometry: ", submesh->usesSharedVertexData ? "true" : "false");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Uses shared geometry: ", submesh->usesSharedVertexData ? "true" : "false");
|
||||||
|
|
||||||
// Index buffer
|
// Index buffer
|
||||||
if (submesh->indexData->count > 0) {
|
if (submesh->indexData->count > 0) {
|
||||||
|
@ -374,7 +374,7 @@ void OgreBinarySerializer::ReadSubMesh(Mesh *mesh) {
|
||||||
uint8_t *indexBuffer = ReadBytes(numBytes);
|
uint8_t *indexBuffer = ReadBytes(numBytes);
|
||||||
submesh->indexData->buffer = MemoryStreamPtr(new Assimp::MemoryIOStream(indexBuffer, numBytes, true));
|
submesh->indexData->buffer = MemoryStreamPtr(new Assimp::MemoryIOStream(indexBuffer, numBytes, true));
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - ", submesh->indexData->faceCount,
|
ASSIMP_LOG_VERBOSE_DEBUG(" - ", submesh->indexData->faceCount,
|
||||||
" faces from ", submesh->indexData->count, (submesh->indexData->is32bit ? " 32bit" : " 16bit"),
|
" faces from ", submesh->indexData->count, (submesh->indexData->is32bit ? " 32bit" : " 16bit"),
|
||||||
" indexes of ", numBytes, " bytes");
|
" indexes of ", numBytes, " bytes");
|
||||||
}
|
}
|
||||||
|
@ -475,7 +475,7 @@ void OgreBinarySerializer::ReadSubMeshNames(Mesh *mesh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
submesh->name = ReadLine();
|
submesh->name = ReadLine();
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - SubMesh ", submesh->index, " name '", submesh->name, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - SubMesh ", submesh->index, " name '", submesh->name, "'");
|
||||||
|
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
id = ReadHeader();
|
id = ReadHeader();
|
||||||
|
@ -488,7 +488,7 @@ void OgreBinarySerializer::ReadSubMeshNames(Mesh *mesh) {
|
||||||
void OgreBinarySerializer::ReadGeometry(VertexData *dest) {
|
void OgreBinarySerializer::ReadGeometry(VertexData *dest) {
|
||||||
dest->count = Read<uint32_t>();
|
dest->count = Read<uint32_t>();
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Reading geometry of ", dest->count, " vertices");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Reading geometry of ", dest->count, " vertices");
|
||||||
|
|
||||||
if (!AtEnd()) {
|
if (!AtEnd()) {
|
||||||
uint16_t id = ReadHeader();
|
uint16_t id = ReadHeader();
|
||||||
|
@ -536,7 +536,7 @@ void OgreBinarySerializer::ReadGeometryVertexElement(VertexData *dest) {
|
||||||
element.offset = Read<uint16_t>();
|
element.offset = Read<uint16_t>();
|
||||||
element.index = Read<uint16_t>();
|
element.index = Read<uint16_t>();
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Vertex element ", element.SemanticToString(), " of type ",
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Vertex element ", element.SemanticToString(), " of type ",
|
||||||
element.TypeToString(), " index=", element.index, " source=", element.source);
|
element.TypeToString(), " index=", element.index, " source=", element.source);
|
||||||
|
|
||||||
dest->vertexElements.push_back(element);
|
dest->vertexElements.push_back(element);
|
||||||
|
@ -557,7 +557,7 @@ void OgreBinarySerializer::ReadGeometryVertexBuffer(VertexData *dest) {
|
||||||
uint8_t *vertexBuffer = ReadBytes(numBytes);
|
uint8_t *vertexBuffer = ReadBytes(numBytes);
|
||||||
dest->vertexBindings[bindIndex] = MemoryStreamPtr(new Assimp::MemoryIOStream(vertexBuffer, numBytes, true));
|
dest->vertexBindings[bindIndex] = MemoryStreamPtr(new Assimp::MemoryIOStream(vertexBuffer, numBytes, true));
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Read vertex buffer for source ", bindIndex, " of ", numBytes, " bytes");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Read vertex buffer for source ", bindIndex, " of ", numBytes, " bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OgreBinarySerializer::ReadEdgeList(Mesh * /*mesh*/) {
|
void OgreBinarySerializer::ReadEdgeList(Mesh * /*mesh*/) {
|
||||||
|
@ -777,12 +777,12 @@ bool OgreBinarySerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml
|
||||||
|
|
||||||
MemoryStreamReaderPtr OgreBinarySerializer::OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename) {
|
MemoryStreamReaderPtr OgreBinarySerializer::OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename) {
|
||||||
if (!EndsWith(filename, ".skeleton", false)) {
|
if (!EndsWith(filename, ".skeleton", false)) {
|
||||||
ASSIMP_LOG_ERROR_F("Imported Mesh is referencing to unsupported '", filename, "' skeleton file.");
|
ASSIMP_LOG_ERROR("Imported Mesh is referencing to unsupported '", filename, "' skeleton file.");
|
||||||
return MemoryStreamReaderPtr();
|
return MemoryStreamReaderPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pIOHandler->Exists(filename)) {
|
if (!pIOHandler->Exists(filename)) {
|
||||||
ASSIMP_LOG_ERROR_F("Failed to find skeleton file '", filename, "' that is referenced by imported Mesh.");
|
ASSIMP_LOG_ERROR("Failed to find skeleton file '", filename, "' that is referenced by imported Mesh.");
|
||||||
return MemoryStreamReaderPtr();
|
return MemoryStreamReaderPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,7 +874,7 @@ void OgreBinarySerializer::ReadBone(Skeleton *skeleton) {
|
||||||
throw DeadlyImportError("Ogre Skeleton bone indexes not contiguous. Error at bone index ", bone->id);
|
throw DeadlyImportError("Ogre Skeleton bone indexes not contiguous. Error at bone index ", bone->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" ", bone->id, " ", bone->name);
|
ASSIMP_LOG_VERBOSE_DEBUG(" ", bone->id, " ", bone->name);
|
||||||
|
|
||||||
skeleton->bones.push_back(bone);
|
skeleton->bones.push_back(bone);
|
||||||
}
|
}
|
||||||
|
@ -919,7 +919,7 @@ void OgreBinarySerializer::ReadSkeletonAnimation(Skeleton *skeleton) {
|
||||||
|
|
||||||
skeleton->animations.push_back(anim);
|
skeleton->animations.push_back(anim);
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" ", anim->name, " (", anim->length, " sec, ", anim->tracks.size(), " tracks)");
|
ASSIMP_LOG_VERBOSE_DEBUG(" ", anim->name, " (", anim->length, " sec, ", anim->tracks.size(), " tracks)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OgreBinarySerializer::ReadSkeletonAnimationTrack(Skeleton * /*skeleton*/, Animation *dest) {
|
void OgreBinarySerializer::ReadSkeletonAnimationTrack(Skeleton * /*skeleton*/, Animation *dest) {
|
||||||
|
|
|
@ -160,16 +160,16 @@ aiMaterial *OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste
|
||||||
if (materialFile) {
|
if (materialFile) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Source file for material '", materialName, "' ", potentialFiles[i], " does not exist");
|
ASSIMP_LOG_VERBOSE_DEBUG("Source file for material '", materialName, "' ", potentialFiles[i], " does not exist");
|
||||||
}
|
}
|
||||||
if (!materialFile) {
|
if (!materialFile) {
|
||||||
ASSIMP_LOG_ERROR_F("Failed to find source file for material '", materialName, "'");
|
ASSIMP_LOG_ERROR("Failed to find source file for material '", materialName, "'");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IOStream> stream(materialFile);
|
std::unique_ptr<IOStream> stream(materialFile);
|
||||||
if (stream->FileSize() == 0) {
|
if (stream->FileSize() == 0) {
|
||||||
ASSIMP_LOG_WARN_F("Source file for material '", materialName, "' is empty (size is 0 bytes)");
|
ASSIMP_LOG_WARN("Source file for material '", materialName, "' is empty (size is 0 bytes)");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ aiMaterial *OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste
|
||||||
ss << &data[0];
|
ss << &data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Reading material '", materialName, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG("Reading material '", materialName, "'");
|
||||||
|
|
||||||
aiMaterial *material = new aiMaterial();
|
aiMaterial *material = new aiMaterial();
|
||||||
m_textures.clear();
|
m_textures.clear();
|
||||||
|
@ -219,11 +219,11 @@ aiMaterial *OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste
|
||||||
|
|
||||||
NextAfterNewLine(ss, linePart);
|
NextAfterNewLine(ss, linePart);
|
||||||
if (linePart != partBlockStart) {
|
if (linePart != partBlockStart) {
|
||||||
ASSIMP_LOG_ERROR_F("Invalid material: block start missing near index ", ss.tellg());
|
ASSIMP_LOG_ERROR("Invalid material: block start missing near index ", ss.tellg());
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("material '", materialName, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG("material '", materialName, "'");
|
||||||
|
|
||||||
while (linePart != partBlockEnd) {
|
while (linePart != partBlockEnd) {
|
||||||
// Proceed to the first technique
|
// Proceed to the first technique
|
||||||
|
@ -303,11 +303,11 @@ bool OgreImporter::ReadTechnique(const std::string &techniqueName, stringstream
|
||||||
ss >> linePart;
|
ss >> linePart;
|
||||||
|
|
||||||
if (linePart != partBlockStart) {
|
if (linePart != partBlockStart) {
|
||||||
ASSIMP_LOG_ERROR_F("Invalid material: Technique block start missing near index ", ss.tellg());
|
ASSIMP_LOG_ERROR("Invalid material: Technique block start missing near index ", ss.tellg());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" technique '", techniqueName, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG(" technique '", techniqueName, "'");
|
||||||
|
|
||||||
const string partPass = "pass";
|
const string partPass = "pass";
|
||||||
|
|
||||||
|
@ -334,11 +334,11 @@ bool OgreImporter::ReadPass(const std::string &passName, stringstream &ss, aiMat
|
||||||
ss >> linePart;
|
ss >> linePart;
|
||||||
|
|
||||||
if (linePart != partBlockStart) {
|
if (linePart != partBlockStart) {
|
||||||
ASSIMP_LOG_ERROR_F("Invalid material: Pass block start missing near index ", ss.tellg());
|
ASSIMP_LOG_ERROR("Invalid material: Pass block start missing near index ", ss.tellg());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" pass '", passName, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG(" pass '", passName, "'");
|
||||||
|
|
||||||
const string partAmbient = "ambient";
|
const string partAmbient = "ambient";
|
||||||
const string partDiffuse = "diffuse";
|
const string partDiffuse = "diffuse";
|
||||||
|
@ -362,7 +362,7 @@ bool OgreImporter::ReadPass(const std::string &passName, stringstream &ss, aiMat
|
||||||
ss >> r >> g >> b;
|
ss >> r >> g >> b;
|
||||||
const aiColor3D color(r, g, b);
|
const aiColor3D color(r, g, b);
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" ", linePart, " ", r, " ", g, " ", b);
|
ASSIMP_LOG_VERBOSE_DEBUG(" ", linePart, " ", r, " ", g, " ", b);
|
||||||
|
|
||||||
if (linePart == partAmbient) {
|
if (linePart == partAmbient) {
|
||||||
material->AddProperty(&color, 1, AI_MATKEY_COLOR_AMBIENT);
|
material->AddProperty(&color, 1, AI_MATKEY_COLOR_AMBIENT);
|
||||||
|
@ -386,11 +386,11 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr
|
||||||
ss >> linePart;
|
ss >> linePart;
|
||||||
|
|
||||||
if (linePart != partBlockStart) {
|
if (linePart != partBlockStart) {
|
||||||
ASSIMP_LOG_ERROR_F("Invalid material: Texture unit block start missing near index ", ss.tellg());
|
ASSIMP_LOG_ERROR("Invalid material: Texture unit block start missing near index ", ss.tellg());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" texture_unit '", textureUnitName, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG(" texture_unit '", textureUnitName, "'");
|
||||||
|
|
||||||
const string partTexture = "texture";
|
const string partTexture = "texture";
|
||||||
const string partTextCoordSet = "tex_coord_set";
|
const string partTextCoordSet = "tex_coord_set";
|
||||||
|
@ -420,7 +420,7 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr
|
||||||
|
|
||||||
if (posSuffix != string::npos && posUnderscore != string::npos && posSuffix > posUnderscore) {
|
if (posSuffix != string::npos && posUnderscore != string::npos && posSuffix > posUnderscore) {
|
||||||
string identifier = ai_tolower(textureRef.substr(posUnderscore, posSuffix - posUnderscore));
|
string identifier = ai_tolower(textureRef.substr(posUnderscore, posSuffix - posUnderscore));
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Detecting texture type from filename postfix '", identifier, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG("Detecting texture type from filename postfix '", identifier, "'");
|
||||||
|
|
||||||
if (identifier == "_n" || identifier == "_nrm" || identifier == "_nrml" || identifier == "_normal" || identifier == "_normals" || identifier == "_normalmap") {
|
if (identifier == "_n" || identifier == "_nrm" || identifier == "_nrml" || identifier == "_normal" || identifier == "_normals" || identifier == "_normalmap") {
|
||||||
textureType = aiTextureType_NORMALS;
|
textureType = aiTextureType_NORMALS;
|
||||||
|
@ -477,14 +477,14 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (textureType == aiTextureType_NONE) {
|
if (textureType == aiTextureType_NONE) {
|
||||||
ASSIMP_LOG_WARN("Failed to detect texture type for '" + textureRef + "', ignoring texture_unit.");
|
ASSIMP_LOG_WARN("Failed to detect texture type for '", textureRef, "', ignoring texture_unit.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int textureTypeIndex = m_textures[textureType];
|
unsigned int textureTypeIndex = m_textures[textureType];
|
||||||
m_textures[textureType]++;
|
m_textures[textureType]++;
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" texture '", textureRef, "' type ", textureType,
|
ASSIMP_LOG_VERBOSE_DEBUG(" texture '", textureRef, "' type ", textureType,
|
||||||
" index ", textureTypeIndex, " UV ", uvCoord);
|
" index ", textureTypeIndex, " UV ", uvCoord);
|
||||||
|
|
||||||
aiString assimpTextureRef(textureRef);
|
aiString assimpTextureRef(textureRef);
|
||||||
|
|
|
@ -545,7 +545,7 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) {
|
||||||
dest->mNumUVComponents[0] = static_cast<unsigned int>(uv1Element->ComponentCount());
|
dest->mNumUVComponents[0] = static_cast<unsigned int>(uv1Element->ComponentCount());
|
||||||
dest->mTextureCoords[0] = new aiVector3D[dest->mNumVertices];
|
dest->mTextureCoords[0] = new aiVector3D[dest->mNumVertices];
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN(Formatter::format() << "Ogre imported UV0 type " << uv1Element->TypeToString() << " is not compatible with Assimp. Ignoring UV.");
|
ASSIMP_LOG_WARN("Ogre imported UV0 type ", uv1Element->TypeToString(), " is not compatible with Assimp. Ignoring UV.");
|
||||||
uv1 = 0;
|
uv1 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) {
|
||||||
dest->mNumUVComponents[1] = static_cast<unsigned int>(uv2Element->ComponentCount());
|
dest->mNumUVComponents[1] = static_cast<unsigned int>(uv2Element->ComponentCount());
|
||||||
dest->mTextureCoords[1] = new aiVector3D[dest->mNumVertices];
|
dest->mTextureCoords[1] = new aiVector3D[dest->mNumVertices];
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN(Formatter::format() << "Ogre imported UV0 type " << uv2Element->TypeToString() << " is not compatible with Assimp. Ignoring UV.");
|
ASSIMP_LOG_WARN("Ogre imported UV0 type ", uv2Element->TypeToString(), " is not compatible with Assimp. Ignoring UV.");
|
||||||
uv2 = 0;
|
uv2 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ void OgreXmlSerializer::ReadMesh(MeshXml *mesh) {
|
||||||
|
|
||||||
void OgreXmlSerializer::ReadGeometry(XmlNode &node, VertexDataXml *dest) {
|
void OgreXmlSerializer::ReadGeometry(XmlNode &node, VertexDataXml *dest) {
|
||||||
dest->count = ReadAttribute<uint32_t>(node, "vertexcount");
|
dest->count = ReadAttribute<uint32_t>(node, "vertexcount");
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Reading geometry of ", dest->count, " vertices");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Reading geometry of ", dest->count, " vertices");
|
||||||
|
|
||||||
for (XmlNode currentNode : node.children()) {
|
for (XmlNode currentNode : node.children()) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
|
@ -290,7 +290,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(XmlNode &node, VertexDataXml *d
|
||||||
dest->tangents.reserve(dest->count);
|
dest->tangents.reserve(dest->count);
|
||||||
}
|
}
|
||||||
if (uvs > 0) {
|
if (uvs > 0) {
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Contains ", uvs, " texture coords");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Contains ", uvs, " texture coords");
|
||||||
dest->uvs.resize(uvs);
|
dest->uvs.resize(uvs);
|
||||||
for (size_t i = 0, len = dest->uvs.size(); i < len; ++i) {
|
for (size_t i = 0, len = dest->uvs.size(); i < len; ++i) {
|
||||||
dest->uvs[i].reserve(dest->count);
|
dest->uvs[i].reserve(dest->count);
|
||||||
|
@ -365,9 +365,9 @@ void OgreXmlSerializer::ReadSubMesh(XmlNode &node, MeshXml *mesh) {
|
||||||
submesh->usesSharedVertexData = ReadAttribute<bool>(node, anUseSharedVertices);
|
submesh->usesSharedVertexData = ReadAttribute<bool>(node, anUseSharedVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Reading SubMesh ", mesh->subMeshes.size());
|
ASSIMP_LOG_VERBOSE_DEBUG("Reading SubMesh ", mesh->subMeshes.size());
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Material: '", submesh->materialRef, "'");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Material: '", submesh->materialRef, "'");
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Uses shared geometry: ", (submesh->usesSharedVertexData ? "true" : "false"));
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Uses shared geometry: ", (submesh->usesSharedVertexData ? "true" : "false"));
|
||||||
|
|
||||||
// TODO: maybe we have always just 1 faces and 1 geometry and always in this order. this loop will only work correct, when the order
|
// TODO: maybe we have always just 1 faces and 1 geometry and always in this order. this loop will only work correct, when the order
|
||||||
// of faces and geometry changed, and not if we have more than one of one
|
// of faces and geometry changed, and not if we have more than one of one
|
||||||
|
@ -398,7 +398,7 @@ void OgreXmlSerializer::ReadSubMesh(XmlNode &node, MeshXml *mesh) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (submesh->indexData->faces.size() == submesh->indexData->faceCount) {
|
if (submesh->indexData->faces.size() == submesh->indexData->faceCount) {
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - Faces ", submesh->indexData->faceCount);
|
ASSIMP_LOG_VERBOSE_DEBUG(" - Faces ", submesh->indexData->faceCount);
|
||||||
} else {
|
} else {
|
||||||
throw DeadlyImportError("Read only ", submesh->indexData->faces.size(), " faces when should have read ", submesh->indexData->faceCount);
|
throw DeadlyImportError("Read only ", submesh->indexData->faces.size(), " faces when should have read ", submesh->indexData->faceCount);
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ void OgreXmlSerializer::ReadBoneAssignments(XmlNode &node, VertexDataXml *dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" - ", dest->boneAssignments.size(), " bone assignments");
|
ASSIMP_LOG_VERBOSE_DEBUG(" - ", dest->boneAssignments.size(), " bone assignments");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skeleton
|
// Skeleton
|
||||||
|
@ -515,12 +515,12 @@ bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh)
|
||||||
|
|
||||||
XmlParserPtr OgreXmlSerializer::OpenXmlParser(Assimp::IOSystem *pIOHandler, const std::string &filename) {
|
XmlParserPtr OgreXmlSerializer::OpenXmlParser(Assimp::IOSystem *pIOHandler, const std::string &filename) {
|
||||||
if (!EndsWith(filename, ".skeleton.xml", false)) {
|
if (!EndsWith(filename, ".skeleton.xml", false)) {
|
||||||
ASSIMP_LOG_ERROR_F("Imported Mesh is referencing to unsupported '", filename, "' skeleton file.");
|
ASSIMP_LOG_ERROR("Imported Mesh is referencing to unsupported '", filename, "' skeleton file.");
|
||||||
return XmlParserPtr();
|
return XmlParserPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pIOHandler->Exists(filename)) {
|
if (!pIOHandler->Exists(filename)) {
|
||||||
ASSIMP_LOG_ERROR_F("Failed to find skeleton file '", filename, "' that is referenced by imported Mesh.");
|
ASSIMP_LOG_ERROR("Failed to find skeleton file '", filename, "' that is referenced by imported Mesh.");
|
||||||
return XmlParserPtr();
|
return XmlParserPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ void OgreXmlSerializer::ReadAnimationKeyFrames(XmlNode &node, Animation *anim, V
|
||||||
if (axis.Equal(zeroVec)) {
|
if (axis.Equal(zeroVec)) {
|
||||||
axis.x = 1.0f;
|
axis.x = 1.0f;
|
||||||
if (angle != 0) {
|
if (angle != 0) {
|
||||||
ASSIMP_LOG_WARN_F("Found invalid a key frame with a zero rotation axis in animation: ", anim->name);
|
ASSIMP_LOG_WARN("Found invalid a key frame with a zero rotation axis in animation: ", anim->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
keyframe.rotation = aiQuaternion(axis, angle);
|
keyframe.rotation = aiQuaternion(axis, angle);
|
||||||
|
@ -741,7 +741,7 @@ void OgreXmlSerializer::ReadBones(XmlNode &node, Skeleton *skeleton) {
|
||||||
as per the Ogre skeleton spec. It might be more that other (later) code in this imported does not break. */
|
as per the Ogre skeleton spec. It might be more that other (later) code in this imported does not break. */
|
||||||
for (size_t i = 0, len = skeleton->bones.size(); i < len; ++i) {
|
for (size_t i = 0, len = skeleton->bones.size(); i < len; ++i) {
|
||||||
Bone *b = skeleton->bones[i];
|
Bone *b = skeleton->bones[i];
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG_F(" ", b->id, " ", b->name);
|
ASSIMP_LOG_VERBOSE_DEBUG(" ", b->id, " ", b->name);
|
||||||
|
|
||||||
if (b->id != static_cast<uint16_t>(i)) {
|
if (b->id != static_cast<uint16_t>(i)) {
|
||||||
throw DeadlyImportError("Bone ids are not in sequence starting from 0. Missing index ", i);
|
throw DeadlyImportError("Bone ids are not in sequence starting from 0. Missing index ", i);
|
||||||
|
|
|
@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <assimp/DefaultIOSystem.h>
|
#include <assimp/DefaultIOSystem.h>
|
||||||
#include <assimp/StringComparison.h>
|
#include <assimp/StringComparison.h>
|
||||||
|
#include <assimp/StringUtils.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
|
||||||
#include <assimp/ai_assert.h>
|
#include <assimp/ai_assert.h>
|
||||||
|
@ -206,7 +207,7 @@ USE_ODDLPARSER_NS
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
static void propId2StdString(Property *prop, std::string &name, std::string &key) {
|
static void propId2StdString(Property *prop, std::string &name, std::string &key) {
|
||||||
name = key = "";
|
name = key = std::string();
|
||||||
if (nullptr == prop) {
|
if (nullptr == prop) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -223,6 +224,18 @@ static void propId2StdString(Property *prop, std::string &name, std::string &key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
static void logDDLParserMessage (LogSeverity severity, const std::string &rawmsg) {
|
||||||
|
std::string msg = ai_str_toprintable(rawmsg);
|
||||||
|
switch (severity) {
|
||||||
|
case ddl_debug_msg: ASSIMP_LOG_DEBUG(msg); break;
|
||||||
|
case ddl_info_msg: ASSIMP_LOG_INFO(msg); break;
|
||||||
|
case ddl_warn_msg: ASSIMP_LOG_WARN(msg); break;
|
||||||
|
case ddl_error_msg: ASSIMP_LOG_ERROR(msg); break;
|
||||||
|
default: ASSIMP_LOG_VERBOSE_DEBUG(msg); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
OpenGEXImporter::VertexContainer::VertexContainer() :
|
OpenGEXImporter::VertexContainer::VertexContainer() :
|
||||||
m_numColors(0), m_colors(nullptr), m_numUVComps(), m_textureCoords() {
|
m_numColors(0), m_colors(nullptr), m_numUVComps(), m_textureCoords() {
|
||||||
|
@ -306,6 +319,7 @@ void OpenGEXImporter::InternReadFile(const std::string &filename, aiScene *pScen
|
||||||
pIOHandler->Close(file);
|
pIOHandler->Close(file);
|
||||||
|
|
||||||
OpenDDLParser myParser;
|
OpenDDLParser myParser;
|
||||||
|
myParser.setLogCallback(&logDDLParserMessage);
|
||||||
myParser.setBuffer(&buffer[0], buffer.size());
|
myParser.setBuffer(&buffer[0], buffer.size());
|
||||||
bool success(myParser.parse());
|
bool success(myParser.parse());
|
||||||
if (success) {
|
if (success) {
|
||||||
|
@ -712,7 +726,7 @@ void OpenGEXImporter::handleMeshNode(ODDLParser::DDLNode *node, aiScene *pScene)
|
||||||
} else if ("quads" == propKey) {
|
} else if ("quads" == propKey) {
|
||||||
m_currentMesh->mPrimitiveTypes |= aiPrimitiveType_POLYGON;
|
m_currentMesh->mPrimitiveTypes |= aiPrimitiveType_POLYGON;
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_WARN_F(propKey, " is not supported primitive type.");
|
ASSIMP_LOG_WARN(propKey, " is not supported primitive type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -735,22 +749,22 @@ enum MeshAttribute {
|
||||||
TexCoord
|
TexCoord
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::string PosToken = "position";
|
constexpr auto PosToken = "position";
|
||||||
static const std::string ColToken = "color";
|
constexpr auto ColToken = "color";
|
||||||
static const std::string NormalToken = "normal";
|
constexpr auto NormalToken = "normal";
|
||||||
static const std::string TexCoordToken = "texcoord";
|
constexpr auto TexCoordToken = "texcoord";
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
static MeshAttribute getAttributeByName(const char *attribName) {
|
static MeshAttribute getAttributeByName(const char *attribName) {
|
||||||
ai_assert(nullptr != attribName);
|
ai_assert(nullptr != attribName);
|
||||||
|
|
||||||
if (0 == strncmp(PosToken.c_str(), attribName, PosToken.size())) {
|
if (0 == strcmp(PosToken, attribName)) {
|
||||||
return Position;
|
return Position;
|
||||||
} else if (0 == strncmp(ColToken.c_str(), attribName, ColToken.size())) {
|
} else if (0 == strcmp(ColToken, attribName)) {
|
||||||
return Color;
|
return Color;
|
||||||
} else if (0 == strncmp(NormalToken.c_str(), attribName, NormalToken.size())) {
|
} else if (0 == strcmp(NormalToken, attribName)) {
|
||||||
return Normal;
|
return Normal;
|
||||||
} else if (0 == strncmp(TexCoordToken.c_str(), attribName, TexCoordToken.size())) {
|
} else if (0 == strcmp(TexCoordToken, attribName)) {
|
||||||
return TexCoord;
|
return TexCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ struct MetricInfo {
|
||||||
int m_intValue;
|
int m_intValue;
|
||||||
|
|
||||||
MetricInfo()
|
MetricInfo()
|
||||||
: m_stringValue( "" )
|
: m_stringValue( )
|
||||||
, m_floatValue( 0.0f )
|
, m_floatValue( 0.0f )
|
||||||
, m_intValue( -1 ) {
|
, m_intValue( -1 ) {
|
||||||
// empty
|
// empty
|
||||||
|
|
|
@ -172,7 +172,7 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
(headerCheck[1] != 'L' && headerCheck[1] != 'l') ||
|
(headerCheck[1] != 'L' && headerCheck[1] != 'l') ||
|
||||||
(headerCheck[2] != 'Y' && headerCheck[2] != 'y')) {
|
(headerCheck[2] != 'Y' && headerCheck[2] != 'y')) {
|
||||||
streamedBuffer.close();
|
streamedBuffer.close();
|
||||||
throw DeadlyImportError("Invalid .ply file: Magic number \'ply\' is no there");
|
throw DeadlyImportError("Invalid .ply file: Incorrect magic number (expected 'ply' or 'PLY').");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> mBuffer2;
|
std::vector<char> mBuffer2;
|
||||||
|
|
|
@ -419,7 +419,8 @@ bool PLY::DOM::ParseHeader(IOStreamBuffer<char> &streamBuffer, std::vector<char>
|
||||||
if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) {
|
if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) {
|
||||||
// add the element to the list of elements
|
// add the element to the list of elements
|
||||||
alElements.push_back(out);
|
alElements.push_back(out);
|
||||||
} else if (TokenMatch(buffer, "end_header", 10)) {
|
} else if ( TokenMatch(buffer, "end_header\r", 11) || //checks for header end with /r/n ending
|
||||||
|
TokenMatch(buffer, "end_header", 10)) { //checks for /n ending, if it doesn't end with /r/n
|
||||||
// we have reached the end of the header
|
// we have reached the end of the header
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -178,7 +178,7 @@ struct Q3BSPModel {
|
||||||
m_Textures(),
|
m_Textures(),
|
||||||
m_Lightmaps(),
|
m_Lightmaps(),
|
||||||
m_EntityData(),
|
m_EntityData(),
|
||||||
m_ModelName( "" )
|
m_ModelName()
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ static const aiImporterDesc desc = {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"pk3"
|
"bsp pk3"
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -113,7 +113,7 @@ static void extractIds(const std::string &key, int &id1, int &id2) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Local helper function to normalize filenames.
|
// Local helper function to normalize filenames.
|
||||||
static void normalizePathName(const std::string &rPath, std::string &normalizedPath) {
|
static void normalizePathName(const std::string &rPath, std::string &normalizedPath) {
|
||||||
normalizedPath = "";
|
normalizedPath = std::string();
|
||||||
if (rPath.empty()) {
|
if (rPath.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene *scene,
|
||||||
throw DeadlyImportError("Failed to open file ", rFile, ".");
|
throw DeadlyImportError("Failed to open file ", rFile, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string archiveName(""), mapName("");
|
std::string archiveName, mapName;
|
||||||
separateMapName(rFile, archiveName, mapName);
|
separateMapName(rFile, archiveName, mapName);
|
||||||
|
|
||||||
if (mapName.empty()) {
|
if (mapName.empty()) {
|
||||||
|
@ -202,8 +202,8 @@ void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene *scene,
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Separates the map name from the import name.
|
// Separates the map name from the import name.
|
||||||
void Q3BSPFileImporter::separateMapName(const std::string &importName, std::string &archiveName, std::string &mapName) {
|
void Q3BSPFileImporter::separateMapName(const std::string &importName, std::string &archiveName, std::string &mapName) {
|
||||||
archiveName = "";
|
archiveName = std::string();
|
||||||
mapName = "";
|
mapName = std::string();
|
||||||
if (importName.empty()) {
|
if (importName.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ void Q3BSPFileImporter::separateMapName(const std::string &importName, std::stri
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns the first map in the map archive.
|
// Returns the first map in the map archive.
|
||||||
bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, std::string &mapName) {
|
bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, std::string &mapName) {
|
||||||
mapName = "";
|
mapName = std::string();
|
||||||
std::vector<std::string> fileList;
|
std::vector<std::string> fileList;
|
||||||
bspArchive.getFileListExtension(fileList, "bsp");
|
bspArchive.getFileListExtension(fileList, "bsp");
|
||||||
if (fileList.empty()) {
|
if (fileList.empty()) {
|
||||||
|
@ -440,13 +440,13 @@ void Q3BSPFileImporter::createMaterials(const Q3BSP::Q3BSPModel *pModel, aiScene
|
||||||
if (-1 != textureId) {
|
if (-1 != textureId) {
|
||||||
sQ3BSPTexture *pTexture = pModel->m_Textures[textureId];
|
sQ3BSPTexture *pTexture = pModel->m_Textures[textureId];
|
||||||
if (nullptr != pTexture) {
|
if (nullptr != pTexture) {
|
||||||
std::string tmp("*"), texName("");
|
std::string tmp("*"), texName;
|
||||||
tmp += pTexture->strName;
|
tmp += pTexture->strName;
|
||||||
tmp += ".jpg";
|
tmp += ".jpg";
|
||||||
normalizePathName(tmp, texName);
|
normalizePathName(tmp, texName);
|
||||||
|
|
||||||
if (!importTextureFromArchive(pModel, pArchive, pScene, pMatHelper, textureId)) {
|
if (!importTextureFromArchive(pModel, pArchive, pScene, pMatHelper, textureId)) {
|
||||||
ASSIMP_LOG_ERROR("Cannot import texture from archive " + texName);
|
ASSIMP_LOG_ERROR("Cannot import texture from archive ", texName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ size_t Q3BSPFileImporter::countTriangles(const std::vector<Q3BSP::sQ3BSPFace *>
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates the faces-to-material map.
|
// Creates the faces-to-material map.
|
||||||
void Q3BSPFileImporter::createMaterialMap(const Q3BSP::Q3BSPModel *pModel) {
|
void Q3BSPFileImporter::createMaterialMap(const Q3BSP::Q3BSPModel *pModel) {
|
||||||
std::string key("");
|
std::string key;
|
||||||
std::vector<sQ3BSPFace *> *pCurFaceArray = nullptr;
|
std::vector<sQ3BSPFace *> *pCurFaceArray = nullptr;
|
||||||
for (size_t idx = 0; idx < pModel->m_Faces.size(); idx++) {
|
for (size_t idx = 0; idx < pModel->m_Faces.size(); idx++) {
|
||||||
Q3BSP::sQ3BSPFace *pQ3BSPFace = pModel->m_Faces[idx];
|
Q3BSP::sQ3BSPFace *pQ3BSPFace = pModel->m_Faces[idx];
|
||||||
|
@ -660,7 +660,7 @@ bool Q3BSPFileImporter::expandFile(ZipArchiveIOSystem *pArchive, const std::stri
|
||||||
|
|
||||||
if (rExtList.empty()) {
|
if (rExtList.empty()) {
|
||||||
rFile = rFilename;
|
rFile = rFilename;
|
||||||
rExt = "";
|
rExt = std::string();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// internal headers
|
// internal headers
|
||||||
#include "Q3DLoader.h"
|
#include "Q3DLoader.h"
|
||||||
|
#include <assimp/StringUtils.h>
|
||||||
#include <assimp/StreamReader.h>
|
#include <assimp/StreamReader.h>
|
||||||
#include <assimp/fast_atof.h>
|
#include <assimp/fast_atof.h>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/importerdesc.h>
|
||||||
|
@ -106,7 +107,12 @@ const aiImporterDesc *Q3DImporter::GetInfo() const {
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void Q3DImporter::InternReadFile(const std::string &pFile,
|
void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene *pScene, IOSystem *pIOHandler) {
|
aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
StreamReaderLE stream(pIOHandler->Open(pFile, "rb"));
|
|
||||||
|
auto file = pIOHandler->Open(pFile, "rb");
|
||||||
|
if (!file)
|
||||||
|
throw DeadlyImportError("Quick3D: Could not open ", pFile);
|
||||||
|
|
||||||
|
StreamReaderLE stream(file);
|
||||||
|
|
||||||
// The header is 22 bytes large
|
// The header is 22 bytes large
|
||||||
if (stream.GetRemainingSize() < 22)
|
if (stream.GetRemainingSize() < 22)
|
||||||
|
@ -115,11 +121,11 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||||
// Check the file's signature
|
// Check the file's signature
|
||||||
if (ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Do", 8) &&
|
if (ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Do", 8) &&
|
||||||
ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Ds", 8)) {
|
ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Ds", 8)) {
|
||||||
throw DeadlyImportError("Not a Quick3D file. Signature string is: ", std::string((const char *)stream.GetPtr(), 8));
|
throw DeadlyImportError("Not a Quick3D file. Signature string is: ", ai_str_toprintable((const char *)stream.GetPtr(), 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the file format version
|
// Print the file format version
|
||||||
ASSIMP_LOG_INFO_F("Quick3D File format version: ",
|
ASSIMP_LOG_INFO("Quick3D File format version: ",
|
||||||
std::string(&((const char *)stream.GetPtr())[8], 2));
|
std::string(&((const char *)stream.GetPtr())[8], 2));
|
||||||
|
|
||||||
// ... an store it
|
// ... an store it
|
||||||
|
|
|
@ -68,6 +68,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
#include <assimp/StringUtils.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -166,21 +167,20 @@ static aiColor3D ReadColor(StreamReaderLE *stream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UnknownChunk(StreamReaderLE * /*stream*/, const SIBChunk &chunk) {
|
static void UnknownChunk(StreamReaderLE * /*stream*/, const SIBChunk &chunk) {
|
||||||
char temp[5] = {
|
char temp[4] = {
|
||||||
static_cast<char>((chunk.Tag >> 24) & 0xff),
|
static_cast<char>((chunk.Tag >> 24) & 0xff),
|
||||||
static_cast<char>((chunk.Tag >> 16) & 0xff),
|
static_cast<char>((chunk.Tag >> 16) & 0xff),
|
||||||
static_cast<char>((chunk.Tag >> 8) & 0xff),
|
static_cast<char>((chunk.Tag >> 8) & 0xff),
|
||||||
static_cast<char>(chunk.Tag & 0xff), '\0'
|
static_cast<char>(chunk.Tag & 0xff)
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSIMP_LOG_WARN((Formatter::format(), "SIB: Skipping unknown '", temp, "' chunk."));
|
ASSIMP_LOG_WARN("SIB: Skipping unknown '", ai_str_toprintable(temp, 4), "' chunk.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads a UTF-16LE string and returns it at UTF-8.
|
// Reads a UTF-16LE string and returns it at UTF-8.
|
||||||
static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) {
|
static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) {
|
||||||
if (nullptr == stream || 0 == numWChars) {
|
if (nullptr == stream || 0 == numWChars) {
|
||||||
static const aiString empty;
|
return aiString();
|
||||||
return empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate buffers (max expansion is 1 byte -> 4 bytes for UTF-8)
|
// Allocate buffers (max expansion is 1 byte -> 4 bytes for UTF-8)
|
||||||
|
@ -804,7 +804,12 @@ static void ReadScene(SIB *sib, StreamReaderLE *stream) {
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void SIBImporter::InternReadFile(const std::string &pFile,
|
void SIBImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene *pScene, IOSystem *pIOHandler) {
|
aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
StreamReaderLE stream(pIOHandler->Open(pFile, "rb"));
|
|
||||||
|
auto file = pIOHandler->Open(pFile, "rb");
|
||||||
|
if (!file)
|
||||||
|
throw DeadlyImportError("SIB: Could not open ", pFile);
|
||||||
|
|
||||||
|
StreamReaderLE stream(file);
|
||||||
|
|
||||||
// We should have at least one chunk
|
// We should have at least one chunk
|
||||||
if (stream.GetRemainingSize() < 16)
|
if (stream.GetRemainingSize() < 16)
|
||||||
|
|
|
@ -297,8 +297,8 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !DefaultLogger::isNullLogger()){
|
if ( !DefaultLogger::isNullLogger()){
|
||||||
ASSIMP_LOG_DEBUG((Formatter::format(),"STEP: got ",map.size()," object records with ",
|
ASSIMP_LOG_DEBUG("STEP: got ",map.size()," object records with ",
|
||||||
db.GetRefs().size()," inverse index entries"));
|
db.GetRefs().size()," inverse index entries");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,9 +228,9 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
|
||||||
a_path = extension + "_a.3d";
|
a_path = extension + "_a.3d";
|
||||||
uc_path = extension + ".uc";
|
uc_path = extension + ".uc";
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F("UNREAL: data file is ", d_path);
|
ASSIMP_LOG_DEBUG("UNREAL: data file is ", d_path);
|
||||||
ASSIMP_LOG_DEBUG_F("UNREAL: aniv file is ", a_path);
|
ASSIMP_LOG_DEBUG("UNREAL: aniv file is ", a_path);
|
||||||
ASSIMP_LOG_DEBUG_F("UNREAL: uc file is ", uc_path);
|
ASSIMP_LOG_DEBUG("UNREAL: uc file is ", uc_path);
|
||||||
|
|
||||||
// and open the files ... we can't live without them
|
// and open the files ... we can't live without them
|
||||||
std::unique_ptr<IOStream> p(pIOHandler->Open(d_path));
|
std::unique_ptr<IOStream> p(pIOHandler->Open(d_path));
|
||||||
|
|
|
@ -130,7 +130,7 @@ struct Mesh {
|
||||||
|
|
||||||
std::vector<Bone> mBones;
|
std::vector<Bone> mBones;
|
||||||
|
|
||||||
explicit Mesh(const std::string &pName = "") AI_NO_EXCEPT
|
explicit Mesh(const std::string &pName = std::string()) AI_NO_EXCEPT
|
||||||
: mName( pName )
|
: mName( pName )
|
||||||
, mPositions()
|
, mPositions()
|
||||||
, mPosFaces()
|
, mPosFaces()
|
||||||
|
|
|
@ -602,7 +602,7 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
|
||||||
}
|
}
|
||||||
|
|
||||||
if( oldMat.sceneIndex == SIZE_MAX ) {
|
if( oldMat.sceneIndex == SIZE_MAX ) {
|
||||||
ASSIMP_LOG_WARN_F( "Could not resolve global material reference \"", oldMat.mName, "\"" );
|
ASSIMP_LOG_WARN( "Could not resolve global material reference \"", oldMat.mName, "\"" );
|
||||||
oldMat.sceneIndex = 0;
|
oldMat.sceneIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,8 +667,8 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
|
||||||
|
|
||||||
// convert to lower case for easier comparison
|
// convert to lower case for easier comparison
|
||||||
for ( unsigned int c = 0; c < sz.length(); ++c ) {
|
for ( unsigned int c = 0; c < sz.length(); ++c ) {
|
||||||
if ( isalpha( sz[ c ] ) ) {
|
if ( isalpha( (unsigned char) sz[ c ] ) ) {
|
||||||
sz[ c ] = (char) tolower( sz[ c ] );
|
sz[ c ] = (char) tolower( (unsigned char) sz[ c ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue