mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge branch 'Preview4_0' of https://github.com/TorqueGameEngines/Torque3D into Preview4_0
This commit is contained in:
commit
6a357d8dfb
|
|
@ -1,5 +1,7 @@
|
|||
cmake_minimum_required (VERSION 2.8.12)
|
||||
cmake_minimum_required (VERSION 3.10.2)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
|
||||
set(TORQUE_LIBS_FOLDER_NAME "Libs" CACHE STRING "The solution folder name to place all libs under")
|
||||
set(TORQUE_APP_NAME "" CACHE STRING "the app name")
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/temp" CACHE PATH "default install path" FORCE )
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial()
|
|||
unsigned int idx( NotSet );
|
||||
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 ) {
|
||||
*it = static_cast< char >( ::tolower( *it ) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -50,7 +50,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||
|
||||
// internal headers
|
||||
#include "3DSLoader.h"
|
||||
#include <assimp/Macros.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -46,22 +46,799 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||
|
||||
#include "AssbinFileWriter.h"
|
||||
#include "Common/assbin_chunks.h"
|
||||
#include "PostProcessing/ProcessHelper.h"
|
||||
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/version.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||
# include <zlib.h>
|
||||
#else
|
||||
# include "../contrib/zlib/zlib.h"
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
template <typename T>
|
||||
size_t Write(IOStream * stream, const T& v) {
|
||||
return stream->Write( &v, sizeof(T), 1 );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an aiString
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiString>(IOStream * stream, const aiString& s) {
|
||||
const size_t s2 = (uint32_t)s.length;
|
||||
stream->Write(&s,4,1);
|
||||
stream->Write(s.data,s2,1);
|
||||
|
||||
return s2+4;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an unsigned int as uint32_t
|
||||
template <>
|
||||
inline
|
||||
size_t Write<unsigned int>(IOStream * stream, const unsigned int& w) {
|
||||
const uint32_t t = (uint32_t)w;
|
||||
if (w > t) {
|
||||
// this shouldn't happen, integers in Assimp data structures never exceed 2^32
|
||||
throw DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion");
|
||||
}
|
||||
|
||||
stream->Write(&t,4,1);
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an unsigned int as uint16_t
|
||||
template <>
|
||||
inline
|
||||
size_t Write<uint16_t>(IOStream * stream, const uint16_t& w) {
|
||||
static_assert(sizeof(uint16_t)==2, "sizeof(uint16_t)==2");
|
||||
stream->Write(&w,2,1);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a float
|
||||
template <>
|
||||
inline
|
||||
size_t Write<float>(IOStream * stream, const float& f) {
|
||||
static_assert(sizeof(float)==4, "sizeof(float)==4");
|
||||
stream->Write(&f,4,1);
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a double
|
||||
template <>
|
||||
inline
|
||||
size_t Write<double>(IOStream * stream, const double& f) {
|
||||
static_assert(sizeof(double)==8, "sizeof(double)==8");
|
||||
stream->Write(&f,8,1);
|
||||
|
||||
return 8;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a vec3
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiVector3D>(IOStream * stream, const aiVector3D& v) {
|
||||
size_t t = Write<float>(stream,v.x);
|
||||
t += Write<float>(stream,v.y);
|
||||
t += Write<float>(stream,v.z);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a color value
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiColor3D>(IOStream * stream, const aiColor3D& v) {
|
||||
size_t t = Write<float>(stream,v.r);
|
||||
t += Write<float>(stream,v.g);
|
||||
t += Write<float>(stream,v.b);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a color value
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiColor4D>(IOStream * stream, const aiColor4D& v) {
|
||||
size_t t = Write<float>(stream,v.r);
|
||||
t += Write<float>(stream,v.g);
|
||||
t += Write<float>(stream,v.b);
|
||||
t += Write<float>(stream,v.a);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a quaternion
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiQuaternion>(IOStream * stream, const aiQuaternion& v) {
|
||||
size_t t = Write<float>(stream,v.w);
|
||||
t += Write<float>(stream,v.x);
|
||||
t += Write<float>(stream,v.y);
|
||||
t += Write<float>(stream,v.z);
|
||||
ai_assert(t == 16);
|
||||
|
||||
return 16;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a vertex weight
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiVertexWeight>(IOStream * stream, const aiVertexWeight& v) {
|
||||
size_t t = Write<unsigned int>(stream,v.mVertexId);
|
||||
|
||||
return t+Write<float>(stream,v.mWeight);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a mat4x4
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiMatrix4x4>(IOStream * stream, const aiMatrix4x4& m) {
|
||||
for (unsigned int i = 0; i < 4;++i) {
|
||||
for (unsigned int i2 = 0; i2 < 4;++i2) {
|
||||
Write<float>(stream,m[i][i2]);
|
||||
}
|
||||
}
|
||||
|
||||
return 64;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an aiVectorKey
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiVectorKey>(IOStream * stream, const aiVectorKey& v) {
|
||||
const size_t t = Write<double>(stream,v.mTime);
|
||||
return t + Write<aiVector3D>(stream,v.mValue);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an aiQuatKey
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiQuatKey>(IOStream * stream, const aiQuatKey& v) {
|
||||
const size_t t = Write<double>(stream,v.mTime);
|
||||
return t + Write<aiQuaternion>(stream,v.mValue);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
size_t WriteBounds(IOStream * stream, const T* in, unsigned int size) {
|
||||
T minc, maxc;
|
||||
ArrayBounds(in,size,minc,maxc);
|
||||
|
||||
const size_t t = Write<T>(stream,minc);
|
||||
return t + Write<T>(stream,maxc);
|
||||
}
|
||||
|
||||
// We use this to write out non-byte arrays so that we write using the specializations.
|
||||
// This way we avoid writing out extra bytes that potentially come from struct alignment.
|
||||
template <typename T>
|
||||
inline
|
||||
size_t WriteArray(IOStream * stream, const T* in, unsigned int size) {
|
||||
size_t n = 0;
|
||||
for (unsigned int i=0; i<size; i++) n += Write<T>(stream,in[i]);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
/** @class AssbinChunkWriter
|
||||
* @brief Chunk writer mechanism for the .assbin file structure
|
||||
*
|
||||
* This is a standard in-memory IOStream (most of the code is based on BlobIOStream),
|
||||
* the difference being that this takes another IOStream as a "container" in the
|
||||
* constructor, and when it is destroyed, it appends the magic number, the chunk size,
|
||||
* and the chunk contents to the container stream. This allows relatively easy chunk
|
||||
* chunk construction, even recursively.
|
||||
*/
|
||||
class AssbinChunkWriter : public IOStream
|
||||
{
|
||||
private:
|
||||
|
||||
uint8_t* buffer;
|
||||
uint32_t magic;
|
||||
IOStream * container;
|
||||
size_t cur_size, cursor, initial;
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------
|
||||
void Grow(size_t need = 0)
|
||||
{
|
||||
size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) ));
|
||||
|
||||
const uint8_t* const old = buffer;
|
||||
buffer = new uint8_t[new_size];
|
||||
|
||||
if (old) {
|
||||
memcpy(buffer,old,cur_size);
|
||||
delete[] old;
|
||||
}
|
||||
|
||||
cur_size = new_size;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
AssbinChunkWriter( IOStream * container, uint32_t magic, size_t initial = 4096)
|
||||
: buffer(NULL), magic(magic), container(container), cur_size(0), cursor(0), initial(initial)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~AssbinChunkWriter()
|
||||
{
|
||||
if (container) {
|
||||
container->Write( &magic, sizeof(uint32_t), 1 );
|
||||
container->Write( &cursor, sizeof(uint32_t), 1 );
|
||||
container->Write( buffer, 1, cursor );
|
||||
}
|
||||
if (buffer) delete[] buffer;
|
||||
}
|
||||
|
||||
void * GetBufferPointer() { return buffer; }
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Read(void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) {
|
||||
return 0;
|
||||
}
|
||||
virtual aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) {
|
||||
return aiReturn_FAILURE;
|
||||
}
|
||||
virtual size_t Tell() const {
|
||||
return cursor;
|
||||
}
|
||||
virtual void Flush() {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
virtual size_t FileSize() const {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) {
|
||||
pSize *= pCount;
|
||||
if (cursor + pSize > cur_size) {
|
||||
Grow(cursor + pSize);
|
||||
}
|
||||
|
||||
memcpy(buffer+cursor, pvBuffer, pSize);
|
||||
cursor += pSize;
|
||||
|
||||
return pCount;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
/** @class AssbinExport
|
||||
* @brief Assbin exporter class
|
||||
*
|
||||
* This class performs the .assbin exporting, and is responsible for the file layout.
|
||||
*/
|
||||
class AssbinExport
|
||||
{
|
||||
private:
|
||||
bool shortened;
|
||||
bool compressed;
|
||||
|
||||
protected:
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryNode( IOStream * container, const aiNode* node)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODE );
|
||||
|
||||
unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
|
||||
|
||||
Write<aiString>(&chunk,node->mName);
|
||||
Write<aiMatrix4x4>(&chunk,node->mTransformation);
|
||||
Write<unsigned int>(&chunk,node->mNumChildren);
|
||||
Write<unsigned int>(&chunk,node->mNumMeshes);
|
||||
Write<unsigned int>(&chunk,nb_metadata);
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumMeshes;++i) {
|
||||
Write<unsigned int>(&chunk,node->mMeshes[i]);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i) {
|
||||
WriteBinaryNode( &chunk, node->mChildren[i] );
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < nb_metadata; ++i) {
|
||||
const aiString& key = node->mMetaData->mKeys[i];
|
||||
aiMetadataType type = node->mMetaData->mValues[i].mType;
|
||||
void* value = node->mMetaData->mValues[i].mData;
|
||||
|
||||
Write<aiString>(&chunk, key);
|
||||
Write<uint16_t>(&chunk, type);
|
||||
|
||||
switch (type) {
|
||||
case AI_BOOL:
|
||||
Write<bool>(&chunk, *((bool*) value));
|
||||
break;
|
||||
case AI_INT32:
|
||||
Write<int32_t>(&chunk, *((int32_t*) value));
|
||||
break;
|
||||
case AI_UINT64:
|
||||
Write<uint64_t>(&chunk, *((uint64_t*) value));
|
||||
break;
|
||||
case AI_FLOAT:
|
||||
Write<float>(&chunk, *((float*) value));
|
||||
break;
|
||||
case AI_DOUBLE:
|
||||
Write<double>(&chunk, *((double*) value));
|
||||
break;
|
||||
case AI_AISTRING:
|
||||
Write<aiString>(&chunk, *((aiString*) value));
|
||||
break;
|
||||
case AI_AIVECTOR3D:
|
||||
Write<aiVector3D>(&chunk, *((aiVector3D*) value));
|
||||
break;
|
||||
#ifdef SWIG
|
||||
case FORCE_32BIT:
|
||||
#endif // SWIG
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryTexture(IOStream * container, const aiTexture* tex)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AITEXTURE );
|
||||
|
||||
Write<unsigned int>(&chunk,tex->mWidth);
|
||||
Write<unsigned int>(&chunk,tex->mHeight);
|
||||
chunk.Write( tex->achFormatHint, sizeof(char), 4 );
|
||||
|
||||
if(!shortened) {
|
||||
if (!tex->mHeight) {
|
||||
chunk.Write(tex->pcData,1,tex->mWidth);
|
||||
}
|
||||
else {
|
||||
chunk.Write(tex->pcData,1,tex->mWidth*tex->mHeight*4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryBone(IOStream * container, const aiBone* b)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIBONE );
|
||||
|
||||
Write<aiString>(&chunk,b->mName);
|
||||
Write<unsigned int>(&chunk,b->mNumWeights);
|
||||
Write<aiMatrix4x4>(&chunk,b->mOffsetMatrix);
|
||||
|
||||
// for the moment we write dumb min/max values for the bones, too.
|
||||
// maybe I'll add a better, hash-like solution later
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,b->mWeights,b->mNumWeights);
|
||||
} // else write as usual
|
||||
else WriteArray<aiVertexWeight>(&chunk,b->mWeights,b->mNumWeights);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryMesh(IOStream * container, const aiMesh* mesh)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMESH );
|
||||
|
||||
Write<unsigned int>(&chunk,mesh->mPrimitiveTypes);
|
||||
Write<unsigned int>(&chunk,mesh->mNumVertices);
|
||||
Write<unsigned int>(&chunk,mesh->mNumFaces);
|
||||
Write<unsigned int>(&chunk,mesh->mNumBones);
|
||||
Write<unsigned int>(&chunk,mesh->mMaterialIndex);
|
||||
|
||||
// first of all, write bits for all existent vertex components
|
||||
unsigned int c = 0;
|
||||
if (mesh->mVertices) {
|
||||
c |= ASSBIN_MESH_HAS_POSITIONS;
|
||||
}
|
||||
if (mesh->mNormals) {
|
||||
c |= ASSBIN_MESH_HAS_NORMALS;
|
||||
}
|
||||
if (mesh->mTangents && mesh->mBitangents) {
|
||||
c |= ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS;
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
||||
if (!mesh->mTextureCoords[n]) {
|
||||
break;
|
||||
}
|
||||
c |= ASSBIN_MESH_HAS_TEXCOORD(n);
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
|
||||
if (!mesh->mColors[n]) {
|
||||
break;
|
||||
}
|
||||
c |= ASSBIN_MESH_HAS_COLOR(n);
|
||||
}
|
||||
Write<unsigned int>(&chunk,c);
|
||||
|
||||
aiVector3D minVec, maxVec;
|
||||
if (mesh->mVertices) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mVertices,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else WriteArray<aiVector3D>(&chunk,mesh->mVertices,mesh->mNumVertices);
|
||||
}
|
||||
if (mesh->mNormals) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mNormals,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else WriteArray<aiVector3D>(&chunk,mesh->mNormals,mesh->mNumVertices);
|
||||
}
|
||||
if (mesh->mTangents && mesh->mBitangents) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mTangents,mesh->mNumVertices);
|
||||
WriteBounds(&chunk,mesh->mBitangents,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else {
|
||||
WriteArray<aiVector3D>(&chunk,mesh->mTangents,mesh->mNumVertices);
|
||||
WriteArray<aiVector3D>(&chunk,mesh->mBitangents,mesh->mNumVertices);
|
||||
}
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
|
||||
if (!mesh->mColors[n])
|
||||
break;
|
||||
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mColors[n],mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else WriteArray<aiColor4D>(&chunk,mesh->mColors[n],mesh->mNumVertices);
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
||||
if (!mesh->mTextureCoords[n])
|
||||
break;
|
||||
|
||||
// write number of UV components
|
||||
Write<unsigned int>(&chunk,mesh->mNumUVComponents[n]);
|
||||
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else WriteArray<aiVector3D>(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices);
|
||||
}
|
||||
|
||||
// write faces. There are no floating-point calculations involved
|
||||
// in these, so we can write a simple hash over the face data
|
||||
// to the dump file. We generate a single 32 Bit hash for 512 faces
|
||||
// using Assimp's standard hashing function.
|
||||
if (shortened) {
|
||||
unsigned int processed = 0;
|
||||
for (unsigned int job;(job = std::min(mesh->mNumFaces-processed,512u));processed += job) {
|
||||
|
||||
uint32_t hash = 0;
|
||||
for (unsigned int a = 0; a < job;++a) {
|
||||
|
||||
const aiFace& f = mesh->mFaces[processed+a];
|
||||
uint32_t tmp = f.mNumIndices;
|
||||
hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
|
||||
for (unsigned int i = 0; i < f.mNumIndices; ++i) {
|
||||
static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff");
|
||||
tmp = static_cast<uint32_t>( f.mIndices[i] );
|
||||
hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
|
||||
}
|
||||
}
|
||||
Write<unsigned int>(&chunk,hash);
|
||||
}
|
||||
}
|
||||
else // else write as usual
|
||||
{
|
||||
// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
|
||||
for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
|
||||
const aiFace& f = mesh->mFaces[i];
|
||||
|
||||
static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff");
|
||||
Write<uint16_t>(&chunk,f.mNumIndices);
|
||||
|
||||
for (unsigned int a = 0; a < f.mNumIndices;++a) {
|
||||
if (mesh->mNumVertices < (1u<<16)) {
|
||||
Write<uint16_t>(&chunk,f.mIndices[a]);
|
||||
}
|
||||
else Write<unsigned int>(&chunk,f.mIndices[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write bones
|
||||
if (mesh->mNumBones) {
|
||||
for (unsigned int a = 0; a < mesh->mNumBones;++a) {
|
||||
const aiBone* b = mesh->mBones[a];
|
||||
WriteBinaryBone(&chunk,b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryMaterialProperty(IOStream * container, const aiMaterialProperty* prop)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIALPROPERTY );
|
||||
|
||||
Write<aiString>(&chunk,prop->mKey);
|
||||
Write<unsigned int>(&chunk,prop->mSemantic);
|
||||
Write<unsigned int>(&chunk,prop->mIndex);
|
||||
|
||||
Write<unsigned int>(&chunk,prop->mDataLength);
|
||||
Write<unsigned int>(&chunk,(unsigned int)prop->mType);
|
||||
chunk.Write(prop->mData,1,prop->mDataLength);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryMaterial(IOStream * container, const aiMaterial* mat)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIAL);
|
||||
|
||||
Write<unsigned int>(&chunk,mat->mNumProperties);
|
||||
for (unsigned int i = 0; i < mat->mNumProperties;++i) {
|
||||
WriteBinaryMaterialProperty( &chunk, mat->mProperties[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryNodeAnim(IOStream * container, const aiNodeAnim* nd)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODEANIM );
|
||||
|
||||
Write<aiString>(&chunk,nd->mNodeName);
|
||||
Write<unsigned int>(&chunk,nd->mNumPositionKeys);
|
||||
Write<unsigned int>(&chunk,nd->mNumRotationKeys);
|
||||
Write<unsigned int>(&chunk,nd->mNumScalingKeys);
|
||||
Write<unsigned int>(&chunk,nd->mPreState);
|
||||
Write<unsigned int>(&chunk,nd->mPostState);
|
||||
|
||||
if (nd->mPositionKeys) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,nd->mPositionKeys,nd->mNumPositionKeys);
|
||||
|
||||
} // else write as usual
|
||||
else WriteArray<aiVectorKey>(&chunk,nd->mPositionKeys,nd->mNumPositionKeys);
|
||||
}
|
||||
if (nd->mRotationKeys) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,nd->mRotationKeys,nd->mNumRotationKeys);
|
||||
|
||||
} // else write as usual
|
||||
else WriteArray<aiQuatKey>(&chunk,nd->mRotationKeys,nd->mNumRotationKeys);
|
||||
}
|
||||
if (nd->mScalingKeys) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,nd->mScalingKeys,nd->mNumScalingKeys);
|
||||
|
||||
} // else write as usual
|
||||
else WriteArray<aiVectorKey>(&chunk,nd->mScalingKeys,nd->mNumScalingKeys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryAnim( IOStream * container, const aiAnimation* anim )
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIANIMATION );
|
||||
|
||||
Write<aiString>(&chunk,anim->mName);
|
||||
Write<double>(&chunk,anim->mDuration);
|
||||
Write<double>(&chunk,anim->mTicksPerSecond);
|
||||
Write<unsigned int>(&chunk,anim->mNumChannels);
|
||||
|
||||
for (unsigned int a = 0; a < anim->mNumChannels;++a) {
|
||||
const aiNodeAnim* nd = anim->mChannels[a];
|
||||
WriteBinaryNodeAnim(&chunk,nd);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryLight( IOStream * container, const aiLight* l )
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AILIGHT );
|
||||
|
||||
Write<aiString>(&chunk,l->mName);
|
||||
Write<unsigned int>(&chunk,l->mType);
|
||||
|
||||
if (l->mType != aiLightSource_DIRECTIONAL) {
|
||||
Write<float>(&chunk,l->mAttenuationConstant);
|
||||
Write<float>(&chunk,l->mAttenuationLinear);
|
||||
Write<float>(&chunk,l->mAttenuationQuadratic);
|
||||
}
|
||||
|
||||
Write<aiColor3D>(&chunk,l->mColorDiffuse);
|
||||
Write<aiColor3D>(&chunk,l->mColorSpecular);
|
||||
Write<aiColor3D>(&chunk,l->mColorAmbient);
|
||||
|
||||
if (l->mType == aiLightSource_SPOT) {
|
||||
Write<float>(&chunk,l->mAngleInnerCone);
|
||||
Write<float>(&chunk,l->mAngleOuterCone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryCamera( IOStream * container, const aiCamera* cam )
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AICAMERA );
|
||||
|
||||
Write<aiString>(&chunk,cam->mName);
|
||||
Write<aiVector3D>(&chunk,cam->mPosition);
|
||||
Write<aiVector3D>(&chunk,cam->mLookAt);
|
||||
Write<aiVector3D>(&chunk,cam->mUp);
|
||||
Write<float>(&chunk,cam->mHorizontalFOV);
|
||||
Write<float>(&chunk,cam->mClipPlaneNear);
|
||||
Write<float>(&chunk,cam->mClipPlaneFar);
|
||||
Write<float>(&chunk,cam->mAspect);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryScene( IOStream * container, const aiScene* scene)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AISCENE );
|
||||
|
||||
// basic scene information
|
||||
Write<unsigned int>(&chunk,scene->mFlags);
|
||||
Write<unsigned int>(&chunk,scene->mNumMeshes);
|
||||
Write<unsigned int>(&chunk,scene->mNumMaterials);
|
||||
Write<unsigned int>(&chunk,scene->mNumAnimations);
|
||||
Write<unsigned int>(&chunk,scene->mNumTextures);
|
||||
Write<unsigned int>(&chunk,scene->mNumLights);
|
||||
Write<unsigned int>(&chunk,scene->mNumCameras);
|
||||
|
||||
// write node graph
|
||||
WriteBinaryNode( &chunk, scene->mRootNode );
|
||||
|
||||
// write all meshes
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||
const aiMesh* mesh = scene->mMeshes[i];
|
||||
WriteBinaryMesh( &chunk,mesh);
|
||||
}
|
||||
|
||||
// write materials
|
||||
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
||||
const aiMaterial* mat = scene->mMaterials[i];
|
||||
WriteBinaryMaterial(&chunk,mat);
|
||||
}
|
||||
|
||||
// write all animations
|
||||
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
||||
const aiAnimation* anim = scene->mAnimations[i];
|
||||
WriteBinaryAnim(&chunk,anim);
|
||||
}
|
||||
|
||||
|
||||
// write all textures
|
||||
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
||||
const aiTexture* mesh = scene->mTextures[i];
|
||||
WriteBinaryTexture(&chunk,mesh);
|
||||
}
|
||||
|
||||
// write lights
|
||||
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
||||
const aiLight* l = scene->mLights[i];
|
||||
WriteBinaryLight(&chunk,l);
|
||||
}
|
||||
|
||||
// write cameras
|
||||
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
||||
const aiCamera* cam = scene->mCameras[i];
|
||||
WriteBinaryCamera(&chunk,cam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
AssbinExport()
|
||||
: shortened(false), compressed(false) // temporary settings until properties are introduced for exporters
|
||||
{
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Write a binary model dump
|
||||
void WriteBinaryDump(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene)
|
||||
{
|
||||
IOStream * out = pIOSystem->Open( pFile, "wb" );
|
||||
if (!out) return;
|
||||
|
||||
time_t tt = time(NULL);
|
||||
#if _WIN32
|
||||
tm* p = gmtime(&tt);
|
||||
#else
|
||||
struct tm now;
|
||||
tm* p = gmtime_r(&tt, &now);
|
||||
#endif
|
||||
|
||||
// header
|
||||
char s[64];
|
||||
memset( s, 0, 64 );
|
||||
#if _MSC_VER >= 1400
|
||||
sprintf_s(s,"ASSIMP.binary-dump.%s",asctime(p));
|
||||
#else
|
||||
ai_snprintf(s,64,"ASSIMP.binary-dump.%s",asctime(p));
|
||||
#endif
|
||||
out->Write( s, 44, 1 );
|
||||
// == 44 bytes
|
||||
|
||||
Write<unsigned int>( out, ASSBIN_VERSION_MAJOR );
|
||||
Write<unsigned int>( out, ASSBIN_VERSION_MINOR );
|
||||
Write<unsigned int>( out, aiGetVersionRevision() );
|
||||
Write<unsigned int>( out, aiGetCompileFlags() );
|
||||
Write<uint16_t>( out, shortened );
|
||||
Write<uint16_t>( out, compressed );
|
||||
// == 20 bytes
|
||||
|
||||
char buff[256];
|
||||
strncpy(buff,pFile,256);
|
||||
out->Write(buff,sizeof(char),256);
|
||||
|
||||
char cmd[] = "\0";
|
||||
strncpy(buff,cmd,128);
|
||||
out->Write(buff,sizeof(char),128);
|
||||
|
||||
// leave 64 bytes free for future extensions
|
||||
memset(buff,0xcd,64);
|
||||
out->Write(buff,sizeof(char),64);
|
||||
// == 435 bytes
|
||||
|
||||
// ==== total header size: 512 bytes
|
||||
ai_assert( out->Tell() == ASSBIN_HEADER_LENGTH );
|
||||
|
||||
// Up to here the data is uncompressed. For compressed files, the rest
|
||||
// is compressed using standard DEFLATE from zlib.
|
||||
if (compressed)
|
||||
{
|
||||
AssbinChunkWriter uncompressedStream( NULL, 0 );
|
||||
WriteBinaryScene( &uncompressedStream, pScene );
|
||||
|
||||
uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());
|
||||
uLongf compressedSize = (uLongf)compressBound(uncompressedSize);
|
||||
uint8_t* compressedBuffer = new uint8_t[ compressedSize ];
|
||||
|
||||
int res = compress2( compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9 );
|
||||
if(res != Z_OK)
|
||||
{
|
||||
delete [] compressedBuffer;
|
||||
pIOSystem->Close(out);
|
||||
throw DeadlyExportError("Compression failed.");
|
||||
}
|
||||
|
||||
out->Write( &uncompressedSize, sizeof(uint32_t), 1 );
|
||||
out->Write( compressedBuffer, sizeof(char), compressedSize );
|
||||
|
||||
delete[] compressedBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteBinaryScene( out, pScene );
|
||||
}
|
||||
|
||||
pIOSystem->Close( out );
|
||||
}
|
||||
};
|
||||
|
||||
void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) {
|
||||
DumpSceneToAssbin(
|
||||
pFile,
|
||||
"\0", // no command(s).
|
||||
pIOSystem,
|
||||
pScene,
|
||||
false, // shortened?
|
||||
false); // compressed?
|
||||
AssbinExport exporter;
|
||||
exporter.WriteBinaryDump( pFile, pIOSystem, pScene );
|
||||
}
|
||||
} // end of namespace Assimp
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -1,858 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
/** @file AssbinFileWriter.cpp
|
||||
* @brief Implementation of Assbin file writer.
|
||||
*/
|
||||
|
||||
#include "AssbinFileWriter.h"
|
||||
|
||||
#include "Common/assbin_chunks.h"
|
||||
#include "PostProcessing/ProcessHelper.h"
|
||||
|
||||
#include <assimp/version.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||
# include <zlib.h>
|
||||
#else
|
||||
# include "../contrib/zlib/zlib.h"
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
template <typename T>
|
||||
size_t Write(IOStream * stream, const T& v) {
|
||||
return stream->Write( &v, sizeof(T), 1 );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an aiString
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiString>(IOStream * stream, const aiString& s) {
|
||||
const size_t s2 = (uint32_t)s.length;
|
||||
stream->Write(&s,4,1);
|
||||
stream->Write(s.data,s2,1);
|
||||
|
||||
return s2+4;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an unsigned int as uint32_t
|
||||
template <>
|
||||
inline
|
||||
size_t Write<unsigned int>(IOStream * stream, const unsigned int& w) {
|
||||
const uint32_t t = (uint32_t)w;
|
||||
if (w > t) {
|
||||
// this shouldn't happen, integers in Assimp data structures never exceed 2^32
|
||||
throw DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion");
|
||||
}
|
||||
|
||||
stream->Write(&t,4,1);
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an unsigned int as uint16_t
|
||||
template <>
|
||||
inline
|
||||
size_t Write<uint16_t>(IOStream * stream, const uint16_t& w) {
|
||||
static_assert(sizeof(uint16_t)==2, "sizeof(uint16_t)==2");
|
||||
stream->Write(&w,2,1);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a float
|
||||
template <>
|
||||
inline
|
||||
size_t Write<float>(IOStream * stream, const float& f) {
|
||||
static_assert(sizeof(float)==4, "sizeof(float)==4");
|
||||
stream->Write(&f,4,1);
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a double
|
||||
template <>
|
||||
inline
|
||||
size_t Write<double>(IOStream * stream, const double& f) {
|
||||
static_assert(sizeof(double)==8, "sizeof(double)==8");
|
||||
stream->Write(&f,8,1);
|
||||
|
||||
return 8;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a vec3
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiVector3D>(IOStream * stream, const aiVector3D& v) {
|
||||
size_t t = Write<float>(stream,v.x);
|
||||
t += Write<float>(stream,v.y);
|
||||
t += Write<float>(stream,v.z);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a color value
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiColor3D>(IOStream * stream, const aiColor3D& v) {
|
||||
size_t t = Write<float>(stream,v.r);
|
||||
t += Write<float>(stream,v.g);
|
||||
t += Write<float>(stream,v.b);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a color value
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiColor4D>(IOStream * stream, const aiColor4D& v) {
|
||||
size_t t = Write<float>(stream,v.r);
|
||||
t += Write<float>(stream,v.g);
|
||||
t += Write<float>(stream,v.b);
|
||||
t += Write<float>(stream,v.a);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a quaternion
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiQuaternion>(IOStream * stream, const aiQuaternion& v) {
|
||||
size_t t = Write<float>(stream,v.w);
|
||||
t += Write<float>(stream,v.x);
|
||||
t += Write<float>(stream,v.y);
|
||||
t += Write<float>(stream,v.z);
|
||||
ai_assert(t == 16);
|
||||
|
||||
return 16;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a vertex weight
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiVertexWeight>(IOStream * stream, const aiVertexWeight& v) {
|
||||
size_t t = Write<unsigned int>(stream,v.mVertexId);
|
||||
|
||||
return t+Write<float>(stream,v.mWeight);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize a mat4x4
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiMatrix4x4>(IOStream * stream, const aiMatrix4x4& m) {
|
||||
for (unsigned int i = 0; i < 4;++i) {
|
||||
for (unsigned int i2 = 0; i2 < 4;++i2) {
|
||||
Write<float>(stream,m[i][i2]);
|
||||
}
|
||||
}
|
||||
|
||||
return 64;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an aiVectorKey
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiVectorKey>(IOStream * stream, const aiVectorKey& v) {
|
||||
const size_t t = Write<double>(stream,v.mTime);
|
||||
return t + Write<aiVector3D>(stream,v.mValue);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Serialize an aiQuatKey
|
||||
template <>
|
||||
inline
|
||||
size_t Write<aiQuatKey>(IOStream * stream, const aiQuatKey& v) {
|
||||
const size_t t = Write<double>(stream,v.mTime);
|
||||
return t + Write<aiQuaternion>(stream,v.mValue);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
size_t WriteBounds(IOStream * stream, const T* in, unsigned int size) {
|
||||
T minc, maxc;
|
||||
ArrayBounds(in,size,minc,maxc);
|
||||
|
||||
const size_t t = Write<T>(stream,minc);
|
||||
return t + Write<T>(stream,maxc);
|
||||
}
|
||||
|
||||
// We use this to write out non-byte arrays so that we write using the specializations.
|
||||
// This way we avoid writing out extra bytes that potentially come from struct alignment.
|
||||
template <typename T>
|
||||
inline
|
||||
size_t WriteArray(IOStream * stream, const T* in, unsigned int size) {
|
||||
size_t n = 0;
|
||||
for (unsigned int i=0; i<size; i++) n += Write<T>(stream,in[i]);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
/** @class AssbinChunkWriter
|
||||
* @brief Chunk writer mechanism for the .assbin file structure
|
||||
*
|
||||
* This is a standard in-memory IOStream (most of the code is based on BlobIOStream),
|
||||
* the difference being that this takes another IOStream as a "container" in the
|
||||
* constructor, and when it is destroyed, it appends the magic number, the chunk size,
|
||||
* and the chunk contents to the container stream. This allows relatively easy chunk
|
||||
* chunk construction, even recursively.
|
||||
*/
|
||||
class AssbinChunkWriter : public IOStream
|
||||
{
|
||||
private:
|
||||
|
||||
uint8_t* buffer;
|
||||
uint32_t magic;
|
||||
IOStream * container;
|
||||
size_t cur_size, cursor, initial;
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------
|
||||
void Grow(size_t need = 0)
|
||||
{
|
||||
size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) ));
|
||||
|
||||
const uint8_t* const old = buffer;
|
||||
buffer = new uint8_t[new_size];
|
||||
|
||||
if (old) {
|
||||
memcpy(buffer,old,cur_size);
|
||||
delete[] old;
|
||||
}
|
||||
|
||||
cur_size = new_size;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
AssbinChunkWriter( IOStream * container, uint32_t magic, size_t initial = 4096)
|
||||
: buffer(NULL), magic(magic), container(container), cur_size(0), cursor(0), initial(initial)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~AssbinChunkWriter()
|
||||
{
|
||||
if (container) {
|
||||
container->Write( &magic, sizeof(uint32_t), 1 );
|
||||
container->Write( &cursor, sizeof(uint32_t), 1 );
|
||||
container->Write( buffer, 1, cursor );
|
||||
}
|
||||
if (buffer) delete[] buffer;
|
||||
}
|
||||
|
||||
void * GetBufferPointer() { return buffer; }
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Read(void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) {
|
||||
return 0;
|
||||
}
|
||||
virtual aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) {
|
||||
return aiReturn_FAILURE;
|
||||
}
|
||||
virtual size_t Tell() const {
|
||||
return cursor;
|
||||
}
|
||||
virtual void Flush() {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
virtual size_t FileSize() const {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) {
|
||||
pSize *= pCount;
|
||||
if (cursor + pSize > cur_size) {
|
||||
Grow(cursor + pSize);
|
||||
}
|
||||
|
||||
memcpy(buffer+cursor, pvBuffer, pSize);
|
||||
cursor += pSize;
|
||||
|
||||
return pCount;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
/** @class AssbinFileWriter
|
||||
* @brief Assbin file writer class
|
||||
*
|
||||
* This class writes an .assbin file, and is responsible for the file layout.
|
||||
*/
|
||||
class AssbinFileWriter
|
||||
{
|
||||
private:
|
||||
bool shortened;
|
||||
bool compressed;
|
||||
|
||||
protected:
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryNode( IOStream * container, const aiNode* node)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODE );
|
||||
|
||||
unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
|
||||
|
||||
Write<aiString>(&chunk,node->mName);
|
||||
Write<aiMatrix4x4>(&chunk,node->mTransformation);
|
||||
Write<unsigned int>(&chunk,node->mNumChildren);
|
||||
Write<unsigned int>(&chunk,node->mNumMeshes);
|
||||
Write<unsigned int>(&chunk,nb_metadata);
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumMeshes;++i) {
|
||||
Write<unsigned int>(&chunk,node->mMeshes[i]);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i) {
|
||||
WriteBinaryNode( &chunk, node->mChildren[i] );
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < nb_metadata; ++i) {
|
||||
const aiString& key = node->mMetaData->mKeys[i];
|
||||
aiMetadataType type = node->mMetaData->mValues[i].mType;
|
||||
void* value = node->mMetaData->mValues[i].mData;
|
||||
|
||||
Write<aiString>(&chunk, key);
|
||||
Write<uint16_t>(&chunk, type);
|
||||
|
||||
switch (type) {
|
||||
case AI_BOOL:
|
||||
Write<bool>(&chunk, *((bool*) value));
|
||||
break;
|
||||
case AI_INT32:
|
||||
Write<int32_t>(&chunk, *((int32_t*) value));
|
||||
break;
|
||||
case AI_UINT64:
|
||||
Write<uint64_t>(&chunk, *((uint64_t*) value));
|
||||
break;
|
||||
case AI_FLOAT:
|
||||
Write<float>(&chunk, *((float*) value));
|
||||
break;
|
||||
case AI_DOUBLE:
|
||||
Write<double>(&chunk, *((double*) value));
|
||||
break;
|
||||
case AI_AISTRING:
|
||||
Write<aiString>(&chunk, *((aiString*) value));
|
||||
break;
|
||||
case AI_AIVECTOR3D:
|
||||
Write<aiVector3D>(&chunk, *((aiVector3D*) value));
|
||||
break;
|
||||
#ifdef SWIG
|
||||
case FORCE_32BIT:
|
||||
#endif // SWIG
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryTexture(IOStream * container, const aiTexture* tex)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AITEXTURE );
|
||||
|
||||
Write<unsigned int>(&chunk,tex->mWidth);
|
||||
Write<unsigned int>(&chunk,tex->mHeight);
|
||||
// Write the texture format, but don't include the null terminator.
|
||||
chunk.Write( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 );
|
||||
|
||||
if(!shortened) {
|
||||
if (!tex->mHeight) {
|
||||
chunk.Write(tex->pcData,1,tex->mWidth);
|
||||
}
|
||||
else {
|
||||
chunk.Write(tex->pcData,1,tex->mWidth*tex->mHeight*4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryBone(IOStream * container, const aiBone* b)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIBONE );
|
||||
|
||||
Write<aiString>(&chunk,b->mName);
|
||||
Write<unsigned int>(&chunk,b->mNumWeights);
|
||||
Write<aiMatrix4x4>(&chunk,b->mOffsetMatrix);
|
||||
|
||||
// for the moment we write dumb min/max values for the bones, too.
|
||||
// maybe I'll add a better, hash-like solution later
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,b->mWeights,b->mNumWeights);
|
||||
} // else write as usual
|
||||
else WriteArray<aiVertexWeight>(&chunk,b->mWeights,b->mNumWeights);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryMesh(IOStream * container, const aiMesh* mesh)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMESH );
|
||||
|
||||
Write<unsigned int>(&chunk,mesh->mPrimitiveTypes);
|
||||
Write<unsigned int>(&chunk,mesh->mNumVertices);
|
||||
Write<unsigned int>(&chunk,mesh->mNumFaces);
|
||||
Write<unsigned int>(&chunk,mesh->mNumBones);
|
||||
Write<unsigned int>(&chunk,mesh->mMaterialIndex);
|
||||
|
||||
// first of all, write bits for all existent vertex components
|
||||
unsigned int c = 0;
|
||||
if (mesh->mVertices) {
|
||||
c |= ASSBIN_MESH_HAS_POSITIONS;
|
||||
}
|
||||
if (mesh->mNormals) {
|
||||
c |= ASSBIN_MESH_HAS_NORMALS;
|
||||
}
|
||||
if (mesh->mTangents && mesh->mBitangents) {
|
||||
c |= ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS;
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
||||
if (!mesh->mTextureCoords[n]) {
|
||||
break;
|
||||
}
|
||||
c |= ASSBIN_MESH_HAS_TEXCOORD(n);
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
|
||||
if (!mesh->mColors[n]) {
|
||||
break;
|
||||
}
|
||||
c |= ASSBIN_MESH_HAS_COLOR(n);
|
||||
}
|
||||
Write<unsigned int>(&chunk,c);
|
||||
|
||||
aiVector3D minVec, maxVec;
|
||||
if (mesh->mVertices) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mVertices,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else WriteArray<aiVector3D>(&chunk,mesh->mVertices,mesh->mNumVertices);
|
||||
}
|
||||
if (mesh->mNormals) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mNormals,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else WriteArray<aiVector3D>(&chunk,mesh->mNormals,mesh->mNumVertices);
|
||||
}
|
||||
if (mesh->mTangents && mesh->mBitangents) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mTangents,mesh->mNumVertices);
|
||||
WriteBounds(&chunk,mesh->mBitangents,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else {
|
||||
WriteArray<aiVector3D>(&chunk,mesh->mTangents,mesh->mNumVertices);
|
||||
WriteArray<aiVector3D>(&chunk,mesh->mBitangents,mesh->mNumVertices);
|
||||
}
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
|
||||
if (!mesh->mColors[n])
|
||||
break;
|
||||
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mColors[n],mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else WriteArray<aiColor4D>(&chunk,mesh->mColors[n],mesh->mNumVertices);
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
||||
if (!mesh->mTextureCoords[n])
|
||||
break;
|
||||
|
||||
// write number of UV components
|
||||
Write<unsigned int>(&chunk,mesh->mNumUVComponents[n]);
|
||||
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else WriteArray<aiVector3D>(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices);
|
||||
}
|
||||
|
||||
// write faces. There are no floating-point calculations involved
|
||||
// in these, so we can write a simple hash over the face data
|
||||
// to the dump file. We generate a single 32 Bit hash for 512 faces
|
||||
// using Assimp's standard hashing function.
|
||||
if (shortened) {
|
||||
unsigned int processed = 0;
|
||||
for (unsigned int job;(job = std::min(mesh->mNumFaces-processed,512u));processed += job) {
|
||||
|
||||
uint32_t hash = 0;
|
||||
for (unsigned int a = 0; a < job;++a) {
|
||||
|
||||
const aiFace& f = mesh->mFaces[processed+a];
|
||||
uint32_t tmp = f.mNumIndices;
|
||||
hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
|
||||
for (unsigned int i = 0; i < f.mNumIndices; ++i) {
|
||||
static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff");
|
||||
tmp = static_cast<uint32_t>( f.mIndices[i] );
|
||||
hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
|
||||
}
|
||||
}
|
||||
Write<unsigned int>(&chunk,hash);
|
||||
}
|
||||
}
|
||||
else // else write as usual
|
||||
{
|
||||
// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
|
||||
for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
|
||||
const aiFace& f = mesh->mFaces[i];
|
||||
|
||||
static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff");
|
||||
Write<uint16_t>(&chunk,f.mNumIndices);
|
||||
|
||||
for (unsigned int a = 0; a < f.mNumIndices;++a) {
|
||||
if (mesh->mNumVertices < (1u<<16)) {
|
||||
Write<uint16_t>(&chunk,f.mIndices[a]);
|
||||
}
|
||||
else Write<unsigned int>(&chunk,f.mIndices[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write bones
|
||||
if (mesh->mNumBones) {
|
||||
for (unsigned int a = 0; a < mesh->mNumBones;++a) {
|
||||
const aiBone* b = mesh->mBones[a];
|
||||
WriteBinaryBone(&chunk,b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryMaterialProperty(IOStream * container, const aiMaterialProperty* prop)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIALPROPERTY );
|
||||
|
||||
Write<aiString>(&chunk,prop->mKey);
|
||||
Write<unsigned int>(&chunk,prop->mSemantic);
|
||||
Write<unsigned int>(&chunk,prop->mIndex);
|
||||
|
||||
Write<unsigned int>(&chunk,prop->mDataLength);
|
||||
Write<unsigned int>(&chunk,(unsigned int)prop->mType);
|
||||
chunk.Write(prop->mData,1,prop->mDataLength);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryMaterial(IOStream * container, const aiMaterial* mat)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIAL);
|
||||
|
||||
Write<unsigned int>(&chunk,mat->mNumProperties);
|
||||
for (unsigned int i = 0; i < mat->mNumProperties;++i) {
|
||||
WriteBinaryMaterialProperty( &chunk, mat->mProperties[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryNodeAnim(IOStream * container, const aiNodeAnim* nd)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODEANIM );
|
||||
|
||||
Write<aiString>(&chunk,nd->mNodeName);
|
||||
Write<unsigned int>(&chunk,nd->mNumPositionKeys);
|
||||
Write<unsigned int>(&chunk,nd->mNumRotationKeys);
|
||||
Write<unsigned int>(&chunk,nd->mNumScalingKeys);
|
||||
Write<unsigned int>(&chunk,nd->mPreState);
|
||||
Write<unsigned int>(&chunk,nd->mPostState);
|
||||
|
||||
if (nd->mPositionKeys) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,nd->mPositionKeys,nd->mNumPositionKeys);
|
||||
|
||||
} // else write as usual
|
||||
else WriteArray<aiVectorKey>(&chunk,nd->mPositionKeys,nd->mNumPositionKeys);
|
||||
}
|
||||
if (nd->mRotationKeys) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,nd->mRotationKeys,nd->mNumRotationKeys);
|
||||
|
||||
} // else write as usual
|
||||
else WriteArray<aiQuatKey>(&chunk,nd->mRotationKeys,nd->mNumRotationKeys);
|
||||
}
|
||||
if (nd->mScalingKeys) {
|
||||
if (shortened) {
|
||||
WriteBounds(&chunk,nd->mScalingKeys,nd->mNumScalingKeys);
|
||||
|
||||
} // else write as usual
|
||||
else WriteArray<aiVectorKey>(&chunk,nd->mScalingKeys,nd->mNumScalingKeys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryAnim( IOStream * container, const aiAnimation* anim )
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIANIMATION );
|
||||
|
||||
Write<aiString>(&chunk,anim->mName);
|
||||
Write<double>(&chunk,anim->mDuration);
|
||||
Write<double>(&chunk,anim->mTicksPerSecond);
|
||||
Write<unsigned int>(&chunk,anim->mNumChannels);
|
||||
|
||||
for (unsigned int a = 0; a < anim->mNumChannels;++a) {
|
||||
const aiNodeAnim* nd = anim->mChannels[a];
|
||||
WriteBinaryNodeAnim(&chunk,nd);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryLight( IOStream * container, const aiLight* l )
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AILIGHT );
|
||||
|
||||
Write<aiString>(&chunk,l->mName);
|
||||
Write<unsigned int>(&chunk,l->mType);
|
||||
|
||||
if (l->mType != aiLightSource_DIRECTIONAL) {
|
||||
Write<float>(&chunk,l->mAttenuationConstant);
|
||||
Write<float>(&chunk,l->mAttenuationLinear);
|
||||
Write<float>(&chunk,l->mAttenuationQuadratic);
|
||||
}
|
||||
|
||||
Write<aiColor3D>(&chunk,l->mColorDiffuse);
|
||||
Write<aiColor3D>(&chunk,l->mColorSpecular);
|
||||
Write<aiColor3D>(&chunk,l->mColorAmbient);
|
||||
|
||||
if (l->mType == aiLightSource_SPOT) {
|
||||
Write<float>(&chunk,l->mAngleInnerCone);
|
||||
Write<float>(&chunk,l->mAngleOuterCone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryCamera( IOStream * container, const aiCamera* cam )
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AICAMERA );
|
||||
|
||||
Write<aiString>(&chunk,cam->mName);
|
||||
Write<aiVector3D>(&chunk,cam->mPosition);
|
||||
Write<aiVector3D>(&chunk,cam->mLookAt);
|
||||
Write<aiVector3D>(&chunk,cam->mUp);
|
||||
Write<float>(&chunk,cam->mHorizontalFOV);
|
||||
Write<float>(&chunk,cam->mClipPlaneNear);
|
||||
Write<float>(&chunk,cam->mClipPlaneFar);
|
||||
Write<float>(&chunk,cam->mAspect);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WriteBinaryScene( IOStream * container, const aiScene* scene)
|
||||
{
|
||||
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AISCENE );
|
||||
|
||||
// basic scene information
|
||||
Write<unsigned int>(&chunk,scene->mFlags);
|
||||
Write<unsigned int>(&chunk,scene->mNumMeshes);
|
||||
Write<unsigned int>(&chunk,scene->mNumMaterials);
|
||||
Write<unsigned int>(&chunk,scene->mNumAnimations);
|
||||
Write<unsigned int>(&chunk,scene->mNumTextures);
|
||||
Write<unsigned int>(&chunk,scene->mNumLights);
|
||||
Write<unsigned int>(&chunk,scene->mNumCameras);
|
||||
|
||||
// write node graph
|
||||
WriteBinaryNode( &chunk, scene->mRootNode );
|
||||
|
||||
// write all meshes
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||
const aiMesh* mesh = scene->mMeshes[i];
|
||||
WriteBinaryMesh( &chunk,mesh);
|
||||
}
|
||||
|
||||
// write materials
|
||||
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
||||
const aiMaterial* mat = scene->mMaterials[i];
|
||||
WriteBinaryMaterial(&chunk,mat);
|
||||
}
|
||||
|
||||
// write all animations
|
||||
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
||||
const aiAnimation* anim = scene->mAnimations[i];
|
||||
WriteBinaryAnim(&chunk,anim);
|
||||
}
|
||||
|
||||
|
||||
// write all textures
|
||||
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
||||
const aiTexture* mesh = scene->mTextures[i];
|
||||
WriteBinaryTexture(&chunk,mesh);
|
||||
}
|
||||
|
||||
// write lights
|
||||
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
||||
const aiLight* l = scene->mLights[i];
|
||||
WriteBinaryLight(&chunk,l);
|
||||
}
|
||||
|
||||
// write cameras
|
||||
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
||||
const aiCamera* cam = scene->mCameras[i];
|
||||
WriteBinaryCamera(&chunk,cam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
AssbinFileWriter(bool shortened, bool compressed)
|
||||
: shortened(shortened), compressed(compressed)
|
||||
{
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Write a binary model dump
|
||||
void WriteBinaryDump(const char* pFile, const char* cmd, IOSystem* pIOSystem, const aiScene* pScene)
|
||||
{
|
||||
IOStream * out = pIOSystem->Open( pFile, "wb" );
|
||||
if (!out)
|
||||
throw std::runtime_error("Unable to open output file " + std::string(pFile) + '\n');
|
||||
|
||||
auto CloseIOStream = [&]() {
|
||||
if (out) {
|
||||
pIOSystem->Close(out);
|
||||
out = nullptr; // Ensure this is only done once.
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
time_t tt = time(NULL);
|
||||
#if _WIN32
|
||||
tm* p = gmtime(&tt);
|
||||
#else
|
||||
struct tm now;
|
||||
tm* p = gmtime_r(&tt, &now);
|
||||
#endif
|
||||
|
||||
// header
|
||||
char s[64];
|
||||
memset(s, 0, 64);
|
||||
#if _MSC_VER >= 1400
|
||||
sprintf_s(s, "ASSIMP.binary-dump.%s", asctime(p));
|
||||
#else
|
||||
ai_snprintf(s, 64, "ASSIMP.binary-dump.%s", asctime(p));
|
||||
#endif
|
||||
out->Write(s, 44, 1);
|
||||
// == 44 bytes
|
||||
|
||||
Write<unsigned int>(out, ASSBIN_VERSION_MAJOR);
|
||||
Write<unsigned int>(out, ASSBIN_VERSION_MINOR);
|
||||
Write<unsigned int>(out, aiGetVersionRevision());
|
||||
Write<unsigned int>(out, aiGetCompileFlags());
|
||||
Write<uint16_t>(out, shortened);
|
||||
Write<uint16_t>(out, compressed);
|
||||
// == 20 bytes
|
||||
|
||||
char buff[256] = {0};
|
||||
ai_snprintf(buff, 256, "%s", pFile);
|
||||
out->Write(buff, sizeof(char), 256);
|
||||
|
||||
memset(buff, 0, sizeof(buff));
|
||||
ai_snprintf(buff, 128, "%s", cmd);
|
||||
out->Write(buff, sizeof(char), 128);
|
||||
|
||||
// leave 64 bytes free for future extensions
|
||||
memset(buff, 0xcd, 64);
|
||||
out->Write(buff, sizeof(char), 64);
|
||||
// == 435 bytes
|
||||
|
||||
// ==== total header size: 512 bytes
|
||||
ai_assert(out->Tell() == ASSBIN_HEADER_LENGTH);
|
||||
|
||||
// Up to here the data is uncompressed. For compressed files, the rest
|
||||
// is compressed using standard DEFLATE from zlib.
|
||||
if (compressed)
|
||||
{
|
||||
AssbinChunkWriter uncompressedStream(NULL, 0);
|
||||
WriteBinaryScene(&uncompressedStream, pScene);
|
||||
|
||||
uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());
|
||||
uLongf compressedSize = (uLongf)compressBound(uncompressedSize);
|
||||
uint8_t* compressedBuffer = new uint8_t[compressedSize];
|
||||
|
||||
int res = compress2(compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9);
|
||||
if (res != Z_OK)
|
||||
{
|
||||
delete[] compressedBuffer;
|
||||
throw DeadlyExportError("Compression failed.");
|
||||
}
|
||||
|
||||
out->Write(&uncompressedSize, sizeof(uint32_t), 1);
|
||||
out->Write(compressedBuffer, sizeof(char), compressedSize);
|
||||
|
||||
delete[] compressedBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteBinaryScene(out, pScene);
|
||||
}
|
||||
|
||||
CloseIOStream();
|
||||
}
|
||||
catch (...) {
|
||||
CloseIOStream();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void DumpSceneToAssbin(
|
||||
const char* pFile, const char* cmd, IOSystem* pIOSystem,
|
||||
const aiScene* pScene, bool shortened, bool compressed) {
|
||||
AssbinFileWriter fileWriter(shortened, compressed);
|
||||
fileWriter.WriteBinaryDump(pFile, cmd, pIOSystem, pScene);
|
||||
}
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file AssbinFileWriter.h
|
||||
* @brief Declaration of Assbin file writer.
|
||||
*/
|
||||
|
||||
#ifndef AI_ASSBINFILEWRITER_H_INC
|
||||
#define AI_ASSBINFILEWRITER_H_INC
|
||||
|
||||
#include <assimp/defs.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
void ASSIMP_API DumpSceneToAssbin(
|
||||
const char* pFile,
|
||||
const char* cmd,
|
||||
IOSystem* pIOSystem,
|
||||
const aiScene* pScene,
|
||||
bool shortened,
|
||||
bool compressed);
|
||||
|
||||
}
|
||||
|
||||
#endif // AI_ASSBINFILEWRITER_H_INC
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -535,7 +535,7 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
|
|||
|
||||
tex->mWidth = Read<unsigned int>(stream);
|
||||
tex->mHeight = Read<unsigned int>(stream);
|
||||
stream->Read( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 );
|
||||
stream->Read( tex->achFormatHint, sizeof(char), 4 );
|
||||
|
||||
if(!shortened) {
|
||||
if (!tex->mHeight) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|||
{
|
||||
state_in->result = result;
|
||||
state_in->step = step_A;
|
||||
return (int)(codechar - code_out);
|
||||
return codechar - code_out;
|
||||
}
|
||||
fragment = *plainchar++;
|
||||
result = (fragment & 0x0fc) >> 2;
|
||||
|
|
@ -53,7 +53,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|||
{
|
||||
state_in->result = result;
|
||||
state_in->step = step_B;
|
||||
return (int)(codechar - code_out);
|
||||
return codechar - code_out;
|
||||
}
|
||||
fragment = *plainchar++;
|
||||
result |= (fragment & 0x0f0) >> 4;
|
||||
|
|
@ -64,7 +64,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|||
{
|
||||
state_in->result = result;
|
||||
state_in->step = step_C;
|
||||
return (int)(codechar - code_out);
|
||||
return codechar - code_out;
|
||||
}
|
||||
fragment = *plainchar++;
|
||||
result |= (fragment & 0x0c0) >> 6;
|
||||
|
|
@ -81,7 +81,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|||
}
|
||||
}
|
||||
/* control should not reach here */
|
||||
return (int)(codechar - code_out);
|
||||
return codechar - code_out;
|
||||
}
|
||||
|
||||
int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
||||
|
|
@ -104,6 +104,6 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
|||
}
|
||||
*codechar++ = '\n';
|
||||
|
||||
return (int)(codechar - code_out);
|
||||
return codechar - code_out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -46,20 +46,607 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
||||
|
||||
#include "AssxmlFileWriter.h"
|
||||
#include "PostProcessing/ProcessHelper.h"
|
||||
|
||||
#include <assimp/version.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||
# include <zlib.h>
|
||||
#else
|
||||
# include <contrib/zlib/zlib.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
namespace AssxmlExport {
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
static int ioprintf( IOStream * io, const char *format, ... ) {
|
||||
using namespace std;
|
||||
if ( nullptr == io ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const int Size = 4096;
|
||||
char sz[ Size ];
|
||||
::memset( sz, '\0', Size );
|
||||
va_list va;
|
||||
va_start( va, format );
|
||||
const unsigned int nSize = vsnprintf( sz, Size-1, format, va );
|
||||
ai_assert( nSize < Size );
|
||||
va_end( va );
|
||||
|
||||
io->Write( sz, sizeof(char), nSize );
|
||||
|
||||
return nSize;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Convert a name to standard XML format
|
||||
static void ConvertName(aiString& out, const aiString& in) {
|
||||
out.length = 0;
|
||||
for (unsigned int i = 0; i < in.length; ++i) {
|
||||
switch (in.data[i]) {
|
||||
case '<':
|
||||
out.Append("<");break;
|
||||
case '>':
|
||||
out.Append(">");break;
|
||||
case '&':
|
||||
out.Append("&");break;
|
||||
case '\"':
|
||||
out.Append(""");break;
|
||||
case '\'':
|
||||
out.Append("'");break;
|
||||
default:
|
||||
out.data[out.length++] = in.data[i];
|
||||
}
|
||||
}
|
||||
out.data[out.length] = 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Write a single node as text dump
|
||||
static void WriteNode(const aiNode* node, IOStream * io, unsigned int depth) {
|
||||
char prefix[512];
|
||||
for (unsigned int i = 0; i < depth;++i)
|
||||
prefix[i] = '\t';
|
||||
prefix[depth] = '\0';
|
||||
|
||||
const aiMatrix4x4& m = node->mTransformation;
|
||||
|
||||
aiString name;
|
||||
ConvertName(name,node->mName);
|
||||
ioprintf(io,"%s<Node name=\"%s\"> \n"
|
||||
"%s\t<Matrix4> \n"
|
||||
"%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"%s\t</Matrix4> \n",
|
||||
prefix,name.data,prefix,
|
||||
prefix,m.a1,m.a2,m.a3,m.a4,
|
||||
prefix,m.b1,m.b2,m.b3,m.b4,
|
||||
prefix,m.c1,m.c2,m.c3,m.c4,
|
||||
prefix,m.d1,m.d2,m.d3,m.d4,prefix);
|
||||
|
||||
if (node->mNumMeshes) {
|
||||
ioprintf(io, "%s\t<MeshRefs num=\"%i\">\n%s\t",
|
||||
prefix,node->mNumMeshes,prefix);
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumMeshes;++i) {
|
||||
ioprintf(io,"%i ",node->mMeshes[i]);
|
||||
}
|
||||
ioprintf(io,"\n%s\t</MeshRefs>\n",prefix);
|
||||
}
|
||||
|
||||
if (node->mNumChildren) {
|
||||
ioprintf(io,"%s\t<NodeList num=\"%i\">\n",
|
||||
prefix,node->mNumChildren);
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i) {
|
||||
WriteNode(node->mChildren[i],io,depth+2);
|
||||
}
|
||||
ioprintf(io,"%s\t</NodeList>\n",prefix);
|
||||
}
|
||||
ioprintf(io,"%s</Node>\n",prefix);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Some chuncks of text will need to be encoded for XML
|
||||
// http://stackoverflow.com/questions/5665231/most-efficient-way-to-escape-xml-html-in-c-string#5665377
|
||||
static std::string encodeXML(const std::string& data) {
|
||||
std::string buffer;
|
||||
buffer.reserve(data.size());
|
||||
for(size_t pos = 0; pos != data.size(); ++pos) {
|
||||
switch(data[pos]) {
|
||||
case '&': buffer.append("&"); break;
|
||||
case '\"': buffer.append("""); break;
|
||||
case '\'': buffer.append("'"); break;
|
||||
case '<': buffer.append("<"); break;
|
||||
case '>': buffer.append(">"); break;
|
||||
default: buffer.append(&data[pos], 1); break;
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Write a text model dump
|
||||
static
|
||||
void WriteDump(const aiScene* scene, IOStream* io, bool shortened) {
|
||||
time_t tt = ::time( NULL );
|
||||
#if _WIN32
|
||||
tm* p = gmtime(&tt);
|
||||
#else
|
||||
struct tm now;
|
||||
tm* p = gmtime_r(&tt, &now);
|
||||
#endif
|
||||
ai_assert(nullptr != p);
|
||||
|
||||
// write header
|
||||
std::string header(
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
||||
"<ASSIMP format_id=\"1\">\n\n"
|
||||
"<!-- XML Model dump produced by assimp dump\n"
|
||||
" Library version: %i.%i.%i\n"
|
||||
" %s\n"
|
||||
"-->"
|
||||
" \n\n"
|
||||
"<Scene flags=\"%d\" postprocessing=\"%i\">\n"
|
||||
);
|
||||
|
||||
const unsigned int majorVersion( aiGetVersionMajor() );
|
||||
const unsigned int minorVersion( aiGetVersionMinor() );
|
||||
const unsigned int rev( aiGetVersionRevision() );
|
||||
const char *curtime( asctime( p ) );
|
||||
ioprintf( io, header.c_str(), majorVersion, minorVersion, rev, curtime, scene->mFlags, 0 );
|
||||
|
||||
// write the node graph
|
||||
WriteNode(scene->mRootNode, io, 0);
|
||||
|
||||
#if 0
|
||||
// write cameras
|
||||
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
||||
aiCamera* cam = scene->mCameras[i];
|
||||
ConvertName(name,cam->mName);
|
||||
|
||||
// camera header
|
||||
ioprintf(io,"\t<Camera parent=\"%s\">\n"
|
||||
"\t\t<Vector3 name=\"up\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Vector3 name=\"lookat\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Vector3 name=\"pos\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Float name=\"fov\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"aspect\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"near_clip\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"far_clip\" > %f </Float>\n"
|
||||
"\t</Camera>\n",
|
||||
name.data,
|
||||
cam->mUp.x,cam->mUp.y,cam->mUp.z,
|
||||
cam->mLookAt.x,cam->mLookAt.y,cam->mLookAt.z,
|
||||
cam->mPosition.x,cam->mPosition.y,cam->mPosition.z,
|
||||
cam->mHorizontalFOV,cam->mAspect,cam->mClipPlaneNear,cam->mClipPlaneFar,i);
|
||||
}
|
||||
|
||||
// write lights
|
||||
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
||||
aiLight* l = scene->mLights[i];
|
||||
ConvertName(name,l->mName);
|
||||
|
||||
// light header
|
||||
ioprintf(io,"\t<Light parent=\"%s\"> type=\"%s\"\n"
|
||||
"\t\t<Vector3 name=\"diffuse\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Vector3 name=\"specular\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Vector3 name=\"ambient\" > %0 8f %0 8f %0 8f </Vector3>\n",
|
||||
name.data,
|
||||
(l->mType == aiLightSource_DIRECTIONAL ? "directional" :
|
||||
(l->mType == aiLightSource_POINT ? "point" : "spot" )),
|
||||
l->mColorDiffuse.r, l->mColorDiffuse.g, l->mColorDiffuse.b,
|
||||
l->mColorSpecular.r,l->mColorSpecular.g,l->mColorSpecular.b,
|
||||
l->mColorAmbient.r, l->mColorAmbient.g, l->mColorAmbient.b);
|
||||
|
||||
if (l->mType != aiLightSource_DIRECTIONAL) {
|
||||
ioprintf(io,
|
||||
"\t\t<Vector3 name=\"pos\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Float name=\"atten_cst\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"atten_lin\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"atten_sqr\" > %f </Float>\n",
|
||||
l->mPosition.x,l->mPosition.y,l->mPosition.z,
|
||||
l->mAttenuationConstant,l->mAttenuationLinear,l->mAttenuationQuadratic);
|
||||
}
|
||||
|
||||
if (l->mType != aiLightSource_POINT) {
|
||||
ioprintf(io,
|
||||
"\t\t<Vector3 name=\"lookat\" > %0 8f %0 8f %0 8f </Vector3>\n",
|
||||
l->mDirection.x,l->mDirection.y,l->mDirection.z);
|
||||
}
|
||||
|
||||
if (l->mType == aiLightSource_SPOT) {
|
||||
ioprintf(io,
|
||||
"\t\t<Float name=\"cone_out\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"cone_inn\" > %f </Float>\n",
|
||||
l->mAngleOuterCone,l->mAngleInnerCone);
|
||||
}
|
||||
ioprintf(io,"\t</Light>\n");
|
||||
}
|
||||
#endif
|
||||
aiString name;
|
||||
|
||||
// write textures
|
||||
if (scene->mNumTextures) {
|
||||
ioprintf(io,"<TextureList num=\"%i\">\n",scene->mNumTextures);
|
||||
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
||||
aiTexture* tex = scene->mTextures[i];
|
||||
bool compressed = (tex->mHeight == 0);
|
||||
|
||||
// mesh header
|
||||
ioprintf(io,"\t<Texture width=\"%i\" height=\"%i\" compressed=\"%s\"> \n",
|
||||
(compressed ? -1 : tex->mWidth),(compressed ? -1 : tex->mHeight),
|
||||
(compressed ? "true" : "false"));
|
||||
|
||||
if (compressed) {
|
||||
ioprintf(io,"\t\t<Data length=\"%i\"> \n",tex->mWidth);
|
||||
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < tex->mWidth;++n) {
|
||||
ioprintf(io,"\t\t\t%2x",reinterpret_cast<uint8_t*>(tex->pcData)[n]);
|
||||
if (n && !(n % 50)) {
|
||||
ioprintf(io,"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!shortened){
|
||||
ioprintf(io,"\t\t<Data length=\"%i\"> \n",tex->mWidth*tex->mHeight*4);
|
||||
|
||||
// const unsigned int width = (unsigned int)std::log10((double)std::max(tex->mHeight,tex->mWidth))+1;
|
||||
for (unsigned int y = 0; y < tex->mHeight;++y) {
|
||||
for (unsigned int x = 0; x < tex->mWidth;++x) {
|
||||
aiTexel* tx = tex->pcData + y*tex->mWidth+x;
|
||||
unsigned int r = tx->r,g=tx->g,b=tx->b,a=tx->a;
|
||||
ioprintf(io,"\t\t\t%2x %2x %2x %2x",r,g,b,a);
|
||||
|
||||
// group by four for readability
|
||||
if ( 0 == ( x + y*tex->mWidth ) % 4 ) {
|
||||
ioprintf( io, "\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Data>\n\t</Texture>\n");
|
||||
}
|
||||
ioprintf(io,"</TextureList>\n");
|
||||
}
|
||||
|
||||
// write materials
|
||||
if (scene->mNumMaterials) {
|
||||
ioprintf(io,"<MaterialList num=\"%i\">\n",scene->mNumMaterials);
|
||||
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
||||
const aiMaterial* mat = scene->mMaterials[i];
|
||||
|
||||
ioprintf(io,"\t<Material>\n");
|
||||
ioprintf(io,"\t\t<MatPropertyList num=\"%i\">\n",mat->mNumProperties);
|
||||
for (unsigned int n = 0; n < mat->mNumProperties;++n) {
|
||||
|
||||
const aiMaterialProperty* prop = mat->mProperties[n];
|
||||
const char* sz = "";
|
||||
if (prop->mType == aiPTI_Float) {
|
||||
sz = "float";
|
||||
}
|
||||
else if (prop->mType == aiPTI_Integer) {
|
||||
sz = "integer";
|
||||
}
|
||||
else if (prop->mType == aiPTI_String) {
|
||||
sz = "string";
|
||||
}
|
||||
else if (prop->mType == aiPTI_Buffer) {
|
||||
sz = "binary_buffer";
|
||||
}
|
||||
|
||||
ioprintf(io,"\t\t\t<MatProperty key=\"%s\" \n\t\t\ttype=\"%s\" tex_usage=\"%s\" tex_index=\"%i\"",
|
||||
prop->mKey.data, sz,
|
||||
::TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex);
|
||||
|
||||
if (prop->mType == aiPTI_Float) {
|
||||
ioprintf(io," size=\"%i\">\n\t\t\t\t",
|
||||
static_cast<int>(prop->mDataLength/sizeof(float)));
|
||||
|
||||
for (unsigned int p = 0; p < prop->mDataLength/sizeof(float);++p) {
|
||||
ioprintf(io,"%f ",*((float*)(prop->mData+p*sizeof(float))));
|
||||
}
|
||||
}
|
||||
else if (prop->mType == aiPTI_Integer) {
|
||||
ioprintf(io," size=\"%i\">\n\t\t\t\t",
|
||||
static_cast<int>(prop->mDataLength/sizeof(int)));
|
||||
|
||||
for (unsigned int p = 0; p < prop->mDataLength/sizeof(int);++p) {
|
||||
ioprintf(io,"%i ",*((int*)(prop->mData+p*sizeof(int))));
|
||||
}
|
||||
}
|
||||
else if (prop->mType == aiPTI_Buffer) {
|
||||
ioprintf(io," size=\"%i\">\n\t\t\t\t",
|
||||
static_cast<int>(prop->mDataLength));
|
||||
|
||||
for (unsigned int p = 0; p < prop->mDataLength;++p) {
|
||||
ioprintf(io,"%2x ",prop->mData[p]);
|
||||
if (p && 0 == p%30) {
|
||||
ioprintf(io,"\n\t\t\t\t");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (prop->mType == aiPTI_String) {
|
||||
ioprintf(io,">\n\t\t\t\t\"%s\"",encodeXML(prop->mData+4).c_str() /* skip length */);
|
||||
}
|
||||
ioprintf(io,"\n\t\t\t</MatProperty>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t</MatPropertyList>\n");
|
||||
ioprintf(io,"\t</Material>\n");
|
||||
}
|
||||
ioprintf(io,"</MaterialList>\n");
|
||||
}
|
||||
|
||||
// write animations
|
||||
if (scene->mNumAnimations) {
|
||||
ioprintf(io,"<AnimationList num=\"%i\">\n",scene->mNumAnimations);
|
||||
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
||||
aiAnimation* anim = scene->mAnimations[i];
|
||||
|
||||
// anim header
|
||||
ConvertName(name,anim->mName);
|
||||
ioprintf(io,"\t<Animation name=\"%s\" duration=\"%e\" tick_cnt=\"%e\">\n",
|
||||
name.data, anim->mDuration, anim->mTicksPerSecond);
|
||||
|
||||
// write bone animation channels
|
||||
if (anim->mNumChannels) {
|
||||
ioprintf(io,"\t\t<NodeAnimList num=\"%i\">\n",anim->mNumChannels);
|
||||
for (unsigned int n = 0; n < anim->mNumChannels;++n) {
|
||||
aiNodeAnim* nd = anim->mChannels[n];
|
||||
|
||||
// node anim header
|
||||
ConvertName(name,nd->mNodeName);
|
||||
ioprintf(io,"\t\t\t<NodeAnim node=\"%s\">\n",name.data);
|
||||
|
||||
if (!shortened) {
|
||||
// write position keys
|
||||
if (nd->mNumPositionKeys) {
|
||||
ioprintf(io,"\t\t\t\t<PositionKeyList num=\"%i\">\n",nd->mNumPositionKeys);
|
||||
for (unsigned int a = 0; a < nd->mNumPositionKeys;++a) {
|
||||
aiVectorKey* vc = nd->mPositionKeys+a;
|
||||
ioprintf(io,"\t\t\t\t\t<PositionKey time=\"%e\">\n"
|
||||
"\t\t\t\t\t\t%0 8f %0 8f %0 8f\n\t\t\t\t\t</PositionKey>\n",
|
||||
vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z);
|
||||
}
|
||||
ioprintf(io,"\t\t\t\t</PositionKeyList>\n");
|
||||
}
|
||||
|
||||
// write scaling keys
|
||||
if (nd->mNumScalingKeys) {
|
||||
ioprintf(io,"\t\t\t\t<ScalingKeyList num=\"%i\">\n",nd->mNumScalingKeys);
|
||||
for (unsigned int a = 0; a < nd->mNumScalingKeys;++a) {
|
||||
aiVectorKey* vc = nd->mScalingKeys+a;
|
||||
ioprintf(io,"\t\t\t\t\t<ScalingKey time=\"%e\">\n"
|
||||
"\t\t\t\t\t\t%0 8f %0 8f %0 8f\n\t\t\t\t\t</ScalingKey>\n",
|
||||
vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z);
|
||||
}
|
||||
ioprintf(io,"\t\t\t\t</ScalingKeyList>\n");
|
||||
}
|
||||
|
||||
// write rotation keys
|
||||
if (nd->mNumRotationKeys) {
|
||||
ioprintf(io,"\t\t\t\t<RotationKeyList num=\"%i\">\n",nd->mNumRotationKeys);
|
||||
for (unsigned int a = 0; a < nd->mNumRotationKeys;++a) {
|
||||
aiQuatKey* vc = nd->mRotationKeys+a;
|
||||
ioprintf(io,"\t\t\t\t\t<RotationKey time=\"%e\">\n"
|
||||
"\t\t\t\t\t\t%0 8f %0 8f %0 8f %0 8f\n\t\t\t\t\t</RotationKey>\n",
|
||||
vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z,vc->mValue.w);
|
||||
}
|
||||
ioprintf(io,"\t\t\t\t</RotationKeyList>\n");
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t\t</NodeAnim>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t</NodeAnimList>\n");
|
||||
}
|
||||
ioprintf(io,"\t</Animation>\n");
|
||||
}
|
||||
ioprintf(io,"</AnimationList>\n");
|
||||
}
|
||||
|
||||
// write meshes
|
||||
if (scene->mNumMeshes) {
|
||||
ioprintf(io,"<MeshList num=\"%i\">\n",scene->mNumMeshes);
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||
aiMesh* mesh = scene->mMeshes[i];
|
||||
// const unsigned int width = (unsigned int)std::log10((double)mesh->mNumVertices)+1;
|
||||
|
||||
// mesh header
|
||||
ioprintf(io,"\t<Mesh types=\"%s %s %s %s\" material_index=\"%i\">\n",
|
||||
(mesh->mPrimitiveTypes & aiPrimitiveType_POINT ? "points" : ""),
|
||||
(mesh->mPrimitiveTypes & aiPrimitiveType_LINE ? "lines" : ""),
|
||||
(mesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE ? "triangles" : ""),
|
||||
(mesh->mPrimitiveTypes & aiPrimitiveType_POLYGON ? "polygons" : ""),
|
||||
mesh->mMaterialIndex);
|
||||
|
||||
// bones
|
||||
if (mesh->mNumBones) {
|
||||
ioprintf(io,"\t\t<BoneList num=\"%i\">\n",mesh->mNumBones);
|
||||
|
||||
for (unsigned int n = 0; n < mesh->mNumBones;++n) {
|
||||
aiBone* bone = mesh->mBones[n];
|
||||
|
||||
ConvertName(name,bone->mName);
|
||||
// bone header
|
||||
ioprintf(io,"\t\t\t<Bone name=\"%s\">\n"
|
||||
"\t\t\t\t<Matrix4> \n"
|
||||
"\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"\t\t\t\t</Matrix4> \n",
|
||||
name.data,
|
||||
bone->mOffsetMatrix.a1,bone->mOffsetMatrix.a2,bone->mOffsetMatrix.a3,bone->mOffsetMatrix.a4,
|
||||
bone->mOffsetMatrix.b1,bone->mOffsetMatrix.b2,bone->mOffsetMatrix.b3,bone->mOffsetMatrix.b4,
|
||||
bone->mOffsetMatrix.c1,bone->mOffsetMatrix.c2,bone->mOffsetMatrix.c3,bone->mOffsetMatrix.c4,
|
||||
bone->mOffsetMatrix.d1,bone->mOffsetMatrix.d2,bone->mOffsetMatrix.d3,bone->mOffsetMatrix.d4);
|
||||
|
||||
if (!shortened && bone->mNumWeights) {
|
||||
ioprintf(io,"\t\t\t\t<WeightList num=\"%i\">\n",bone->mNumWeights);
|
||||
|
||||
// bone weights
|
||||
for (unsigned int a = 0; a < bone->mNumWeights;++a) {
|
||||
aiVertexWeight* wght = bone->mWeights+a;
|
||||
|
||||
ioprintf(io,"\t\t\t\t\t<Weight index=\"%i\">\n\t\t\t\t\t\t%f\n\t\t\t\t\t</Weight>\n",
|
||||
wght->mVertexId,wght->mWeight);
|
||||
}
|
||||
ioprintf(io,"\t\t\t\t</WeightList>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t\t</Bone>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t</BoneList>\n");
|
||||
}
|
||||
|
||||
// faces
|
||||
if (!shortened && mesh->mNumFaces) {
|
||||
ioprintf(io,"\t\t<FaceList num=\"%i\">\n",mesh->mNumFaces);
|
||||
for (unsigned int n = 0; n < mesh->mNumFaces; ++n) {
|
||||
aiFace& f = mesh->mFaces[n];
|
||||
ioprintf(io,"\t\t\t<Face num=\"%i\">\n"
|
||||
"\t\t\t\t",f.mNumIndices);
|
||||
|
||||
for (unsigned int j = 0; j < f.mNumIndices;++j)
|
||||
ioprintf(io,"%i ",f.mIndices[j]);
|
||||
|
||||
ioprintf(io,"\n\t\t\t</Face>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t</FaceList>\n");
|
||||
}
|
||||
|
||||
// vertex positions
|
||||
if (mesh->HasPositions()) {
|
||||
ioprintf(io,"\t\t<Positions num=\"%i\" set=\"0\" num_components=\"3\"> \n",mesh->mNumVertices);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mVertices[n].x,
|
||||
mesh->mVertices[n].y,
|
||||
mesh->mVertices[n].z);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Positions>\n");
|
||||
}
|
||||
|
||||
// vertex normals
|
||||
if (mesh->HasNormals()) {
|
||||
ioprintf(io,"\t\t<Normals num=\"%i\" set=\"0\" num_components=\"3\"> \n",mesh->mNumVertices);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mNormals[n].x,
|
||||
mesh->mNormals[n].y,
|
||||
mesh->mNormals[n].z);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Normals>\n");
|
||||
}
|
||||
|
||||
// vertex tangents and bitangents
|
||||
if (mesh->HasTangentsAndBitangents()) {
|
||||
ioprintf(io,"\t\t<Tangents num=\"%i\" set=\"0\" num_components=\"3\"> \n",mesh->mNumVertices);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mTangents[n].x,
|
||||
mesh->mTangents[n].y,
|
||||
mesh->mTangents[n].z);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Tangents>\n");
|
||||
|
||||
ioprintf(io,"\t\t<Bitangents num=\"%i\" set=\"0\" num_components=\"3\"> \n",mesh->mNumVertices);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mBitangents[n].x,
|
||||
mesh->mBitangents[n].y,
|
||||
mesh->mBitangents[n].z);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Bitangents>\n");
|
||||
}
|
||||
|
||||
// texture coordinates
|
||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
||||
if (!mesh->mTextureCoords[a])
|
||||
break;
|
||||
|
||||
ioprintf(io,"\t\t<TextureCoords num=\"%i\" set=\"%i\" num_components=\"%i\"> \n",mesh->mNumVertices,
|
||||
a,mesh->mNumUVComponents[a]);
|
||||
|
||||
if (!shortened) {
|
||||
if (mesh->mNumUVComponents[a] == 3) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mTextureCoords[a][n].x,
|
||||
mesh->mTextureCoords[a][n].y,
|
||||
mesh->mTextureCoords[a][n].z);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f\n",
|
||||
mesh->mTextureCoords[a][n].x,
|
||||
mesh->mTextureCoords[a][n].y);
|
||||
}
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</TextureCoords>\n");
|
||||
}
|
||||
|
||||
// vertex colors
|
||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
|
||||
if (!mesh->mColors[a])
|
||||
break;
|
||||
ioprintf(io,"\t\t<Colors num=\"%i\" set=\"%i\" num_components=\"4\"> \n",mesh->mNumVertices,a);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f %0 8f\n",
|
||||
mesh->mColors[a][n].r,
|
||||
mesh->mColors[a][n].g,
|
||||
mesh->mColors[a][n].b,
|
||||
mesh->mColors[a][n].a);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Colors>\n");
|
||||
}
|
||||
ioprintf(io,"\t</Mesh>\n");
|
||||
}
|
||||
ioprintf(io,"</MeshList>\n");
|
||||
}
|
||||
ioprintf(io,"</Scene>\n</ASSIMP>");
|
||||
}
|
||||
|
||||
} // end of namespace AssxmlExport
|
||||
|
||||
void ExportSceneAssxml(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/)
|
||||
{
|
||||
DumpSceneToAssxml(
|
||||
pFile,
|
||||
"\0", // command(s)
|
||||
pIOSystem,
|
||||
pScene,
|
||||
false); // shortened?
|
||||
IOStream * out = pIOSystem->Open( pFile, "wt" );
|
||||
if (!out) return;
|
||||
|
||||
bool shortened = false;
|
||||
AssxmlExport::WriteDump( pScene, out, shortened );
|
||||
|
||||
pIOSystem->Close( out );
|
||||
}
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -1,664 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file AssxmlFileWriter.cpp
|
||||
* @brief Implementation of Assxml file writer.
|
||||
*/
|
||||
|
||||
#include "AssxmlFileWriter.h"
|
||||
|
||||
#include "PostProcessing/ProcessHelper.h"
|
||||
|
||||
#include <assimp/version.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||
# include <zlib.h>
|
||||
#else
|
||||
# include <contrib/zlib/zlib.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <memory>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
namespace AssxmlFileWriter {
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
static int ioprintf( IOStream * io, const char *format, ... ) {
|
||||
using namespace std;
|
||||
if ( nullptr == io ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const int Size = 4096;
|
||||
char sz[ Size ];
|
||||
::memset( sz, '\0', Size );
|
||||
va_list va;
|
||||
va_start( va, format );
|
||||
const unsigned int nSize = vsnprintf( sz, Size-1, format, va );
|
||||
ai_assert( nSize < Size );
|
||||
va_end( va );
|
||||
|
||||
io->Write( sz, sizeof(char), nSize );
|
||||
|
||||
return nSize;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Convert a name to standard XML format
|
||||
static void ConvertName(aiString& out, const aiString& in) {
|
||||
out.length = 0;
|
||||
for (unsigned int i = 0; i < in.length; ++i) {
|
||||
switch (in.data[i]) {
|
||||
case '<':
|
||||
out.Append("<");break;
|
||||
case '>':
|
||||
out.Append(">");break;
|
||||
case '&':
|
||||
out.Append("&");break;
|
||||
case '\"':
|
||||
out.Append(""");break;
|
||||
case '\'':
|
||||
out.Append("'");break;
|
||||
default:
|
||||
out.data[out.length++] = in.data[i];
|
||||
}
|
||||
}
|
||||
out.data[out.length] = 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Write a single node as text dump
|
||||
static void WriteNode(const aiNode* node, IOStream * io, unsigned int depth) {
|
||||
char prefix[512];
|
||||
for (unsigned int i = 0; i < depth;++i)
|
||||
prefix[i] = '\t';
|
||||
prefix[depth] = '\0';
|
||||
|
||||
const aiMatrix4x4& m = node->mTransformation;
|
||||
|
||||
aiString name;
|
||||
ConvertName(name,node->mName);
|
||||
ioprintf(io,"%s<Node name=\"%s\"> \n"
|
||||
"%s\t<Matrix4> \n"
|
||||
"%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"%s\t</Matrix4> \n",
|
||||
prefix,name.data,prefix,
|
||||
prefix,m.a1,m.a2,m.a3,m.a4,
|
||||
prefix,m.b1,m.b2,m.b3,m.b4,
|
||||
prefix,m.c1,m.c2,m.c3,m.c4,
|
||||
prefix,m.d1,m.d2,m.d3,m.d4,prefix);
|
||||
|
||||
if (node->mNumMeshes) {
|
||||
ioprintf(io, "%s\t<MeshRefs num=\"%u\">\n%s\t",
|
||||
prefix,node->mNumMeshes,prefix);
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumMeshes;++i) {
|
||||
ioprintf(io,"%u ",node->mMeshes[i]);
|
||||
}
|
||||
ioprintf(io,"\n%s\t</MeshRefs>\n",prefix);
|
||||
}
|
||||
|
||||
if (node->mNumChildren) {
|
||||
ioprintf(io,"%s\t<NodeList num=\"%u\">\n",
|
||||
prefix,node->mNumChildren);
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i) {
|
||||
WriteNode(node->mChildren[i],io,depth+2);
|
||||
}
|
||||
ioprintf(io,"%s\t</NodeList>\n",prefix);
|
||||
}
|
||||
ioprintf(io,"%s</Node>\n",prefix);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Some chuncks of text will need to be encoded for XML
|
||||
// http://stackoverflow.com/questions/5665231/most-efficient-way-to-escape-xml-html-in-c-string#5665377
|
||||
static std::string encodeXML(const std::string& data) {
|
||||
std::string buffer;
|
||||
buffer.reserve(data.size());
|
||||
for(size_t pos = 0; pos != data.size(); ++pos) {
|
||||
switch(data[pos]) {
|
||||
case '&': buffer.append("&"); break;
|
||||
case '\"': buffer.append("""); break;
|
||||
case '\'': buffer.append("'"); break;
|
||||
case '<': buffer.append("<"); break;
|
||||
case '>': buffer.append(">"); break;
|
||||
default: buffer.append(&data[pos], 1); break;
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Write a text model dump
|
||||
static
|
||||
void WriteDump(const char* pFile, const char* cmd, const aiScene* scene, IOStream* io, bool shortened) {
|
||||
time_t tt = ::time( NULL );
|
||||
#if _WIN32
|
||||
tm* p = gmtime(&tt);
|
||||
#else
|
||||
struct tm now;
|
||||
tm* p = gmtime_r(&tt, &now);
|
||||
#endif
|
||||
ai_assert(nullptr != p);
|
||||
|
||||
std::string c = cmd;
|
||||
std::string::size_type s;
|
||||
|
||||
// https://sourceforge.net/tracker/?func=detail&aid=3167364&group_id=226462&atid=1067632
|
||||
// -- not allowed in XML comments
|
||||
while((s = c.find("--")) != std::string::npos) {
|
||||
c[s] = '?';
|
||||
}
|
||||
|
||||
// write header
|
||||
std::string header(
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
||||
"<ASSIMP format_id=\"1\">\n\n"
|
||||
"<!-- XML Model dump produced by assimp dump\n"
|
||||
" Library version: %u.%u.%u\n"
|
||||
" Source: %s\n"
|
||||
" Command line: %s\n"
|
||||
" %s\n"
|
||||
"-->"
|
||||
" \n\n"
|
||||
"<Scene flags=\"%u\" postprocessing=\"%u\">\n"
|
||||
);
|
||||
|
||||
const unsigned int majorVersion( aiGetVersionMajor() );
|
||||
const unsigned int minorVersion( aiGetVersionMinor() );
|
||||
const unsigned int rev( aiGetVersionRevision() );
|
||||
const char *curtime( asctime( p ) );
|
||||
ioprintf( io, header.c_str(), majorVersion, minorVersion, rev, pFile, c.c_str(), curtime, scene->mFlags, 0u );
|
||||
|
||||
// write the node graph
|
||||
WriteNode(scene->mRootNode, io, 0);
|
||||
|
||||
#if 0
|
||||
// write cameras
|
||||
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
||||
aiCamera* cam = scene->mCameras[i];
|
||||
ConvertName(name,cam->mName);
|
||||
|
||||
// camera header
|
||||
ioprintf(io,"\t<Camera parent=\"%s\">\n"
|
||||
"\t\t<Vector3 name=\"up\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Vector3 name=\"lookat\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Vector3 name=\"pos\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Float name=\"fov\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"aspect\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"near_clip\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"far_clip\" > %f </Float>\n"
|
||||
"\t</Camera>\n",
|
||||
name.data,
|
||||
cam->mUp.x,cam->mUp.y,cam->mUp.z,
|
||||
cam->mLookAt.x,cam->mLookAt.y,cam->mLookAt.z,
|
||||
cam->mPosition.x,cam->mPosition.y,cam->mPosition.z,
|
||||
cam->mHorizontalFOV,cam->mAspect,cam->mClipPlaneNear,cam->mClipPlaneFar,i);
|
||||
}
|
||||
|
||||
// write lights
|
||||
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
||||
aiLight* l = scene->mLights[i];
|
||||
ConvertName(name,l->mName);
|
||||
|
||||
// light header
|
||||
ioprintf(io,"\t<Light parent=\"%s\"> type=\"%s\"\n"
|
||||
"\t\t<Vector3 name=\"diffuse\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Vector3 name=\"specular\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Vector3 name=\"ambient\" > %0 8f %0 8f %0 8f </Vector3>\n",
|
||||
name.data,
|
||||
(l->mType == aiLightSource_DIRECTIONAL ? "directional" :
|
||||
(l->mType == aiLightSource_POINT ? "point" : "spot" )),
|
||||
l->mColorDiffuse.r, l->mColorDiffuse.g, l->mColorDiffuse.b,
|
||||
l->mColorSpecular.r,l->mColorSpecular.g,l->mColorSpecular.b,
|
||||
l->mColorAmbient.r, l->mColorAmbient.g, l->mColorAmbient.b);
|
||||
|
||||
if (l->mType != aiLightSource_DIRECTIONAL) {
|
||||
ioprintf(io,
|
||||
"\t\t<Vector3 name=\"pos\" > %0 8f %0 8f %0 8f </Vector3>\n"
|
||||
"\t\t<Float name=\"atten_cst\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"atten_lin\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"atten_sqr\" > %f </Float>\n",
|
||||
l->mPosition.x,l->mPosition.y,l->mPosition.z,
|
||||
l->mAttenuationConstant,l->mAttenuationLinear,l->mAttenuationQuadratic);
|
||||
}
|
||||
|
||||
if (l->mType != aiLightSource_POINT) {
|
||||
ioprintf(io,
|
||||
"\t\t<Vector3 name=\"lookat\" > %0 8f %0 8f %0 8f </Vector3>\n",
|
||||
l->mDirection.x,l->mDirection.y,l->mDirection.z);
|
||||
}
|
||||
|
||||
if (l->mType == aiLightSource_SPOT) {
|
||||
ioprintf(io,
|
||||
"\t\t<Float name=\"cone_out\" > %f </Float>\n"
|
||||
"\t\t<Float name=\"cone_inn\" > %f </Float>\n",
|
||||
l->mAngleOuterCone,l->mAngleInnerCone);
|
||||
}
|
||||
ioprintf(io,"\t</Light>\n");
|
||||
}
|
||||
#endif
|
||||
aiString name;
|
||||
|
||||
// write textures
|
||||
if (scene->mNumTextures) {
|
||||
ioprintf(io,"<TextureList num=\"%u\">\n",scene->mNumTextures);
|
||||
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
||||
aiTexture* tex = scene->mTextures[i];
|
||||
bool compressed = (tex->mHeight == 0);
|
||||
|
||||
// mesh header
|
||||
ioprintf(io,"\t<Texture width=\"%u\" height=\"%u\" compressed=\"%s\"> \n",
|
||||
(compressed ? -1 : tex->mWidth),(compressed ? -1 : tex->mHeight),
|
||||
(compressed ? "true" : "false"));
|
||||
|
||||
if (compressed) {
|
||||
ioprintf(io,"\t\t<Data length=\"%u\"> \n",tex->mWidth);
|
||||
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < tex->mWidth;++n) {
|
||||
ioprintf(io,"\t\t\t%2x",reinterpret_cast<uint8_t*>(tex->pcData)[n]);
|
||||
if (n && !(n % 50)) {
|
||||
ioprintf(io,"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!shortened){
|
||||
ioprintf(io,"\t\t<Data length=\"%u\"> \n",tex->mWidth*tex->mHeight*4);
|
||||
|
||||
// const unsigned int width = (unsigned int)std::log10((double)std::max(tex->mHeight,tex->mWidth))+1;
|
||||
for (unsigned int y = 0; y < tex->mHeight;++y) {
|
||||
for (unsigned int x = 0; x < tex->mWidth;++x) {
|
||||
aiTexel* tx = tex->pcData + y*tex->mWidth+x;
|
||||
unsigned int r = tx->r,g=tx->g,b=tx->b,a=tx->a;
|
||||
ioprintf(io,"\t\t\t%2x %2x %2x %2x",r,g,b,a);
|
||||
|
||||
// group by four for readability
|
||||
if ( 0 == ( x + y*tex->mWidth ) % 4 ) {
|
||||
ioprintf( io, "\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Data>\n\t</Texture>\n");
|
||||
}
|
||||
ioprintf(io,"</TextureList>\n");
|
||||
}
|
||||
|
||||
// write materials
|
||||
if (scene->mNumMaterials) {
|
||||
ioprintf(io,"<MaterialList num=\"%u\">\n",scene->mNumMaterials);
|
||||
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
||||
const aiMaterial* mat = scene->mMaterials[i];
|
||||
|
||||
ioprintf(io,"\t<Material>\n");
|
||||
ioprintf(io,"\t\t<MatPropertyList num=\"%u\">\n",mat->mNumProperties);
|
||||
for (unsigned int n = 0; n < mat->mNumProperties;++n) {
|
||||
|
||||
const aiMaterialProperty* prop = mat->mProperties[n];
|
||||
const char* sz = "";
|
||||
if (prop->mType == aiPTI_Float) {
|
||||
sz = "float";
|
||||
}
|
||||
else if (prop->mType == aiPTI_Integer) {
|
||||
sz = "integer";
|
||||
}
|
||||
else if (prop->mType == aiPTI_String) {
|
||||
sz = "string";
|
||||
}
|
||||
else if (prop->mType == aiPTI_Buffer) {
|
||||
sz = "binary_buffer";
|
||||
}
|
||||
|
||||
ioprintf(io,"\t\t\t<MatProperty key=\"%s\" \n\t\t\ttype=\"%s\" tex_usage=\"%s\" tex_index=\"%u\"",
|
||||
prop->mKey.data, sz,
|
||||
::TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex);
|
||||
|
||||
if (prop->mType == aiPTI_Float) {
|
||||
ioprintf(io," size=\"%i\">\n\t\t\t\t",
|
||||
static_cast<int>(prop->mDataLength/sizeof(float)));
|
||||
|
||||
for (unsigned int p = 0; p < prop->mDataLength/sizeof(float);++p) {
|
||||
ioprintf(io,"%f ",*((float*)(prop->mData+p*sizeof(float))));
|
||||
}
|
||||
}
|
||||
else if (prop->mType == aiPTI_Integer) {
|
||||
ioprintf(io," size=\"%i\">\n\t\t\t\t",
|
||||
static_cast<int>(prop->mDataLength/sizeof(int)));
|
||||
|
||||
for (unsigned int p = 0; p < prop->mDataLength/sizeof(int);++p) {
|
||||
ioprintf(io,"%i ",*((int*)(prop->mData+p*sizeof(int))));
|
||||
}
|
||||
}
|
||||
else if (prop->mType == aiPTI_Buffer) {
|
||||
ioprintf(io," size=\"%i\">\n\t\t\t\t",
|
||||
static_cast<int>(prop->mDataLength));
|
||||
|
||||
for (unsigned int p = 0; p < prop->mDataLength;++p) {
|
||||
ioprintf(io,"%2x ",prop->mData[p]);
|
||||
if (p && 0 == p%30) {
|
||||
ioprintf(io,"\n\t\t\t\t");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (prop->mType == aiPTI_String) {
|
||||
ioprintf(io,">\n\t\t\t\t\"%s\"",encodeXML(prop->mData+4).c_str() /* skip length */);
|
||||
}
|
||||
ioprintf(io,"\n\t\t\t</MatProperty>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t</MatPropertyList>\n");
|
||||
ioprintf(io,"\t</Material>\n");
|
||||
}
|
||||
ioprintf(io,"</MaterialList>\n");
|
||||
}
|
||||
|
||||
// write animations
|
||||
if (scene->mNumAnimations) {
|
||||
ioprintf(io,"<AnimationList num=\"%u\">\n",scene->mNumAnimations);
|
||||
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
||||
aiAnimation* anim = scene->mAnimations[i];
|
||||
|
||||
// anim header
|
||||
ConvertName(name,anim->mName);
|
||||
ioprintf(io,"\t<Animation name=\"%s\" duration=\"%e\" tick_cnt=\"%e\">\n",
|
||||
name.data, anim->mDuration, anim->mTicksPerSecond);
|
||||
|
||||
// write bone animation channels
|
||||
if (anim->mNumChannels) {
|
||||
ioprintf(io,"\t\t<NodeAnimList num=\"%u\">\n",anim->mNumChannels);
|
||||
for (unsigned int n = 0; n < anim->mNumChannels;++n) {
|
||||
aiNodeAnim* nd = anim->mChannels[n];
|
||||
|
||||
// node anim header
|
||||
ConvertName(name,nd->mNodeName);
|
||||
ioprintf(io,"\t\t\t<NodeAnim node=\"%s\">\n",name.data);
|
||||
|
||||
if (!shortened) {
|
||||
// write position keys
|
||||
if (nd->mNumPositionKeys) {
|
||||
ioprintf(io,"\t\t\t\t<PositionKeyList num=\"%u\">\n",nd->mNumPositionKeys);
|
||||
for (unsigned int a = 0; a < nd->mNumPositionKeys;++a) {
|
||||
aiVectorKey* vc = nd->mPositionKeys+a;
|
||||
ioprintf(io,"\t\t\t\t\t<PositionKey time=\"%e\">\n"
|
||||
"\t\t\t\t\t\t%0 8f %0 8f %0 8f\n\t\t\t\t\t</PositionKey>\n",
|
||||
vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z);
|
||||
}
|
||||
ioprintf(io,"\t\t\t\t</PositionKeyList>\n");
|
||||
}
|
||||
|
||||
// write scaling keys
|
||||
if (nd->mNumScalingKeys) {
|
||||
ioprintf(io,"\t\t\t\t<ScalingKeyList num=\"%u\">\n",nd->mNumScalingKeys);
|
||||
for (unsigned int a = 0; a < nd->mNumScalingKeys;++a) {
|
||||
aiVectorKey* vc = nd->mScalingKeys+a;
|
||||
ioprintf(io,"\t\t\t\t\t<ScalingKey time=\"%e\">\n"
|
||||
"\t\t\t\t\t\t%0 8f %0 8f %0 8f\n\t\t\t\t\t</ScalingKey>\n",
|
||||
vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z);
|
||||
}
|
||||
ioprintf(io,"\t\t\t\t</ScalingKeyList>\n");
|
||||
}
|
||||
|
||||
// write rotation keys
|
||||
if (nd->mNumRotationKeys) {
|
||||
ioprintf(io,"\t\t\t\t<RotationKeyList num=\"%u\">\n",nd->mNumRotationKeys);
|
||||
for (unsigned int a = 0; a < nd->mNumRotationKeys;++a) {
|
||||
aiQuatKey* vc = nd->mRotationKeys+a;
|
||||
ioprintf(io,"\t\t\t\t\t<RotationKey time=\"%e\">\n"
|
||||
"\t\t\t\t\t\t%0 8f %0 8f %0 8f %0 8f\n\t\t\t\t\t</RotationKey>\n",
|
||||
vc->mTime,vc->mValue.x,vc->mValue.y,vc->mValue.z,vc->mValue.w);
|
||||
}
|
||||
ioprintf(io,"\t\t\t\t</RotationKeyList>\n");
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t\t</NodeAnim>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t</NodeAnimList>\n");
|
||||
}
|
||||
ioprintf(io,"\t</Animation>\n");
|
||||
}
|
||||
ioprintf(io,"</AnimationList>\n");
|
||||
}
|
||||
|
||||
// write meshes
|
||||
if (scene->mNumMeshes) {
|
||||
ioprintf(io,"<MeshList num=\"%u\">\n",scene->mNumMeshes);
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||
aiMesh* mesh = scene->mMeshes[i];
|
||||
// const unsigned int width = (unsigned int)std::log10((double)mesh->mNumVertices)+1;
|
||||
|
||||
// mesh header
|
||||
ioprintf(io,"\t<Mesh types=\"%s %s %s %s\" material_index=\"%u\">\n",
|
||||
(mesh->mPrimitiveTypes & aiPrimitiveType_POINT ? "points" : ""),
|
||||
(mesh->mPrimitiveTypes & aiPrimitiveType_LINE ? "lines" : ""),
|
||||
(mesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE ? "triangles" : ""),
|
||||
(mesh->mPrimitiveTypes & aiPrimitiveType_POLYGON ? "polygons" : ""),
|
||||
mesh->mMaterialIndex);
|
||||
|
||||
// bones
|
||||
if (mesh->mNumBones) {
|
||||
ioprintf(io,"\t\t<BoneList num=\"%u\">\n",mesh->mNumBones);
|
||||
|
||||
for (unsigned int n = 0; n < mesh->mNumBones;++n) {
|
||||
aiBone* bone = mesh->mBones[n];
|
||||
|
||||
ConvertName(name,bone->mName);
|
||||
// bone header
|
||||
ioprintf(io,"\t\t\t<Bone name=\"%s\">\n"
|
||||
"\t\t\t\t<Matrix4> \n"
|
||||
"\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"\t\t\t\t\t%0 6f %0 6f %0 6f %0 6f\n"
|
||||
"\t\t\t\t</Matrix4> \n",
|
||||
name.data,
|
||||
bone->mOffsetMatrix.a1,bone->mOffsetMatrix.a2,bone->mOffsetMatrix.a3,bone->mOffsetMatrix.a4,
|
||||
bone->mOffsetMatrix.b1,bone->mOffsetMatrix.b2,bone->mOffsetMatrix.b3,bone->mOffsetMatrix.b4,
|
||||
bone->mOffsetMatrix.c1,bone->mOffsetMatrix.c2,bone->mOffsetMatrix.c3,bone->mOffsetMatrix.c4,
|
||||
bone->mOffsetMatrix.d1,bone->mOffsetMatrix.d2,bone->mOffsetMatrix.d3,bone->mOffsetMatrix.d4);
|
||||
|
||||
if (!shortened && bone->mNumWeights) {
|
||||
ioprintf(io,"\t\t\t\t<WeightList num=\"%u\">\n",bone->mNumWeights);
|
||||
|
||||
// bone weights
|
||||
for (unsigned int a = 0; a < bone->mNumWeights;++a) {
|
||||
aiVertexWeight* wght = bone->mWeights+a;
|
||||
|
||||
ioprintf(io,"\t\t\t\t\t<Weight index=\"%u\">\n\t\t\t\t\t\t%f\n\t\t\t\t\t</Weight>\n",
|
||||
wght->mVertexId,wght->mWeight);
|
||||
}
|
||||
ioprintf(io,"\t\t\t\t</WeightList>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t\t</Bone>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t</BoneList>\n");
|
||||
}
|
||||
|
||||
// faces
|
||||
if (!shortened && mesh->mNumFaces) {
|
||||
ioprintf(io,"\t\t<FaceList num=\"%u\">\n",mesh->mNumFaces);
|
||||
for (unsigned int n = 0; n < mesh->mNumFaces; ++n) {
|
||||
aiFace& f = mesh->mFaces[n];
|
||||
ioprintf(io,"\t\t\t<Face num=\"%u\">\n"
|
||||
"\t\t\t\t",f.mNumIndices);
|
||||
|
||||
for (unsigned int j = 0; j < f.mNumIndices;++j)
|
||||
ioprintf(io,"%u ",f.mIndices[j]);
|
||||
|
||||
ioprintf(io,"\n\t\t\t</Face>\n");
|
||||
}
|
||||
ioprintf(io,"\t\t</FaceList>\n");
|
||||
}
|
||||
|
||||
// vertex positions
|
||||
if (mesh->HasPositions()) {
|
||||
ioprintf(io,"\t\t<Positions num=\"%u\" set=\"0\" num_components=\"3\"> \n",mesh->mNumVertices);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mVertices[n].x,
|
||||
mesh->mVertices[n].y,
|
||||
mesh->mVertices[n].z);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Positions>\n");
|
||||
}
|
||||
|
||||
// vertex normals
|
||||
if (mesh->HasNormals()) {
|
||||
ioprintf(io,"\t\t<Normals num=\"%u\" set=\"0\" num_components=\"3\"> \n",mesh->mNumVertices);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mNormals[n].x,
|
||||
mesh->mNormals[n].y,
|
||||
mesh->mNormals[n].z);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Normals>\n");
|
||||
}
|
||||
|
||||
// vertex tangents and bitangents
|
||||
if (mesh->HasTangentsAndBitangents()) {
|
||||
ioprintf(io,"\t\t<Tangents num=\"%u\" set=\"0\" num_components=\"3\"> \n",mesh->mNumVertices);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mTangents[n].x,
|
||||
mesh->mTangents[n].y,
|
||||
mesh->mTangents[n].z);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Tangents>\n");
|
||||
|
||||
ioprintf(io,"\t\t<Bitangents num=\"%u\" set=\"0\" num_components=\"3\"> \n",mesh->mNumVertices);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mBitangents[n].x,
|
||||
mesh->mBitangents[n].y,
|
||||
mesh->mBitangents[n].z);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Bitangents>\n");
|
||||
}
|
||||
|
||||
// texture coordinates
|
||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
||||
if (!mesh->mTextureCoords[a])
|
||||
break;
|
||||
|
||||
ioprintf(io,"\t\t<TextureCoords num=\"%u\" set=\"%u\" num_components=\"%u\"> \n",mesh->mNumVertices,
|
||||
a,mesh->mNumUVComponents[a]);
|
||||
|
||||
if (!shortened) {
|
||||
if (mesh->mNumUVComponents[a] == 3) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f\n",
|
||||
mesh->mTextureCoords[a][n].x,
|
||||
mesh->mTextureCoords[a][n].y,
|
||||
mesh->mTextureCoords[a][n].z);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f\n",
|
||||
mesh->mTextureCoords[a][n].x,
|
||||
mesh->mTextureCoords[a][n].y);
|
||||
}
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</TextureCoords>\n");
|
||||
}
|
||||
|
||||
// vertex colors
|
||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
|
||||
if (!mesh->mColors[a])
|
||||
break;
|
||||
ioprintf(io,"\t\t<Colors num=\"%u\" set=\"%u\" num_components=\"4\"> \n",mesh->mNumVertices,a);
|
||||
if (!shortened) {
|
||||
for (unsigned int n = 0; n < mesh->mNumVertices; ++n) {
|
||||
ioprintf(io,"\t\t%0 8f %0 8f %0 8f %0 8f\n",
|
||||
mesh->mColors[a][n].r,
|
||||
mesh->mColors[a][n].g,
|
||||
mesh->mColors[a][n].b,
|
||||
mesh->mColors[a][n].a);
|
||||
}
|
||||
}
|
||||
ioprintf(io,"\t\t</Colors>\n");
|
||||
}
|
||||
ioprintf(io,"\t</Mesh>\n");
|
||||
}
|
||||
ioprintf(io,"</MeshList>\n");
|
||||
}
|
||||
ioprintf(io,"</Scene>\n</ASSIMP>");
|
||||
}
|
||||
|
||||
} // end of namespace AssxmlFileWriter
|
||||
|
||||
void DumpSceneToAssxml(
|
||||
const char* pFile, const char* cmd, IOSystem* pIOSystem,
|
||||
const aiScene* pScene, bool shortened) {
|
||||
std::unique_ptr<IOStream> file(pIOSystem->Open(pFile, "wt"));
|
||||
if (!file.get()) {
|
||||
throw std::runtime_error("Unable to open output file " + std::string(pFile) + '\n');
|
||||
}
|
||||
|
||||
AssxmlFileWriter::WriteDump(pFile, cmd, pScene, file.get(), shortened);
|
||||
}
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file AssxmlFileWriter.h
|
||||
* @brief Declaration of Assxml file writer.
|
||||
*/
|
||||
|
||||
#ifndef AI_ASSXMLFILEWRITER_H_INC
|
||||
#define AI_ASSXMLFILEWRITER_H_INC
|
||||
|
||||
#include <assimp/defs.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
void ASSIMP_API DumpSceneToAssxml(
|
||||
const char* pFile,
|
||||
const char* cmd,
|
||||
IOSystem* pIOSystem,
|
||||
const aiScene* pScene,
|
||||
bool shortened);
|
||||
|
||||
}
|
||||
|
||||
#endif // AI_ASSXMLFILEWRITER_H_INC
|
||||
|
|
@ -3,7 +3,9 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -76,6 +78,7 @@ static const aiImporterDesc desc = {
|
|||
"b3d"
|
||||
};
|
||||
|
||||
// (fixme, Aramis) quick workaround to get rid of all those signed to unsigned warnings
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable: 4018)
|
||||
#endif
|
||||
|
|
@ -83,8 +86,10 @@ static const aiImporterDesc desc = {
|
|||
//#define DEBUG_B3D
|
||||
|
||||
template<typename T>
|
||||
void DeleteAllBarePointers(std::vector<T>& x) {
|
||||
for(auto p : x) {
|
||||
void DeleteAllBarePointers(std::vector<T>& x)
|
||||
{
|
||||
for(auto p : x)
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
|
@ -97,14 +102,10 @@ B3DImporter::~B3DImporter()
|
|||
bool B3DImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const{
|
||||
|
||||
size_t pos=pFile.find_last_of( '.' );
|
||||
if( pos==string::npos ) {
|
||||
return false;
|
||||
}
|
||||
if( pos==string::npos ) return false;
|
||||
|
||||
string ext=pFile.substr( pos+1 );
|
||||
if( ext.size()!=3 ) {
|
||||
return false;
|
||||
}
|
||||
if( ext.size()!=3 ) return false;
|
||||
|
||||
return (ext[0]=='b' || ext[0]=='B') && (ext[1]=='3') && (ext[2]=='d' || ext[2]=='D');
|
||||
}
|
||||
|
|
@ -116,21 +117,30 @@ const aiImporterDesc* B3DImporter::GetInfo () const
|
|||
return &desc;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_B3D
|
||||
extern "C"{ void _stdcall AllocConsole(); }
|
||||
#endif
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void B3DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler){
|
||||
|
||||
#ifdef DEBUG_B3D
|
||||
AllocConsole();
|
||||
freopen( "conin$","r",stdin );
|
||||
freopen( "conout$","w",stdout );
|
||||
freopen( "conout$","w",stderr );
|
||||
cout<<"Hello world from the B3DImporter!"<<endl;
|
||||
#endif
|
||||
|
||||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||
|
||||
// Check whether we can read from the file
|
||||
if( file.get() == nullptr) {
|
||||
if( file.get() == NULL)
|
||||
throw DeadlyImportError( "Failed to open B3D file " + pFile + ".");
|
||||
}
|
||||
|
||||
// check whether the .b3d file is large enough to contain
|
||||
// at least one chunk.
|
||||
size_t fileSize = file->FileSize();
|
||||
if( fileSize<8 ) {
|
||||
throw DeadlyImportError( "B3D File is too small.");
|
||||
}
|
||||
if( fileSize<8 ) throw DeadlyImportError( "B3D File is too small.");
|
||||
|
||||
_pos=0;
|
||||
_buf.resize( fileSize );
|
||||
|
|
@ -148,17 +158,14 @@ AI_WONT_RETURN void B3DImporter::Oops(){
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
AI_WONT_RETURN void B3DImporter::Fail( string str ){
|
||||
#ifdef DEBUG_B3D
|
||||
ASSIMP_LOG_ERROR_F("Error in B3D file data: ", str);
|
||||
cout<<"Error in B3D file data: "<<str<<endl;
|
||||
#endif
|
||||
throw DeadlyImportError( "B3D Importer - error in B3D file data: "+str );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
int B3DImporter::ReadByte(){
|
||||
if( _pos<_buf.size() ) {
|
||||
return _buf[_pos++];
|
||||
}
|
||||
|
||||
if( _pos<_buf.size() ) return _buf[_pos++];
|
||||
Fail( "EOF" );
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -217,9 +224,7 @@ string B3DImporter::ReadString(){
|
|||
string str;
|
||||
while( _pos<_buf.size() ){
|
||||
char c=(char)ReadByte();
|
||||
if( !c ) {
|
||||
return str;
|
||||
}
|
||||
if( !c ) return str;
|
||||
str+=c;
|
||||
}
|
||||
Fail( "EOF" );
|
||||
|
|
@ -233,7 +238,7 @@ string B3DImporter::ReadChunk(){
|
|||
tag+=char( ReadByte() );
|
||||
}
|
||||
#ifdef DEBUG_B3D
|
||||
ASSIMP_LOG_DEBUG_F("ReadChunk: ", tag);
|
||||
// cout<<"ReadChunk:"<<tag<<endl;
|
||||
#endif
|
||||
unsigned sz=(unsigned)ReadInt();
|
||||
_stack.push_back( _pos+sz );
|
||||
|
|
@ -264,6 +269,7 @@ T *B3DImporter::to_array( const vector<T> &v ){
|
|||
return p;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template<class T>
|
||||
T **unique_to_array( vector<std::unique_ptr<T> > &v ){
|
||||
|
|
@ -277,6 +283,7 @@ T **unique_to_array( vector<std::unique_ptr<T> > &v ){
|
|||
return p;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void B3DImporter::ReadTEXS(){
|
||||
while( ChunkSize() ){
|
||||
|
|
@ -369,13 +376,9 @@ void B3DImporter::ReadVRTS(){
|
|||
|
||||
v.vertex=ReadVec3();
|
||||
|
||||
if( _vflags & 1 ) {
|
||||
v.normal=ReadVec3();
|
||||
}
|
||||
if( _vflags & 1 ) v.normal=ReadVec3();
|
||||
|
||||
if( _vflags & 2 ) {
|
||||
ReadQuat(); //skip v 4bytes...
|
||||
}
|
||||
if( _vflags & 2 ) ReadQuat(); //skip v 4bytes...
|
||||
|
||||
for( int i=0;i<_tcsets;++i ){
|
||||
float t[4]={0,0,0,0};
|
||||
|
|
@ -383,55 +386,53 @@ void B3DImporter::ReadVRTS(){
|
|||
t[j]=ReadFloat();
|
||||
}
|
||||
t[1]=1-t[1];
|
||||
if( !i ) {
|
||||
v.texcoords=aiVector3D( t[0],t[1],t[2] );
|
||||
}
|
||||
if( !i ) v.texcoords=aiVector3D( t[0],t[1],t[2] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void B3DImporter::ReadTRIS(int v0) {
|
||||
int matid = ReadInt();
|
||||
if (matid == -1) {
|
||||
matid = 0;
|
||||
} else if (matid < 0 || matid >= (int)_materials.size()) {
|
||||
void B3DImporter::ReadTRIS( int v0 ){
|
||||
int matid=ReadInt();
|
||||
if( matid==-1 ){
|
||||
matid=0;
|
||||
}else if( matid<0 || matid>=(int)_materials.size() ){
|
||||
#ifdef DEBUG_B3D
|
||||
ASSIMP_LOG_ERROR_F("material id=", matid);
|
||||
cout<<"material id="<<matid<<endl;
|
||||
#endif
|
||||
Fail("Bad material id");
|
||||
}
|
||||
Fail( "Bad material id" );
|
||||
}
|
||||
|
||||
std::unique_ptr<aiMesh> mesh(new aiMesh);
|
||||
std::unique_ptr<aiMesh> mesh(new aiMesh);
|
||||
|
||||
mesh->mMaterialIndex = matid;
|
||||
mesh->mNumFaces = 0;
|
||||
mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||
mesh->mMaterialIndex=matid;
|
||||
mesh->mNumFaces=0;
|
||||
mesh->mPrimitiveTypes=aiPrimitiveType_TRIANGLE;
|
||||
|
||||
int n_tris = ChunkSize() / 12;
|
||||
aiFace *face = mesh->mFaces = new aiFace[n_tris];
|
||||
int n_tris=ChunkSize()/12;
|
||||
aiFace *face=mesh->mFaces=new aiFace[n_tris];
|
||||
|
||||
for (int i = 0; i < n_tris; ++i) {
|
||||
int i0 = ReadInt() + v0;
|
||||
int i1 = 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()) {
|
||||
for( int i=0;i<n_tris;++i ){
|
||||
int i0=ReadInt()+v0;
|
||||
int i1=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() ){
|
||||
#ifdef DEBUG_B3D
|
||||
ASSIMP_LOG_ERROR_F("Bad triangle index: i0=", i0, ", i1=", i1, ", i2=", i2);
|
||||
cout<<"Bad triangle index: i0="<<i0<<", i1="<<i1<<", i2="<<i2<<endl;
|
||||
#endif
|
||||
Fail("Bad triangle index");
|
||||
continue;
|
||||
}
|
||||
face->mNumIndices = 3;
|
||||
face->mIndices = new unsigned[3];
|
||||
face->mIndices[0] = i0;
|
||||
face->mIndices[1] = i1;
|
||||
face->mIndices[2] = i2;
|
||||
++mesh->mNumFaces;
|
||||
++face;
|
||||
}
|
||||
Fail( "Bad triangle index" );
|
||||
continue;
|
||||
}
|
||||
face->mNumIndices=3;
|
||||
face->mIndices=new unsigned[3];
|
||||
face->mIndices[0]=i0;
|
||||
face->mIndices[1]=i1;
|
||||
face->mIndices[2]=i2;
|
||||
++mesh->mNumFaces;
|
||||
++face;
|
||||
}
|
||||
|
||||
_meshes.emplace_back(std::move(mesh));
|
||||
_meshes.emplace_back( std::move(mesh) );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -452,23 +453,29 @@ void B3DImporter::ReadMESH(){
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void B3DImporter::ReadBONE(int id) {
|
||||
while (ChunkSize()) {
|
||||
int vertex = ReadInt();
|
||||
float weight = ReadFloat();
|
||||
if (vertex < 0 || vertex >= (int)_vertices.size()) {
|
||||
Fail("Bad vertex index");
|
||||
}
|
||||
void B3DImporter::ReadBONE( int id ){
|
||||
while( ChunkSize() ){
|
||||
int vertex=ReadInt();
|
||||
float weight=ReadFloat();
|
||||
if( vertex<0 || vertex>=(int)_vertices.size() ){
|
||||
Fail( "Bad vertex index" );
|
||||
}
|
||||
|
||||
Vertex &v = _vertices[vertex];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (!v.weights[i]) {
|
||||
v.bones[i] = id;
|
||||
v.weights[i] = weight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Vertex &v=_vertices[vertex];
|
||||
int i;
|
||||
for( i=0;i<4;++i ){
|
||||
if( !v.weights[i] ){
|
||||
v.bones[i]=id;
|
||||
v.weights[i]=weight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_B3D
|
||||
if( i==4 ){
|
||||
cout<<"Too many bone weights"<<endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -626,15 +633,11 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
|||
}
|
||||
ExitChunk();
|
||||
|
||||
if( !_nodes.size() ) {
|
||||
Fail( "No nodes" );
|
||||
}
|
||||
if( !_nodes.size() ) Fail( "No nodes" );
|
||||
|
||||
if( !_meshes.size() ) {
|
||||
Fail( "No meshes" );
|
||||
}
|
||||
if( !_meshes.size() ) Fail( "No meshes" );
|
||||
|
||||
// Fix nodes/meshes/bones
|
||||
//Fix nodes/meshes/bones
|
||||
for(size_t i=0;i<_nodes.size();++i ){
|
||||
aiNode *node=_nodes[i];
|
||||
|
||||
|
|
@ -645,12 +648,8 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
|||
int n_verts=mesh->mNumVertices=n_tris * 3;
|
||||
|
||||
aiVector3D *mv=mesh->mVertices=new aiVector3D[ n_verts ],*mn=0,*mc=0;
|
||||
if( _vflags & 1 ) {
|
||||
mn=mesh->mNormals=new aiVector3D[ n_verts ];
|
||||
}
|
||||
if( _tcsets ) {
|
||||
mc=mesh->mTextureCoords[0]=new aiVector3D[ n_verts ];
|
||||
}
|
||||
if( _vflags & 1 ) mn=mesh->mNormals=new aiVector3D[ n_verts ];
|
||||
if( _tcsets ) mc=mesh->mTextureCoords[0]=new aiVector3D[ n_verts ];
|
||||
|
||||
aiFace *face=mesh->mFaces;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2013, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2013, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (ASSIMP)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, ASSIMP Development Team
|
||||
Copyright (c) 2006-2016, ASSIMP Development Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (ASSIMP)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, ASSIMP Development Team
|
||||
Copyright (c) 2006-2016, ASSIMP Development Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Open Asset Import Library (assimp)
|
||||
# ----------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006-2020, assimp team
|
||||
# Copyright (c) 2006-2019, assimp team
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
|
|
@ -49,7 +49,7 @@ SET( HEADER_PATH ../include/assimp )
|
|||
if(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
message(WARNING "Requesting Android JNI I/O-System in non-Android toolchain. Resetting ASSIMP_ANDROID_JNIIOSYSTEM to OFF.")
|
||||
set(ASSIMP_ANDROID_JNIIOSYSTEM OFF)
|
||||
endif()
|
||||
endif(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
|
||||
SET( COMPILER_HEADERS
|
||||
${HEADER_PATH}/Compiler/pushpack1.h
|
||||
|
|
@ -66,7 +66,6 @@ SET( PUBLIC_HEADERS
|
|||
${HEADER_PATH}/color4.h
|
||||
${HEADER_PATH}/color4.inl
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../include/assimp/config.h
|
||||
${HEADER_PATH}/commonMetaData.h
|
||||
${HEADER_PATH}/defs.h
|
||||
${HEADER_PATH}/Defines.h
|
||||
${HEADER_PATH}/cfileio.h
|
||||
|
|
@ -138,6 +137,7 @@ SET( PUBLIC_HEADERS
|
|||
${HEADER_PATH}/irrXMLWrapper.h
|
||||
${HEADER_PATH}/BlobIOSystem.h
|
||||
${HEADER_PATH}/MathFunctions.h
|
||||
${HEADER_PATH}/Macros.h
|
||||
${HEADER_PATH}/Exceptional.h
|
||||
${HEADER_PATH}/ByteSwapper.h
|
||||
)
|
||||
|
|
@ -148,7 +148,7 @@ SET( Core_SRCS
|
|||
|
||||
IF(MSVC)
|
||||
list(APPEND Core_SRCS "res/assimp.rc")
|
||||
ENDIF()
|
||||
ENDIF(MSVC)
|
||||
|
||||
SET( Logging_SRCS
|
||||
${HEADER_PATH}/DefaultLogger.hpp
|
||||
|
|
@ -185,6 +185,8 @@ SET( Common_SRCS
|
|||
Common/ScenePreprocessor.cpp
|
||||
Common/ScenePreprocessor.h
|
||||
Common/SkeletonMeshBuilder.cpp
|
||||
Common/SplitByBoneCountProcess.cpp
|
||||
Common/SplitByBoneCountProcess.h
|
||||
Common/StandardShapes.cpp
|
||||
Common/TargetAnimation.cpp
|
||||
Common/TargetAnimation.h
|
||||
|
|
@ -196,7 +198,6 @@ SET( Common_SRCS
|
|||
Common/CreateAnimMesh.cpp
|
||||
Common/simd.h
|
||||
Common/simd.cpp
|
||||
Common/material.cpp
|
||||
)
|
||||
SOURCE_GROUP(Common FILES ${Common_SRCS})
|
||||
|
||||
|
|
@ -220,7 +221,7 @@ IF ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER )
|
|||
C4D/C4DImporter.h
|
||||
)
|
||||
SOURCE_GROUP( C4D FILES ${C4D_SRCS})
|
||||
ENDIF ()
|
||||
ENDIF ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER )
|
||||
|
||||
# if this variable is set to TRUE, the user can manually disable importers by setting
|
||||
# ASSIMP_BUILD_XXX_IMPORTER to FALSE for each importer
|
||||
|
|
@ -250,39 +251,35 @@ MACRO(ADD_ASSIMP_IMPORTER name)
|
|||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
if (NOT ASSIMP_NO_EXPORT)
|
||||
# if this variable is set to TRUE, the user can manually disable exporters by setting
|
||||
# ASSIMP_BUILD_XXX_EXPORTER to FALSE for each exporter
|
||||
# if this variable is set to FALSE, the user can manually enable exporters by setting
|
||||
# ASSIMP_BUILD_XXX_EXPORTER to TRUE for each exporter
|
||||
OPTION(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_EXPORTER values" TRUE)
|
||||
|
||||
# if this variable is set to TRUE, the user can manually disable exporters by setting
|
||||
# ASSIMP_BUILD_XXX_EXPORTER to FALSE for each exporter
|
||||
# if this variable is set to FALSE, the user can manually enable exporters by setting
|
||||
# ASSIMP_BUILD_XXX_EXPORTER to TRUE for each exporter
|
||||
OPTION(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_EXPORTER values" TRUE)
|
||||
|
||||
# macro to add the CMake Option ADD_ASSIMP_IMPORTER_<name> which enables compile of loader
|
||||
# this way selective loaders can be compiled (reduces filesize + compile time)
|
||||
MACRO(ADD_ASSIMP_EXPORTER name)
|
||||
IF (ASSIMP_NO_EXPORT)
|
||||
# macro to add the CMake Option ADD_ASSIMP_IMPORTER_<name> which enables compile of loader
|
||||
# this way selective loaders can be compiled (reduces filesize + compile time)
|
||||
MACRO(ADD_ASSIMP_EXPORTER name)
|
||||
IF (ASSIMP_NO_EXPORT)
|
||||
set(ASSIMP_EXPORTER_ENABLED FALSE)
|
||||
ELSEIF (ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT)
|
||||
set(ASSIMP_EXPORTER_ENABLED TRUE)
|
||||
IF (DEFINED ASSIMP_BUILD_${name}_EXPORTER AND NOT ASSIMP_BUILD_${name}_EXPORTER)
|
||||
set(ASSIMP_EXPORTER_ENABLED FALSE)
|
||||
ELSEIF (ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT)
|
||||
set(ASSIMP_EXPORTER_ENABLED TRUE)
|
||||
IF (DEFINED ASSIMP_BUILD_${name}_EXPORTER AND NOT ASSIMP_BUILD_${name}_EXPORTER)
|
||||
set(ASSIMP_EXPORTER_ENABLED FALSE)
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
set(ASSIMP_EXPORTER_ENABLED ${ASSIMP_BUILD_${name}_EXPORTER})
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
set(ASSIMP_EXPORTER_ENABLED ${ASSIMP_BUILD_${name}_EXPORTER})
|
||||
ENDIF ()
|
||||
|
||||
IF (ASSIMP_EXPORTER_ENABLED)
|
||||
SET(ASSIMP_EXPORTERS_ENABLED "${ASSIMP_EXPORTERS_ENABLED} ${name}")
|
||||
LIST(APPEND ASSIMP_EXPORTER_SRCS ${ARGN})
|
||||
SOURCE_GROUP(${name}_EXPORTER FILES ${ARGN})
|
||||
ELSE()
|
||||
SET(ASSIMP_EXPORTERS_DISABLED "${ASSIMP_EXPORTERS_DISABLED} ${name}")
|
||||
add_definitions(-DASSIMP_BUILD_NO_${name}_EXPORTER)
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
endif()
|
||||
IF (ASSIMP_EXPORTER_ENABLED)
|
||||
SET(ASSIMP_EXPORTERS_ENABLED "${ASSIMP_EXPORTERS_ENABLED} ${name}")
|
||||
LIST(APPEND ASSIMP_EXPORTER_SRCS ${ARGN})
|
||||
SOURCE_GROUP(${name}_EXPORTER FILES ${ARGN})
|
||||
ELSE()
|
||||
SET(ASSIMP_EXPORTERS_DISABLED "${ASSIMP_EXPORTERS_DISABLED} ${name}")
|
||||
add_definitions(-DASSIMP_BUILD_NO_${name}_EXPORTER)
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
SET(ASSIMP_LOADER_SRCS "")
|
||||
SET(ASSIMP_IMPORTERS_ENABLED "") # list of enabled importers
|
||||
|
|
@ -309,6 +306,11 @@ ADD_ASSIMP_IMPORTER( 3DS
|
|||
3DS/3DSLoader.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( 3DS
|
||||
3DS/3DSExporter.h
|
||||
3DS/3DSExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( AC
|
||||
AC/ACLoader.cpp
|
||||
AC/ACLoader.h
|
||||
|
|
@ -326,6 +328,16 @@ ADD_ASSIMP_IMPORTER( ASSBIN
|
|||
Assbin/AssbinLoader.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( ASSBIN
|
||||
Assbin/AssbinExporter.h
|
||||
Assbin/AssbinExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( ASSXML
|
||||
Assxml/AssxmlExporter.h
|
||||
Assxml/AssxmlExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( B3D
|
||||
B3D/B3DImporter.cpp
|
||||
B3D/B3DImporter.h
|
||||
|
|
@ -337,7 +349,6 @@ ADD_ASSIMP_IMPORTER( BVH
|
|||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( COLLADA
|
||||
Collada/ColladaHelper.cpp
|
||||
Collada/ColladaHelper.h
|
||||
Collada/ColladaLoader.cpp
|
||||
Collada/ColladaLoader.h
|
||||
|
|
@ -345,6 +356,11 @@ ADD_ASSIMP_IMPORTER( COLLADA
|
|||
Collada/ColladaParser.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( COLLADA
|
||||
Collada/ColladaExporter.h
|
||||
Collada/ColladaExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( DXF
|
||||
DXF/DXFLoader.cpp
|
||||
DXF/DXFLoader.h
|
||||
|
|
@ -392,15 +408,6 @@ ADD_ASSIMP_IMPORTER( LWS
|
|||
LWS/LWSLoader.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( M3D
|
||||
M3D/M3DMaterials.h
|
||||
M3D/M3DImporter.h
|
||||
M3D/M3DImporter.cpp
|
||||
M3D/M3DWrapper.h
|
||||
M3D/M3DWrapper.cpp
|
||||
M3D/m3d.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( MD2
|
||||
MD2/MD2FileData.h
|
||||
MD2/MD2Loader.cpp
|
||||
|
|
@ -434,16 +441,6 @@ ADD_ASSIMP_IMPORTER( MDL
|
|||
MDL/MDLLoader.cpp
|
||||
MDL/MDLLoader.h
|
||||
MDL/MDLMaterialLoader.cpp
|
||||
MDL/HalfLife/HalfLifeMDLBaseHeader.h
|
||||
MDL/HalfLife/HL1FileData.h
|
||||
MDL/HalfLife/HL1MDLLoader.cpp
|
||||
MDL/HalfLife/HL1MDLLoader.h
|
||||
MDL/HalfLife/HL1ImportDefinitions.h
|
||||
MDL/HalfLife/HL1ImportSettings.h
|
||||
MDL/HalfLife/HL1MeshTrivert.h
|
||||
MDL/HalfLife/LogFunctions.h
|
||||
MDL/HalfLife/UniqueNameGenerator.cpp
|
||||
MDL/HalfLife/UniqueNameGenerator.h
|
||||
)
|
||||
|
||||
SET( MaterialSystem_SRCS
|
||||
|
|
@ -478,6 +475,11 @@ ADD_ASSIMP_IMPORTER( OBJ
|
|||
Obj/ObjTools.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( OBJ
|
||||
Obj/ObjExporter.h
|
||||
Obj/ObjExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( OGRE
|
||||
Ogre/OgreImporter.h
|
||||
Ogre/OgreStructs.h
|
||||
|
|
@ -497,6 +499,11 @@ ADD_ASSIMP_IMPORTER( OPENGEX
|
|||
OpenGEX/OpenGEXStructs.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( OPENGEX
|
||||
OpenGEX/OpenGEXExporter.cpp
|
||||
OpenGEX/OpenGEXExporter.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( PLY
|
||||
Ply/PlyLoader.cpp
|
||||
Ply/PlyLoader.h
|
||||
|
|
@ -504,6 +511,11 @@ ADD_ASSIMP_IMPORTER( PLY
|
|||
Ply/PlyParser.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( PLY
|
||||
Ply/PlyExporter.cpp
|
||||
Ply/PlyExporter.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( MS3D
|
||||
MS3D/MS3DLoader.cpp
|
||||
MS3D/MS3DLoader.h
|
||||
|
|
@ -557,7 +569,7 @@ if (ASSIMP_BUILD_IFC_IMPORTER)
|
|||
elseif(CMAKE_COMPILER_IS_MINGW)
|
||||
set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "-O2 -Wa,-mbig-obj")
|
||||
endif()
|
||||
endif ()
|
||||
endif (ASSIMP_BUILD_IFC_IMPORTER)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( XGL
|
||||
XGL/XGLLoader.cpp
|
||||
|
|
@ -593,86 +605,14 @@ ADD_ASSIMP_IMPORTER( FBX
|
|||
FBX/FBXCommon.h
|
||||
)
|
||||
|
||||
if (NOT ASSIMP_NO_EXPORT)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( OBJ
|
||||
Obj/ObjExporter.h
|
||||
Obj/ObjExporter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( OPENGEX
|
||||
OpenGEX/OpenGEXExporter.cpp
|
||||
OpenGEX/OpenGEXExporter.h)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( PLY
|
||||
Ply/PlyExporter.cpp
|
||||
Ply/PlyExporter.h)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( 3DS
|
||||
3DS/3DSExporter.h
|
||||
3DS/3DSExporter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( ASSBIN
|
||||
Assbin/AssbinExporter.h
|
||||
Assbin/AssbinExporter.cpp
|
||||
Assbin/AssbinFileWriter.h
|
||||
Assbin/AssbinFileWriter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( ASSXML
|
||||
Assxml/AssxmlExporter.h
|
||||
Assxml/AssxmlExporter.cpp
|
||||
Assxml/AssxmlFileWriter.h
|
||||
Assxml/AssxmlFileWriter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER(M3D
|
||||
M3D/M3DExporter.h
|
||||
M3D/M3DExporter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER(COLLADA
|
||||
Collada/ColladaExporter.h
|
||||
Collada/ColladaExporter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( FBX
|
||||
FBX/FBXExporter.h
|
||||
FBX/FBXExporter.cpp
|
||||
FBX/FBXExportNode.h
|
||||
FBX/FBXExportNode.cpp
|
||||
FBX/FBXExportProperty.h
|
||||
FBX/FBXExportProperty.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( STL
|
||||
STL/STLExporter.h
|
||||
STL/STLExporter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( X
|
||||
X/XFileExporter.h
|
||||
X/XFileExporter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( X3D
|
||||
X3D/X3DExporter.cpp
|
||||
X3D/X3DExporter.hpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( GLTF
|
||||
glTF/glTFExporter.h
|
||||
glTF/glTFExporter.cpp
|
||||
glTF2/glTF2Exporter.h
|
||||
glTF2/glTF2Exporter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( 3MF
|
||||
3MF/D3MFExporter.h
|
||||
3MF/D3MFExporter.cpp)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( ASSJSON
|
||||
Assjson/cencode.c
|
||||
Assjson/cencode.h
|
||||
Assjson/json_exporter.cpp
|
||||
Assjson/mesh_splitter.cpp
|
||||
Assjson/mesh_splitter.h)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( STEP
|
||||
Step/StepExporter.h
|
||||
Step/StepExporter.cpp)
|
||||
|
||||
endif()
|
||||
ADD_ASSIMP_EXPORTER( FBX
|
||||
FBX/FBXExporter.h
|
||||
FBX/FBXExporter.cpp
|
||||
FBX/FBXExportNode.h
|
||||
FBX/FBXExportNode.cpp
|
||||
FBX/FBXExportProperty.h
|
||||
FBX/FBXExportProperty.cpp
|
||||
)
|
||||
|
||||
SET( PostProcessing_SRCS
|
||||
PostProcessing/CalcTangentsProcess.cpp
|
||||
|
|
@ -731,12 +671,8 @@ SET( PostProcessing_SRCS
|
|||
PostProcessing/MakeVerboseFormat.h
|
||||
PostProcessing/ScaleProcess.cpp
|
||||
PostProcessing/ScaleProcess.h
|
||||
PostProcessing/ArmaturePopulate.cpp
|
||||
PostProcessing/ArmaturePopulate.h
|
||||
PostProcessing/GenBoundingBoxesProcess.cpp
|
||||
PostProcessing/GenBoundingBoxesProcess.h
|
||||
PostProcessing/SplitByBoneCountProcess.cpp
|
||||
PostProcessing/SplitByBoneCountProcess.h
|
||||
)
|
||||
SOURCE_GROUP( PostProcessing FILES ${PostProcessing_SRCS})
|
||||
|
||||
|
|
@ -776,6 +712,11 @@ ADD_ASSIMP_IMPORTER( STL
|
|||
STL/STLLoader.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( STL
|
||||
STL/STLExporter.h
|
||||
STL/STLExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( TERRAGEN
|
||||
Terragen/TerragenLoader.cpp
|
||||
Terragen/TerragenLoader.h
|
||||
|
|
@ -794,6 +735,11 @@ ADD_ASSIMP_IMPORTER( X
|
|||
X/XFileParser.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( X
|
||||
X/XFileExporter.h
|
||||
X/XFileExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( X3D
|
||||
X3D/X3DImporter.cpp
|
||||
X3D/X3DImporter.hpp
|
||||
|
|
@ -814,6 +760,11 @@ ADD_ASSIMP_IMPORTER( X3D
|
|||
X3D/X3DVocabulary.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( X3D
|
||||
X3D/X3DExporter.cpp
|
||||
X3D/X3DExporter.hpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( GLTF
|
||||
glTF/glTFCommon.h
|
||||
glTF/glTFCommon.cpp
|
||||
|
|
@ -831,6 +782,13 @@ ADD_ASSIMP_IMPORTER( GLTF
|
|||
glTF2/glTF2Importer.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( GLTF
|
||||
glTF/glTFExporter.h
|
||||
glTF/glTFExporter.cpp
|
||||
glTF2/glTF2Exporter.h
|
||||
glTF2/glTF2Exporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( 3MF
|
||||
3MF/D3MFImporter.h
|
||||
3MF/D3MFImporter.cpp
|
||||
|
|
@ -839,6 +797,11 @@ ADD_ASSIMP_IMPORTER( 3MF
|
|||
3MF/3MFXmlTags.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( 3MF
|
||||
3MF/D3MFExporter.h
|
||||
3MF/D3MFExporter.cpp
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( MMD
|
||||
MMD/MMDCpp14.h
|
||||
MMD/MMDImporter.cpp
|
||||
|
|
@ -849,6 +812,14 @@ ADD_ASSIMP_IMPORTER( MMD
|
|||
MMD/MMDVmdParser.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( ASSJSON
|
||||
Assjson/cencode.c
|
||||
Assjson/cencode.h
|
||||
Assjson/json_exporter.cpp
|
||||
Assjson/mesh_splitter.cpp
|
||||
Assjson/mesh_splitter.h
|
||||
)
|
||||
|
||||
# Workaround for issue #2406 - force problematic large file to be optimized to prevent string table overflow error
|
||||
# Used -Os instead of -O2 as previous issues had mentioned, since -Os is roughly speaking -O2, excluding any
|
||||
# optimizations that take up extra space. Given that the issue is a string table overflowing, -Os seemed appropriate
|
||||
|
|
@ -871,6 +842,11 @@ ADD_ASSIMP_IMPORTER( STEP
|
|||
Importer/StepFile/StepReaderGen.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_EXPORTER( STEP
|
||||
Step/StepExporter.h
|
||||
Step/StepExporter.cpp
|
||||
)
|
||||
|
||||
if ((NOT ASSIMP_NO_EXPORT) OR (NOT ASSIMP_EXPORTERS_ENABLED STREQUAL ""))
|
||||
SET( Exporter_SRCS
|
||||
Common/Exporter.cpp
|
||||
|
|
@ -889,35 +865,35 @@ SOURCE_GROUP( Extra FILES ${Extra_SRCS})
|
|||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(irrXML)
|
||||
find_package(irrXML CONFIG REQUIRED)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
# irrXML already included in contrib directory by parent CMakeLists.txt.
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# utf8
|
||||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(utf8)
|
||||
find_package(utf8 CONFIG REQUIRED)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
# utf8 is header-only, so Assimp doesn't need to do anything.
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# polyclipping
|
||||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(polyclipping)
|
||||
find_package(polyclipping CONFIG REQUIRED)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
SET( Clipper_SRCS
|
||||
../contrib/clipper/clipper.hpp
|
||||
../contrib/clipper/clipper.cpp
|
||||
)
|
||||
SOURCE_GROUP( Contrib\\Clipper FILES ${Clipper_SRCS})
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# poly2tri
|
||||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(poly2tri)
|
||||
find_package(poly2tri CONFIG REQUIRED)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
SET( Poly2Tri_SRCS
|
||||
../contrib/poly2tri/poly2tri/common/shapes.cc
|
||||
../contrib/poly2tri/poly2tri/common/shapes.h
|
||||
|
|
@ -932,13 +908,13 @@ ELSE()
|
|||
../contrib/poly2tri/poly2tri/sweep/sweep_context.h
|
||||
)
|
||||
SOURCE_GROUP( Contrib\\Poly2Tri FILES ${Poly2Tri_SRCS})
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# minizip/unzip
|
||||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(minizip)
|
||||
find_package(minizip CONFIG REQUIRED)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
SET( unzip_SRCS
|
||||
../contrib/unzip/crypt.h
|
||||
../contrib/unzip/ioapi.c
|
||||
|
|
@ -947,13 +923,13 @@ ELSE()
|
|||
../contrib/unzip/unzip.h
|
||||
)
|
||||
SOURCE_GROUP(Contrib\\unzip FILES ${unzip_SRCS})
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# zip (https://github.com/kuba--/zip)
|
||||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(zip)
|
||||
find_package(zip CONFIG REQUIRED)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
SET( ziplib_SRCS
|
||||
../contrib/zip/src/miniz.h
|
||||
../contrib/zip/src/zip.c
|
||||
|
|
@ -968,13 +944,13 @@ ELSE()
|
|||
endif()
|
||||
|
||||
SOURCE_GROUP( ziplib FILES ${ziplib_SRCS} )
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# openddlparser
|
||||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(openddlparser)
|
||||
find_package(openddlparser CONFIG REQUIRED)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
SET ( openddl_parser_SRCS
|
||||
../contrib/openddlparser/code/OpenDDLParser.cpp
|
||||
../contrib/openddlparser/code/DDLNode.cpp
|
||||
|
|
@ -991,12 +967,12 @@ ELSE()
|
|||
../contrib/openddlparser/include/openddlparser/Value.h
|
||||
)
|
||||
SOURCE_GROUP( Contrib\\openddl_parser FILES ${openddl_parser_SRCS})
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# Open3DGC
|
||||
IF(HUNTER_ENABLED)
|
||||
# Nothing to do, not available in Hunter yet.
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
SET ( open3dgc_SRCS
|
||||
../contrib/Open3DGC/o3dgcAdjacencyInfo.h
|
||||
../contrib/Open3DGC/o3dgcArithmeticCodec.cpp
|
||||
|
|
@ -1029,7 +1005,7 @@ ELSE()
|
|||
../contrib/Open3DGC/o3dgcVector.inl
|
||||
)
|
||||
SOURCE_GROUP( Contrib\\open3dgc FILES ${open3dgc_SRCS})
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# Check dependencies for glTF importer with Open3DGC-compression.
|
||||
# RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
|
||||
|
|
@ -1048,44 +1024,40 @@ ENDIF ()
|
|||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(RapidJSON)
|
||||
find_package(RapidJSON CONFIG REQUIRED)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
INCLUDE_DIRECTORIES( "../contrib/rapidjson/include" )
|
||||
INCLUDE_DIRECTORIES( "../contrib" )
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
# VC2010 fixes
|
||||
if(MSVC10)
|
||||
option( VC10_STDINT_FIX "Fix for VC10 Compiler regarding pstdint.h redefinition errors" OFF )
|
||||
if( VC10_STDINT_FIX )
|
||||
ADD_DEFINITIONS( -D_STDINT )
|
||||
endif()
|
||||
endif()
|
||||
endif( VC10_STDINT_FIX )
|
||||
endif(MSVC10)
|
||||
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_DLL_EXPORT )
|
||||
|
||||
if ( MSVC )
|
||||
ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
|
||||
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
||||
endif ()
|
||||
endif ( MSVC )
|
||||
|
||||
IF(NOT HUNTER_ENABLED)
|
||||
if (UNZIP_FOUND)
|
||||
SET (unzip_compile_SRCS "")
|
||||
else ()
|
||||
else (UNZIP_FOUND)
|
||||
SET (unzip_compile_SRCS ${unzip_SRCS})
|
||||
INCLUDE_DIRECTORIES( "../contrib/unzip/" )
|
||||
endif ()
|
||||
ENDIF()
|
||||
endif (UNZIP_FOUND)
|
||||
ENDIF(NOT HUNTER_ENABLED)
|
||||
|
||||
MESSAGE(STATUS "Enabled importer formats:${ASSIMP_IMPORTERS_ENABLED}")
|
||||
MESSAGE(STATUS "Disabled importer formats:${ASSIMP_IMPORTERS_DISABLED}")
|
||||
|
||||
if (NOT ASSIMP_NO_EXPORT)
|
||||
MESSAGE(STATUS "Enabled exporter formats:${ASSIMP_EXPORTERS_ENABLED}")
|
||||
MESSAGE(STATUS "Disabled exporter formats:${ASSIMP_EXPORTERS_DISABLED}")
|
||||
endif()
|
||||
|
||||
SOURCE_GROUP( include\\assimp FILES ${PUBLIC_HEADERS} )
|
||||
MESSAGE(STATUS "Enabled exporter formats:${ASSIMP_EXPORTERS_ENABLED}")
|
||||
MESSAGE(STATUS "Disabled exporter formats:${ASSIMP_EXPORTERS_DISABLED}")
|
||||
|
||||
SET( assimp_src
|
||||
# Assimp Files
|
||||
|
|
@ -1123,12 +1095,12 @@ IF(NOT HUNTER_ENABLED)
|
|||
${IRRXML_INCLUDE_DIR}
|
||||
../contrib/openddlparser/include
|
||||
)
|
||||
ENDIF()
|
||||
ENDIF(NOT HUNTER_ENABLED)
|
||||
|
||||
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||
SET( assimp_src ${assimp_src} ${C4D_SRCS})
|
||||
INCLUDE_DIRECTORIES(${C4D_INCLUDES})
|
||||
ENDIF ()
|
||||
ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||
|
||||
ADD_LIBRARY( assimp ${assimp_src} )
|
||||
ADD_LIBRARY(assimp::assimp ALIAS assimp)
|
||||
|
|
@ -1152,21 +1124,21 @@ IF(HUNTER_ENABLED)
|
|||
utf8::utf8
|
||||
zip::zip
|
||||
)
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES} ${IRRXML_LIBRARY} )
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
if(ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
set(ASSIMP_ANDROID_JNIIOSYSTEM_PATH port/AndroidJNI)
|
||||
add_subdirectory(../${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/ ../${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/)
|
||||
target_link_libraries(assimp android_jniiosystem)
|
||||
endif()
|
||||
endif(ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
|
||||
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||
TARGET_LINK_LIBRARIES(assimp optimized ${C4D_RELEASE_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(assimp debug ${C4D_DEBUG_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(assimp ${C4D_EXTRA_LIBRARIES})
|
||||
ENDIF ()
|
||||
ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||
|
||||
if( MSVC )
|
||||
# in order to prevent DLL hell, each of the DLLs have to be suffixed with the major version and msvc prefix
|
||||
|
|
@ -1212,6 +1184,10 @@ SET_TARGET_PROPERTIES( assimp PROPERTIES
|
|||
)
|
||||
|
||||
if (APPLE)
|
||||
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
||||
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR}"
|
||||
)
|
||||
|
||||
if (BUILD_FRAMEWORK)
|
||||
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
|
|
@ -1227,8 +1203,8 @@ if (APPLE)
|
|||
"../${HEADER_PATH}/Compiler"
|
||||
assimp.framework/Headers/Compiler
|
||||
COMMENT "Copying public ./Compiler/ header files to framework bundle's Headers/Compiler/")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF(BUILD_FRAMEWORK)
|
||||
ENDIF(APPLE)
|
||||
|
||||
# Build against external unzip, or add ../contrib/unzip so
|
||||
# assimp can #include "unzip.h"
|
||||
|
|
@ -1236,15 +1212,15 @@ IF(NOT HUNTER_ENABLED)
|
|||
if (UNZIP_FOUND)
|
||||
INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS})
|
||||
TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES})
|
||||
else ()
|
||||
else (UNZIP_FOUND)
|
||||
INCLUDE_DIRECTORIES("../")
|
||||
endif ()
|
||||
ENDIF()
|
||||
endif (UNZIP_FOUND)
|
||||
ENDIF(NOT HUNTER_ENABLED)
|
||||
|
||||
# Add RT-extension library for glTF importer with Open3DGC-compression.
|
||||
IF (RT_FOUND AND ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC)
|
||||
TARGET_LINK_LIBRARIES(assimp ${RT_LIBRARY})
|
||||
ENDIF ()
|
||||
ENDIF (RT_FOUND AND ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC)
|
||||
|
||||
IF(HUNTER_ENABLED)
|
||||
INSTALL( TARGETS assimp
|
||||
|
|
@ -1255,14 +1231,14 @@ IF(HUNTER_ENABLED)
|
|||
FRAMEWORK DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
COMPONENT ${LIBASSIMP_COMPONENT}
|
||||
INCLUDES DESTINATION "include")
|
||||
ELSE()
|
||||
ELSE(HUNTER_ENABLED)
|
||||
INSTALL( TARGETS assimp
|
||||
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR}
|
||||
FRAMEWORK DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
COMPONENT ${LIBASSIMP_COMPONENT})
|
||||
ENDIF()
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
INSTALL( FILES ${PUBLIC_HEADERS} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}/assimp COMPONENT assimp-dev)
|
||||
INSTALL( FILES ${COMPILER_HEADERS} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}/assimp/Compiler COMPONENT assimp-dev)
|
||||
|
||||
|
|
@ -1270,7 +1246,7 @@ if (ASSIMP_ANDROID_JNIIOSYSTEM)
|
|||
INSTALL(FILES ${HEADER_PATH}/${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/AndroidJNIIOSystem.h
|
||||
DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}
|
||||
COMPONENT assimp-dev)
|
||||
ENDIF()
|
||||
ENDIF(ASSIMP_ANDROID_JNIIOSYSTEM)
|
||||
|
||||
if(MSVC AND ASSIMP_INSTALL_PDB)
|
||||
# When only the static library is built, these properties must
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ aiNode* COBImporter::BuildNodes(const Node& root,const Scene& scin,aiScene* fill
|
|||
const Mesh& ndmesh = (const Mesh&)(root);
|
||||
if (ndmesh.vertex_positions.size() && ndmesh.texture_coords.size()) {
|
||||
|
||||
typedef std::pair<const unsigned int,Mesh::FaceRefList> Entry;
|
||||
typedef std::pair<unsigned int,Mesh::FaceRefList> Entry;
|
||||
for(const Entry& reflist : ndmesh.temp_map) {
|
||||
{ // create mesh
|
||||
size_t n = 0;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
|||
*ot++ = *buffer++;
|
||||
|
||||
*ot = '\0';
|
||||
nda->mNodeName.length = (ai_uint32)(ot-nda->mNodeName.data);
|
||||
nda->mNodeName.length = (size_t)(ot-nda->mNodeName.data);
|
||||
}
|
||||
|
||||
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "ColladaExporter.h"
|
||||
#include <assimp/Bitmap.h>
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/MathFunctions.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/SceneCombiner.h>
|
||||
|
|
@ -93,36 +92,6 @@ void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* p
|
|||
|
||||
} // end of namespace Assimp
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Encodes a string into a valid XML ID using the xsd:ID schema qualifications.
|
||||
static const std::string XMLIDEncode(const std::string& name) {
|
||||
const char XML_ID_CHARS[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.";
|
||||
const unsigned int XML_ID_CHARS_COUNT = sizeof(XML_ID_CHARS) / sizeof(char);
|
||||
|
||||
if (name.length() == 0) {
|
||||
return name;
|
||||
}
|
||||
|
||||
std::stringstream idEncoded;
|
||||
|
||||
// xsd:ID must start with letter or underscore
|
||||
if (!((name[0] >= 'A' && name[0] <= 'z') || name[0] == '_')) {
|
||||
idEncoded << '_';
|
||||
}
|
||||
|
||||
for (std::string::const_iterator it = name.begin(); it != name.end(); ++it) {
|
||||
// xsd:ID can only contain letters, digits, underscores, hyphens and periods
|
||||
if (strchr(XML_ID_CHARS, *it) != nullptr) {
|
||||
idEncoded << *it;
|
||||
} else {
|
||||
// Select placeholder character based on invalid character to prevent name collisions
|
||||
idEncoded << XML_ID_CHARS[(*it) % XML_ID_CHARS_COUNT];
|
||||
}
|
||||
}
|
||||
|
||||
return idEncoded.str();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor for a specific scene to export
|
||||
ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file)
|
||||
|
|
@ -177,7 +146,7 @@ void ColladaExporter::WriteFile() {
|
|||
// useless Collada fu at the end, just in case we haven't had enough indirections, yet.
|
||||
mOutput << startstr << "<scene>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<instance_visual_scene url=\"#" + XMLIDEncode(mScene->mRootNode->mName.C_Str()) + "\" />" << endstr;
|
||||
mOutput << startstr << "<instance_visual_scene url=\"#" + XMLEscape(mScene->mRootNode->mName.C_Str()) + "\" />" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</scene>" << endstr;
|
||||
PopTag();
|
||||
|
|
@ -278,7 +247,7 @@ void ColladaExporter::WriteHeader() {
|
|||
mOutput << startstr << "<author>" << XMLEscape(value.C_Str()) << "</author>" << endstr;
|
||||
}
|
||||
|
||||
if (nullptr == meta || !meta->Get(AI_METADATA_SOURCE_GENERATOR, value)) {
|
||||
if (nullptr == meta || !meta->Get("AuthoringTool", value)) {
|
||||
mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr;
|
||||
} else {
|
||||
mOutput << startstr << "<authoring_tool>" << XMLEscape(value.C_Str()) << "</authoring_tool>" << endstr;
|
||||
|
|
@ -288,7 +257,7 @@ void ColladaExporter::WriteHeader() {
|
|||
if (meta->Get("Comments", value)) {
|
||||
mOutput << startstr << "<comments>" << XMLEscape(value.C_Str()) << "</comments>" << endstr;
|
||||
}
|
||||
if (meta->Get(AI_METADATA_SOURCE_COPYRIGHT, value)) {
|
||||
if (meta->Get("Copyright", value)) {
|
||||
mOutput << startstr << "<copyright>" << XMLEscape(value.C_Str()) << "</copyright>" << endstr;
|
||||
}
|
||||
if (meta->Get("SourceData", value)) {
|
||||
|
|
@ -387,10 +356,9 @@ void ColladaExporter::WriteCamerasLibrary() {
|
|||
void ColladaExporter::WriteCamera(size_t pIndex){
|
||||
|
||||
const aiCamera *cam = mScene->mCameras[pIndex];
|
||||
const std::string cameraName = XMLEscape(cam->mName.C_Str());
|
||||
const std::string cameraId = XMLIDEncode(cam->mName.C_Str());
|
||||
const std::string idstrEscaped = XMLEscape(cam->mName.C_Str());
|
||||
|
||||
mOutput << startstr << "<camera id=\"" << cameraId << "-camera\" name=\"" << cameraName << "\" >" << endstr;
|
||||
mOutput << startstr << "<camera id=\"" << idstrEscaped << "-camera\" name=\"" << idstrEscaped << "_name\" >" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<optics>" << endstr;
|
||||
PushTag();
|
||||
|
|
@ -444,11 +412,10 @@ void ColladaExporter::WriteLightsLibrary() {
|
|||
void ColladaExporter::WriteLight(size_t pIndex){
|
||||
|
||||
const aiLight *light = mScene->mLights[pIndex];
|
||||
const std::string lightName = XMLEscape(light->mName.C_Str());
|
||||
const std::string lightId = XMLIDEncode(light->mName.C_Str());
|
||||
const std::string idstrEscaped = XMLEscape(light->mName.C_Str());
|
||||
|
||||
mOutput << startstr << "<light id=\"" << lightId << "-light\" name=\""
|
||||
<< lightName << "\" >" << endstr;
|
||||
mOutput << startstr << "<light id=\"" << idstrEscaped << "-light\" name=\""
|
||||
<< idstrEscaped << "_name\" >" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<technique_common>" << endstr;
|
||||
PushTag();
|
||||
|
|
@ -619,7 +586,7 @@ static bool isalnum_C(char c) {
|
|||
void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::string& pNameAdd) {
|
||||
if( !pSurface.texture.empty() )
|
||||
{
|
||||
mOutput << startstr << "<image id=\"" << XMLIDEncode(pNameAdd) << "\">" << endstr;
|
||||
mOutput << startstr << "<image id=\"" << XMLEscape(pNameAdd) << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<init_from>";
|
||||
|
||||
|
|
@ -652,7 +619,7 @@ void ColladaExporter::WriteTextureColorEntry( const Surface& pSurface, const std
|
|||
}
|
||||
else
|
||||
{
|
||||
mOutput << startstr << "<texture texture=\"" << XMLIDEncode(pImageName) << "\" texcoord=\"CHANNEL" << pSurface.channel << "\" />" << endstr;
|
||||
mOutput << startstr << "<texture texture=\"" << XMLEscape(pImageName) << "\" texcoord=\"CHANNEL" << pSurface.channel << "\" />" << endstr;
|
||||
}
|
||||
PopTag();
|
||||
mOutput << startstr << "</" << pTypeName << ">" << endstr;
|
||||
|
|
@ -666,21 +633,21 @@ void ColladaExporter::WriteTextureParamEntry( const Surface& pSurface, const std
|
|||
// if surface is a texture, write out the sampler and the surface parameters necessary to reference the texture
|
||||
if( !pSurface.texture.empty() )
|
||||
{
|
||||
mOutput << startstr << "<newparam sid=\"" << XMLIDEncode(pMatName) << "-" << pTypeName << "-surface\">" << endstr;
|
||||
mOutput << startstr << "<newparam sid=\"" << XMLEscape(pMatName) << "-" << pTypeName << "-surface\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<surface type=\"2D\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<init_from>" << XMLIDEncode(pMatName) << "-" << pTypeName << "-image</init_from>" << endstr;
|
||||
mOutput << startstr << "<init_from>" << XMLEscape(pMatName) << "-" << pTypeName << "-image</init_from>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</surface>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</newparam>" << endstr;
|
||||
|
||||
mOutput << startstr << "<newparam sid=\"" << XMLIDEncode(pMatName) << "-" << pTypeName << "-sampler\">" << endstr;
|
||||
mOutput << startstr << "<newparam sid=\"" << XMLEscape(pMatName) << "-" << pTypeName << "-sampler\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<sampler2D>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<source>" << XMLIDEncode(pMatName) << "-" << pTypeName << "-surface</source>" << endstr;
|
||||
mOutput << startstr << "<source>" << XMLEscape(pMatName) << "-" << pTypeName << "-surface</source>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</sampler2D>" << endstr;
|
||||
PopTag();
|
||||
|
|
@ -732,6 +699,11 @@ void ColladaExporter::WriteMaterials()
|
|||
materials[a].name = std::string(name.C_Str()) + to_string(materialCountWithThisName);
|
||||
}
|
||||
}
|
||||
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) {
|
||||
if( !isalnum_C( *it ) ) {
|
||||
*it = '_';
|
||||
}
|
||||
}
|
||||
|
||||
aiShadingMode shading = aiShadingMode_Flat;
|
||||
materials[a].shading_model = "phong";
|
||||
|
|
@ -796,7 +768,7 @@ void ColladaExporter::WriteMaterials()
|
|||
{
|
||||
const Material& mat = *it;
|
||||
// this is so ridiculous it must be right
|
||||
mOutput << startstr << "<effect id=\"" << XMLIDEncode(mat.name) << "-fx\" name=\"" << XMLEscape(mat.name) << "\">" << endstr;
|
||||
mOutput << startstr << "<effect id=\"" << XMLEscape(mat.name) << "-fx\" name=\"" << XMLEscape(mat.name) << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<profile_COMMON>" << endstr;
|
||||
PushTag();
|
||||
|
|
@ -847,9 +819,9 @@ void ColladaExporter::WriteMaterials()
|
|||
for( std::vector<Material>::const_iterator it = materials.begin(); it != materials.end(); ++it )
|
||||
{
|
||||
const Material& mat = *it;
|
||||
mOutput << startstr << "<material id=\"" << XMLIDEncode(mat.name) << "\" name=\"" << XMLEscape(mat.name) << "\">" << endstr;
|
||||
mOutput << startstr << "<material id=\"" << XMLEscape(mat.name) << "\" name=\"" << mat.name << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<instance_effect url=\"#" << XMLIDEncode(mat.name) << "-fx\"/>" << endstr;
|
||||
mOutput << startstr << "<instance_effect url=\"#" << XMLEscape(mat.name) << "-fx\"/>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</material>" << endstr;
|
||||
}
|
||||
|
|
@ -878,8 +850,8 @@ void ColladaExporter::WriteControllerLibrary()
|
|||
void ColladaExporter::WriteController( size_t pIndex)
|
||||
{
|
||||
const aiMesh* mesh = mScene->mMeshes[pIndex];
|
||||
const std::string idstr = mesh->mName.length == 0 ? GetMeshId(pIndex) : mesh->mName.C_Str();
|
||||
const std::string idstrEscaped = XMLIDEncode(idstr);
|
||||
const std::string idstr = GetMeshId( pIndex);
|
||||
const std::string idstrEscaped = XMLEscape(idstr);
|
||||
|
||||
if ( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
||||
return;
|
||||
|
|
@ -914,7 +886,7 @@ void ColladaExporter::WriteController( size_t pIndex)
|
|||
mOutput << startstr << "<Name_array id=\"" << idstrEscaped << "-skin-joints-array\" count=\"" << mesh->mNumBones << "\">";
|
||||
|
||||
for( size_t i = 0; i < mesh->mNumBones; ++i )
|
||||
mOutput << XMLIDEncode(mesh->mBones[i]->mName.C_Str()) << " ";
|
||||
mOutput << XMLEscape(mesh->mBones[i]->mName.C_Str()) << " ";
|
||||
|
||||
mOutput << "</Name_array>" << endstr;
|
||||
|
||||
|
|
@ -1049,15 +1021,14 @@ void ColladaExporter::WriteGeometryLibrary()
|
|||
void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||
{
|
||||
const aiMesh* mesh = mScene->mMeshes[pIndex];
|
||||
const std::string idstr = mesh->mName.length == 0 ? GetMeshId(pIndex) : mesh->mName.C_Str();
|
||||
const std::string geometryName = XMLEscape(idstr);
|
||||
const std::string geometryId = XMLIDEncode(idstr);
|
||||
const std::string idstr = GetMeshId( pIndex);
|
||||
const std::string idstrEscaped = XMLEscape(idstr);
|
||||
|
||||
if ( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
||||
return;
|
||||
|
||||
// opening tag
|
||||
mOutput << startstr << "<geometry id=\"" << geometryId << "\" name=\"" << geometryName << "\" >" << endstr;
|
||||
mOutput << startstr << "<geometry id=\"" << idstrEscaped << "\" name=\"" << idstrEscaped << "_name\" >" << endstr;
|
||||
PushTag();
|
||||
|
||||
mOutput << startstr << "<mesh>" << endstr;
|
||||
|
|
@ -1088,9 +1059,9 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
|||
|
||||
// assemble vertex structure
|
||||
// Only write input for POSITION since we will write other as shared inputs in polygon definition
|
||||
mOutput << startstr << "<vertices id=\"" << geometryId << "-vertices" << "\">" << endstr;
|
||||
mOutput << startstr << "<vertices id=\"" << idstrEscaped << "-vertices" << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<input semantic=\"POSITION\" source=\"#" << geometryId << "-positions\" />" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"POSITION\" source=\"#" << idstrEscaped << "-positions\" />" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</vertices>" << endstr;
|
||||
|
||||
|
|
@ -1108,18 +1079,18 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
|||
{
|
||||
mOutput << startstr << "<lines count=\"" << countLines << "\" material=\"defaultMaterial\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << geometryId << "-vertices\" />" << endstr;
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstrEscaped << "-vertices\" />" << endstr;
|
||||
if( mesh->HasNormals() )
|
||||
mOutput << startstr << "<input semantic=\"NORMAL\" source=\"#" << geometryId << "-normals\" />" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"NORMAL\" source=\"#" << idstrEscaped << "-normals\" />" << endstr;
|
||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
|
||||
{
|
||||
if( mesh->HasTextureCoords(static_cast<unsigned int>(a)) )
|
||||
mOutput << startstr << "<input semantic=\"TEXCOORD\" source=\"#" << geometryId << "-tex" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"TEXCOORD\" source=\"#" << idstrEscaped << "-tex" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
|
||||
}
|
||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
|
||||
{
|
||||
if( mesh->HasVertexColors(static_cast<unsigned int>(a) ) )
|
||||
mOutput << startstr << "<input semantic=\"COLOR\" source=\"#" << geometryId << "-color" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"COLOR\" source=\"#" << idstrEscaped << "-color" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<p>";
|
||||
|
|
@ -1142,18 +1113,18 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
|||
{
|
||||
mOutput << startstr << "<polylist count=\"" << countPoly << "\" material=\"defaultMaterial\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << geometryId << "-vertices\" />" << endstr;
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstrEscaped << "-vertices\" />" << endstr;
|
||||
if( mesh->HasNormals() )
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"NORMAL\" source=\"#" << geometryId << "-normals\" />" << endstr;
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"NORMAL\" source=\"#" << idstrEscaped << "-normals\" />" << endstr;
|
||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
|
||||
{
|
||||
if( mesh->HasTextureCoords(static_cast<unsigned int>(a)) )
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"TEXCOORD\" source=\"#" << geometryId << "-tex" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"TEXCOORD\" source=\"#" << idstrEscaped << "-tex" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
|
||||
}
|
||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
|
||||
{
|
||||
if( mesh->HasVertexColors(static_cast<unsigned int>(a) ) )
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"COLOR\" source=\"#" << geometryId << "-color" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"COLOR\" source=\"#" << idstrEscaped << "-color" << a << "\" " << "set=\"" << a << "\"" << " />" << endstr;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<vcount>";
|
||||
|
|
@ -1202,13 +1173,13 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy
|
|||
return;
|
||||
}
|
||||
|
||||
std::string arrayId = XMLIDEncode(pIdString) + "-array";
|
||||
std::string arrayId = pIdString + "-array";
|
||||
|
||||
mOutput << startstr << "<source id=\"" << XMLIDEncode(pIdString) << "\" name=\"" << XMLEscape(pIdString) << "\">" << endstr;
|
||||
mOutput << startstr << "<source id=\"" << XMLEscape(pIdString) << "\" name=\"" << XMLEscape(pIdString) << "\">" << endstr;
|
||||
PushTag();
|
||||
|
||||
// source array
|
||||
mOutput << startstr << "<float_array id=\"" << arrayId << "\" count=\"" << pElementCount * floatsPerElement << "\"> ";
|
||||
mOutput << startstr << "<float_array id=\"" << XMLEscape(arrayId) << "\" count=\"" << pElementCount * floatsPerElement << "\"> ";
|
||||
PushTag();
|
||||
|
||||
if( pType == FloatType_TexCoord2 )
|
||||
|
|
@ -1294,12 +1265,11 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy
|
|||
// Writes the scene library
|
||||
void ColladaExporter::WriteSceneLibrary()
|
||||
{
|
||||
const std::string sceneName = XMLEscape(mScene->mRootNode->mName.C_Str());
|
||||
const std::string sceneId = XMLIDEncode(mScene->mRootNode->mName.C_Str());
|
||||
const std::string scene_name_escaped = XMLEscape(mScene->mRootNode->mName.C_Str());
|
||||
|
||||
mOutput << startstr << "<library_visual_scenes>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<visual_scene id=\"" + sceneId + "\" name=\"" + sceneName + "\">" << endstr;
|
||||
mOutput << startstr << "<visual_scene id=\"" + scene_name_escaped + "\" name=\"" + scene_name_escaped + "\">" << endstr;
|
||||
PushTag();
|
||||
|
||||
// start recursive write at the root node
|
||||
|
|
@ -1330,7 +1300,7 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
idstr = idstr + ending;
|
||||
}
|
||||
|
||||
const std::string idstrEscaped = XMLIDEncode(idstr);
|
||||
const std::string idstrEscaped = XMLEscape(idstr);
|
||||
|
||||
mOutput << startstr << "<animation id=\"" + idstrEscaped + "\" name=\"" + animation_name_escaped + "\">" << endstr;
|
||||
PushTag();
|
||||
|
|
@ -1402,13 +1372,13 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
}
|
||||
|
||||
const std::string node_idstr = nodeAnim->mNodeName.data + std::string("_matrix-interpolation");
|
||||
std::string arrayId = XMLIDEncode(node_idstr) + "-array";
|
||||
std::string arrayId = node_idstr + "-array";
|
||||
|
||||
mOutput << startstr << "<source id=\"" << XMLIDEncode(node_idstr) << "\">" << endstr;
|
||||
mOutput << startstr << "<source id=\"" << XMLEscape(node_idstr) << "\">" << endstr;
|
||||
PushTag();
|
||||
|
||||
// source array
|
||||
mOutput << startstr << "<Name_array id=\"" << arrayId << "\" count=\"" << names.size() << "\"> ";
|
||||
mOutput << startstr << "<Name_array id=\"" << XMLEscape(arrayId) << "\" count=\"" << names.size() << "\"> ";
|
||||
for( size_t a = 0; a < names.size(); ++a ) {
|
||||
mOutput << names[a] << " ";
|
||||
}
|
||||
|
|
@ -1417,7 +1387,7 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
mOutput << startstr << "<technique_common>" << endstr;
|
||||
PushTag();
|
||||
|
||||
mOutput << startstr << "<accessor source=\"#" << arrayId << "\" count=\"" << names.size() << "\" stride=\"" << 1 << "\">" << endstr;
|
||||
mOutput << startstr << "<accessor source=\"#" << XMLEscape(arrayId) << "\" count=\"" << names.size() << "\" stride=\"" << 1 << "\">" << endstr;
|
||||
PushTag();
|
||||
|
||||
mOutput << startstr << "<param name=\"INTERPOLATION\" type=\"name\"></param>" << endstr;
|
||||
|
|
@ -1439,12 +1409,12 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
{
|
||||
// samplers
|
||||
const std::string node_idstr = nodeAnim->mNodeName.data + std::string("_matrix-sampler");
|
||||
mOutput << startstr << "<sampler id=\"" << XMLIDEncode(node_idstr) << "\">" << endstr;
|
||||
mOutput << startstr << "<sampler id=\"" << XMLEscape(node_idstr) << "\">" << endstr;
|
||||
PushTag();
|
||||
|
||||
mOutput << startstr << "<input semantic=\"INPUT\" source=\"#" << XMLIDEncode( nodeAnim->mNodeName.data + std::string("_matrix-input") ) << "\"/>" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"OUTPUT\" source=\"#" << XMLIDEncode( nodeAnim->mNodeName.data + std::string("_matrix-output") ) << "\"/>" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"INTERPOLATION\" source=\"#" << XMLIDEncode( nodeAnim->mNodeName.data + std::string("_matrix-interpolation") ) << "\"/>" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"INPUT\" source=\"#" << XMLEscape( nodeAnim->mNodeName.data + std::string("_matrix-input") ) << "\"/>" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"OUTPUT\" source=\"#" << XMLEscape( nodeAnim->mNodeName.data + std::string("_matrix-output") ) << "\"/>" << endstr;
|
||||
mOutput << startstr << "<input semantic=\"INTERPOLATION\" source=\"#" << XMLEscape( nodeAnim->mNodeName.data + std::string("_matrix-interpolation") ) << "\"/>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</sampler>" << endstr;
|
||||
|
|
@ -1456,7 +1426,7 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
|
||||
{
|
||||
// channels
|
||||
mOutput << startstr << "<channel source=\"#" << XMLIDEncode( nodeAnim->mNodeName.data + std::string("_matrix-sampler") ) << "\" target=\"" << XMLIDEncode(nodeAnim->mNodeName.data) << "/matrix\"/>" << endstr;
|
||||
mOutput << startstr << "<channel source=\"#" << XMLEscape( nodeAnim->mNodeName.data + std::string("_matrix-sampler") ) << "\" target=\"" << XMLEscape(nodeAnim->mNodeName.data) << "/matrix\"/>" << endstr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1467,6 +1437,8 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex)
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
void ColladaExporter::WriteAnimationsLibrary()
|
||||
{
|
||||
const std::string scene_name_escaped = XMLEscape(mScene->mRootNode->mName.C_Str());
|
||||
|
||||
if ( mScene->mNumAnimations > 0 ) {
|
||||
mOutput << startstr << "<library_animations>" << endstr;
|
||||
PushTag();
|
||||
|
|
@ -1574,17 +1546,16 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
|
|||
}
|
||||
}
|
||||
|
||||
const std::string node_id = XMLIDEncode(pNode->mName.data);
|
||||
const std::string node_name = XMLEscape(pNode->mName.data);
|
||||
const std::string node_name_escaped = XMLEscape(pNode->mName.data);
|
||||
mOutput << startstr << "<node ";
|
||||
if(is_skeleton_root) {
|
||||
mOutput << "id=\"" << node_id << "\" " << (is_joint ? "sid=\"" + node_id +"\"" : "") ; // For now, only support one skeleton in a scene.
|
||||
mFoundSkeletonRootNodeID = node_id;
|
||||
mOutput << "id=\"" << node_name_escaped << "\" " << (is_joint ? "sid=\"" + node_name_escaped +"\"" : "") ; // For now, only support one skeleton in a scene.
|
||||
mFoundSkeletonRootNodeID = node_name_escaped;
|
||||
} else {
|
||||
mOutput << "id=\"" << node_id << "\" " << (is_joint ? "sid=\"" + node_id +"\"": "") ;
|
||||
mOutput << "id=\"" << node_name_escaped << "\" " << (is_joint ? "sid=\"" + node_name_escaped +"\"": "") ;
|
||||
}
|
||||
|
||||
mOutput << " name=\"" << node_name
|
||||
mOutput << " name=\"" << node_name_escaped
|
||||
<< "\" type=\"" << node_type
|
||||
<< "\">" << endstr;
|
||||
PushTag();
|
||||
|
|
@ -1623,14 +1594,14 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
|
|||
//check if it is a camera node
|
||||
for(size_t i=0; i<mScene->mNumCameras; i++){
|
||||
if(mScene->mCameras[i]->mName == pNode->mName){
|
||||
mOutput << startstr <<"<instance_camera url=\"#" << node_id << "-camera\"/>" << endstr;
|
||||
mOutput << startstr <<"<instance_camera url=\"#" << node_name_escaped << "-camera\"/>" << endstr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//check if it is a light node
|
||||
for(size_t i=0; i<mScene->mNumLights; i++){
|
||||
if(mScene->mLights[i]->mName == pNode->mName){
|
||||
mOutput << startstr <<"<instance_light url=\"#" << node_id << "-light\"/>" << endstr;
|
||||
mOutput << startstr <<"<instance_light url=\"#" << node_name_escaped << "-light\"/>" << endstr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1644,17 +1615,15 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
|
|||
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
||||
continue;
|
||||
|
||||
const std::string meshName = mesh->mName.length == 0 ? GetMeshId(pNode->mMeshes[a]) : mesh->mName.C_Str();
|
||||
|
||||
if( mesh->mNumBones == 0 )
|
||||
{
|
||||
mOutput << startstr << "<instance_geometry url=\"#" << XMLIDEncode(meshName) << "\">" << endstr;
|
||||
mOutput << startstr << "<instance_geometry url=\"#" << XMLEscape(GetMeshId( pNode->mMeshes[a])) << "\">" << endstr;
|
||||
PushTag();
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutput << startstr
|
||||
<< "<instance_controller url=\"#" << XMLIDEncode(meshName) << "-skin\">"
|
||||
<< "<instance_controller url=\"#" << XMLEscape(GetMeshId( pNode->mMeshes[a])) << "-skin\">"
|
||||
<< endstr;
|
||||
PushTag();
|
||||
|
||||
|
|
@ -1662,7 +1631,7 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
|
|||
// use the first bone to find skeleton root
|
||||
const aiNode * skeletonRootBoneNode = findSkeletonRootNode( pScene, mesh );
|
||||
if ( skeletonRootBoneNode ) {
|
||||
mFoundSkeletonRootNodeID = XMLIDEncode( skeletonRootBoneNode->mName.C_Str() );
|
||||
mFoundSkeletonRootNodeID = XMLEscape( skeletonRootBoneNode->mName.C_Str() );
|
||||
}
|
||||
mOutput << startstr << "<skeleton>#" << mFoundSkeletonRootNodeID << "</skeleton>" << endstr;
|
||||
}
|
||||
|
|
@ -1670,7 +1639,7 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
|
|||
PushTag();
|
||||
mOutput << startstr << "<technique_common>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<instance_material symbol=\"defaultMaterial\" target=\"#" << XMLIDEncode(materials[mesh->mMaterialIndex].name) << "\">" << endstr;
|
||||
mOutput << startstr << "<instance_material symbol=\"defaultMaterial\" target=\"#" << XMLEscape(materials[mesh->mMaterialIndex].name) << "\">" << endstr;
|
||||
PushTag();
|
||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -1,107 +0,0 @@
|
|||
/** Helper structures for the Collada loader */
|
||||
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "ColladaHelper.h"
|
||||
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Collada {
|
||||
|
||||
const MetaKeyPairVector MakeColladaAssimpMetaKeys() {
|
||||
MetaKeyPairVector result;
|
||||
result.emplace_back("authoring_tool", AI_METADATA_SOURCE_GENERATOR);
|
||||
result.emplace_back("copyright", AI_METADATA_SOURCE_COPYRIGHT);
|
||||
return result;
|
||||
};
|
||||
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeys() {
|
||||
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
|
||||
return result;
|
||||
}
|
||||
|
||||
const MetaKeyPairVector MakeColladaAssimpMetaKeysCamelCase() {
|
||||
MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
|
||||
for (auto &val : result)
|
||||
{
|
||||
ToCamelCase(val.first);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase()
|
||||
{
|
||||
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeysCamelCase();
|
||||
return result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert underscore_separated to CamelCase: "authoring_tool" becomes "AuthoringTool"
|
||||
void ToCamelCase(std::string &text)
|
||||
{
|
||||
if (text.empty())
|
||||
return;
|
||||
// Capitalise first character
|
||||
auto it = text.begin();
|
||||
(*it) = ToUpper(*it);
|
||||
++it;
|
||||
for (/*started above*/ ; it != text.end(); /*iterated below*/)
|
||||
{
|
||||
if ((*it) == '_')
|
||||
{
|
||||
it = text.erase(it);
|
||||
if (it != text.end())
|
||||
(*it) = ToUpper(*it);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make lower case
|
||||
(*it) = ToLower(*it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Collada
|
||||
} // namespace Assimp
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <assimp/light.h>
|
||||
#include <assimp/mesh.h>
|
||||
|
|
@ -105,17 +104,6 @@ enum MorphMethod
|
|||
Relative
|
||||
};
|
||||
|
||||
/** Common metadata keys as <Collada, Assimp> */
|
||||
typedef std::pair<std::string, std::string> MetaKeyPair;
|
||||
typedef std::vector<MetaKeyPair> MetaKeyPairVector;
|
||||
|
||||
// Collada as lower_case (native)
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeys();
|
||||
// Collada as CamelCase (used by Assimp for consistency)
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase();
|
||||
|
||||
/** Convert underscore_separated to CamelCase "authoring_tool" becomes "AuthoringTool" */
|
||||
void ToCamelCase(std::string &text);
|
||||
|
||||
/** Contains all data for one of the different transformation types */
|
||||
struct Transform
|
||||
|
|
@ -595,7 +583,7 @@ struct Image
|
|||
/** Embedded image data */
|
||||
std::vector<uint8_t> mImageData;
|
||||
|
||||
/** File format hint of embedded image data */
|
||||
/** File format hint ofembedded image data */
|
||||
std::string mEmbeddedFormat;
|
||||
};
|
||||
|
||||
|
|
@ -659,37 +647,23 @@ struct Animation
|
|||
|
||||
void CombineSingleChannelAnimationsRecursively(Animation *pParent)
|
||||
{
|
||||
std::set<std::string> childrenTargets;
|
||||
bool childrenAnimationsHaveDifferentChannels = true;
|
||||
|
||||
for (std::vector<Animation*>::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();)
|
||||
{
|
||||
Animation *anim = *it;
|
||||
|
||||
CombineSingleChannelAnimationsRecursively(anim);
|
||||
|
||||
if (childrenAnimationsHaveDifferentChannels && anim->mChannels.size() == 1 &&
|
||||
childrenTargets.find(anim->mChannels[0].mTarget) == childrenTargets.end()) {
|
||||
childrenTargets.insert(anim->mChannels[0].mTarget);
|
||||
} else {
|
||||
childrenAnimationsHaveDifferentChannels = false;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
// We only want to combine animations if they have different channels
|
||||
if (childrenAnimationsHaveDifferentChannels)
|
||||
{
|
||||
for (std::vector<Animation*>::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();)
|
||||
if (anim->mChannels.size() == 1)
|
||||
{
|
||||
Animation *anim = *it;
|
||||
|
||||
pParent->mChannels.push_back(anim->mChannels[0]);
|
||||
|
||||
it = pParent->mSubAnims.erase(it);
|
||||
|
||||
delete anim;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -963,38 +963,18 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
|
|||
|
||||
// catch special case: many animations with the same length, each affecting only a single node.
|
||||
// we need to unite all those single-node-anims to a proper combined animation
|
||||
for(size_t a = 0; a < mAnims.size(); ++a) {
|
||||
for( size_t a = 0; a < mAnims.size(); ++a) {
|
||||
aiAnimation* templateAnim = mAnims[a];
|
||||
|
||||
if (templateAnim->mNumChannels == 1) {
|
||||
if( templateAnim->mNumChannels == 1) {
|
||||
// search for other single-channel-anims with the same duration
|
||||
std::vector<size_t> collectedAnimIndices;
|
||||
for( size_t b = a+1; b < mAnims.size(); ++b) {
|
||||
aiAnimation* other = mAnims[b];
|
||||
if (other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration &&
|
||||
other->mTicksPerSecond == templateAnim->mTicksPerSecond)
|
||||
collectedAnimIndices.push_back(b);
|
||||
collectedAnimIndices.push_back(b);
|
||||
}
|
||||
|
||||
// We only want to combine the animations if they have different channels
|
||||
std::set<std::string> animTargets;
|
||||
animTargets.insert(templateAnim->mChannels[0]->mNodeName.C_Str());
|
||||
bool collectedAnimationsHaveDifferentChannels = true;
|
||||
for (size_t b = 0; b < collectedAnimIndices.size(); ++b)
|
||||
{
|
||||
aiAnimation* srcAnimation = mAnims[collectedAnimIndices[b]];
|
||||
std::string channelName = std::string(srcAnimation->mChannels[0]->mNodeName.C_Str());
|
||||
if (animTargets.find(channelName) == animTargets.end()) {
|
||||
animTargets.insert(channelName);
|
||||
} else {
|
||||
collectedAnimationsHaveDifferentChannels = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!collectedAnimationsHaveDifferentChannels)
|
||||
continue;
|
||||
|
||||
// if there are other animations which fit the template anim, combine all channels into a single anim
|
||||
if (!collectedAnimIndices.empty())
|
||||
{
|
||||
|
|
@ -1755,7 +1735,6 @@ void ColladaLoader::BuildMaterials(ColladaParser& pParser, aiScene* /*pScene*/)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Resolves the texture name for the given effect texture entry
|
||||
// and loads the texture data
|
||||
aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser& pParser,
|
||||
const Collada::Effect& pEffect, const std::string& pName)
|
||||
{
|
||||
|
|
@ -1783,7 +1762,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser& pParse
|
|||
|
||||
//set default texture file name
|
||||
result.Set(name + ".jpg");
|
||||
ColladaParser::UriDecodePath(result);
|
||||
ConvertPath(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -1802,7 +1781,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser& pParse
|
|||
|
||||
|
||||
// setup format hint
|
||||
if (imIt->second.mEmbeddedFormat.length() >= HINTMAXTEXTURELEN) {
|
||||
if (imIt->second.mEmbeddedFormat.length() > 3) {
|
||||
ASSIMP_LOG_WARN("Collada: texture format hint is too long, truncating to 3 characters");
|
||||
}
|
||||
strncpy(tex->achFormatHint, imIt->second.mEmbeddedFormat.c_str(), 3);
|
||||
|
|
@ -1823,10 +1802,61 @@ aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser& pParse
|
|||
}
|
||||
|
||||
result.Set(imIt->second.mFileName);
|
||||
ConvertPath(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert a path read from a collada file to the usual representation
|
||||
void ColladaLoader::ConvertPath(aiString& ss)
|
||||
{
|
||||
// TODO: collada spec, p 22. Handle URI correctly.
|
||||
// For the moment we're just stripping the file:// away to make it work.
|
||||
// Windows doesn't seem to be able to find stuff like
|
||||
// 'file://..\LWO\LWO2\MappingModes\earthSpherical.jpg'
|
||||
if (0 == strncmp(ss.data, "file://", 7))
|
||||
{
|
||||
ss.length -= 7;
|
||||
memmove(ss.data, ss.data + 7, ss.length);
|
||||
ss.data[ss.length] = '\0';
|
||||
}
|
||||
|
||||
// Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes...
|
||||
// I need to filter it without destroying linux paths starting with "/somewhere"
|
||||
#if defined( _MSC_VER )
|
||||
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
||||
#else
|
||||
if (ss.data[0] == '/' && isalpha(ss.data[1]) && ss.data[2] == ':') {
|
||||
#endif
|
||||
--ss.length;
|
||||
::memmove(ss.data, ss.data + 1, ss.length);
|
||||
ss.data[ss.length] = 0;
|
||||
}
|
||||
|
||||
// find and convert all %xy special chars
|
||||
char* out = ss.data;
|
||||
for (const char* it = ss.data; it != ss.data + ss.length; /**/)
|
||||
{
|
||||
if (*it == '%' && (it + 3) < ss.data + ss.length)
|
||||
{
|
||||
// separate the number to avoid dragging in chars from behind into the parsing
|
||||
char mychar[3] = { it[1], it[2], 0 };
|
||||
size_t nbr = strtoul16(mychar);
|
||||
it += 3;
|
||||
*out++ = (char)(nbr & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
*out++ = *it++;
|
||||
}
|
||||
}
|
||||
|
||||
// adjust length and terminator of the shortened string
|
||||
*out = 0;
|
||||
ss.length = (ptrdiff_t)(out - ss.data);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads a float value from an accessor and its data array.
|
||||
ai_real ColladaLoader::ReadFloat(const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -94,7 +94,7 @@ public:
|
|||
public:
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
* See BaseImporter::CanRead() for details. */
|
||||
bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
|
||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
|
||||
|
||||
protected:
|
||||
/** Return importer meta information.
|
||||
|
|
@ -184,6 +184,9 @@ protected:
|
|||
aiString FindFilenameForEffectTexture( const ColladaParser& pParser,
|
||||
const Collada::Effect& pEffect, const std::string& pName);
|
||||
|
||||
/** Converts a path read from a collada file to the usual representation */
|
||||
void ConvertPath( aiString& ss);
|
||||
|
||||
/** Reads a float value from an accessor and its data array.
|
||||
* @param pAccessor The accessor to use for reading
|
||||
* @param pData The data array to read from
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -50,7 +50,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include "ColladaParser.h"
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
|
@ -184,75 +183,18 @@ std::string ColladaParser::ReadZaeManifest(ZipArchiveIOSystem &zip_archive) {
|
|||
if (filepath == nullptr)
|
||||
return std::string();
|
||||
|
||||
aiString ai_str(filepath);
|
||||
UriDecodePath(ai_str);
|
||||
|
||||
return std::string(ai_str.C_Str());
|
||||
return std::string(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert a path read from a collada file to the usual representation
|
||||
void ColladaParser::UriDecodePath(aiString& ss)
|
||||
{
|
||||
// TODO: collada spec, p 22. Handle URI correctly.
|
||||
// For the moment we're just stripping the file:// away to make it work.
|
||||
// Windows doesn't seem to be able to find stuff like
|
||||
// 'file://..\LWO\LWO2\MappingModes\earthSpherical.jpg'
|
||||
if (0 == strncmp(ss.data, "file://", 7))
|
||||
{
|
||||
ss.length -= 7;
|
||||
memmove(ss.data, ss.data + 7, ss.length);
|
||||
ss.data[ss.length] = '\0';
|
||||
}
|
||||
|
||||
// Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes...
|
||||
// I need to filter it without destroying linux paths starting with "/somewhere"
|
||||
#if defined( _MSC_VER )
|
||||
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
||||
#else
|
||||
if (ss.data[0] == '/' && isalpha(ss.data[1]) && ss.data[2] == ':') {
|
||||
#endif
|
||||
--ss.length;
|
||||
::memmove(ss.data, ss.data + 1, ss.length);
|
||||
ss.data[ss.length] = 0;
|
||||
}
|
||||
|
||||
// find and convert all %xy special chars
|
||||
char* out = ss.data;
|
||||
for (const char* it = ss.data; it != ss.data + ss.length; /**/)
|
||||
{
|
||||
if (*it == '%' && (it + 3) < ss.data + ss.length)
|
||||
{
|
||||
// separate the number to avoid dragging in chars from behind into the parsing
|
||||
char mychar[3] = { it[1], it[2], 0 };
|
||||
size_t nbr = strtoul16(mychar);
|
||||
it += 3;
|
||||
*out++ = (char)(nbr & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
*out++ = *it++;
|
||||
}
|
||||
}
|
||||
|
||||
// adjust length and terminator of the shortened string
|
||||
*out = 0;
|
||||
ai_assert(out > ss.data);
|
||||
ss.length = static_cast<ai_uint32>(out - ss.data);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Read bool from text contents of current element
|
||||
bool ColladaParser::ReadBoolFromTextContent()
|
||||
{
|
||||
const char* cur = GetTextContent();
|
||||
if ( nullptr == cur) {
|
||||
return false;
|
||||
}
|
||||
return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur);
|
||||
}
|
||||
|
||||
|
|
@ -261,9 +203,6 @@ bool ColladaParser::ReadBoolFromTextContent()
|
|||
ai_real ColladaParser::ReadFloatFromTextContent()
|
||||
{
|
||||
const char* cur = GetTextContent();
|
||||
if ( nullptr == cur ) {
|
||||
return 0.0;
|
||||
}
|
||||
return fast_atof(cur);
|
||||
}
|
||||
|
||||
|
|
@ -283,11 +222,6 @@ void ColladaParser::ReadContents()
|
|||
if (attrib != -1) {
|
||||
const char* version = mReader->getAttributeValue(attrib);
|
||||
|
||||
// Store declared format version string
|
||||
aiString v;
|
||||
v.Set(version);
|
||||
mAssetMetaData.emplace(AI_METADATA_SOURCE_FORMAT_VERSION, v );
|
||||
|
||||
if (!::strncmp(version, "1.5", 3)) {
|
||||
mFormat = FV_1_5_n;
|
||||
ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n");
|
||||
|
|
@ -446,39 +380,23 @@ void ColladaParser::ReadContributorInfo()
|
|||
}
|
||||
}
|
||||
|
||||
static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVector &key_renaming, size_t &found_index) {
|
||||
for (size_t i = 0; i < key_renaming.size(); ++i) {
|
||||
if (key_renaming[i].first == collada_key) {
|
||||
found_index = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
found_index = std::numeric_limits<size_t>::max();
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads a single string metadata item
|
||||
void ColladaParser::ReadMetaDataItem(StringMetaData &metadata) {
|
||||
const Collada::MetaKeyPairVector &key_renaming = GetColladaAssimpMetaKeysCamelCase();
|
||||
// Metadata such as created, keywords, subject etc
|
||||
const char *key_char = mReader->getNodeName();
|
||||
if (key_char != nullptr) {
|
||||
void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
||||
{
|
||||
// Metadata such as created, keywords, subject etc
|
||||
const char* key_char = mReader->getNodeName();
|
||||
if (key_char != nullptr)
|
||||
{
|
||||
const std::string key_str(key_char);
|
||||
const char *value_char = TestTextContent();
|
||||
if (value_char != nullptr) {
|
||||
const char* value_char = TestTextContent();
|
||||
if (value_char != nullptr)
|
||||
{
|
||||
std::string camel_key_str = key_str;
|
||||
ToCamelCase(camel_key_str);
|
||||
aiString aistr;
|
||||
aistr.Set(value_char);
|
||||
|
||||
std::string camel_key_str(key_str);
|
||||
ToCamelCase(camel_key_str);
|
||||
|
||||
size_t found_index;
|
||||
if (FindCommonKey(camel_key_str, key_renaming, found_index)) {
|
||||
metadata.emplace(key_renaming[found_index].second, aistr);
|
||||
} else {
|
||||
metadata.emplace(camel_key_str, aistr);
|
||||
}
|
||||
aistr.Set(value_char);
|
||||
metadata.emplace(camel_key_str, aistr);
|
||||
}
|
||||
TestClosing(key_str.c_str());
|
||||
}
|
||||
|
|
@ -486,6 +404,27 @@ void ColladaParser::ReadMetaDataItem(StringMetaData &metadata) {
|
|||
SkipElement();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert underscore_seperated to CamelCase: "authoring_tool" becomes "AuthoringTool"
|
||||
void ColladaParser::ToCamelCase(std::string &text)
|
||||
{
|
||||
if (text.empty())
|
||||
return;
|
||||
// Capitalise first character
|
||||
text[0] = ToUpper(text[0]);
|
||||
for (auto it = text.begin(); it != text.end(); /*iterated below*/)
|
||||
{
|
||||
if ((*it) == '_')
|
||||
{
|
||||
it = text.erase(it);
|
||||
if (it != text.end())
|
||||
(*it) = ToUpper(*it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads the animation clips
|
||||
void ColladaParser::ReadAnimationClipLibrary()
|
||||
|
|
@ -1181,12 +1120,7 @@ void ColladaParser::ReadImage(Collada::Image& pImage)
|
|||
if (!mReader->isEmptyElement()) {
|
||||
// element content is filename - hopefully
|
||||
const char* sz = TestTextContent();
|
||||
if (sz)
|
||||
{
|
||||
aiString filepath(sz);
|
||||
UriDecodePath(filepath);
|
||||
pImage.mFileName = filepath.C_Str();
|
||||
}
|
||||
if (sz)pImage.mFileName = sz;
|
||||
TestClosing("init_from");
|
||||
}
|
||||
if (!pImage.mFileName.length()) {
|
||||
|
|
@ -1219,12 +1153,7 @@ void ColladaParser::ReadImage(Collada::Image& pImage)
|
|||
{
|
||||
// element content is filename - hopefully
|
||||
const char* sz = TestTextContent();
|
||||
if (sz)
|
||||
{
|
||||
aiString filepath(sz);
|
||||
UriDecodePath(filepath);
|
||||
pImage.mFileName = filepath.C_Str();
|
||||
}
|
||||
if (sz)pImage.mFileName = sz;
|
||||
TestClosing("ref");
|
||||
}
|
||||
else if (IsElement("hex") && !pImage.mFileName.length())
|
||||
|
|
@ -3127,7 +3056,7 @@ void ColladaParser::ReadMaterialVertexInputBinding(Collada::SemanticMappingTable
|
|||
}
|
||||
}
|
||||
|
||||
void ColladaParser::ReadEmbeddedTextures(ZipArchiveIOSystem& zip_archive)
|
||||
void Assimp::ColladaParser::ReadEmbeddedTextures(ZipArchiveIOSystem& zip_archive)
|
||||
{
|
||||
// Attempt to load any undefined Collada::Image in ImageLibrary
|
||||
for (ImageLibrary::iterator it = mImageLibrary.begin(); it != mImageLibrary.end(); ++it) {
|
||||
|
|
@ -3241,12 +3170,13 @@ void ColladaParser::ReadScene()
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Aborts the file reading with an exception
|
||||
AI_WONT_RETURN void ColladaParser::ThrowException(const std::string& pError) const {
|
||||
AI_WONT_RETURN void ColladaParser::ThrowException(const std::string& pError) const
|
||||
{
|
||||
throw DeadlyImportError(format() << "Collada: " << mFileName << " - " << pError);
|
||||
}
|
||||
|
||||
void ColladaParser::ReportWarning(const char* msg, ...) {
|
||||
ai_assert(nullptr != msg);
|
||||
void ColladaParser::ReportWarning(const char* msg, ...)
|
||||
{
|
||||
ai_assert(NULL != msg);
|
||||
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
|
|
@ -3261,11 +3191,11 @@ void ColladaParser::ReportWarning(const char* msg, ...) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Skips all data until the end node of the current element
|
||||
void ColladaParser::SkipElement() {
|
||||
void ColladaParser::SkipElement()
|
||||
{
|
||||
// nothing to skip if it's an <element />
|
||||
if (mReader->isEmptyElement()) {
|
||||
if (mReader->isEmptyElement())
|
||||
return;
|
||||
}
|
||||
|
||||
// reroute
|
||||
SkipElement(mReader->getNodeName());
|
||||
|
|
@ -3273,75 +3203,63 @@ void ColladaParser::SkipElement() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Skips all data until the end node of the given element
|
||||
void ColladaParser::SkipElement(const char* pElement) {
|
||||
void ColladaParser::SkipElement(const char* pElement)
|
||||
{
|
||||
// copy the current node's name because it'a pointer to the reader's internal buffer,
|
||||
// which is going to change with the upcoming parsing
|
||||
std::string element = pElement;
|
||||
while (mReader->read()) {
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
|
||||
if (mReader->getNodeName() == element) {
|
||||
while (mReader->read())
|
||||
{
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END)
|
||||
if (mReader->getNodeName() == element)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for an opening element of the given name, throws an exception if not found
|
||||
void ColladaParser::TestOpening(const char* pName) {
|
||||
void ColladaParser::TestOpening(const char* pName)
|
||||
{
|
||||
// read element start
|
||||
if (!mReader->read()) {
|
||||
if (!mReader->read())
|
||||
ThrowException(format() << "Unexpected end of file while beginning of <" << pName << "> element.");
|
||||
}
|
||||
// whitespace in front is ok, just read again if found
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT) {
|
||||
if (!mReader->read()) {
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT)
|
||||
if (!mReader->read())
|
||||
ThrowException(format() << "Unexpected end of file while reading beginning of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT || strcmp(mReader->getNodeName(), pName) != 0) {
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT || strcmp(mReader->getNodeName(), pName) != 0)
|
||||
ThrowException(format() << "Expected start of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for the closing tag of the given element, throws an exception if not found
|
||||
void ColladaParser::TestClosing(const char* pName) {
|
||||
// check if we have an empty (self-closing) element
|
||||
if (mReader->isEmptyElement()) {
|
||||
return;
|
||||
}
|
||||
|
||||
void ColladaParser::TestClosing(const char* pName)
|
||||
{
|
||||
// check if we're already on the closing tag and return right away
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END && strcmp(mReader->getNodeName(), pName) == 0) {
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END && strcmp(mReader->getNodeName(), pName) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
// if not, read some more
|
||||
if (!mReader->read()) {
|
||||
if (!mReader->read())
|
||||
ThrowException(format() << "Unexpected end of file while reading end of <" << pName << "> element.");
|
||||
}
|
||||
// whitespace in front is ok, just read again if found
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT) {
|
||||
if (!mReader->read()) {
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT)
|
||||
if (!mReader->read())
|
||||
ThrowException(format() << "Unexpected end of file while reading end of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// but this has the be the closing tag, or we're lost
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT_END || strcmp(mReader->getNodeName(), pName) != 0) {
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT_END || strcmp(mReader->getNodeName(), pName) != 0)
|
||||
ThrowException(format() << "Expected end of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns the index of the named attribute or -1 if not found. Does not throw, therefore useful for optional attributes
|
||||
int ColladaParser::GetAttribute(const char* pAttr) const {
|
||||
int ColladaParser::GetAttribute(const char* pAttr) const
|
||||
{
|
||||
int index = TestAttribute(pAttr);
|
||||
if (index != -1) {
|
||||
if (index != -1)
|
||||
return index;
|
||||
}
|
||||
|
||||
// attribute not found -> throw an exception
|
||||
ThrowException(format() << "Expected attribute \"" << pAttr << "\" for element <" << mReader->getNodeName() << ">.");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -66,15 +66,12 @@ namespace Assimp
|
|||
{
|
||||
friend class ColladaLoader;
|
||||
|
||||
/** Converts a path read from a collada file to the usual representation */
|
||||
static void UriDecodePath(aiString& ss);
|
||||
|
||||
protected:
|
||||
/** Map for generic metadata as aiString */
|
||||
typedef std::map<std::string, aiString> StringMetaData;
|
||||
|
||||
/** Constructor from XML file */
|
||||
ColladaParser(IOSystem* pIOHandler, const std::string& pFile);
|
||||
ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
|
||||
|
||||
/** Destructor */
|
||||
~ColladaParser();
|
||||
|
|
@ -94,9 +91,12 @@ namespace Assimp
|
|||
/** Reads contributor information such as author and legal blah */
|
||||
void ReadContributorInfo();
|
||||
|
||||
/** Reads generic metadata into provided map and renames keys for Assimp */
|
||||
/** Reads generic metadata into provided map */
|
||||
void ReadMetaDataItem(StringMetaData &metadata);
|
||||
|
||||
/** Convert underscore_seperated to CamelCase "authoring_tool" becomes "AuthoringTool" */
|
||||
static void ToCamelCase(std::string &text);
|
||||
|
||||
/** Reads the animation library */
|
||||
void ReadAnimationLibrary();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -67,20 +67,7 @@ using namespace Assimp;
|
|||
// Constructor to be privately used by Importer
|
||||
BaseImporter::BaseImporter() AI_NO_EXCEPT
|
||||
: m_progress() {
|
||||
/**
|
||||
* Assimp Importer
|
||||
* unit conversions available
|
||||
* if you need another measurment unit add it below.
|
||||
* it's currently defined in assimp that we prefer meters.
|
||||
*
|
||||
* NOTE: Initialised here rather than in the header file
|
||||
* to workaround a VS2013 bug with brace initialisers
|
||||
* */
|
||||
importerUnits[ImporterUnits::M] = 1.0;
|
||||
importerUnits[ImporterUnits::CM] = 0.01;
|
||||
importerUnits[ImporterUnits::MM] = 0.001;
|
||||
importerUnits[ImporterUnits::INCHES] = 0.0254;
|
||||
importerUnits[ImporterUnits::FEET] = 0.3048;
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -191,7 +178,7 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions) {
|
|||
}
|
||||
|
||||
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
||||
if (pStream) {
|
||||
if (pStream.get() ) {
|
||||
// read 200 characters from the file
|
||||
std::unique_ptr<char[]> _buffer (new char[searchBytes+1 /* for the '\0' */]);
|
||||
char *buffer( _buffer.get() );
|
||||
|
|
@ -283,6 +270,7 @@ std::string BaseImporter::GetExtension( const std::string& file ) {
|
|||
return "";
|
||||
}
|
||||
|
||||
|
||||
// thanks to Andy Maloney for the hint
|
||||
std::string ret = file.substr( pos + 1 );
|
||||
std::transform( ret.begin(), ret.end(), ret.begin(), ToLower<char>);
|
||||
|
|
@ -308,7 +296,7 @@ std::string BaseImporter::GetExtension( const std::string& file ) {
|
|||
};
|
||||
magic = reinterpret_cast<const char*>(_magic);
|
||||
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
||||
if (pStream) {
|
||||
if (pStream.get() ) {
|
||||
|
||||
// skip to offset
|
||||
pStream->Seek(offset,aiOrigin_SET);
|
||||
|
|
@ -602,7 +590,7 @@ unsigned int BatchLoader::AddLoadRequest(const std::string& file,
|
|||
}
|
||||
|
||||
// no, we don't have it. So add it to the queue ...
|
||||
m_data->requests.emplace_back(file, steps, map, m_data->next_id);
|
||||
m_data->requests.push_back(LoadRequest(file,steps,map, m_data->next_id));
|
||||
return m_data->next_id++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -41,43 +43,45 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of BaseProcess */
|
||||
|
||||
#include "BaseProcess.h"
|
||||
#include "Importer.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/scene.h>
|
||||
#include "BaseProcess.h"
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include "Importer.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
BaseProcess::BaseProcess() AI_NO_EXCEPT
|
||||
: shared(),
|
||||
progress() {
|
||||
// empty
|
||||
: shared()
|
||||
, progress()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
BaseProcess::~BaseProcess() {
|
||||
BaseProcess::~BaseProcess()
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BaseProcess::ExecuteOnScene(Importer *pImp) {
|
||||
ai_assert( nullptr != pImp );
|
||||
ai_assert( nullptr != pImp->Pimpl()->mScene);
|
||||
void BaseProcess::ExecuteOnScene( Importer* pImp)
|
||||
{
|
||||
ai_assert(NULL != pImp && NULL != pImp->Pimpl()->mScene);
|
||||
|
||||
progress = pImp->GetProgressHandler();
|
||||
ai_assert(nullptr != progress);
|
||||
ai_assert(progress);
|
||||
|
||||
SetupProperties(pImp);
|
||||
SetupProperties( pImp );
|
||||
|
||||
// catch exceptions thrown inside the PostProcess-Step
|
||||
try {
|
||||
try
|
||||
{
|
||||
Execute(pImp->Pimpl()->mScene);
|
||||
|
||||
} catch (const std::exception &err) {
|
||||
} catch( const std::exception& err ) {
|
||||
|
||||
// extract error description
|
||||
pImp->Pimpl()->mErrorString = err.what();
|
||||
|
|
@ -90,11 +94,14 @@ void BaseProcess::ExecuteOnScene(Importer *pImp) {
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BaseProcess::SetupProperties(const Importer * /*pImp*/) {
|
||||
void BaseProcess::SetupProperties(const Importer* /*pImp*/)
|
||||
{
|
||||
// the default implementation does nothing
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool BaseProcess::RequireVerboseFormat() const {
|
||||
bool BaseProcess::RequireVerboseFormat() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -43,13 +44,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_BASEPROCESS_H
|
||||
#define INCLUDED_AI_BASEPROCESS_H
|
||||
|
||||
#include <assimp/GenericProperty.h>
|
||||
|
||||
#include <map>
|
||||
#include <assimp/GenericProperty.h>
|
||||
|
||||
struct aiScene;
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
class Importer;
|
||||
|
||||
|
|
@ -60,50 +60,64 @@ class Importer;
|
|||
* to provide additional information to other steps. This is primarily
|
||||
* intended for cross-step optimizations.
|
||||
*/
|
||||
class SharedPostProcessInfo {
|
||||
class SharedPostProcessInfo
|
||||
{
|
||||
public:
|
||||
struct Base {
|
||||
virtual ~Base() {}
|
||||
|
||||
struct Base
|
||||
{
|
||||
virtual ~Base()
|
||||
{}
|
||||
};
|
||||
|
||||
//! Represents data that is allocated on the heap, thus needs to be deleted
|
||||
template <typename T>
|
||||
struct THeapData : public Base {
|
||||
explicit THeapData(T *in) :
|
||||
data(in) {}
|
||||
struct THeapData : public Base
|
||||
{
|
||||
explicit THeapData(T* in)
|
||||
: data (in)
|
||||
{}
|
||||
|
||||
~THeapData() {
|
||||
~THeapData()
|
||||
{
|
||||
delete data;
|
||||
}
|
||||
T *data;
|
||||
T* data;
|
||||
};
|
||||
|
||||
//! Represents static, by-value data not allocated on the heap
|
||||
template <typename T>
|
||||
struct TStaticData : public Base {
|
||||
explicit TStaticData(T in) :
|
||||
data(in) {}
|
||||
struct TStaticData : public Base
|
||||
{
|
||||
explicit TStaticData(T in)
|
||||
: data (in)
|
||||
{}
|
||||
|
||||
~TStaticData() {}
|
||||
~TStaticData()
|
||||
{}
|
||||
|
||||
T data;
|
||||
};
|
||||
|
||||
// some typedefs for cleaner code
|
||||
typedef unsigned int KeyType;
|
||||
typedef std::map<KeyType, Base *> PropertyMap;
|
||||
typedef std::map<KeyType, Base*> PropertyMap;
|
||||
|
||||
public:
|
||||
|
||||
//! Destructor
|
||||
~SharedPostProcessInfo() {
|
||||
~SharedPostProcessInfo()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//! Remove all stored properties from the table
|
||||
void Clean() {
|
||||
void Clean()
|
||||
{
|
||||
// invoke the virtual destructor for all stored properties
|
||||
for (PropertyMap::iterator it = pmap.begin(), end = pmap.end();
|
||||
it != end; ++it) {
|
||||
it != end; ++it)
|
||||
{
|
||||
delete (*it).second;
|
||||
}
|
||||
pmap.clear();
|
||||
|
|
@ -111,21 +125,24 @@ public:
|
|||
|
||||
//! Add a heap property to the list
|
||||
template <typename T>
|
||||
void AddProperty(const char *name, T *in) {
|
||||
AddProperty(name, (Base *)new THeapData<T>(in));
|
||||
void AddProperty( const char* name, T* in ){
|
||||
AddProperty(name,(Base*)new THeapData<T>(in));
|
||||
}
|
||||
|
||||
//! Add a static by-value property to the list
|
||||
template <typename T>
|
||||
void AddProperty(const char *name, T in) {
|
||||
AddProperty(name, (Base *)new TStaticData<T>(in));
|
||||
void AddProperty( const char* name, T in ){
|
||||
AddProperty(name,(Base*)new TStaticData<T>(in));
|
||||
}
|
||||
|
||||
|
||||
//! Get a heap property
|
||||
template <typename T>
|
||||
bool GetProperty(const char *name, T *&out) const {
|
||||
THeapData<T> *t = (THeapData<T> *)GetPropertyInternal(name);
|
||||
if (!t) {
|
||||
bool GetProperty( const char* name, T*& out ) const
|
||||
{
|
||||
THeapData<T>* t = (THeapData<T>*)GetPropertyInternal(name);
|
||||
if(!t)
|
||||
{
|
||||
out = NULL;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -135,34 +152,53 @@ public:
|
|||
|
||||
//! Get a static, by-value property
|
||||
template <typename T>
|
||||
bool GetProperty(const char *name, T &out) const {
|
||||
TStaticData<T> *t = (TStaticData<T> *)GetPropertyInternal(name);
|
||||
if ( nullptr == t) {
|
||||
return false;
|
||||
}
|
||||
bool GetProperty( const char* name, T& out ) const
|
||||
{
|
||||
TStaticData<T>* t = (TStaticData<T>*)GetPropertyInternal(name);
|
||||
if(!t)return false;
|
||||
out = t->data;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Remove a property of a specific type
|
||||
void RemoveProperty(const char *name) {
|
||||
SetGenericPropertyPtr<Base>(pmap, name, nullptr );
|
||||
void RemoveProperty( const char* name) {
|
||||
SetGenericPropertyPtr<Base>(pmap,name,NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
void AddProperty(const char *name, Base *data) {
|
||||
SetGenericPropertyPtr<Base>(pmap, name, data);
|
||||
|
||||
void AddProperty( const char* name, Base* data) {
|
||||
SetGenericPropertyPtr<Base>(pmap,name,data);
|
||||
}
|
||||
|
||||
Base *GetPropertyInternal(const char *name) const {
|
||||
return GetGenericProperty<Base *>(pmap, name, nullptr );
|
||||
Base* GetPropertyInternal( const char* name) const {
|
||||
return GetGenericProperty<Base*>(pmap,name,NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Map of all stored properties
|
||||
PropertyMap pmap;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Represents a dependency table for a postprocessing steps.
|
||||
*
|
||||
* For future use.
|
||||
*/
|
||||
struct PPDependencyTable
|
||||
{
|
||||
unsigned int execute_me_before_these;
|
||||
unsigned int execute_me_after_these;
|
||||
unsigned int only_if_these_are_not_specified;
|
||||
unsigned int mutually_exclusive_with;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define AI_SPP_SPATIAL_SORT "$Spat"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -192,7 +228,7 @@ public:
|
|||
* @return true if the process is present in this flag fields,
|
||||
* false if not.
|
||||
*/
|
||||
virtual bool IsActive(unsigned int pFlags) const = 0;
|
||||
virtual bool IsActive( unsigned int pFlags) const = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Check whether this step expects its input vertex data to be
|
||||
|
|
@ -205,14 +241,14 @@ public:
|
|||
* the object pointer will be set to NULL).
|
||||
* @param pImp Importer instance (pImp->mScene must be valid)
|
||||
*/
|
||||
void ExecuteOnScene(Importer *pImp);
|
||||
void ExecuteOnScene( Importer* pImp);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called prior to ExecuteOnScene().
|
||||
* The function is a request to the process to update its configuration
|
||||
* basing on the Importer's configuration property list.
|
||||
*/
|
||||
virtual void SetupProperties(const Importer *pImp);
|
||||
virtual void SetupProperties(const Importer* pImp);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Executes the post processing step on the given imported data.
|
||||
|
|
@ -220,32 +256,35 @@ public:
|
|||
* This method must be implemented by deriving classes.
|
||||
* @param pScene The imported data to work at.
|
||||
*/
|
||||
virtual void Execute(aiScene *pScene) = 0;
|
||||
virtual void Execute( aiScene* pScene) = 0;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Assign a new SharedPostProcessInfo to the step. This object
|
||||
* allows multiple postprocess steps to share data.
|
||||
* @param sh May be NULL
|
||||
*/
|
||||
inline void SetSharedData(SharedPostProcessInfo *sh) {
|
||||
inline void SetSharedData(SharedPostProcessInfo* sh) {
|
||||
shared = sh;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get the shared data that is assigned to the step.
|
||||
*/
|
||||
inline SharedPostProcessInfo *GetSharedData() {
|
||||
inline SharedPostProcessInfo* GetSharedData() {
|
||||
return shared;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/** See the doc of #SharedPostProcessInfo for more details */
|
||||
SharedPostProcessInfo *shared;
|
||||
SharedPostProcessInfo* shared;
|
||||
|
||||
/** Currently active progress handler */
|
||||
ProgressHandler *progress;
|
||||
ProgressHandler* progress;
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_BASEPROCESS_H_INC
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Open Asset Import Library (assimp)
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (C) 2016 The Qt Company Ltd.
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2012, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -52,35 +52,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
using namespace Assimp;
|
||||
|
||||
namespace
|
||||
{
|
||||
template<size_t sizeOfPointer>
|
||||
size_t select_ftell(FILE* file)
|
||||
{
|
||||
return ::ftell(file);
|
||||
}
|
||||
|
||||
template<size_t sizeOfPointer>
|
||||
int select_fseek(FILE* file, int64_t offset, int origin)
|
||||
{
|
||||
return ::fseek(file, static_cast<long>(offset), origin);
|
||||
}
|
||||
|
||||
#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
|
||||
template<>
|
||||
size_t select_ftell<8>(FILE* file)
|
||||
{
|
||||
return ::_ftelli64(file);
|
||||
}
|
||||
|
||||
template<>
|
||||
int select_fseek<8>(FILE* file, int64_t offset, int origin)
|
||||
{
|
||||
return ::_fseeki64(file, offset, origin);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
DefaultIOStream::~DefaultIOStream()
|
||||
{
|
||||
|
|
@ -122,7 +93,7 @@ aiReturn DefaultIOStream::Seek(size_t pOffset,
|
|||
aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET");
|
||||
|
||||
// do the seek
|
||||
return (0 == select_fseek<sizeof(void*)>(mFile, (int64_t)pOffset,(int)pOrigin) ? AI_SUCCESS : AI_FAILURE);
|
||||
return (0 == ::fseek(mFile, (long)pOffset,(int)pOrigin) ? AI_SUCCESS : AI_FAILURE);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
|
@ -131,7 +102,7 @@ size_t DefaultIOStream::Tell() const
|
|||
if (!mFile) {
|
||||
return 0;
|
||||
}
|
||||
return select_ftell<sizeof(void*)>(mFile);
|
||||
return ::ftell(mFile);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ LogStream* LogStream::createDefaultStream(aiDefaultLogStream streams,
|
|||
return nullptr;
|
||||
#endif
|
||||
|
||||
// Platform-independent default streams
|
||||
// Platform-independent default streams
|
||||
case aiDefaultLogStream_STDERR:
|
||||
return new StdOStreamLogStream(std::cerr);
|
||||
case aiDefaultLogStream_STDOUT:
|
||||
|
|
@ -121,7 +121,7 @@ LogStream* LogStream::createDefaultStream(aiDefaultLogStream streams,
|
|||
};
|
||||
|
||||
// For compilers without dead code path detection
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -102,92 +102,94 @@ void ExportSceneX3D(const char*, IOSystem*, const aiScene*, const ExportProperti
|
|||
void ExportSceneFBX(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneFBXA(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportScene3MF( const char*, IOSystem*, const aiScene*, const ExportProperties* );
|
||||
void ExportSceneM3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneM3DA(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportAssimp2Json(const char* , IOSystem*, const aiScene* , const Assimp::ExportProperties*);
|
||||
|
||||
|
||||
static void setupExporterArray(std::vector<Exporter::ExportFormatEntry> &exporters) {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// global array of all export formats which Assimp supports in its current build
|
||||
Exporter::ExportFormatEntry gExporters[] =
|
||||
{
|
||||
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada));
|
||||
Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_X_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("x", "X Files", "x", &ExportSceneXFile,
|
||||
aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs));
|
||||
Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile,
|
||||
aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_STEP_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("stp", "Step Files", "stp", &ExportSceneStep, 0));
|
||||
Exporter::ExportFormatEntry( "stp", "Step Files", "stp", &ExportSceneStep, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("obj", "Wavefront OBJ format", "obj", &ExportSceneObj,
|
||||
aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl,
|
||||
aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */));
|
||||
Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj,
|
||||
aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ ),
|
||||
Exporter::ExportFormatEntry( "objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl,
|
||||
aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_STL_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("stl", "Stereolithography", "stl", &ExportSceneSTL,
|
||||
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("stlb", "Stereolithography (binary)", "stl", &ExportSceneSTLBinary,
|
||||
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices));
|
||||
Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL,
|
||||
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices
|
||||
),
|
||||
Exporter::ExportFormatEntry( "stlb", "Stereolithography (binary)", "stl" , &ExportSceneSTLBinary,
|
||||
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices
|
||||
),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_PLY_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("ply", "Stanford Polygon Library", "ply", &ExportScenePly,
|
||||
aiProcess_PreTransformVertices));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("plyb", "Stanford Polygon Library (binary)", "ply", &ExportScenePlyBinary,
|
||||
aiProcess_PreTransformVertices));
|
||||
Exporter::ExportFormatEntry( "ply", "Stanford Polygon Library", "ply" , &ExportScenePly,
|
||||
aiProcess_PreTransformVertices
|
||||
),
|
||||
Exporter::ExportFormatEntry( "plyb", "Stanford Polygon Library (binary)", "ply", &ExportScenePlyBinary,
|
||||
aiProcess_PreTransformVertices
|
||||
),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_3DS_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("3ds", "Autodesk 3DS (legacy)", "3ds", &ExportScene3DS,
|
||||
aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices));
|
||||
Exporter::ExportFormatEntry( "3ds", "Autodesk 3DS (legacy)", "3ds" , &ExportScene3DS,
|
||||
aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("gltf2", "GL Transmission Format v. 2", "gltf", &ExportSceneGLTF2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("glb2", "GL Transmission Format v. 2 (binary)", "glb", &ExportSceneGLB2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType));
|
||||
Exporter::ExportFormatEntry( "gltf2", "GL Transmission Format v. 2", "gltf", &ExportSceneGLTF2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
Exporter::ExportFormatEntry( "glb2", "GL Transmission Format v. 2 (binary)", "glb", &ExportSceneGLB2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
Exporter::ExportFormatEntry( "gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
Exporter::ExportFormatEntry( "glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("assbin", "Assimp Binary File", "assbin", &ExportSceneAssbin, 0));
|
||||
Exporter::ExportFormatEntry( "assbin", "Assimp Binary File", "assbin" , &ExportSceneAssbin, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("assxml", "Assimp XML Document", "assxml", &ExportSceneAssxml, 0));
|
||||
Exporter::ExportFormatEntry( "assxml", "Assimp XML Document", "assxml" , &ExportSceneAssxml, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_X3D_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("x3d", "Extensible 3D", "x3d", &ExportSceneX3D, 0));
|
||||
Exporter::ExportFormatEntry( "x3d", "Extensible 3D", "x3d" , &ExportSceneX3D, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_FBX_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("fbx", "Autodesk FBX (binary)", "fbx", &ExportSceneFBX, 0));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("fbxa", "Autodesk FBX (ascii)", "fbx", &ExportSceneFBXA, 0));
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_M3D_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("m3d", "Model 3D (binary)", "m3d", &ExportSceneM3D, 0));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("m3da", "Model 3D (ascii)", "a3d", &ExportSceneM3DA, 0));
|
||||
Exporter::ExportFormatEntry( "fbx", "Autodesk FBX (binary)", "fbx", &ExportSceneFBX, 0 ),
|
||||
Exporter::ExportFormatEntry( "fbxa", "Autodesk FBX (ascii)", "fbx", &ExportSceneFBXA, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_3MF_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0));
|
||||
Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_ASSJSON_EXPORTER
|
||||
exporters.push_back(Exporter::ExportFormatEntry("assjson", "Assimp JSON Document", "json", &ExportAssimp2Json, 0));
|
||||
Exporter::ExportFormatEntry( "assjson", "Assimp JSON Document", "json", &ExportAssimp2Json, 0)
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#define ASSIMP_NUM_EXPORTERS (sizeof(gExporters)/sizeof(gExporters[0]))
|
||||
|
||||
|
||||
class ExporterPimpl {
|
||||
public:
|
||||
|
|
@ -203,7 +205,10 @@ public:
|
|||
GetPostProcessingStepInstanceList(mPostProcessingSteps);
|
||||
|
||||
// grab all built-in exporters
|
||||
setupExporterArray(mExporters);
|
||||
if ( 0 != ( ASSIMP_NUM_EXPORTERS ) ) {
|
||||
mExporters.resize( ASSIMP_NUM_EXPORTERS );
|
||||
std::copy( gExporters, gExporters + ASSIMP_NUM_EXPORTERS, mExporters.begin() );
|
||||
}
|
||||
}
|
||||
|
||||
~ExporterPimpl() {
|
||||
|
|
@ -247,28 +252,24 @@ Exporter :: Exporter()
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Exporter::~Exporter() {
|
||||
ai_assert(nullptr != pimpl);
|
||||
FreeBlob();
|
||||
FreeBlob();
|
||||
delete pimpl;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Exporter::SetIOHandler( IOSystem* pIOHandler) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
pimpl->mIsDefaultIOHandler = !pIOHandler;
|
||||
pimpl->mIsDefaultIOHandler = !pIOHandler;
|
||||
pimpl->mIOSystem.reset(pIOHandler);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
IOSystem* Exporter::GetIOHandler() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
return pimpl->mIOSystem.get();
|
||||
return pimpl->mIOSystem.get();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Exporter::IsDefaultIOHandler() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
return pimpl->mIsDefaultIOHandler;
|
||||
return pimpl->mIsDefaultIOHandler;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -294,7 +295,6 @@ void Exporter::SetProgressHandler(ProgressHandler* pHandler) {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const char* pFormatId,
|
||||
unsigned int pPreprocessing, const ExportProperties* pProperties) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
if (pimpl->blob) {
|
||||
delete pimpl->blob;
|
||||
pimpl->blob = nullptr;
|
||||
|
|
@ -319,7 +319,7 @@ const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const cha
|
|||
aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const char* pPath,
|
||||
unsigned int pPreprocessing, const ExportProperties* pProperties) {
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
// when they create scenes from scratch, users will likely create them not in verbose
|
||||
// format. They will likely not be aware that there is a flag in the scene to indicate
|
||||
// this, however. To avoid surprises and bug reports, we check for duplicates in
|
||||
|
|
@ -445,7 +445,8 @@ aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const c
|
|||
|
||||
ExportProperties emptyProperties; // Never pass NULL ExportProperties so Exporters don't have to worry.
|
||||
ExportProperties* pProp = pProperties ? (ExportProperties*)pProperties : &emptyProperties;
|
||||
pProp->SetPropertyBool("bJoinIdenticalVertices", pp & aiProcess_JoinIdenticalVertices);
|
||||
pProp->SetPropertyBool("bJoinIdenticalVertices", must_join_again);
|
||||
exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProp);
|
||||
exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProp);
|
||||
|
||||
pimpl->mProgressHandler->UpdateFileWrite(4, 4);
|
||||
|
|
@ -465,13 +466,11 @@ aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const c
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const char* Exporter::GetErrorString() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
return pimpl->mError.c_str();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Exporter::FreeBlob() {
|
||||
ai_assert(nullptr != pimpl);
|
||||
delete pimpl->blob;
|
||||
pimpl->blob = nullptr;
|
||||
|
||||
|
|
@ -480,34 +479,30 @@ void Exporter::FreeBlob() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const aiExportDataBlob* Exporter::GetBlob() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
return pimpl->blob;
|
||||
return pimpl->blob;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const aiExportDataBlob* Exporter::GetOrphanedBlob() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
const aiExportDataBlob *tmp = pimpl->blob;
|
||||
const aiExportDataBlob* tmp = pimpl->blob;
|
||||
pimpl->blob = nullptr;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
size_t Exporter::GetExportFormatCount() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
return pimpl->mExporters.size();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const aiExportFormatDesc* Exporter::GetExportFormatDescription( size_t index ) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
if (index >= GetExportFormatCount()) {
|
||||
if (index >= GetExportFormatCount()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Return from static storage if the requested index is built-in.
|
||||
if (index < pimpl->mExporters.size()) {
|
||||
return &pimpl->mExporters[index].mDescription;
|
||||
if (index < sizeof(gExporters) / sizeof(gExporters[0])) {
|
||||
return &gExporters[index].mDescription;
|
||||
}
|
||||
|
||||
return &pimpl->mExporters[index].mDescription;
|
||||
|
|
@ -515,8 +510,7 @@ const aiExportFormatDesc* Exporter::GetExportFormatDescription( size_t index ) c
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
aiReturn Exporter::RegisterExporter(const ExportFormatEntry& desc) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
for (const ExportFormatEntry &e : pimpl->mExporters) {
|
||||
for(const ExportFormatEntry& e : pimpl->mExporters) {
|
||||
if (!strcmp(e.mDescription.id,desc.mDescription.id)) {
|
||||
return aiReturn_FAILURE;
|
||||
}
|
||||
|
|
@ -528,8 +522,7 @@ aiReturn Exporter::RegisterExporter(const ExportFormatEntry& desc) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Exporter::UnregisterExporter(const char* id) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
for (std::vector<ExportFormatEntry>::iterator it = pimpl->mExporters.begin();
|
||||
for(std::vector<ExportFormatEntry>::iterator it = pimpl->mExporters.begin();
|
||||
it != pimpl->mExporters.end(); ++it) {
|
||||
if (!strcmp((*it).mDescription.id,id)) {
|
||||
pimpl->mExporters.erase(it);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2008, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -76,8 +78,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/TinyFormatter.h>
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/Profiler.h>
|
||||
#include <assimp/commonMetaData.h>
|
||||
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <cctype>
|
||||
|
|
@ -119,7 +119,7 @@ void* AllocateFromAssimpHeap::operator new ( size_t num_bytes, const std::nothro
|
|||
return AllocateFromAssimpHeap::operator new( num_bytes );
|
||||
}
|
||||
catch( ... ) {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,8 +134,9 @@ void* AllocateFromAssimpHeap::operator new[] ( size_t num_bytes) {
|
|||
void* AllocateFromAssimpHeap::operator new[] ( size_t num_bytes, const std::nothrow_t& ) throw() {
|
||||
try {
|
||||
return AllocateFromAssimpHeap::operator new[]( num_bytes );
|
||||
} catch( ... ) {
|
||||
return nullptr;
|
||||
}
|
||||
catch( ... ) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +148,7 @@ void AllocateFromAssimpHeap::operator delete[] ( void* data) {
|
|||
// Importer constructor.
|
||||
Importer::Importer()
|
||||
: pimpl( new ImporterPimpl ) {
|
||||
pimpl->mScene = nullptr;
|
||||
pimpl->mScene = NULL;
|
||||
pimpl->mErrorString = "";
|
||||
|
||||
// Allocate a default IO handler
|
||||
|
|
@ -173,14 +174,14 @@ Importer::Importer()
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor of Importer
|
||||
Importer::~Importer() {
|
||||
Importer::~Importer()
|
||||
{
|
||||
// Delete all import plugins
|
||||
DeleteImporterInstanceList(pimpl->mImporter);
|
||||
|
||||
// Delete all post-processing plug-ins
|
||||
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); ++a ) {
|
||||
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++)
|
||||
delete pimpl->mPostProcessingSteps[a];
|
||||
}
|
||||
|
||||
// Delete the assigned IO and progress handler
|
||||
delete pimpl->mIOHandler;
|
||||
|
|
@ -198,9 +199,9 @@ Importer::~Importer() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Register a custom post-processing step
|
||||
aiReturn Importer::RegisterPPStep(BaseProcess* pImp) {
|
||||
ai_assert( nullptr != pImp );
|
||||
|
||||
aiReturn Importer::RegisterPPStep(BaseProcess* pImp)
|
||||
{
|
||||
ai_assert(NULL != pImp);
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
|
||||
pimpl->mPostProcessingSteps.push_back(pImp);
|
||||
|
|
@ -212,9 +213,9 @@ aiReturn Importer::RegisterPPStep(BaseProcess* pImp) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Register a custom loader plugin
|
||||
aiReturn Importer::RegisterLoader(BaseImporter* pImp) {
|
||||
ai_assert(nullptr != pImp);
|
||||
|
||||
aiReturn Importer::RegisterLoader(BaseImporter* pImp)
|
||||
{
|
||||
ai_assert(NULL != pImp);
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
|
@ -241,13 +242,13 @@ aiReturn Importer::RegisterLoader(BaseImporter* pImp) {
|
|||
pimpl->mImporter.push_back(pImp);
|
||||
ASSIMP_LOG_INFO_F("Registering custom importer for these file extensions: ", baked);
|
||||
ASSIMP_END_EXCEPTION_REGION(aiReturn);
|
||||
|
||||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Unregister a custom loader plugin
|
||||
aiReturn Importer::UnregisterLoader(BaseImporter* pImp) {
|
||||
aiReturn Importer::UnregisterLoader(BaseImporter* pImp)
|
||||
{
|
||||
if(!pImp) {
|
||||
// unregistering a NULL importer is no problem for us ... really!
|
||||
return AI_SUCCESS;
|
||||
|
|
@ -264,13 +265,13 @@ aiReturn Importer::UnregisterLoader(BaseImporter* pImp) {
|
|||
}
|
||||
ASSIMP_LOG_WARN("Unable to remove custom importer: I can't find you ...");
|
||||
ASSIMP_END_EXCEPTION_REGION(aiReturn);
|
||||
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Unregister a custom loader plugin
|
||||
aiReturn Importer::UnregisterPPStep(BaseProcess* pImp) {
|
||||
aiReturn Importer::UnregisterPPStep(BaseProcess* pImp)
|
||||
{
|
||||
if(!pImp) {
|
||||
// unregistering a NULL ppstep is no problem for us ... really!
|
||||
return AI_SUCCESS;
|
||||
|
|
@ -287,22 +288,24 @@ aiReturn Importer::UnregisterPPStep(BaseProcess* pImp) {
|
|||
}
|
||||
ASSIMP_LOG_WARN("Unable to remove custom post-processing step: I can't find you ..");
|
||||
ASSIMP_END_EXCEPTION_REGION(aiReturn);
|
||||
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Supplies a custom IO handler to the importer to open and access files.
|
||||
void Importer::SetIOHandler( IOSystem* pIOHandler) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
void Importer::SetIOHandler( IOSystem* pIOHandler)
|
||||
{
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
// If the new handler is zero, allocate a default IO implementation.
|
||||
if (!pIOHandler) {
|
||||
if (!pIOHandler)
|
||||
{
|
||||
// Release pointer in the possession of the caller
|
||||
pimpl->mIOHandler = new DefaultIOSystem();
|
||||
pimpl->mIsDefaultHandler = true;
|
||||
} else if (pimpl->mIOHandler != pIOHandler) { // Otherwise register the custom handler
|
||||
}
|
||||
// Otherwise register the custom handler
|
||||
else if (pimpl->mIOHandler != pIOHandler)
|
||||
{
|
||||
delete pimpl->mIOHandler;
|
||||
pimpl->mIOHandler = pIOHandler;
|
||||
pimpl->mIsDefaultHandler = false;
|
||||
|
|
@ -313,32 +316,29 @@ void Importer::SetIOHandler( IOSystem* pIOHandler) {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Get the currently set IO handler
|
||||
IOSystem* Importer::GetIOHandler() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
return pimpl->mIOHandler;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Check whether a custom IO handler is currently set
|
||||
bool Importer::IsDefaultIOHandler() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
return pimpl->mIsDefaultHandler;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Supplies a custom progress handler to get regular callbacks during importing
|
||||
void Importer::SetProgressHandler ( ProgressHandler* pHandler ) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
|
||||
// If the new handler is zero, allocate a default implementation.
|
||||
if (!pHandler) {
|
||||
if (!pHandler)
|
||||
{
|
||||
// Release pointer in the possession of the caller
|
||||
pimpl->mProgressHandler = new DefaultProgressHandler();
|
||||
pimpl->mIsDefaultProgressHandler = true;
|
||||
} else if (pimpl->mProgressHandler != pHandler) { // Otherwise register the custom handler
|
||||
}
|
||||
// Otherwise register the custom handler
|
||||
else if (pimpl->mProgressHandler != pHandler)
|
||||
{
|
||||
delete pimpl->mProgressHandler;
|
||||
pimpl->mProgressHandler = pHandler;
|
||||
pimpl->mIsDefaultProgressHandler = false;
|
||||
|
|
@ -349,22 +349,19 @@ void Importer::SetProgressHandler ( ProgressHandler* pHandler ) {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Get the currently set progress handler
|
||||
ProgressHandler* Importer::GetProgressHandler() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
return pimpl->mProgressHandler;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Check whether a custom progress handler is currently set
|
||||
bool Importer::IsDefaultProgressHandler() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
return pimpl->mIsDefaultProgressHandler;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Validate post process step flags
|
||||
bool _ValidateFlags(unsigned int pFlags) {
|
||||
bool _ValidateFlags(unsigned int pFlags)
|
||||
{
|
||||
if (pFlags & aiProcess_GenSmoothNormals && pFlags & aiProcess_GenNormals) {
|
||||
ASSIMP_LOG_ERROR("#aiProcess_GenSmoothNormals and #aiProcess_GenNormals are incompatible");
|
||||
return false;
|
||||
|
|
@ -378,13 +375,12 @@ bool _ValidateFlags(unsigned int pFlags) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Free the current scene
|
||||
void Importer::FreeScene( ) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
void Importer::FreeScene( )
|
||||
{
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
|
||||
delete pimpl->mScene;
|
||||
pimpl->mScene = nullptr;
|
||||
pimpl->mScene = NULL;
|
||||
|
||||
pimpl->mErrorString = "";
|
||||
ASSIMP_END_EXCEPTION_REGION(void);
|
||||
|
|
@ -392,48 +388,44 @@ void Importer::FreeScene( ) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get the current error string, if any
|
||||
const char* Importer::GetErrorString() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
// Must remain valid as long as ReadFile() or FreeFile() are not called
|
||||
const char* Importer::GetErrorString() const
|
||||
{
|
||||
/* Must remain valid as long as ReadFile() or FreeFile() are not called */
|
||||
return pimpl->mErrorString.c_str();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Enable extra-verbose mode
|
||||
void Importer::SetExtraVerbose(bool bDo) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
void Importer::SetExtraVerbose(bool bDo)
|
||||
{
|
||||
pimpl->bExtraVerbose = bDo;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get the current scene
|
||||
const aiScene* Importer::GetScene() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
const aiScene* Importer::GetScene() const
|
||||
{
|
||||
return pimpl->mScene;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Orphan the current scene and return it.
|
||||
aiScene* Importer::GetOrphanedScene() {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
aiScene* Importer::GetOrphanedScene()
|
||||
{
|
||||
aiScene* s = pimpl->mScene;
|
||||
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
pimpl->mScene = nullptr;
|
||||
pimpl->mScene = NULL;
|
||||
|
||||
pimpl->mErrorString = ""; // reset error string
|
||||
pimpl->mErrorString = ""; /* reset error string */
|
||||
ASSIMP_END_EXCEPTION_REGION(aiScene*);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Validate post-processing flags
|
||||
bool Importer::ValidateFlags(unsigned int pFlags) const {
|
||||
bool Importer::ValidateFlags(unsigned int pFlags) const
|
||||
{
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
// run basic checks for mutually exclusive flags
|
||||
if(!_ValidateFlags(pFlags)) {
|
||||
|
|
@ -475,9 +467,8 @@ bool Importer::ValidateFlags(unsigned int pFlags) const {
|
|||
const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
|
||||
size_t pLength,
|
||||
unsigned int pFlags,
|
||||
const char* pHint /*= ""*/) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
const char* pHint /*= ""*/)
|
||||
{
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
if (!pHint) {
|
||||
pHint = "";
|
||||
|
|
@ -485,12 +476,12 @@ const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
|
|||
|
||||
if (!pBuffer || !pLength || strlen(pHint) > MaxLenHint ) {
|
||||
pimpl->mErrorString = "Invalid parameters passed to ReadFileFromMemory()";
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// prevent deletion of the previous IOHandler
|
||||
IOSystem* io = pimpl->mIOHandler;
|
||||
pimpl->mIOHandler = nullptr;
|
||||
pimpl->mIOHandler = NULL;
|
||||
|
||||
SetIOHandler(new MemoryIOSystem((const uint8_t*)pBuffer,pLength,io));
|
||||
|
||||
|
|
@ -502,13 +493,13 @@ const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
|
|||
ReadFile(fbuff,pFlags);
|
||||
SetIOHandler(io);
|
||||
|
||||
ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString);
|
||||
ASSIMP_END_EXCEPTION_REGION(const aiScene*);
|
||||
return pimpl->mScene;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void WriteLogOpening(const std::string& file) {
|
||||
|
||||
void WriteLogOpening(const std::string& file)
|
||||
{
|
||||
ASSIMP_LOG_INFO_F("Load ", file);
|
||||
|
||||
// print a full version dump. This is nice because we don't
|
||||
|
|
@ -559,9 +550,8 @@ void WriteLogOpening(const std::string& file) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads the given file and returns its contents if successful.
|
||||
const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
|
||||
{
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
const std::string pFile(_pFile);
|
||||
|
||||
|
|
@ -590,7 +580,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
|
|||
|
||||
pimpl->mErrorString = "Unable to open file \"" + pFile + "\".";
|
||||
ASSIMP_LOG_ERROR(pimpl->mErrorString);
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::unique_ptr<Profiler> profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,0)?new Profiler():NULL);
|
||||
|
|
@ -599,7 +589,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
|
|||
}
|
||||
|
||||
// Find an worker class which can handle the file
|
||||
BaseImporter* imp = nullptr;
|
||||
BaseImporter* imp = NULL;
|
||||
SetPropertyInteger("importerIndex", -1);
|
||||
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
|
||||
|
||||
|
|
@ -627,7 +617,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
|
|||
if( !imp) {
|
||||
pimpl->mErrorString = "No suitable reader found for the file format of file \"" + pFile + "\".";
|
||||
ASSIMP_LOG_ERROR(pimpl->mErrorString);
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -643,7 +633,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
|
|||
// Dispatch the reading to the worker class for this format
|
||||
const aiImporterDesc *desc( imp->GetInfo() );
|
||||
std::string ext( "unknown" );
|
||||
if ( nullptr != desc ) {
|
||||
if ( NULL != desc ) {
|
||||
ext = desc->mName;
|
||||
}
|
||||
ASSIMP_LOG_INFO("Found a matching importer for this file format: " + ext + "." );
|
||||
|
|
@ -664,20 +654,15 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
|
|||
|
||||
// If successful, apply all active post processing steps to the imported data
|
||||
if( pimpl->mScene) {
|
||||
if (!pimpl->mScene->mMetaData || !pimpl->mScene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT)) {
|
||||
if (!pimpl->mScene->mMetaData) {
|
||||
pimpl->mScene->mMetaData = new aiMetadata;
|
||||
}
|
||||
pimpl->mScene->mMetaData->Add(AI_METADATA_SOURCE_FORMAT, aiString(ext));
|
||||
}
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
||||
// The ValidateDS process is an exception. It is executed first, even before ScenePreprocessor is called.
|
||||
if (pFlags & aiProcess_ValidateDataStructure) {
|
||||
if (pFlags & aiProcess_ValidateDataStructure)
|
||||
{
|
||||
ValidateDSProcess ds;
|
||||
ds.ExecuteOnScene (this);
|
||||
if (!pimpl->mScene) {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif // no validation
|
||||
|
|
@ -710,7 +695,8 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
|
|||
}
|
||||
}
|
||||
#ifdef ASSIMP_CATCH_GLOBAL_EXCEPTIONS
|
||||
catch (std::exception &e) {
|
||||
catch (std::exception &e)
|
||||
{
|
||||
#if (defined _MSC_VER) && (defined _CPPRTTI)
|
||||
// if we have RTTI get the full name of the exception that occurred
|
||||
pimpl->mErrorString = std::string(typeid( e ).name()) + ": " + e.what();
|
||||
|
|
@ -719,26 +705,24 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
|
|||
#endif
|
||||
|
||||
ASSIMP_LOG_ERROR(pimpl->mErrorString);
|
||||
delete pimpl->mScene; pimpl->mScene = nullptr;
|
||||
delete pimpl->mScene; pimpl->mScene = NULL;
|
||||
}
|
||||
#endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS
|
||||
|
||||
// either successful or failure - the pointer expresses it anyways
|
||||
ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString);
|
||||
|
||||
ASSIMP_END_EXCEPTION_REGION(const aiScene*);
|
||||
return pimpl->mScene;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Apply post-processing to the currently bound scene
|
||||
const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
|
||||
{
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
// Return immediately if no scene is active
|
||||
if (!pimpl->mScene) {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// If no flags are given, return the current scene with no further action
|
||||
|
|
@ -753,11 +737,12 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
|
|||
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
||||
// The ValidateDS process plays an exceptional role. It isn't contained in the global
|
||||
// list of post-processing steps, so we need to call it manually.
|
||||
if (pFlags & aiProcess_ValidateDataStructure) {
|
||||
if (pFlags & aiProcess_ValidateDataStructure)
|
||||
{
|
||||
ValidateDSProcess ds;
|
||||
ds.ExecuteOnScene (this);
|
||||
if (!pimpl->mScene) {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif // no validation
|
||||
|
|
@ -777,9 +762,11 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
|
|||
|
||||
std::unique_ptr<Profiler> profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,0)?new Profiler():NULL);
|
||||
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
|
||||
|
||||
BaseProcess* process = pimpl->mPostProcessingSteps[a];
|
||||
pimpl->mProgressHandler->UpdatePostProcess(static_cast<int>(a), static_cast<int>(pimpl->mPostProcessingSteps.size()) );
|
||||
if( process->IsActive( pFlags)) {
|
||||
|
||||
if (profiler) {
|
||||
profiler->BeginRegion("postprocess");
|
||||
}
|
||||
|
|
@ -816,28 +803,24 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
|
|||
static_cast<int>(pimpl->mPostProcessingSteps.size()) );
|
||||
|
||||
// update private scene flags
|
||||
if( pimpl->mScene ) {
|
||||
if( pimpl->mScene )
|
||||
ScenePriv(pimpl->mScene)->mPPStepsApplied |= pFlags;
|
||||
}
|
||||
|
||||
// clear any data allocated by post-process steps
|
||||
pimpl->mPPShared->Clean();
|
||||
ASSIMP_LOG_INFO("Leaving post processing pipeline");
|
||||
|
||||
ASSIMP_END_EXCEPTION_REGION(const aiScene*);
|
||||
|
||||
return pimpl->mScene;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation ) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
|
||||
// Return immediately if no scene is active
|
||||
if ( nullptr == pimpl->mScene ) {
|
||||
return nullptr;
|
||||
if ( NULL == pimpl->mScene ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// If no flags are given, return the current scene with no further action
|
||||
|
|
@ -856,7 +839,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess
|
|||
ValidateDSProcess ds;
|
||||
ds.ExecuteOnScene( this );
|
||||
if ( !pimpl->mScene ) {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif // no validation
|
||||
|
|
@ -907,50 +890,46 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Helper function to check whether an extension is supported by ASSIMP
|
||||
bool Importer::IsExtensionSupported(const char* szExtension) const {
|
||||
bool Importer::IsExtensionSupported(const char* szExtension) const
|
||||
{
|
||||
return nullptr != GetImporter(szExtension);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
size_t Importer::GetImporterCount() const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
size_t Importer::GetImporterCount() const
|
||||
{
|
||||
return pimpl->mImporter.size();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const aiImporterDesc* Importer::GetImporterInfo(size_t index) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
const aiImporterDesc* Importer::GetImporterInfo(size_t index) const
|
||||
{
|
||||
if (index >= pimpl->mImporter.size()) {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
return pimpl->mImporter[index]->GetInfo();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BaseImporter* Importer::GetImporter (size_t index) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
BaseImporter* Importer::GetImporter (size_t index) const
|
||||
{
|
||||
if (index >= pimpl->mImporter.size()) {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
return pimpl->mImporter[index];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Find a loader plugin for a given file extension
|
||||
BaseImporter* Importer::GetImporter (const char* szExtension) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
BaseImporter* Importer::GetImporter (const char* szExtension) const
|
||||
{
|
||||
return GetImporter(GetImporterIndex(szExtension));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Find a loader plugin for a given file extension
|
||||
size_t Importer::GetImporterIndex (const char* szExtension) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
ai_assert(nullptr != szExtension);
|
||||
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
|
|
@ -981,9 +960,8 @@ size_t Importer::GetImporterIndex (const char* szExtension) const {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Helper function to build a list of all file extensions supported by ASSIMP
|
||||
void Importer::GetExtensionList(aiString& szOut) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
void Importer::GetExtensionList(aiString& szOut) const
|
||||
{
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
std::set<std::string> str;
|
||||
for (std::vector<BaseImporter*>::const_iterator i = pimpl->mImporter.begin();i != pimpl->mImporter.end();++i) {
|
||||
|
|
@ -1007,9 +985,8 @@ void Importer::GetExtensionList(aiString& szOut) const {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyInteger(const char* szName, int iValue) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
bool Importer::SetPropertyInteger(const char* szName, int iValue)
|
||||
{
|
||||
bool existing;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
existing = SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue);
|
||||
|
|
@ -1019,9 +996,8 @@ bool Importer::SetPropertyInteger(const char* szName, int iValue) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyFloat(const char* szName, ai_real iValue) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
bool Importer::SetPropertyFloat(const char* szName, ai_real iValue)
|
||||
{
|
||||
bool existing;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
existing = SetGenericProperty<ai_real>(pimpl->mFloatProperties, szName,iValue);
|
||||
|
|
@ -1031,9 +1007,8 @@ bool Importer::SetPropertyFloat(const char* szName, ai_real iValue) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyString(const char* szName, const std::string& value) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
bool Importer::SetPropertyString(const char* szName, const std::string& value)
|
||||
{
|
||||
bool existing;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
existing = SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value);
|
||||
|
|
@ -1043,9 +1018,8 @@ bool Importer::SetPropertyString(const char* szName, const std::string& value) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
|
||||
{
|
||||
bool existing;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
existing = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);
|
||||
|
|
@ -1055,43 +1029,40 @@ bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a configuration property
|
||||
int Importer::GetPropertyInteger(const char* szName, int iErrorReturn /*= 0xffffffff*/) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
int Importer::GetPropertyInteger(const char* szName,
|
||||
int iErrorReturn /*= 0xffffffff*/) const
|
||||
{
|
||||
return GetGenericProperty<int>(pimpl->mIntProperties,szName,iErrorReturn);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a configuration property
|
||||
ai_real Importer::GetPropertyFloat(const char* szName, ai_real iErrorReturn /*= 10e10*/) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
ai_real Importer::GetPropertyFloat(const char* szName,
|
||||
ai_real iErrorReturn /*= 10e10*/) const
|
||||
{
|
||||
return GetGenericProperty<ai_real>(pimpl->mFloatProperties,szName,iErrorReturn);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a configuration property
|
||||
std::string Importer::GetPropertyString(const char* szName, const std::string& iErrorReturn /*= ""*/) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
const std::string Importer::GetPropertyString(const char* szName,
|
||||
const std::string& iErrorReturn /*= ""*/) const
|
||||
{
|
||||
return GetGenericProperty<std::string>(pimpl->mStringProperties,szName,iErrorReturn);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a configuration property
|
||||
aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName, const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
const aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName,
|
||||
const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const
|
||||
{
|
||||
return GetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties,szName,iErrorReturn);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get the memory requirements of a single node
|
||||
inline
|
||||
void AddNodeWeight(unsigned int& iScene,const aiNode* pcNode) {
|
||||
if ( nullptr == pcNode ) {
|
||||
return;
|
||||
}
|
||||
inline void AddNodeWeight(unsigned int& iScene,const aiNode* pcNode)
|
||||
{
|
||||
iScene += sizeof(aiNode);
|
||||
iScene += sizeof(unsigned int) * pcNode->mNumMeshes;
|
||||
iScene += sizeof(void*) * pcNode->mNumChildren;
|
||||
|
|
@ -1103,20 +1074,21 @@ void AddNodeWeight(unsigned int& iScene,const aiNode* pcNode) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get the memory requirements of the scene
|
||||
void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
void Importer::GetMemoryRequirements(aiMemoryInfo& in) const
|
||||
{
|
||||
in = aiMemoryInfo();
|
||||
aiScene* mScene = pimpl->mScene;
|
||||
|
||||
// return if we have no scene loaded
|
||||
if (!mScene)
|
||||
if (!pimpl->mScene)
|
||||
return;
|
||||
|
||||
|
||||
in.total = sizeof(aiScene);
|
||||
|
||||
// add all meshes
|
||||
for (unsigned int i = 0; i < mScene->mNumMeshes;++i) {
|
||||
for (unsigned int i = 0; i < mScene->mNumMeshes;++i)
|
||||
{
|
||||
in.meshes += sizeof(aiMesh);
|
||||
if (mScene->mMeshes[i]->HasPositions()) {
|
||||
in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
|
||||
|
|
@ -1133,16 +1105,14 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
|
|||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a) {
|
||||
if (mScene->mMeshes[i]->HasVertexColors(a)) {
|
||||
in.meshes += sizeof(aiColor4D) * mScene->mMeshes[i]->mNumVertices;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a) {
|
||||
if (mScene->mMeshes[i]->HasTextureCoords(a)) {
|
||||
in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
if (mScene->mMeshes[i]->HasBones()) {
|
||||
in.meshes += sizeof(void*) * mScene->mMeshes[i]->mNumBones;
|
||||
|
|
@ -1161,9 +1131,8 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
|
|||
in.textures += sizeof(aiTexture);
|
||||
if (pc->mHeight) {
|
||||
in.textures += 4 * pc->mHeight * pc->mWidth;
|
||||
} else {
|
||||
in.textures += pc->mWidth;
|
||||
}
|
||||
else in.textures += pc->mWidth;
|
||||
}
|
||||
in.total += in.textures;
|
||||
|
||||
|
|
@ -1201,6 +1170,5 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
|
|||
in.materials += pc->mProperties[a]->mDataLength;
|
||||
}
|
||||
}
|
||||
|
||||
in.total += in.materials;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -197,9 +197,6 @@ corresponding preprocessor flag to selectively disable formats.
|
|||
#ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
|
||||
# include "MMD/MMDImporter.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||
# include "M3D/M3DImporter.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER
|
||||
# include "Importer/StepFile/StepFileImporter.h"
|
||||
#endif
|
||||
|
|
@ -226,9 +223,6 @@ void GetImporterInstanceList(std::vector< BaseImporter* >& out)
|
|||
#if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
|
||||
out.push_back( new Discreet3DSImporter());
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_M3D_IMPORTER)
|
||||
out.push_back( new M3DImporter());
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_MD3_IMPORTER)
|
||||
out.push_back( new MD3Importer());
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ corresponding preprocessor flag to selectively disable steps.
|
|||
# include "PostProcessing/OptimizeGraph.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS
|
||||
# include "PostProcessing/SplitByBoneCountProcess.h"
|
||||
# include "Common/SplitByBoneCountProcess.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_DEBONE_PROCESS
|
||||
# include "PostProcessing/DeboneProcess.h"
|
||||
|
|
@ -131,15 +131,11 @@ corresponding preprocessor flag to selectively disable steps.
|
|||
#if (!defined ASSIMP_BUILD_NO_GLOBALSCALE_PROCESS)
|
||||
# include "PostProcessing/ScaleProcess.h"
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS)
|
||||
# include "PostProcessing/ArmaturePopulate.h"
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_GENBOUNDINGBOXES_PROCESS)
|
||||
# include "PostProcessing/GenBoundingBoxesProcess.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -184,9 +180,6 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
|
|||
#if (!defined ASSIMP_BUILD_NO_GLOBALSCALE_PROCESS)
|
||||
out.push_back( new ScaleProcess());
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS)
|
||||
out.push_back( new ArmaturePopulate());
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_PRETRANSFORMVERTICES_PROCESS)
|
||||
out.push_back( new PretransformVertices());
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -1196,7 +1196,6 @@ void SceneCombiner::Copy( aiAnimation** _dest, const aiAnimation* src ) {
|
|||
|
||||
// and reallocate all arrays
|
||||
CopyPtrArray( dest->mChannels, src->mChannels, dest->mNumChannels );
|
||||
CopyPtrArray( dest->mMorphMeshChannels, src->mMorphMeshChannels, dest->mNumMorphMeshChannels );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -1216,26 +1215,6 @@ void SceneCombiner::Copy(aiNodeAnim** _dest, const aiNodeAnim* src) {
|
|||
GetArrayCopy( dest->mRotationKeys, dest->mNumRotationKeys );
|
||||
}
|
||||
|
||||
void SceneCombiner::Copy(aiMeshMorphAnim** _dest, const aiMeshMorphAnim* src) {
|
||||
if ( nullptr == _dest || nullptr == src ) {
|
||||
return;
|
||||
}
|
||||
|
||||
aiMeshMorphAnim* dest = *_dest = new aiMeshMorphAnim();
|
||||
|
||||
// get a flat copy
|
||||
::memcpy(dest,src,sizeof(aiMeshMorphAnim));
|
||||
|
||||
// and reallocate all arrays
|
||||
GetArrayCopy( dest->mKeys, dest->mNumKeys );
|
||||
for (ai_uint i = 0; i < dest->mNumKeys;++i) {
|
||||
dest->mKeys[i].mValues = new unsigned int[dest->mKeys[i].mNumValuesAndWeights];
|
||||
dest->mKeys[i].mWeights = new double[dest->mKeys[i].mNumValuesAndWeights];
|
||||
::memcpy(dest->mKeys[i].mValues, src->mKeys[i].mValues, dest->mKeys[i].mNumValuesAndWeights * sizeof(unsigned int));
|
||||
::memcpy(dest->mKeys[i].mWeights, src->mKeys[i].mWeights, dest->mKeys[i].mNumValuesAndWeights * sizeof(double));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SceneCombiner::Copy( aiCamera** _dest,const aiCamera* src) {
|
||||
if ( nullptr == _dest || nullptr == src ) {
|
||||
|
|
@ -1312,6 +1291,7 @@ void SceneCombiner::Copy(aiMetadata** _dest, const aiMetadata* src) {
|
|||
aiMetadata* dest = *_dest = aiMetadata::Alloc( src->mNumProperties );
|
||||
std::copy(src->mKeys, src->mKeys + src->mNumProperties, dest->mKeys);
|
||||
|
||||
dest->mValues = new aiMetadataEntry[src->mNumProperties];
|
||||
for (unsigned int i = 0; i < src->mNumProperties; ++i) {
|
||||
aiMetadataEntry& in = src->mValues[i];
|
||||
aiMetadataEntry& out = dest->mValues[i];
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -217,7 +217,6 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim)
|
|||
|
||||
// No rotation keys? Generate a dummy track
|
||||
if (!channel->mNumRotationKeys) {
|
||||
ai_assert(!channel->mRotationKeys);
|
||||
channel->mNumRotationKeys = 1;
|
||||
channel->mRotationKeys = new aiQuatKey[1];
|
||||
aiQuatKey& q = channel->mRotationKeys[0];
|
||||
|
|
@ -226,13 +225,10 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim)
|
|||
q.mValue = rotation;
|
||||
|
||||
ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy rotation track has been generated");
|
||||
} else {
|
||||
ai_assert(channel->mRotationKeys);
|
||||
}
|
||||
|
||||
// No scaling keys? Generate a dummy track
|
||||
if (!channel->mNumScalingKeys) {
|
||||
ai_assert(!channel->mScalingKeys);
|
||||
channel->mNumScalingKeys = 1;
|
||||
channel->mScalingKeys = new aiVectorKey[1];
|
||||
aiVectorKey& q = channel->mScalingKeys[0];
|
||||
|
|
@ -241,13 +237,10 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim)
|
|||
q.mValue = scaling;
|
||||
|
||||
ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy scaling track has been generated");
|
||||
} else {
|
||||
ai_assert(channel->mScalingKeys);
|
||||
}
|
||||
|
||||
// No position keys? Generate a dummy track
|
||||
if (!channel->mNumPositionKeys) {
|
||||
ai_assert(!channel->mPositionKeys);
|
||||
channel->mNumPositionKeys = 1;
|
||||
channel->mPositionKeys = new aiVectorKey[1];
|
||||
aiVectorKey& q = channel->mPositionKeys[0];
|
||||
|
|
@ -256,8 +249,6 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim)
|
|||
q.mValue = position;
|
||||
|
||||
ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy position track has been generated");
|
||||
} else {
|
||||
ai_assert(channel->mPositionKeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue