Merge branch 'master' into master
commit
2c3d52a5a1
|
@ -84,10 +84,6 @@ OPTION( ASSIMP_NO_EXPORT
|
||||||
"Disable Assimp's export functionality."
|
"Disable Assimp's export functionality."
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
OPTION( ASSIMP_BUILD_ZLIB
|
|
||||||
"Build your own zlib"
|
|
||||||
OFF
|
|
||||||
)
|
|
||||||
OPTION( ASSIMP_BUILD_ASSIMP_TOOLS
|
OPTION( ASSIMP_BUILD_ASSIMP_TOOLS
|
||||||
"If the supplementary tools for Assimp are built in addition to the library."
|
"If the supplementary tools for Assimp are built in addition to the library."
|
||||||
OFF
|
OFF
|
||||||
|
@ -134,6 +130,18 @@ OPTION ( ASSIMP_IGNORE_GIT_HASH
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF (WIN32)
|
||||||
|
OPTION( ASSIMP_BUILD_ZLIB
|
||||||
|
"Build your own zlib"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
ELSE()
|
||||||
|
OPTION( ASSIMP_BUILD_ZLIB
|
||||||
|
"Build your own zlib"
|
||||||
|
OFF
|
||||||
|
)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF (WIN32)
|
IF (WIN32)
|
||||||
# Use subset of Windows.h
|
# Use subset of Windows.h
|
||||||
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
|
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
|
||||||
|
|
|
@ -150,7 +150,7 @@ AI_WONT_RETURN void B3DImporter::Fail(const string &str) {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int B3DImporter::ReadByte() {
|
int B3DImporter::ReadByte() {
|
||||||
if (_pos > _buf.size()) {
|
if (_pos >= _buf.size()) {
|
||||||
Fail("EOF");
|
Fail("EOF");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -975,7 +975,7 @@ void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7 **apcOutBones)
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the name of the bone
|
// store the name of the bone
|
||||||
pcOutBone->mName.length = (size_t)iMaxLen;
|
pcOutBone->mName.length = static_cast<ai_uint32>(iMaxLen);
|
||||||
::memcpy(pcOutBone->mName.data, pcBone->name, pcOutBone->mName.length);
|
::memcpy(pcOutBone->mName.data, pcBone->name, pcOutBone->mName.length);
|
||||||
pcOutBone->mName.data[pcOutBone->mName.length] = '\0';
|
pcOutBone->mName.data[pcOutBone->mName.length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,7 +486,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
for (unsigned int j = 0,n = 0; j < m->mNumFaces; ++j) {
|
for (unsigned int j = 0,n = 0; j < m->mNumFaces; ++j) {
|
||||||
aiFace& f = m->mFaces[j];
|
aiFace& f = m->mFaces[j];
|
||||||
if (g.triangles[j]>triangles.size()) {
|
if (g.triangles[j] >= triangles.size()) {
|
||||||
throw DeadlyImportError("MS3D: Encountered invalid triangle index, file is malformed");
|
throw DeadlyImportError("MS3D: Encountered invalid triangle index, file is malformed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile,
|
||||||
f.mIndices = new unsigned int[f.mNumIndices=3];
|
f.mIndices = new unsigned int[f.mNumIndices=3];
|
||||||
|
|
||||||
for (unsigned int k = 0; k < 3; ++k,++n) {
|
for (unsigned int k = 0; k < 3; ++k,++n) {
|
||||||
if (t.indices[k]>vertices.size()) {
|
if (t.indices[k] >= vertices.size()) {
|
||||||
throw DeadlyImportError("MS3D: Encountered invalid vertex index, file is malformed");
|
throw DeadlyImportError("MS3D: Encountered invalid vertex index, file is malformed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -590,7 +590,7 @@ void SMDImporter::CreateOutputMaterials() {
|
||||||
pScene->mMaterials[iMat] = pcMat;
|
pScene->mMaterials[iMat] = pcMat;
|
||||||
|
|
||||||
aiString szName;
|
aiString szName;
|
||||||
szName.length = (size_t)ai_snprintf(szName.data,MAXLEN,"Texture_%u",iMat);
|
szName.length = static_cast<ai_uint32>(ai_snprintf(szName.data,MAXLEN,"Texture_%u",iMat));
|
||||||
pcMat->AddProperty(&szName,AI_MATKEY_NAME);
|
pcMat->AddProperty(&szName,AI_MATKEY_NAME);
|
||||||
|
|
||||||
if (aszTextures[iMat].length())
|
if (aszTextures[iMat].length())
|
||||||
|
|
|
@ -836,7 +836,7 @@ namespace glTF2 {
|
||||||
throw DeadlyExportError("Failed to write scene data!");
|
throw DeadlyExportError("Failed to write scene data!");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t jsonChunkLength = (docBuffer.GetSize() + 3) & ~3; // Round up to next multiple of 4
|
uint32_t jsonChunkLength = static_cast<uint32_t>((docBuffer.GetSize() + 3) & ~3); // Round up to next multiple of 4
|
||||||
auto paddingLength = jsonChunkLength - docBuffer.GetSize();
|
auto paddingLength = jsonChunkLength - docBuffer.GetSize();
|
||||||
|
|
||||||
GLB_Chunk jsonChunk;
|
GLB_Chunk jsonChunk;
|
||||||
|
@ -862,7 +862,7 @@ namespace glTF2 {
|
||||||
int GLB_Chunk_count = 1;
|
int GLB_Chunk_count = 1;
|
||||||
uint32_t binaryChunkLength = 0;
|
uint32_t binaryChunkLength = 0;
|
||||||
if (bodyBuffer->byteLength > 0) {
|
if (bodyBuffer->byteLength > 0) {
|
||||||
binaryChunkLength = (bodyBuffer->byteLength + 3) & ~3; // Round up to next multiple of 4
|
binaryChunkLength = static_cast<uint32_t>((bodyBuffer->byteLength + 3) & ~3); // Round up to next multiple of 4
|
||||||
|
|
||||||
auto curPaddingLength = binaryChunkLength - bodyBuffer->byteLength;
|
auto curPaddingLength = binaryChunkLength - bodyBuffer->byteLength;
|
||||||
++GLB_Chunk_count;
|
++GLB_Chunk_count;
|
||||||
|
|
|
@ -482,37 +482,43 @@ bool Importer::ValidateFlags(unsigned int pFlags) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
|
const aiScene* Importer::ReadFileFromMemory(const void* pBuffer, size_t pLength, unsigned int pFlags, const char* pHint ) {
|
||||||
size_t pLength,
|
|
||||||
unsigned int pFlags,
|
|
||||||
const char* pHint /*= ""*/) {
|
|
||||||
ai_assert(nullptr != pimpl);
|
ai_assert(nullptr != pimpl);
|
||||||
|
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
|
||||||
if (!pHint) {
|
|
||||||
pHint = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pBuffer || !pLength || strlen(pHint) > MaxLenHint ) {
|
|
||||||
pimpl->mErrorString = "Invalid parameters passed to ReadFileFromMemory()";
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// prevent deletion of the previous IOHandler
|
|
||||||
IOSystem* io = pimpl->mIOHandler;
|
IOSystem* io = pimpl->mIOHandler;
|
||||||
pimpl->mIOHandler = nullptr;
|
try {
|
||||||
|
if (pHint == nullptr) {
|
||||||
|
pHint = "";
|
||||||
|
}
|
||||||
|
if (!pBuffer || !pLength || strlen(pHint) > MaxLenHint ) {
|
||||||
|
pimpl->mErrorString = "Invalid parameters passed to ReadFileFromMemory()";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
// prevent deletion of the previous IOHandler
|
||||||
|
pimpl->mIOHandler = nullptr;
|
||||||
|
|
||||||
SetIOHandler(new MemoryIOSystem((const uint8_t*)pBuffer,pLength,io));
|
SetIOHandler(new MemoryIOSystem((const uint8_t*)pBuffer,pLength,io));
|
||||||
|
|
||||||
// read the file and recover the previous IOSystem
|
// read the file and recover the previous IOSystem
|
||||||
static const size_t BufSize(Importer::MaxLenHint + 28);
|
static const size_t BufSize(Importer::MaxLenHint + 28);
|
||||||
char fbuff[BufSize];
|
char fbuff[BufSize];
|
||||||
ai_snprintf(fbuff, BufSize, "%s.%s",AI_MEMORYIO_MAGIC_FILENAME,pHint);
|
ai_snprintf(fbuff, BufSize, "%s.%s",AI_MEMORYIO_MAGIC_FILENAME,pHint);
|
||||||
|
|
||||||
ReadFile(fbuff,pFlags);
|
ReadFile(fbuff,pFlags);
|
||||||
SetIOHandler(io);
|
SetIOHandler(io);
|
||||||
|
} catch(const DeadlyImportError &e) {
|
||||||
|
pimpl->mErrorString = e.what();
|
||||||
|
pimpl->mException = std::current_exception();
|
||||||
|
SetIOHandler(io);
|
||||||
|
return ExceptionSwallower<const aiScene*>()(); \
|
||||||
|
} catch(...) {
|
||||||
|
pimpl->mErrorString = "Unknown exception";
|
||||||
|
pimpl->mException = std::current_exception();
|
||||||
|
SetIOHandler(io);
|
||||||
|
return ExceptionSwallower<const aiScene*>()(); \
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString, pimpl->mException);
|
|
||||||
return pimpl->mScene;
|
return pimpl->mScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6092,8 +6092,8 @@ mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) {
|
||||||
if (!pZip->m_file_offset_alignment)
|
if (!pZip->m_file_offset_alignment)
|
||||||
return 0;
|
return 0;
|
||||||
n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1));
|
n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1));
|
||||||
return (pZip->m_file_offset_alignment - n) &
|
return (mz_uint)((pZip->m_file_offset_alignment - n) &
|
||||||
(pZip->m_file_offset_alignment - 1);
|
(pZip->m_file_offset_alignment - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip,
|
static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip,
|
||||||
|
|
|
@ -14,7 +14,7 @@ __Importers__:
|
||||||
- B3D
|
- B3D
|
||||||
- [BLEND](https://en.wikipedia.org/wiki/.blend_(file_format))
|
- [BLEND](https://en.wikipedia.org/wiki/.blend_(file_format))
|
||||||
- [BVH](https://en.wikipedia.org/wiki/Biovision_Hierarchy)
|
- [BVH](https://en.wikipedia.org/wiki/Biovision_Hierarchy)
|
||||||
- CMS
|
- CSM
|
||||||
- COB
|
- COB
|
||||||
- [DAE/Collada](https://en.wikipedia.org/wiki/COLLADA)
|
- [DAE/Collada](https://en.wikipedia.org/wiki/COLLADA)
|
||||||
- [DXF](https://en.wikipedia.org/wiki/AutoCAD_DXF)
|
- [DXF](https://en.wikipedia.org/wiki/AutoCAD_DXF)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2023, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
||||||
aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
|
aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
|
||||||
aiAttachLogStream(&stream);
|
aiAttachLogStream(&stream);
|
||||||
|
|
||||||
Importer importer;
|
Importer importer;
|
||||||
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize,
|
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize,
|
||||||
|
@ -57,3 +57,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2022, assimp team
|
Copyright (c) 2006-2022, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -66,23 +65,21 @@ namespace Assimp {
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
class MemoryIOStream : public IOStream {
|
class MemoryIOStream : public IOStream {
|
||||||
public:
|
public:
|
||||||
MemoryIOStream (const uint8_t* buff, size_t len, bool own = false)
|
MemoryIOStream (const uint8_t* buff, size_t len, bool own = false) :
|
||||||
: buffer (buff)
|
buffer (buff),
|
||||||
, length(len)
|
length(len),
|
||||||
, pos((size_t)0)
|
pos(static_cast<size_t>(0)),
|
||||||
, own(own) {
|
own(own) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
~MemoryIOStream () {
|
~MemoryIOStream() override {
|
||||||
if(own) {
|
if(own) {
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) override {
|
||||||
// Read from stream
|
|
||||||
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) {
|
|
||||||
ai_assert(nullptr != pvBuffer);
|
ai_assert(nullptr != pvBuffer);
|
||||||
ai_assert(0 != pSize);
|
ai_assert(0 != pSize);
|
||||||
|
|
||||||
|
@ -95,16 +92,12 @@ public:
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
size_t Write(const void*, size_t, size_t ) override {
|
||||||
// Write to stream
|
|
||||||
size_t Write(const void* /*pvBuffer*/, size_t /*pSize*/,size_t /*pCount*/) {
|
|
||||||
ai_assert(false); // won't be needed
|
ai_assert(false); // won't be needed
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override {
|
||||||
// Seek specific position
|
|
||||||
aiReturn Seek(size_t pOffset, aiOrigin pOrigin) {
|
|
||||||
if (aiOrigin_SET == pOrigin) {
|
if (aiOrigin_SET == pOrigin) {
|
||||||
if (pOffset > length) {
|
if (pOffset > length) {
|
||||||
return AI_FAILURE;
|
return AI_FAILURE;
|
||||||
|
@ -124,21 +117,15 @@ public:
|
||||||
return AI_SUCCESS;
|
return AI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
size_t Tell() const override {
|
||||||
// Get current seek position
|
|
||||||
size_t Tell() const {
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
size_t FileSize() const override {
|
||||||
// Get size of file
|
|
||||||
size_t FileSize() const {
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
void Flush() override{
|
||||||
// Flush file contents
|
|
||||||
void Flush() {
|
|
||||||
ai_assert(false); // won't be needed
|
ai_assert(false); // won't be needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,24 +136,21 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Dummy IO system to read from a memory buffer */
|
/// @brief Dummy IO system to read from a memory buffer.
|
||||||
class MemoryIOSystem : public IOSystem {
|
class MemoryIOSystem : public IOSystem {
|
||||||
public:
|
public:
|
||||||
/** Constructor. */
|
/// @brief Constructor.
|
||||||
MemoryIOSystem(const uint8_t* buff, size_t len, IOSystem* io)
|
MemoryIOSystem(const uint8_t* buff, size_t len, IOSystem* io) : buffer(buff), length(len), existing_io(io) {
|
||||||
: buffer(buff)
|
|
||||||
, length(len)
|
|
||||||
, existing_io(io)
|
|
||||||
, created_streams() {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destructor. */
|
/// @brief Destructor.
|
||||||
~MemoryIOSystem() = default;
|
~MemoryIOSystem() = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Tests for the existence of a file at the given path. */
|
/// @brief Tests for the existence of a file at the given path.
|
||||||
bool Exists(const char* pFile) const override {
|
bool Exists(const char* pFile) const override {
|
||||||
|
printf("Exists\n");
|
||||||
if (0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) {
|
if (0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -174,24 +158,24 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns the directory separator. */
|
/// @brief Returns the directory separator.
|
||||||
char getOsSeparator() const override {
|
char getOsSeparator() const override {
|
||||||
return existing_io ? existing_io->getOsSeparator()
|
return existing_io ? existing_io->getOsSeparator()
|
||||||
: '/'; // why not? it doesn't care
|
: '/'; // why not? it doesn't care
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Open a new file with a given path. */
|
/// @brief Open a new file with a given path.
|
||||||
IOStream* Open(const char* pFile, const char* pMode = "rb") override {
|
IOStream* Open(const char* pFile, const char* pMode = "rb") override {
|
||||||
if ( 0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) {
|
if ( 0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) {
|
||||||
created_streams.emplace_back(new MemoryIOStream(buffer, length));
|
created_streams.emplace_back(new MemoryIOStream(buffer, length));
|
||||||
return created_streams.back();
|
return created_streams.back();
|
||||||
}
|
}
|
||||||
return existing_io ? existing_io->Open(pFile, pMode) : NULL;
|
return existing_io ? existing_io->Open(pFile, pMode) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Closes the given file and releases all resources associated with it. */
|
/// @brief Closes the given file and releases all resources associated with it.
|
||||||
void Close( IOStream* pFile) override {
|
void Close( IOStream* pFile) override {
|
||||||
auto it = std::find(created_streams.begin(), created_streams.end(), pFile);
|
auto it = std::find(created_streams.begin(), created_streams.end(), pFile);
|
||||||
if (it != created_streams.end()) {
|
if (it != created_streams.end()) {
|
||||||
|
@ -203,36 +187,43 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Compare two paths */
|
/// @brief Compare two paths
|
||||||
bool ComparePaths(const char* one, const char* second) const override {
|
bool ComparePaths(const char* one, const char* second) const override {
|
||||||
return existing_io ? existing_io->ComparePaths(one, second) : false;
|
return existing_io ? existing_io->ComparePaths(one, second) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will push the directory.
|
||||||
bool PushDirectory( const std::string &path ) override {
|
bool PushDirectory( const std::string &path ) override {
|
||||||
return existing_io ? existing_io->PushDirectory(path) : false;
|
return existing_io ? existing_io->PushDirectory(path) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will return the current directory from the stack top.
|
||||||
const std::string &CurrentDirectory() const override {
|
const std::string &CurrentDirectory() const override {
|
||||||
static std::string empty;
|
static std::string empty;
|
||||||
return existing_io ? existing_io->CurrentDirectory() : empty;
|
return existing_io ? existing_io->CurrentDirectory() : empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Returns the stack size.
|
||||||
size_t StackSize() const override {
|
size_t StackSize() const override {
|
||||||
return existing_io ? existing_io->StackSize() : 0;
|
return existing_io ? existing_io->StackSize() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will pop the upper directory.
|
||||||
bool PopDirectory() override {
|
bool PopDirectory() override {
|
||||||
return existing_io ? existing_io->PopDirectory() : false;
|
return existing_io ? existing_io->PopDirectory() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will create the directory.
|
||||||
bool CreateDirectory( const std::string &path ) override {
|
bool CreateDirectory( const std::string &path ) override {
|
||||||
return existing_io ? existing_io->CreateDirectory(path) : false;
|
return existing_io ? existing_io->CreateDirectory(path) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will change the directory.
|
||||||
bool ChangeDirectory( const std::string &path ) override {
|
bool ChangeDirectory( const std::string &path ) override {
|
||||||
return existing_io ? existing_io->ChangeDirectory(path) : false;
|
return existing_io ? existing_io->ChangeDirectory(path) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will delete the file.
|
||||||
bool DeleteFile( const std::string &file ) override {
|
bool DeleteFile( const std::string &file ) override {
|
||||||
return existing_io ? existing_io->DeleteFile(file) : false;
|
return existing_io ? existing_io->DeleteFile(file) : false;
|
||||||
}
|
}
|
||||||
|
@ -246,4 +237,4 @@ private:
|
||||||
|
|
||||||
} // end namespace Assimp
|
} // end namespace Assimp
|
||||||
|
|
||||||
#endif
|
#endif // AI_MEMORYIOSTREAM_H_INC
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2022, assimp team
|
Copyright (c) 2006-2023, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -111,7 +111,8 @@ extern "C" {
|
||||||
#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS
|
#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** @brief A single face in a mesh, referring to multiple vertices.
|
/**
|
||||||
|
* @brief A single face in a mesh, referring to multiple vertices.
|
||||||
*
|
*
|
||||||
* If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3
|
* If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3
|
||||||
* it's called 'polygon' (hey, that's just a definition!).
|
* it's called 'polygon' (hey, that's just a definition!).
|
||||||
|
@ -142,25 +143,25 @@ struct aiFace {
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
//! Default constructor
|
//! @brief Default constructor.
|
||||||
aiFace() AI_NO_EXCEPT
|
aiFace() AI_NO_EXCEPT
|
||||||
: mNumIndices(0),
|
: mNumIndices(0),
|
||||||
mIndices(nullptr) {
|
mIndices(nullptr) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Default destructor. Delete the index array
|
//! @brief Default destructor. Delete the index array
|
||||||
~aiFace() {
|
~aiFace() {
|
||||||
delete[] mIndices;
|
delete[] mIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Copy constructor. Copy the index array
|
//! @brief Copy constructor. Copy the index array
|
||||||
aiFace(const aiFace &o) :
|
aiFace(const aiFace &o) :
|
||||||
mNumIndices(0), mIndices(nullptr) {
|
mNumIndices(0), mIndices(nullptr) {
|
||||||
*this = o;
|
*this = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Assignment operator. Copy the index array
|
//! @brief Assignment operator. Copy the index array
|
||||||
aiFace &operator=(const aiFace &o) {
|
aiFace &operator=(const aiFace &o) {
|
||||||
if (&o == this) {
|
if (&o == this) {
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -178,8 +179,7 @@ struct aiFace {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Comparison operator. Checks whether the index array
|
//! @brief Comparison operator. Checks whether the index array of two faces is identical.
|
||||||
//! of two faces is identical
|
|
||||||
bool operator==(const aiFace &o) const {
|
bool operator==(const aiFace &o) const {
|
||||||
if (mIndices == o.mIndices) {
|
if (mIndices == o.mIndices) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -202,7 +202,7 @@ struct aiFace {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Inverse comparison operator. Checks whether the index
|
//! @brief Inverse comparison operator. Checks whether the index
|
||||||
//! array of two faces is NOT identical
|
//! array of two faces is NOT identical
|
||||||
bool operator!=(const aiFace &o) const {
|
bool operator!=(const aiFace &o) const {
|
||||||
return !(*this == o);
|
return !(*this == o);
|
||||||
|
@ -223,14 +223,14 @@ struct aiVertexWeight {
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
//! Default constructor
|
//! @brief Default constructor
|
||||||
aiVertexWeight() AI_NO_EXCEPT
|
aiVertexWeight() AI_NO_EXCEPT
|
||||||
: mVertexId(0),
|
: mVertexId(0),
|
||||||
mWeight(0.0f) {
|
mWeight(0.0f) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Initialization from a given index and vertex weight factor
|
//! @brief Initialization from a given index and vertex weight factor
|
||||||
//! \param pID ID
|
//! \param pID ID
|
||||||
//! \param pWeight Vertex weight factor
|
//! \param pWeight Vertex weight factor
|
||||||
aiVertexWeight(unsigned int pID, float pWeight) :
|
aiVertexWeight(unsigned int pID, float pWeight) :
|
||||||
|
@ -261,27 +261,38 @@ struct aiNode;
|
||||||
* position of the bone at the time of binding.
|
* position of the bone at the time of binding.
|
||||||
*/
|
*/
|
||||||
struct aiBone {
|
struct aiBone {
|
||||||
//! The name of the bone.
|
/**
|
||||||
|
* The name of the bone.
|
||||||
|
*/
|
||||||
C_STRUCT aiString mName;
|
C_STRUCT aiString mName;
|
||||||
|
|
||||||
//! The number of vertices affected by this bone.
|
/**
|
||||||
//! The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
|
* The number of vertices affected by this bone.
|
||||||
|
* The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
|
||||||
|
*/
|
||||||
unsigned int mNumWeights;
|
unsigned int mNumWeights;
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
||||||
/// The bone armature node - used for skeleton conversion
|
/**
|
||||||
/// you must enable aiProcess_PopulateArmatureData to populate this
|
* The bone armature node - used for skeleton conversion
|
||||||
|
* you must enable aiProcess_PopulateArmatureData to populate this
|
||||||
|
*/
|
||||||
C_STRUCT aiNode *mArmature;
|
C_STRUCT aiNode *mArmature;
|
||||||
|
|
||||||
/// The bone node in the scene - used for skeleton conversion
|
/**
|
||||||
/// you must enable aiProcess_PopulateArmatureData to populate this
|
* The bone node in the scene - used for skeleton conversion
|
||||||
|
* you must enable aiProcess_PopulateArmatureData to populate this
|
||||||
|
*/
|
||||||
C_STRUCT aiNode *mNode;
|
C_STRUCT aiNode *mNode;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
//! The influence weights of this bone, by vertex index.
|
/**
|
||||||
|
* The influence weights of this bone, by vertex index.
|
||||||
|
*/
|
||||||
C_STRUCT aiVertexWeight *mWeights;
|
C_STRUCT aiVertexWeight *mWeights;
|
||||||
|
|
||||||
/** Matrix that transforms from mesh space to bone space in bind pose.
|
/**
|
||||||
|
* Matrix that transforms from mesh space to bone space in bind pose.
|
||||||
*
|
*
|
||||||
* This matrix describes the position of the mesh
|
* This matrix describes the position of the mesh
|
||||||
* in the local space of this bone when the skeleton was bound.
|
* in the local space of this bone when the skeleton was bound.
|
||||||
|
@ -338,7 +349,7 @@ struct aiBone {
|
||||||
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Assignment operator
|
//! @brief Assignment operator
|
||||||
aiBone &operator = (const aiBone &other) {
|
aiBone &operator = (const aiBone &other) {
|
||||||
if (this == &other) {
|
if (this == &other) {
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -352,6 +363,7 @@ struct aiBone {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Compare operator.
|
||||||
bool operator==(const aiBone &rhs) const {
|
bool operator==(const aiBone &rhs) const {
|
||||||
if (mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
|
if (mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -365,7 +377,7 @@ struct aiBone {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//! Destructor - deletes the array of vertex weights
|
//! @brief Destructor - deletes the array of vertex weights
|
||||||
~aiBone() {
|
~aiBone() {
|
||||||
delete[] mWeights;
|
delete[] mWeights;
|
||||||
}
|
}
|
||||||
|
@ -381,27 +393,31 @@ struct aiBone {
|
||||||
* @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types.
|
* @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types.
|
||||||
*/
|
*/
|
||||||
enum aiPrimitiveType {
|
enum aiPrimitiveType {
|
||||||
/** A point primitive.
|
/**
|
||||||
|
* @brief A point primitive.
|
||||||
*
|
*
|
||||||
* This is just a single vertex in the virtual world,
|
* This is just a single vertex in the virtual world,
|
||||||
* #aiFace contains just one index for such a primitive.
|
* #aiFace contains just one index for such a primitive.
|
||||||
*/
|
*/
|
||||||
aiPrimitiveType_POINT = 0x1,
|
aiPrimitiveType_POINT = 0x1,
|
||||||
|
|
||||||
/** A line primitive.
|
/**
|
||||||
|
* @brief A line primitive.
|
||||||
*
|
*
|
||||||
* This is a line defined through a start and an end position.
|
* This is a line defined through a start and an end position.
|
||||||
* #aiFace contains exactly two indices for such a primitive.
|
* #aiFace contains exactly two indices for such a primitive.
|
||||||
*/
|
*/
|
||||||
aiPrimitiveType_LINE = 0x2,
|
aiPrimitiveType_LINE = 0x2,
|
||||||
|
|
||||||
/** A triangular primitive.
|
/**
|
||||||
|
* @brief A triangular primitive.
|
||||||
*
|
*
|
||||||
* A triangle consists of three indices.
|
* A triangle consists of three indices.
|
||||||
*/
|
*/
|
||||||
aiPrimitiveType_TRIANGLE = 0x4,
|
aiPrimitiveType_TRIANGLE = 0x4,
|
||||||
|
|
||||||
/** A higher-level polygon with more than 3 edges.
|
/**
|
||||||
|
* @brief A higher-level polygon with more than 3 edges.
|
||||||
*
|
*
|
||||||
* A triangle is a polygon, but polygon in this context means
|
* A triangle is a polygon, but polygon in this context means
|
||||||
* "all polygons that are not triangles". The "Triangulate"-Step
|
* "all polygons that are not triangles". The "Triangulate"-Step
|
||||||
|
@ -411,7 +427,7 @@ enum aiPrimitiveType {
|
||||||
aiPrimitiveType_POLYGON = 0x8,
|
aiPrimitiveType_POLYGON = 0x8,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag to determine whether this triangles only mesh is NGON encoded.
|
* @brief A flag to determine whether this triangles only mesh is NGON encoded.
|
||||||
*
|
*
|
||||||
* NGON encoding is a special encoding that tells whether 2 or more consecutive triangles
|
* NGON encoding is a special encoding that tells whether 2 or more consecutive triangles
|
||||||
* should be considered as a triangle fan. This is identified by looking at the first vertex index.
|
* should be considered as a triangle fan. This is identified by looking at the first vertex index.
|
||||||
|
@ -428,8 +444,9 @@ enum aiPrimitiveType {
|
||||||
*/
|
*/
|
||||||
aiPrimitiveType_NGONEncodingFlag = 0x10,
|
aiPrimitiveType_NGONEncodingFlag = 0x10,
|
||||||
|
|
||||||
/** This value is not used. It is just here to force the
|
/**
|
||||||
* compiler to map this enum to a 32 Bit integer.
|
* This value is not used. It is just here to force the
|
||||||
|
* compiler to map this enum to a 32 Bit integer.
|
||||||
*/
|
*/
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
_aiPrimitiveType_Force32Bit = INT_MAX
|
_aiPrimitiveType_Force32Bit = INT_MAX
|
||||||
|
@ -494,25 +511,20 @@ struct aiAnimMesh {
|
||||||
float mWeight;
|
float mWeight;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
/// @brief The class constructor.
|
||||||
aiAnimMesh() AI_NO_EXCEPT
|
aiAnimMesh() AI_NO_EXCEPT :
|
||||||
: mVertices(nullptr),
|
mVertices(nullptr),
|
||||||
mNormals(nullptr),
|
mNormals(nullptr),
|
||||||
mTangents(nullptr),
|
mTangents(nullptr),
|
||||||
mBitangents(nullptr),
|
mBitangents(nullptr),
|
||||||
mColors(),
|
mColors {nullptr},
|
||||||
mTextureCoords(),
|
mTextureCoords{nullptr},
|
||||||
mNumVertices(0),
|
mNumVertices(0),
|
||||||
mWeight(0.0f) {
|
mWeight(0.0f) {
|
||||||
// fixme consider moving this to the ctor initializer list as well
|
// empty
|
||||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
|
|
||||||
mTextureCoords[a] = nullptr;
|
|
||||||
}
|
|
||||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
|
|
||||||
mColors[a] = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief The class destructor.
|
||||||
~aiAnimMesh() {
|
~aiAnimMesh() {
|
||||||
delete[] mVertices;
|
delete[] mVertices;
|
||||||
delete[] mNormals;
|
delete[] mNormals;
|
||||||
|
@ -526,35 +538,51 @@ struct aiAnimMesh {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the anim mesh overrides the vertex positions
|
/**
|
||||||
* of its host mesh*/
|
* @brief Check whether the anim-mesh overrides the vertex positions
|
||||||
|
* of its host mesh.
|
||||||
|
* @return true if positions are stored, false if not.
|
||||||
|
*/
|
||||||
bool HasPositions() const {
|
bool HasPositions() const {
|
||||||
return mVertices != nullptr;
|
return mVertices != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the anim mesh overrides the vertex normals
|
/**
|
||||||
* of its host mesh*/
|
* @brief Check whether the anim-mesh overrides the vertex normals
|
||||||
|
* of its host mesh
|
||||||
|
* @return true if normals are stored, false if not.
|
||||||
|
*/
|
||||||
bool HasNormals() const {
|
bool HasNormals() const {
|
||||||
return mNormals != nullptr;
|
return mNormals != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the anim mesh overrides the vertex tangents
|
/**
|
||||||
* and bitangents of its host mesh. As for aiMesh,
|
* @brief Check whether the anim-mesh overrides the vertex tangents
|
||||||
* tangents and bitangents always go together. */
|
* and bitangents of its host mesh. As for aiMesh,
|
||||||
|
* tangents and bitangents always go together.
|
||||||
|
* @return true if tangents and bi-tangents are stored, false if not.
|
||||||
|
*/
|
||||||
bool HasTangentsAndBitangents() const {
|
bool HasTangentsAndBitangents() const {
|
||||||
return mTangents != nullptr;
|
return mTangents != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the anim mesh overrides a particular
|
/**
|
||||||
* set of vertex colors on his host mesh.
|
* @brief Check whether the anim mesh overrides a particular
|
||||||
* @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS */
|
* set of vertex colors on his host mesh.
|
||||||
|
* @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS
|
||||||
|
* @return true if vertex colors are stored, false if not.
|
||||||
|
*/
|
||||||
|
|
||||||
bool HasVertexColors(unsigned int pIndex) const {
|
bool HasVertexColors(unsigned int pIndex) const {
|
||||||
return pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != nullptr;
|
return pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the anim mesh overrides a particular
|
/**
|
||||||
* set of texture coordinates on his host mesh.
|
* @brief Check whether the anim mesh overrides a particular
|
||||||
* @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS */
|
* set of texture coordinates on his host mesh.
|
||||||
|
* @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS
|
||||||
|
* @return true if texture coordinates are stored, false if not.
|
||||||
|
*/
|
||||||
bool HasTextureCoords(unsigned int pIndex) const {
|
bool HasTextureCoords(unsigned int pIndex) const {
|
||||||
return pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != nullptr;
|
return pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != nullptr;
|
||||||
}
|
}
|
||||||
|
@ -588,143 +616,167 @@ enum aiMorphingMethod {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** @brief A mesh represents a geometry or model with a single material.
|
/** @brief A mesh represents a geometry or model with a single material.
|
||||||
*
|
*
|
||||||
* It usually consists of a number of vertices and a series of primitives/faces
|
* It usually consists of a number of vertices and a series of primitives/faces
|
||||||
* referencing the vertices. In addition there might be a series of bones, each
|
* referencing the vertices. In addition there might be a series of bones, each
|
||||||
* of them addressing a number of vertices with a certain weight. Vertex data
|
* of them addressing a number of vertices with a certain weight. Vertex data
|
||||||
* is presented in channels with each channel containing a single per-vertex
|
* is presented in channels with each channel containing a single per-vertex
|
||||||
* information such as a set of texture coordinates or a normal vector.
|
* information such as a set of texture coordinates or a normal vector.
|
||||||
* If a data pointer is non-null, the corresponding data stream is present.
|
* If a data pointer is non-null, the corresponding data stream is present.
|
||||||
* From C++-programs you can also use the comfort functions Has*() to
|
* From C++-programs you can also use the comfort functions Has*() to
|
||||||
* test for the presence of various data streams.
|
* test for the presence of various data streams.
|
||||||
*
|
*
|
||||||
* A Mesh uses only a single material which is referenced by a material ID.
|
* A Mesh uses only a single material which is referenced by a material ID.
|
||||||
* @note The mPositions member is usually not optional. However, vertex positions
|
* @note The mPositions member is usually not optional. However, vertex positions
|
||||||
* *could* be missing if the #AI_SCENE_FLAGS_INCOMPLETE flag is set in
|
* *could* be missing if the #AI_SCENE_FLAGS_INCOMPLETE flag is set in
|
||||||
* @code
|
* @code
|
||||||
* aiScene::mFlags
|
* aiScene::mFlags
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
struct aiMesh {
|
struct aiMesh {
|
||||||
/** Bitwise combination of the members of the #aiPrimitiveType enum.
|
/**
|
||||||
|
* Bitwise combination of the members of the #aiPrimitiveType enum.
|
||||||
* This specifies which types of primitives are present in the mesh.
|
* This specifies which types of primitives are present in the mesh.
|
||||||
* The "SortByPrimitiveType"-Step can be used to make sure the
|
* The "SortByPrimitiveType"-Step can be used to make sure the
|
||||||
* output meshes consist of one primitive type each.
|
* output meshes consist of one primitive type each.
|
||||||
*/
|
*/
|
||||||
unsigned int mPrimitiveTypes;
|
unsigned int mPrimitiveTypes;
|
||||||
|
|
||||||
/** The number of vertices in this mesh.
|
/**
|
||||||
* This is also the size of all of the per-vertex data arrays.
|
* The number of vertices in this mesh.
|
||||||
* The maximum value for this member is #AI_MAX_VERTICES.
|
* This is also the size of all of the per-vertex data arrays.
|
||||||
*/
|
* The maximum value for this member is #AI_MAX_VERTICES.
|
||||||
|
*/
|
||||||
unsigned int mNumVertices;
|
unsigned int mNumVertices;
|
||||||
|
|
||||||
/** The number of primitives (triangles, polygons, lines) in this mesh.
|
/**
|
||||||
* This is also the size of the mFaces array.
|
* The number of primitives (triangles, polygons, lines) in this mesh.
|
||||||
* The maximum value for this member is #AI_MAX_FACES.
|
* This is also the size of the mFaces array.
|
||||||
*/
|
* The maximum value for this member is #AI_MAX_FACES.
|
||||||
|
*/
|
||||||
unsigned int mNumFaces;
|
unsigned int mNumFaces;
|
||||||
|
|
||||||
/** Vertex positions.
|
/**
|
||||||
* This array is always present in a mesh. The array is
|
* @brief Vertex positions.
|
||||||
* mNumVertices in size.
|
*
|
||||||
*/
|
* This array is always present in a mesh. The array is
|
||||||
|
* mNumVertices in size.
|
||||||
|
*/
|
||||||
C_STRUCT aiVector3D *mVertices;
|
C_STRUCT aiVector3D *mVertices;
|
||||||
|
|
||||||
/** Vertex normals.
|
/**
|
||||||
* The array contains normalized vectors, nullptr if not present.
|
* @brief Vertex normals.
|
||||||
* The array is mNumVertices in size. Normals are undefined for
|
*
|
||||||
* point and line primitives. A mesh consisting of points and
|
* The array contains normalized vectors, nullptr if not present.
|
||||||
* lines only may not have normal vectors. Meshes with mixed
|
* The array is mNumVertices in size. Normals are undefined for
|
||||||
* primitive types (i.e. lines and triangles) may have normals,
|
* point and line primitives. A mesh consisting of points and
|
||||||
* but the normals for vertices that are only referenced by
|
* lines only may not have normal vectors. Meshes with mixed
|
||||||
* point or line primitives are undefined and set to QNaN (WARN:
|
* primitive types (i.e. lines and triangles) may have normals,
|
||||||
* qNaN compares to inequal to *everything*, even to qNaN itself.
|
* but the normals for vertices that are only referenced by
|
||||||
* Using code like this to check whether a field is qnan is:
|
* point or line primitives are undefined and set to QNaN (WARN:
|
||||||
* @code
|
* qNaN compares to inequal to *everything*, even to qNaN itself.
|
||||||
* #define IS_QNAN(f) (f != f)
|
* Using code like this to check whether a field is qnan is:
|
||||||
* @endcode
|
* @code
|
||||||
* still dangerous because even 1.f == 1.f could evaluate to false! (
|
* #define IS_QNAN(f) (f != f)
|
||||||
* remember the subtleties of IEEE754 artithmetics). Use stuff like
|
* @endcode
|
||||||
* @c fpclassify instead.
|
* still dangerous because even 1.f == 1.f could evaluate to false! (
|
||||||
* @note Normal vectors computed by Assimp are always unit-length.
|
* remember the subtleties of IEEE754 artithmetics). Use stuff like
|
||||||
* However, this needn't apply for normals that have been taken
|
* @c fpclassify instead.
|
||||||
* directly from the model file.
|
* @note Normal vectors computed by Assimp are always unit-length.
|
||||||
*/
|
* However, this needn't apply for normals that have been taken
|
||||||
|
* directly from the model file.
|
||||||
|
*/
|
||||||
C_STRUCT aiVector3D *mNormals;
|
C_STRUCT aiVector3D *mNormals;
|
||||||
|
|
||||||
/** Vertex tangents.
|
/**
|
||||||
* The tangent of a vertex points in the direction of the positive
|
* @brief Vertex tangents.
|
||||||
* X texture axis. The array contains normalized vectors, nullptr if
|
*
|
||||||
* not present. The array is mNumVertices in size. A mesh consisting
|
* The tangent of a vertex points in the direction of the positive
|
||||||
* of points and lines only may not have normal vectors. Meshes with
|
* X texture axis. The array contains normalized vectors, nullptr if
|
||||||
* mixed primitive types (i.e. lines and triangles) may have
|
* not present. The array is mNumVertices in size. A mesh consisting
|
||||||
* normals, but the normals for vertices that are only referenced by
|
* of points and lines only may not have normal vectors. Meshes with
|
||||||
* point or line primitives are undefined and set to qNaN. See
|
* mixed primitive types (i.e. lines and triangles) may have
|
||||||
* the #mNormals member for a detailed discussion of qNaNs.
|
* normals, but the normals for vertices that are only referenced by
|
||||||
* @note If the mesh contains tangents, it automatically also
|
* point or line primitives are undefined and set to qNaN. See
|
||||||
* contains bitangents.
|
* the #mNormals member for a detailed discussion of qNaNs.
|
||||||
*/
|
* @note If the mesh contains tangents, it automatically also
|
||||||
|
* contains bitangents.
|
||||||
|
*/
|
||||||
C_STRUCT aiVector3D *mTangents;
|
C_STRUCT aiVector3D *mTangents;
|
||||||
|
|
||||||
/** Vertex bitangents.
|
/**
|
||||||
* The bitangent of a vertex points in the direction of the positive
|
* @brief Vertex bitangents.
|
||||||
* Y texture axis. The array contains normalized vectors, nullptr if not
|
*
|
||||||
* present. The array is mNumVertices in size.
|
* The bitangent of a vertex points in the direction of the positive
|
||||||
* @note If the mesh contains tangents, it automatically also contains
|
* Y texture axis. The array contains normalized vectors, nullptr if not
|
||||||
* bitangents.
|
* present. The array is mNumVertices in size.
|
||||||
*/
|
* @note If the mesh contains tangents, it automatically also contains
|
||||||
|
* bitangents.
|
||||||
|
*/
|
||||||
C_STRUCT aiVector3D *mBitangents;
|
C_STRUCT aiVector3D *mBitangents;
|
||||||
|
|
||||||
/** Vertex color sets.
|
/**
|
||||||
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
|
* @brief Vertex color sets.
|
||||||
* colors per vertex. nullptr if not present. Each array is
|
*
|
||||||
* mNumVertices in size if present.
|
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
|
||||||
*/
|
* colors per vertex. nullptr if not present. Each array is
|
||||||
|
* mNumVertices in size if present.
|
||||||
|
*/
|
||||||
C_STRUCT aiColor4D *mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
|
C_STRUCT aiColor4D *mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
|
||||||
|
|
||||||
/** Vertex texture coordinates, also known as UV channels.
|
/**
|
||||||
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
* @brief Vertex texture coordinates, also known as UV channels.
|
||||||
* vertex. nullptr if not present. The array is mNumVertices in size.
|
*
|
||||||
*/
|
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
||||||
|
* vertex. nullptr if not present. The array is mNumVertices in size.
|
||||||
|
*/
|
||||||
C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
|
||||||
/** Specifies the number of components for a given UV channel.
|
/**
|
||||||
* Up to three channels are supported (UVW, for accessing volume
|
* @brief Specifies the number of components for a given UV channel.
|
||||||
* or cube maps). If the value is 2 for a given channel n, the
|
*
|
||||||
* component p.z of mTextureCoords[n][p] is set to 0.0f.
|
* Up to three channels are supported (UVW, for accessing volume
|
||||||
* If the value is 1 for a given channel, p.y is set to 0.0f, too.
|
* or cube maps). If the value is 2 for a given channel n, the
|
||||||
* @note 4D coordinates are not supported
|
* component p.z of mTextureCoords[n][p] is set to 0.0f.
|
||||||
*/
|
* If the value is 1 for a given channel, p.y is set to 0.0f, too.
|
||||||
|
* @note 4D coordinates are not supported
|
||||||
|
*/
|
||||||
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
|
||||||
/** The faces the mesh is constructed from.
|
/**
|
||||||
* Each face refers to a number of vertices by their indices.
|
* @brief The faces the mesh is constructed from.
|
||||||
* This array is always present in a mesh, its size is given
|
*
|
||||||
* in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
|
* Each face refers to a number of vertices by their indices.
|
||||||
* is NOT set each face references an unique set of vertices.
|
* This array is always present in a mesh, its size is given
|
||||||
*/
|
* in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
|
||||||
|
* is NOT set each face references an unique set of vertices.
|
||||||
|
*/
|
||||||
C_STRUCT aiFace *mFaces;
|
C_STRUCT aiFace *mFaces;
|
||||||
|
|
||||||
/** The number of bones this mesh contains.
|
/**
|
||||||
* Can be 0, in which case the mBones array is nullptr.
|
* The number of bones this mesh contains. Can be 0, in which case the mBones array is nullptr.
|
||||||
*/
|
*/
|
||||||
unsigned int mNumBones;
|
unsigned int mNumBones;
|
||||||
|
|
||||||
/** The bones of this mesh.
|
/**
|
||||||
* A bone consists of a name by which it can be found in the
|
* @brief The bones of this mesh.
|
||||||
* frame hierarchy and a set of vertex weights.
|
*
|
||||||
*/
|
* A bone consists of a name by which it can be found in the
|
||||||
|
* frame hierarchy and a set of vertex weights.
|
||||||
|
*/
|
||||||
C_STRUCT aiBone **mBones;
|
C_STRUCT aiBone **mBones;
|
||||||
|
|
||||||
/** The material used by this mesh.
|
/**
|
||||||
|
* @brief The material used by this mesh.
|
||||||
|
*
|
||||||
* A mesh uses only a single material. If an imported model uses
|
* A mesh uses only a single material. If an imported model uses
|
||||||
* multiple materials, the import splits up the mesh. Use this value
|
* multiple materials, the import splits up the mesh. Use this value
|
||||||
* as index into the scene's material list.
|
* as index into the scene's material list.
|
||||||
*/
|
*/
|
||||||
unsigned int mMaterialIndex;
|
unsigned int mMaterialIndex;
|
||||||
|
|
||||||
/** Name of the mesh. Meshes can be named, but this is not a
|
/**
|
||||||
|
* Name of the mesh. Meshes can be named, but this is not a
|
||||||
* requirement and leaving this field empty is totally fine.
|
* requirement and leaving this field empty is totally fine.
|
||||||
* There are mainly three uses for mesh names:
|
* There are mainly three uses for mesh names:
|
||||||
* - some formats name nodes and meshes independently.
|
* - some formats name nodes and meshes independently.
|
||||||
|
@ -734,22 +786,24 @@ struct aiMesh {
|
||||||
* aids the caller at recovering the original mesh
|
* aids the caller at recovering the original mesh
|
||||||
* partitioning.
|
* partitioning.
|
||||||
* - Vertex animations refer to meshes by their names.
|
* - Vertex animations refer to meshes by their names.
|
||||||
**/
|
*/
|
||||||
C_STRUCT aiString mName;
|
C_STRUCT aiString mName;
|
||||||
|
|
||||||
/** The number of attachment meshes.
|
/**
|
||||||
* Currently known to work with loaders:
|
* The number of attachment meshes.
|
||||||
* - Collada
|
* Currently known to work with loaders:
|
||||||
* - gltf
|
* - Collada
|
||||||
|
* - gltf
|
||||||
*/
|
*/
|
||||||
unsigned int mNumAnimMeshes;
|
unsigned int mNumAnimMeshes;
|
||||||
|
|
||||||
/** Attachment meshes for this mesh, for vertex-based animation.
|
/**
|
||||||
* Attachment meshes carry replacement data for some of the
|
* Attachment meshes for this mesh, for vertex-based animation.
|
||||||
* mesh'es vertex components (usually positions, normals).
|
* Attachment meshes carry replacement data for some of the
|
||||||
* Currently known to work with loaders:
|
* mesh'es vertex components (usually positions, normals).
|
||||||
* - Collada
|
* Currently known to work with loaders:
|
||||||
* - gltf
|
* - Collada
|
||||||
|
* - gltf
|
||||||
*/
|
*/
|
||||||
C_STRUCT aiAnimMesh **mAnimMeshes;
|
C_STRUCT aiAnimMesh **mAnimMeshes;
|
||||||
|
|
||||||
|
@ -764,13 +818,14 @@ struct aiMesh {
|
||||||
*/
|
*/
|
||||||
C_STRUCT aiAABB mAABB;
|
C_STRUCT aiAABB mAABB;
|
||||||
|
|
||||||
/** Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
|
/**
|
||||||
|
* Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
|
||||||
*/
|
*/
|
||||||
C_STRUCT aiString **mTextureCoordsNames;
|
C_STRUCT aiString **mTextureCoordsNames;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
//! Default constructor. Initializes all members to 0
|
//! The default class constructor.
|
||||||
aiMesh() AI_NO_EXCEPT
|
aiMesh() AI_NO_EXCEPT
|
||||||
: mPrimitiveTypes(0),
|
: mPrimitiveTypes(0),
|
||||||
mNumVertices(0),
|
mNumVertices(0),
|
||||||
|
@ -779,9 +834,9 @@ struct aiMesh {
|
||||||
mNormals(nullptr),
|
mNormals(nullptr),
|
||||||
mTangents(nullptr),
|
mTangents(nullptr),
|
||||||
mBitangents(nullptr),
|
mBitangents(nullptr),
|
||||||
mColors(),
|
mColors{nullptr},
|
||||||
mTextureCoords(),
|
mTextureCoords{nullptr},
|
||||||
mNumUVComponents(),
|
mNumUVComponents{0},
|
||||||
mFaces(nullptr),
|
mFaces(nullptr),
|
||||||
mNumBones(0),
|
mNumBones(0),
|
||||||
mBones(nullptr),
|
mBones(nullptr),
|
||||||
|
@ -791,17 +846,10 @@ struct aiMesh {
|
||||||
mMethod(aiMorphingMethod_UNKNOWN),
|
mMethod(aiMorphingMethod_UNKNOWN),
|
||||||
mAABB(),
|
mAABB(),
|
||||||
mTextureCoordsNames(nullptr) {
|
mTextureCoordsNames(nullptr) {
|
||||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
// empty
|
||||||
mNumUVComponents[a] = 0;
|
|
||||||
mTextureCoords[a] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
|
|
||||||
mColors[a] = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Deletes all storage allocated for the mesh
|
//! @brief The class destructor.
|
||||||
~aiMesh() {
|
~aiMesh() {
|
||||||
delete[] mVertices;
|
delete[] mVertices;
|
||||||
delete[] mNormals;
|
delete[] mNormals;
|
||||||
|
@ -842,44 +890,58 @@ struct aiMesh {
|
||||||
delete[] mFaces;
|
delete[] mFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains positions. Provided no special
|
//! @brief Check whether the mesh contains positions. Provided no special
|
||||||
//! scene flags are set, this will always be true
|
//! scene flags are set, this will always be true
|
||||||
bool HasPositions() const { return mVertices != nullptr && mNumVertices > 0; }
|
//! @return true, if positions are stored, false if not.
|
||||||
|
bool HasPositions() const {
|
||||||
|
return mVertices != nullptr && mNumVertices > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains faces. If no special scene flags
|
//! @brief Check whether the mesh contains faces. If no special scene flags
|
||||||
//! are set this should always return true
|
//! are set this should always return true
|
||||||
bool HasFaces() const { return mFaces != nullptr && mNumFaces > 0; }
|
//! @return true, if faces are stored, false if not.
|
||||||
|
bool HasFaces() const {
|
||||||
|
return mFaces != nullptr && mNumFaces > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains normal vectors
|
//! @brief Check whether the mesh contains normal vectors
|
||||||
bool HasNormals() const { return mNormals != nullptr && mNumVertices > 0; }
|
//! @return true, if normals are stored, false if not.
|
||||||
|
bool HasNormals() const {
|
||||||
|
return mNormals != nullptr && mNumVertices > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains tangent and bitangent vectors
|
//! @brief Check whether the mesh contains tangent and bitangent vectors.
|
||||||
|
//!
|
||||||
//! It is not possible that it contains tangents and no bitangents
|
//! It is not possible that it contains tangents and no bitangents
|
||||||
//! (or the other way round). The existence of one of them
|
//! (or the other way round). The existence of one of them
|
||||||
//! implies that the second is there, too.
|
//! implies that the second is there, too.
|
||||||
bool HasTangentsAndBitangents() const { return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; }
|
//! @return true, if tangents and bi-tangents are stored, false if not.
|
||||||
|
bool HasTangentsAndBitangents() const {
|
||||||
//! Check whether the mesh contains a vertex color set
|
return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0;
|
||||||
//! \param pIndex Index of the vertex color set
|
|
||||||
bool HasVertexColors(unsigned int pIndex) const {
|
|
||||||
if (pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return mColors[pIndex] != nullptr && mNumVertices > 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains a texture coordinate set
|
//! @brief Check whether the mesh contains a vertex color set
|
||||||
//! \param pIndex Index of the texture coordinates set
|
//! @param index Index of the vertex color set
|
||||||
bool HasTextureCoords(unsigned int pIndex) const {
|
//! @return true, if vertex colors are stored, false if not.
|
||||||
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
bool HasVertexColors(unsigned int index) const {
|
||||||
|
if (index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return mTextureCoords[pIndex] != nullptr && mNumVertices > 0;
|
|
||||||
}
|
}
|
||||||
|
return mColors[index] != nullptr && mNumVertices > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get the number of UV channels the mesh contains
|
//! @brief Check whether the mesh contains a texture coordinate set
|
||||||
|
//! @param index Index of the texture coordinates set
|
||||||
|
//! @return true, if texture coordinates are stored, false if not.
|
||||||
|
bool HasTextureCoords(unsigned int index) const {
|
||||||
|
if (index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (mTextureCoords[index] != nullptr && mNumVertices > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! @brief Get the number of UV channels the mesh contains.
|
||||||
|
//! @return the number of stored uv-channels.
|
||||||
unsigned int GetNumUVChannels() const {
|
unsigned int GetNumUVChannels() const {
|
||||||
unsigned int n(0);
|
unsigned int n(0);
|
||||||
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
|
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
|
||||||
|
@ -889,7 +951,8 @@ struct aiMesh {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get the number of vertex color channels the mesh contains
|
//! @brief Get the number of vertex color channels the mesh contains.
|
||||||
|
//! @return The number of stored color channels.
|
||||||
unsigned int GetNumColorChannels() const {
|
unsigned int GetNumColorChannels() const {
|
||||||
unsigned int n(0);
|
unsigned int n(0);
|
||||||
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) {
|
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) {
|
||||||
|
@ -898,13 +961,15 @@ struct aiMesh {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains bones
|
//! @brief Check whether the mesh contains bones.
|
||||||
|
//! @return true, if bones are stored.
|
||||||
bool HasBones() const {
|
bool HasBones() const {
|
||||||
return mBones != nullptr && mNumBones > 0;
|
return mBones != nullptr && mNumBones > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains a texture coordinate set name
|
//! @brief Check whether the mesh contains a texture coordinate set name
|
||||||
//! \param pIndex Index of the texture coordinates set
|
//! @param pIndex Index of the texture coordinates set
|
||||||
|
//! @return true, if texture coordinates for the index exists.
|
||||||
bool HasTextureCoordsName(unsigned int pIndex) const {
|
bool HasTextureCoordsName(unsigned int pIndex) const {
|
||||||
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -912,9 +977,9 @@ struct aiMesh {
|
||||||
return mTextureCoordsNames[pIndex] != nullptr;
|
return mTextureCoordsNames[pIndex] != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Set a texture coordinate set name
|
//! @brief Set a texture coordinate set name
|
||||||
//! \param pIndex Index of the texture coordinates set
|
//! @param pIndex Index of the texture coordinates set
|
||||||
//! \param texCoordsName name of the texture coordinate set
|
//! @param texCoordsName name of the texture coordinate set
|
||||||
void SetTextureCoordsName(unsigned int pIndex, const aiString &texCoordsName) {
|
void SetTextureCoordsName(unsigned int pIndex, const aiString &texCoordsName) {
|
||||||
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||||
return;
|
return;
|
||||||
|
@ -939,30 +1004,46 @@ struct aiMesh {
|
||||||
*mTextureCoordsNames[pIndex] = texCoordsName;
|
*mTextureCoordsNames[pIndex] = texCoordsName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get a texture coordinate set name
|
//! @brief Get a texture coordinate set name
|
||||||
//! \param pIndex Index of the texture coordinates set
|
//! @param pIndex Index of the texture coordinates set
|
||||||
const aiString *GetTextureCoordsName(unsigned int pIndex) const {
|
//! @return The texture coordinate name.
|
||||||
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
const aiString *GetTextureCoordsName(unsigned int index) const {
|
||||||
|
if (mTextureCoordsNames == nullptr || index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mTextureCoordsNames[pIndex];
|
return mTextureCoordsNames[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A skeleton bone represents a single bone is a skeleton structure.
|
||||||
|
*
|
||||||
|
* Skeleton-Animations can be represented via a skeleton struct, which describes
|
||||||
|
* a hierarchical tree assembled from skeleton bones. A bone is linked to a mesh.
|
||||||
|
* The bone knows its parent bone. If there is no parent bone the parent id is
|
||||||
|
* marked with -1.
|
||||||
|
* The skeleton-bone stores a pointer to its used armature. If there is no
|
||||||
|
* armature this value if set to nullptr.
|
||||||
|
* A skeleton bone stores its offset-matrix, which is the absolute transformation
|
||||||
|
* for the bone. The bone stores the locale transformation to its parent as well.
|
||||||
|
* You can compute the offset matrix by multiplying the hierarchy like:
|
||||||
|
* Tree: s1 -> s2 -> s3
|
||||||
|
* Offset-Matrix s3 = locale-s3 * locale-s2 * locale-s1
|
||||||
|
*/
|
||||||
struct aiSkeletonBone {
|
struct aiSkeletonBone {
|
||||||
/// The parent bone index, is -1 one if this bone represents the root bone.
|
/// The parent bone index, is -1 one if this bone represents the root bone.
|
||||||
int mParent;
|
int mParent;
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
||||||
/// The bone armature node - used for skeleton conversion
|
/// @brief The bone armature node - used for skeleton conversion
|
||||||
/// you must enable aiProcess_PopulateArmatureData to populate this
|
/// you must enable aiProcess_PopulateArmatureData to populate this
|
||||||
C_STRUCT aiNode *mArmature;
|
C_STRUCT aiNode *mArmature;
|
||||||
|
|
||||||
/// The bone node in the scene - used for skeleton conversion
|
/// @brief The bone node in the scene - used for skeleton conversion
|
||||||
/// you must enable aiProcess_PopulateArmatureData to populate this
|
/// you must enable aiProcess_PopulateArmatureData to populate this
|
||||||
C_STRUCT aiNode *mNode;
|
C_STRUCT aiNode *mNode;
|
||||||
|
|
||||||
|
@ -993,6 +1074,7 @@ struct aiSkeletonBone {
|
||||||
C_STRUCT aiMatrix4x4 mLocalMatrix;
|
C_STRUCT aiMatrix4x4 mLocalMatrix;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
/// @brief The class constructor.
|
||||||
aiSkeletonBone() :
|
aiSkeletonBone() :
|
||||||
mParent(-1),
|
mParent(-1),
|
||||||
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
||||||
|
@ -1007,6 +1089,22 @@ struct aiSkeletonBone {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief The class constructor with its parent
|
||||||
|
/// @param parent The parent node index.
|
||||||
|
aiSkeletonBone(unsigned int parent) :
|
||||||
|
mParent(parent),
|
||||||
|
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
||||||
|
mArmature(nullptr),
|
||||||
|
mNode(nullptr),
|
||||||
|
#endif
|
||||||
|
mNumnWeights(0),
|
||||||
|
mMeshId(nullptr),
|
||||||
|
mWeights(nullptr),
|
||||||
|
mOffsetMatrix(),
|
||||||
|
mLocalMatrix() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
/// @brief The class destructor.
|
||||||
~aiSkeletonBone() {
|
~aiSkeletonBone() {
|
||||||
delete[] mWeights;
|
delete[] mWeights;
|
||||||
mWeights = nullptr;
|
mWeights = nullptr;
|
||||||
|
@ -1014,34 +1112,45 @@ struct aiSkeletonBone {
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief A skeleton represents the bone hierarchy of an animation.
|
||||||
|
*
|
||||||
|
* Skeleton animations can be described as a tree of bones:
|
||||||
|
* root
|
||||||
|
* |
|
||||||
|
* node1
|
||||||
|
* / \
|
||||||
|
* node3 node4
|
||||||
|
* If you want to calculate the transformation of node three you need to compute the
|
||||||
|
* transformation hierarchy for the transformation chain of node3:
|
||||||
|
* root->node1->node3
|
||||||
|
* Each node is represented as a skeleton instance.
|
||||||
*/
|
*/
|
||||||
struct aiSkeleton {
|
struct aiSkeleton {
|
||||||
/**
|
/**
|
||||||
*
|
* @brief The name of the skeleton instance.
|
||||||
*/
|
*/
|
||||||
C_STRUCT aiString mName;
|
C_STRUCT aiString mName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @brief The number of bones in the skeleton.
|
||||||
*/
|
*/
|
||||||
unsigned int mNumBones;
|
unsigned int mNumBones;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @brief The bone instance in the skeleton.
|
||||||
*/
|
*/
|
||||||
C_STRUCT aiSkeletonBone **mBones;
|
C_STRUCT aiSkeletonBone **mBones;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
/**
|
/**
|
||||||
*
|
* @brief The class constructor.
|
||||||
*/
|
*/
|
||||||
aiSkeleton() AI_NO_EXCEPT : mName(), mNumBones(0), mBones(nullptr) {
|
aiSkeleton() AI_NO_EXCEPT : mName(), mNumBones(0), mBones(nullptr) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @brief The class destructor.
|
||||||
*/
|
*/
|
||||||
~aiSkeleton() {
|
~aiSkeleton() {
|
||||||
delete[] mBones;
|
delete[] mBones;
|
||||||
|
@ -1051,4 +1160,6 @@ struct aiSkeleton {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif //! extern "C"
|
#endif //! extern "C"
|
||||||
|
|
||||||
#endif // AI_MESH_H_INC
|
#endif // AI_MESH_H_INC
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <assimp/quaternion.h>
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Enum used to distinguish data types
|
* Enum used to distinguish data types
|
||||||
|
@ -70,7 +72,9 @@ typedef enum aiMetadataType {
|
||||||
AI_AISTRING = 5,
|
AI_AISTRING = 5,
|
||||||
AI_AIVECTOR3D = 6,
|
AI_AIVECTOR3D = 6,
|
||||||
AI_AIMETADATA = 7,
|
AI_AIMETADATA = 7,
|
||||||
AI_META_MAX = 8,
|
AI_INT64 = 8,
|
||||||
|
AI_UINT32 = 9,
|
||||||
|
AI_META_MAX = 10,
|
||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
FORCE_32BIT = INT_MAX
|
FORCE_32BIT = INT_MAX
|
||||||
|
@ -133,6 +137,12 @@ inline aiMetadataType GetAiType(const aiVector3D &) {
|
||||||
inline aiMetadataType GetAiType(const aiMetadata &) {
|
inline aiMetadataType GetAiType(const aiMetadata &) {
|
||||||
return AI_AIMETADATA;
|
return AI_AIMETADATA;
|
||||||
}
|
}
|
||||||
|
inline aiMetadataType GetAiType(int64_t) {
|
||||||
|
return AI_INT64;
|
||||||
|
}
|
||||||
|
inline aiMetadataType GetAiType(uint32_t) {
|
||||||
|
return AI_UINT32;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
@ -215,6 +225,16 @@ struct aiMetadata {
|
||||||
rhs.Get<aiMetadata>(static_cast<unsigned int>(i), v);
|
rhs.Get<aiMetadata>(static_cast<unsigned int>(i), v);
|
||||||
mValues[i].mData = new aiMetadata(v);
|
mValues[i].mData = new aiMetadata(v);
|
||||||
} break;
|
} break;
|
||||||
|
case AI_INT64: {
|
||||||
|
int64_t v;
|
||||||
|
::memcpy(&v, rhs.mValues[i].mData, sizeof(int64_t));
|
||||||
|
mValues[i].mData = new int64_t(v);
|
||||||
|
} break;
|
||||||
|
case AI_UINT32: {
|
||||||
|
uint32_t v;
|
||||||
|
::memcpy(&v, rhs.mValues[i].mData, sizeof(uint32_t));
|
||||||
|
mValues[i].mData = new uint32_t(v);
|
||||||
|
} break;
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
case FORCE_32BIT:
|
case FORCE_32BIT:
|
||||||
#endif
|
#endif
|
||||||
|
@ -267,6 +287,12 @@ struct aiMetadata {
|
||||||
case AI_AIMETADATA:
|
case AI_AIMETADATA:
|
||||||
delete static_cast<aiMetadata *>(data);
|
delete static_cast<aiMetadata *>(data);
|
||||||
break;
|
break;
|
||||||
|
case AI_INT64:
|
||||||
|
delete static_cast<int64_t *>(data);
|
||||||
|
break;
|
||||||
|
case AI_UINT32:
|
||||||
|
delete static_cast<uint32_t *>(data);
|
||||||
|
break;
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
case FORCE_32BIT:
|
case FORCE_32BIT:
|
||||||
#endif
|
#endif
|
||||||
|
@ -510,6 +536,16 @@ struct aiMetadata {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case AI_INT64: {
|
||||||
|
if (*static_cast<int64_t *>(lhs.mValues[i].mData) != *static_cast<int64_t *>(rhs.mValues[i].mData)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case AI_UINT32: {
|
||||||
|
if (*static_cast<uint32_t *>(lhs.mValues[i].mData) != *static_cast<uint32_t *>(rhs.mValues[i].mData)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
case FORCE_32BIT:
|
case FORCE_32BIT:
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -76,7 +76,7 @@ $ python setup.py install
|
||||||
```
|
```
|
||||||
|
|
||||||
PyAssimp requires a assimp dynamic library (`DLL` on windows,
|
PyAssimp requires a assimp dynamic library (`DLL` on windows,
|
||||||
`.so` on linux, `.dynlib` on macOS) in order to work. The default search directories are:
|
`.so` on linux, `.dylib` on macOS) in order to work. The default search directories are:
|
||||||
- the current directory
|
- the current directory
|
||||||
- on linux additionally: `/usr/lib`, `/usr/local/lib`,
|
- on linux additionally: `/usr/lib`, `/usr/local/lib`,
|
||||||
`/usr/lib/x86_64-linux-gnu`
|
`/usr/lib/x86_64-linux-gnu`
|
||||||
|
|
|
@ -81,7 +81,7 @@ Install ``pyassimp`` by running:
|
||||||
$ python setup.py install
|
$ python setup.py install
|
||||||
|
|
||||||
PyAssimp requires a assimp dynamic library (``DLL`` on windows, ``.so``
|
PyAssimp requires a assimp dynamic library (``DLL`` on windows, ``.so``
|
||||||
on linux, ``.dynlib`` on macOS) in order to work. The default search
|
on linux, ``.dylib`` on macOS) in order to work. The default search
|
||||||
directories are:
|
directories are:
|
||||||
|
|
||||||
- the current directory
|
- the current directory
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2022, assimp team
|
Copyright (c) 2006-2022, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -84,7 +82,7 @@ TEST_F( utMetadata, allocTest ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utMetadata, get_set_pod_Test ) {
|
TEST_F( utMetadata, get_set_pod_Test ) {
|
||||||
m_data = aiMetadata::Alloc( 5 );
|
m_data = aiMetadata::Alloc( 7 );
|
||||||
|
|
||||||
// int, 32 bit
|
// int, 32 bit
|
||||||
unsigned int index( 0 );
|
unsigned int index( 0 );
|
||||||
|
@ -137,6 +135,28 @@ TEST_F( utMetadata, get_set_pod_Test ) {
|
||||||
EXPECT_TRUE( success );
|
EXPECT_TRUE( success );
|
||||||
EXPECT_DOUBLE_EQ( 3.0, result_double );
|
EXPECT_DOUBLE_EQ( 3.0, result_double );
|
||||||
|
|
||||||
|
// int64_t
|
||||||
|
index++;
|
||||||
|
const std::string key_int64 = "test_int64";
|
||||||
|
int64_t val_int64 = 64;
|
||||||
|
success = m_data->Set(index, key_int64, val_int64);
|
||||||
|
EXPECT_TRUE(success);
|
||||||
|
int64_t result_int64(0);
|
||||||
|
success = m_data->Get(key_int64, result_int64);
|
||||||
|
EXPECT_TRUE(success);
|
||||||
|
EXPECT_EQ(result_int64, val_int64);
|
||||||
|
|
||||||
|
// uint32
|
||||||
|
index++;
|
||||||
|
const std::string key_uint32 = "test_uint32";
|
||||||
|
int64_t val_uint32 = 32;
|
||||||
|
success = m_data->Set(index, key_uint32, val_uint32);
|
||||||
|
EXPECT_TRUE(success);
|
||||||
|
int64_t result_uint32(0);
|
||||||
|
success = m_data->Get(key_uint32, result_uint32);
|
||||||
|
EXPECT_TRUE(success);
|
||||||
|
EXPECT_EQ(result_uint32, val_uint32);
|
||||||
|
|
||||||
// error
|
// error
|
||||||
int result;
|
int result;
|
||||||
success = m_data->Get( "bla", result );
|
success = m_data->Get( "bla", result );
|
||||||
|
@ -181,6 +201,7 @@ TEST_F( utMetadata, get_set_aiVector3D_Test ) {
|
||||||
EXPECT_TRUE( success );
|
EXPECT_TRUE( success );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F( utMetadata, copy_test ) {
|
TEST_F( utMetadata, copy_test ) {
|
||||||
m_data = aiMetadata::Alloc( AI_META_MAX );
|
m_data = aiMetadata::Alloc( AI_META_MAX );
|
||||||
bool bv = true;
|
bool bv = true;
|
||||||
|
@ -199,9 +220,12 @@ TEST_F( utMetadata, copy_test ) {
|
||||||
m_data->Set( 6, "aiVector3D", vecVal );
|
m_data->Set( 6, "aiVector3D", vecVal );
|
||||||
aiMetadata metaVal;
|
aiMetadata metaVal;
|
||||||
m_data->Set( 7, "aiMetadata", metaVal );
|
m_data->Set( 7, "aiMetadata", metaVal );
|
||||||
|
int64_t i64 = 64;
|
||||||
aiMetadata copy( *m_data );
|
m_data->Set(8, "int64_t", i64);
|
||||||
EXPECT_EQ( 8u, copy.mNumProperties );
|
uint32_t ui32 = 32;
|
||||||
|
m_data->Set(9, "uint32_t", ui32);
|
||||||
|
aiMetadata copy(*m_data);
|
||||||
|
EXPECT_EQ( 10u, copy.mNumProperties );
|
||||||
|
|
||||||
// bool test
|
// bool test
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,26 +55,28 @@ constexpr char AICMD_MSG_INFO_HELP_E[] =
|
||||||
"\t-v,--verbose: Print verbose info such as node transform data\n"
|
"\t-v,--verbose: Print verbose info such as node transform data\n"
|
||||||
"\t-s, --silent: Print only minimal info\n";
|
"\t-s, --silent: Print only minimal info\n";
|
||||||
|
|
||||||
constexpr char TREE_BRANCH_ASCII[] = "|-";
|
|
||||||
constexpr char TREE_BRANCH_UTF8[] = "\xe2\x94\x9c\xe2\x95\xb4";
|
|
||||||
constexpr char TREE_STOP_ASCII[] = "'-";
|
|
||||||
constexpr char TREE_STOP_UTF8[] = "\xe2\x94\x94\xe2\x95\xb4";
|
|
||||||
constexpr char TREE_CONTINUE_ASCII[] = "| ";
|
|
||||||
constexpr char TREE_CONTINUE_UTF8[] = "\xe2\x94\x82 ";
|
|
||||||
|
|
||||||
// note: by default this is using utf-8 text.
|
// note: by default this is using utf-8 text.
|
||||||
// this is well supported on pretty much any linux terminal.
|
// this is well supported on pretty much any linux terminal.
|
||||||
// if this causes problems on some platform,
|
// if this causes problems on some platform,
|
||||||
// put an #ifdef to use the ascii version for that platform.
|
// put an #ifdef to use the ascii version for that platform.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
constexpr char TREE_BRANCH_ASCII[] = "|-";
|
||||||
|
constexpr char TREE_STOP_ASCII[] = "'-";
|
||||||
|
constexpr char TREE_CONTINUE_ASCII[] = "| ";
|
||||||
|
|
||||||
const char *TREE_BRANCH = TREE_BRANCH_ASCII;
|
const char *TREE_BRANCH = TREE_BRANCH_ASCII;
|
||||||
const char *TREE_STOP = TREE_STOP_ASCII;
|
const char *TREE_STOP = TREE_STOP_ASCII;
|
||||||
const char *TREE_CONTINUE = TREE_CONTINUE_ASCII;
|
const char *TREE_CONTINUE = TREE_CONTINUE_ASCII;
|
||||||
#else
|
#else // _WIN32
|
||||||
|
constexpr char TREE_BRANCH_UTF8[] = "\xe2\x94\x9c\xe2\x95\xb4";
|
||||||
|
constexpr char TREE_STOP_UTF8[] = "\xe2\x94\x94\xe2\x95\xb4";
|
||||||
|
constexpr char TREE_CONTINUE_UTF8[] = "\xe2\x94\x82 ";
|
||||||
|
|
||||||
const char *TREE_BRANCH = TREE_BRANCH_UTF8;
|
const char *TREE_BRANCH = TREE_BRANCH_UTF8;
|
||||||
const char *TREE_STOP = TREE_STOP_UTF8;
|
const char *TREE_STOP = TREE_STOP_UTF8;
|
||||||
const char *TREE_CONTINUE = TREE_CONTINUE_UTF8;
|
const char *TREE_CONTINUE = TREE_CONTINUE_UTF8;
|
||||||
#endif
|
#endif // _WIN32
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
unsigned int CountNodes(const aiNode *root) {
|
unsigned int CountNodes(const aiNode *root) {
|
||||||
|
|
Loading…
Reference in New Issue