Merge branch 'master' into gltf2-anim-duration
commit
aa0a5bb36f
|
@ -170,7 +170,7 @@ IF(NOT IGNORE_GIT_HASH)
|
||||||
|
|
||||||
# Get the latest abbreviated commit hash of the working branch
|
# Get the latest abbreviated commit hash of the working branch
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
COMMAND git log -1 --format=%h --no-show-signature
|
COMMAND git rev-parse --short=8 HEAD
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
|
|
@ -161,19 +161,21 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene* pScene, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
|
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
|
||||||
this->stream = &stream;
|
|
||||||
|
|
||||||
// We should have at least one chunk
|
// We should have at least one chunk
|
||||||
if (stream.GetRemainingSize() < 16) {
|
if (stream.GetRemainingSize() < 16) {
|
||||||
throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile);
|
throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile);
|
||||||
}
|
}
|
||||||
|
this->stream = &stream;
|
||||||
|
|
||||||
// Allocate our temporary 3DS representation
|
// Allocate our temporary 3DS representation
|
||||||
mScene = new D3DS::Scene();
|
D3DS::Scene _scene;
|
||||||
|
mScene = &_scene;
|
||||||
|
|
||||||
// Initialize members
|
// Initialize members
|
||||||
|
D3DS::Node _rootNode("UNNAMED");
|
||||||
mLastNodeIndex = -1;
|
mLastNodeIndex = -1;
|
||||||
mCurrentNode = new D3DS::Node("UNNAMED");
|
mCurrentNode = &_rootNode;
|
||||||
mRootNode = mCurrentNode;
|
mRootNode = mCurrentNode;
|
||||||
mRootNode->mHierarchyPos = -1;
|
mRootNode->mHierarchyPos = -1;
|
||||||
mRootNode->mHierarchyIndex = -1;
|
mRootNode->mHierarchyIndex = -1;
|
||||||
|
@ -193,7 +195,6 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
// file.
|
// file.
|
||||||
for (auto &mesh : mScene->mMeshes) {
|
for (auto &mesh : mScene->mMeshes) {
|
||||||
if (mesh.mFaces.size() > 0 && mesh.mPositions.size() == 0) {
|
if (mesh.mFaces.size() > 0 && mesh.mPositions.size() == 0) {
|
||||||
delete mScene;
|
|
||||||
throw DeadlyImportError("3DS file contains faces but no vertices: " + pFile);
|
throw DeadlyImportError("3DS file contains faces but no vertices: " + pFile);
|
||||||
}
|
}
|
||||||
CheckIndices(mesh);
|
CheckIndices(mesh);
|
||||||
|
@ -201,7 +202,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
|
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace all occurrences of the default material with a
|
// Replace all occurences of the default material with a
|
||||||
// valid material. Generate it if no material containing
|
// valid material. Generate it if no material containing
|
||||||
// DEFAULT in its name has been found in the file
|
// DEFAULT in its name has been found in the file
|
||||||
ReplaceDefaultMaterial();
|
ReplaceDefaultMaterial();
|
||||||
|
@ -218,10 +219,8 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
// Now apply the master scaling factor to the scene
|
// Now apply the master scaling factor to the scene
|
||||||
ApplyMasterScale(pScene);
|
ApplyMasterScale(pScene);
|
||||||
|
|
||||||
// Delete our internal scene representation and the root
|
// Our internal scene representation and the root
|
||||||
// node, so the whole hierarchy will follow
|
// node will be automatically deleted, so the whole hierarchy will follow
|
||||||
delete mRootNode;
|
|
||||||
delete mScene;
|
|
||||||
|
|
||||||
AI_DEBUG_INVALIDATE_PTR(mRootNode);
|
AI_DEBUG_INVALIDATE_PTR(mRootNode);
|
||||||
AI_DEBUG_INVALIDATE_PTR(mScene);
|
AI_DEBUG_INVALIDATE_PTR(mScene);
|
||||||
|
|
|
@ -89,7 +89,7 @@ size_t Write<unsigned int>(IOStream * stream, const unsigned int& w) {
|
||||||
const uint32_t t = (uint32_t)w;
|
const uint32_t t = (uint32_t)w;
|
||||||
if (w > t) {
|
if (w > t) {
|
||||||
// this shouldn't happen, integers in Assimp data structures never exceed 2^32
|
// this shouldn't happen, integers in Assimp data structures never exceed 2^32
|
||||||
throw new DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion");
|
throw DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion");
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->Write(&t,4,1);
|
stream->Write(&t,4,1);
|
||||||
|
@ -805,10 +805,16 @@ public:
|
||||||
WriteBinaryScene( &uncompressedStream, pScene );
|
WriteBinaryScene( &uncompressedStream, pScene );
|
||||||
|
|
||||||
uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());
|
uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());
|
||||||
uLongf compressedSize = (uLongf)(uncompressedStream.Tell() * 1.001 + 12.);
|
uLongf compressedSize = (uLongf)compressBound(uncompressedSize);
|
||||||
uint8_t* compressedBuffer = new uint8_t[ compressedSize ];
|
uint8_t* compressedBuffer = new uint8_t[ compressedSize ];
|
||||||
|
|
||||||
compress2( compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9 );
|
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( &uncompressedSize, sizeof(uint32_t), 1 );
|
||||||
out->Write( compressedBuffer, sizeof(char), compressedSize );
|
out->Write( compressedBuffer, sizeof(char), compressedSize );
|
||||||
|
|
|
@ -57,6 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/anim.h>
|
#include <assimp/anim.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/importerdesc.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||||
# include <zlib.h>
|
# include <zlib.h>
|
||||||
|
@ -103,7 +104,9 @@ bool AssbinImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bo
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Read(IOStream * stream) {
|
T Read(IOStream * stream) {
|
||||||
T t;
|
T t;
|
||||||
stream->Read( &t, sizeof(T), 1 );
|
size_t res = stream->Read( &t, sizeof(T), 1 );
|
||||||
|
if(res != 1)
|
||||||
|
throw DeadlyImportError("Unexpected EOF");
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +147,7 @@ template <>
|
||||||
aiString Read<aiString>(IOStream * stream) {
|
aiString Read<aiString>(IOStream * stream) {
|
||||||
aiString s;
|
aiString s;
|
||||||
stream->Read(&s.length,4,1);
|
stream->Read(&s.length,4,1);
|
||||||
|
if(s.length)
|
||||||
stream->Read(s.data,s.length,1);
|
stream->Read(s.data,s.length,1);
|
||||||
s.data[s.length] = 0;
|
s.data[s.length] = 0;
|
||||||
return s;
|
return s;
|
||||||
|
@ -207,46 +211,48 @@ void ReadBounds( IOStream * stream, T* /*p*/, unsigned int n ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent ) {
|
void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** onode, aiNode* parent ) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AINODE)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AINODE);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
*node = new aiNode();
|
std::unique_ptr<aiNode> node(new aiNode());
|
||||||
|
|
||||||
(*node)->mName = Read<aiString>(stream);
|
node->mName = Read<aiString>(stream);
|
||||||
(*node)->mTransformation = Read<aiMatrix4x4>(stream);
|
node->mTransformation = Read<aiMatrix4x4>(stream);
|
||||||
(*node)->mNumChildren = Read<unsigned int>(stream);
|
unsigned numChildren = Read<unsigned int>(stream);
|
||||||
(*node)->mNumMeshes = Read<unsigned int>(stream);
|
unsigned numMeshes = Read<unsigned int>(stream);
|
||||||
unsigned int nb_metadata = Read<unsigned int>(stream);
|
unsigned int nb_metadata = Read<unsigned int>(stream);
|
||||||
|
|
||||||
if(parent) {
|
if(parent) {
|
||||||
(*node)->mParent = parent;
|
node->mParent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*node)->mNumMeshes) {
|
if (numMeshes)
|
||||||
(*node)->mMeshes = new unsigned int[(*node)->mNumMeshes];
|
{
|
||||||
for (unsigned int i = 0; i < (*node)->mNumMeshes; ++i) {
|
node->mMeshes = new unsigned int[numMeshes];
|
||||||
(*node)->mMeshes[i] = Read<unsigned int>(stream);
|
for (unsigned int i = 0; i < numMeshes; ++i) {
|
||||||
|
node->mMeshes[i] = Read<unsigned int>(stream);
|
||||||
|
node->mNumMeshes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*node)->mNumChildren) {
|
if (numChildren) {
|
||||||
(*node)->mChildren = new aiNode*[(*node)->mNumChildren];
|
node->mChildren = new aiNode*[numChildren];
|
||||||
for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) {
|
for (unsigned int i = 0; i < numChildren; ++i) {
|
||||||
ReadBinaryNode( stream, &(*node)->mChildren[i], *node );
|
ReadBinaryNode( stream, &node->mChildren[i], node.get() );
|
||||||
|
node->mNumChildren++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( nb_metadata > 0 ) {
|
if ( nb_metadata > 0 ) {
|
||||||
(*node)->mMetaData = aiMetadata::Alloc(nb_metadata);
|
node->mMetaData = aiMetadata::Alloc(nb_metadata);
|
||||||
for (unsigned int i = 0; i < nb_metadata; ++i) {
|
for (unsigned int i = 0; i < nb_metadata; ++i) {
|
||||||
(*node)->mMetaData->mKeys[i] = Read<aiString>(stream);
|
node->mMetaData->mKeys[i] = Read<aiString>(stream);
|
||||||
(*node)->mMetaData->mValues[i].mType = (aiMetadataType) Read<uint16_t>(stream);
|
node->mMetaData->mValues[i].mType = (aiMetadataType) Read<uint16_t>(stream);
|
||||||
void* data( nullptr );
|
void* data = nullptr;
|
||||||
|
|
||||||
switch ((*node)->mMetaData->mValues[i].mType) {
|
switch (node->mMetaData->mValues[i].mType) {
|
||||||
case AI_BOOL:
|
case AI_BOOL:
|
||||||
data = new bool(Read<bool>(stream));
|
data = new bool(Read<bool>(stream));
|
||||||
break;
|
break;
|
||||||
|
@ -275,16 +281,16 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* p
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*node)->mMetaData->mValues[i].mData = data;
|
node->mMetaData->mValues[i].mData = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*onode = node.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) {
|
void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIBONE)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AIBONE);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
b->mName = Read<aiString>(stream);
|
b->mName = Read<aiString>(stream);
|
||||||
|
@ -306,12 +312,10 @@ void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) {
|
||||||
static bool fitsIntoUI16(unsigned int mNumVertices) {
|
static bool fitsIntoUI16(unsigned int mNumVertices) {
|
||||||
return ( mNumVertices < (1u<<16) );
|
return ( mNumVertices < (1u<<16) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) {
|
void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIMESH)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AIMESH);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
mesh->mPrimitiveTypes = Read<unsigned int>(stream);
|
mesh->mPrimitiveTypes = Read<unsigned int>(stream);
|
||||||
|
@ -423,9 +427,8 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop) {
|
void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIMATERIALPROPERTY)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
prop->mKey = Read<aiString>(stream);
|
prop->mKey = Read<aiString>(stream);
|
||||||
|
@ -440,9 +443,8 @@ void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialPro
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) {
|
void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIMATERIAL)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIAL);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
mat->mNumAllocated = mat->mNumProperties = Read<unsigned int>(stream);
|
mat->mNumAllocated = mat->mNumProperties = Read<unsigned int>(stream);
|
||||||
|
@ -462,9 +464,8 @@ void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) {
|
void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AINODEANIM)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AINODEANIM);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
nd->mNodeName = Read<aiString>(stream);
|
nd->mNodeName = Read<aiString>(stream);
|
||||||
|
@ -508,9 +509,8 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) {
|
void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIANIMATION)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AIANIMATION);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
anim->mName = Read<aiString> (stream);
|
anim->mName = Read<aiString> (stream);
|
||||||
|
@ -529,9 +529,8 @@ void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
|
void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AITEXTURE)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AITEXTURE);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
tex->mWidth = Read<unsigned int>(stream);
|
tex->mWidth = Read<unsigned int>(stream);
|
||||||
|
@ -551,9 +550,8 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) {
|
void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AILIGHT)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AILIGHT);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
l->mName = Read<aiString>(stream);
|
l->mName = Read<aiString>(stream);
|
||||||
|
@ -577,9 +575,8 @@ void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) {
|
void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AICAMERA)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AICAMERA);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
cam->mName = Read<aiString>(stream);
|
cam->mName = Read<aiString>(stream);
|
||||||
|
@ -594,9 +591,8 @@ void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
|
void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AISCENE)
|
||||||
(void)(chunkID);
|
throw DeadlyImportError("Magic chunk identifiers are wrong!");
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AISCENE);
|
|
||||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||||
|
|
||||||
scene->mFlags = Read<unsigned int>(stream);
|
scene->mFlags = Read<unsigned int>(stream);
|
||||||
|
@ -614,6 +610,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
|
||||||
// Read all meshes
|
// Read all meshes
|
||||||
if (scene->mNumMeshes) {
|
if (scene->mNumMeshes) {
|
||||||
scene->mMeshes = new aiMesh*[scene->mNumMeshes];
|
scene->mMeshes = new aiMesh*[scene->mNumMeshes];
|
||||||
|
memset(scene->mMeshes, 0, scene->mNumMeshes*sizeof(aiMesh*));
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||||
scene->mMeshes[i] = new aiMesh();
|
scene->mMeshes[i] = new aiMesh();
|
||||||
ReadBinaryMesh( stream,scene->mMeshes[i]);
|
ReadBinaryMesh( stream,scene->mMeshes[i]);
|
||||||
|
@ -623,6 +620,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
|
||||||
// Read materials
|
// Read materials
|
||||||
if (scene->mNumMaterials) {
|
if (scene->mNumMaterials) {
|
||||||
scene->mMaterials = new aiMaterial*[scene->mNumMaterials];
|
scene->mMaterials = new aiMaterial*[scene->mNumMaterials];
|
||||||
|
memset(scene->mMaterials, 0, scene->mNumMaterials*sizeof(aiMaterial*));
|
||||||
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
||||||
scene->mMaterials[i] = new aiMaterial();
|
scene->mMaterials[i] = new aiMaterial();
|
||||||
ReadBinaryMaterial(stream,scene->mMaterials[i]);
|
ReadBinaryMaterial(stream,scene->mMaterials[i]);
|
||||||
|
@ -632,6 +630,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
|
||||||
// Read all animations
|
// Read all animations
|
||||||
if (scene->mNumAnimations) {
|
if (scene->mNumAnimations) {
|
||||||
scene->mAnimations = new aiAnimation*[scene->mNumAnimations];
|
scene->mAnimations = new aiAnimation*[scene->mNumAnimations];
|
||||||
|
memset(scene->mAnimations, 0, scene->mNumAnimations*sizeof(aiAnimation*));
|
||||||
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
||||||
scene->mAnimations[i] = new aiAnimation();
|
scene->mAnimations[i] = new aiAnimation();
|
||||||
ReadBinaryAnim(stream,scene->mAnimations[i]);
|
ReadBinaryAnim(stream,scene->mAnimations[i]);
|
||||||
|
@ -641,6 +640,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
|
||||||
// Read all textures
|
// Read all textures
|
||||||
if (scene->mNumTextures) {
|
if (scene->mNumTextures) {
|
||||||
scene->mTextures = new aiTexture*[scene->mNumTextures];
|
scene->mTextures = new aiTexture*[scene->mNumTextures];
|
||||||
|
memset(scene->mTextures, 0, scene->mNumTextures*sizeof(aiTexture*));
|
||||||
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
||||||
scene->mTextures[i] = new aiTexture();
|
scene->mTextures[i] = new aiTexture();
|
||||||
ReadBinaryTexture(stream,scene->mTextures[i]);
|
ReadBinaryTexture(stream,scene->mTextures[i]);
|
||||||
|
@ -650,6 +650,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
|
||||||
// Read lights
|
// Read lights
|
||||||
if (scene->mNumLights) {
|
if (scene->mNumLights) {
|
||||||
scene->mLights = new aiLight*[scene->mNumLights];
|
scene->mLights = new aiLight*[scene->mNumLights];
|
||||||
|
memset(scene->mLights, 0, scene->mNumLights*sizeof(aiLight*));
|
||||||
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
||||||
scene->mLights[i] = new aiLight();
|
scene->mLights[i] = new aiLight();
|
||||||
ReadBinaryLight(stream,scene->mLights[i]);
|
ReadBinaryLight(stream,scene->mLights[i]);
|
||||||
|
@ -659,6 +660,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
|
||||||
// Read cameras
|
// Read cameras
|
||||||
if (scene->mNumCameras) {
|
if (scene->mNumCameras) {
|
||||||
scene->mCameras = new aiCamera*[scene->mNumCameras];
|
scene->mCameras = new aiCamera*[scene->mNumCameras];
|
||||||
|
memset(scene->mCameras, 0, scene->mNumCameras*sizeof(aiCamera*));
|
||||||
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
||||||
scene->mCameras[i] = new aiCamera();
|
scene->mCameras[i] = new aiCamera();
|
||||||
ReadBinaryCamera(stream,scene->mCameras[i]);
|
ReadBinaryCamera(stream,scene->mCameras[i]);
|
||||||
|
@ -701,11 +703,19 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
uLongf compressedSize = static_cast<uLongf>(stream->FileSize() - stream->Tell());
|
uLongf compressedSize = static_cast<uLongf>(stream->FileSize() - stream->Tell());
|
||||||
|
|
||||||
unsigned char * compressedData = new unsigned char[ compressedSize ];
|
unsigned char * compressedData = new unsigned char[ compressedSize ];
|
||||||
stream->Read( compressedData, 1, compressedSize );
|
size_t len = stream->Read( compressedData, 1, compressedSize );
|
||||||
|
ai_assert(len == compressedSize);
|
||||||
|
|
||||||
unsigned char * uncompressedData = new unsigned char[ uncompressedSize ];
|
unsigned char * uncompressedData = new unsigned char[ uncompressedSize ];
|
||||||
|
|
||||||
uncompress( uncompressedData, &uncompressedSize, compressedData, compressedSize );
|
int res = uncompress( uncompressedData, &uncompressedSize, compressedData, len );
|
||||||
|
if(res != Z_OK)
|
||||||
|
{
|
||||||
|
delete [] uncompressedData;
|
||||||
|
delete [] compressedData;
|
||||||
|
pIOHandler->Close(stream);
|
||||||
|
throw DeadlyImportError("Zlib decompression failed.");
|
||||||
|
}
|
||||||
|
|
||||||
MemoryIOStream io( uncompressedData, uncompressedSize );
|
MemoryIOStream io( uncompressedData, uncompressedSize );
|
||||||
|
|
||||||
|
|
|
@ -181,8 +181,7 @@ void MS3DImporter :: CollectChildJoints(const std::vector<TempJoint>& joints,
|
||||||
ch->mParent = nd;
|
ch->mParent = nd;
|
||||||
|
|
||||||
ch->mTransformation = aiMatrix4x4::Translation(joints[i].position,aiMatrix4x4()=aiMatrix4x4())*
|
ch->mTransformation = aiMatrix4x4::Translation(joints[i].position,aiMatrix4x4()=aiMatrix4x4())*
|
||||||
// XXX actually, I don't *know* why we need the inverse here. Probably column vs. row order?
|
aiMatrix4x4().FromEulerAnglesXYZ(joints[i].rotation);
|
||||||
aiMatrix4x4().FromEulerAnglesXYZ(joints[i].rotation).Transpose();
|
|
||||||
|
|
||||||
const aiMatrix4x4 abs = absTrafo*ch->mTransformation;
|
const aiMatrix4x4 abs = absTrafo*ch->mTransformation;
|
||||||
for(unsigned int a = 0; a < mScene->mNumMeshes; ++a) {
|
for(unsigned int a = 0; a < mScene->mNumMeshes; ++a) {
|
||||||
|
@ -639,11 +638,8 @@ void MS3DImporter::InternReadFile( const std::string& pFile,
|
||||||
aiQuatKey& q = nd->mRotationKeys[nd->mNumRotationKeys++];
|
aiQuatKey& q = nd->mRotationKeys[nd->mNumRotationKeys++];
|
||||||
|
|
||||||
q.mTime = (*rot).time*animfps;
|
q.mTime = (*rot).time*animfps;
|
||||||
|
q.mValue = aiQuaternion(aiMatrix3x3(aiMatrix4x4().FromEulerAnglesXYZ((*it).rotation)*
|
||||||
// XXX it seems our matrix&quaternion code has faults in its conversion routines --
|
aiMatrix4x4().FromEulerAnglesXYZ((*rot).value)));
|
||||||
// aiQuaternion(x,y,z) seems to besomething different as quat(matrix.fromeuler(x,y,z)).
|
|
||||||
q.mValue = aiQuaternion(aiMatrix3x3(aiMatrix4x4().FromEulerAnglesXYZ((*rot).value)*
|
|
||||||
aiMatrix4x4().FromEulerAnglesXYZ((*it).rotation)).Transpose());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -219,6 +219,7 @@ protected:
|
||||||
/** Parse the SMD file and create the output scene
|
/** Parse the SMD file and create the output scene
|
||||||
*/
|
*/
|
||||||
void ParseFile();
|
void ParseFile();
|
||||||
|
void ReadSmd(const std::string &pFile, IOSystem* pIOHandler);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Parse the triangles section of the SMD file
|
/** Parse the triangles section of the SMD file
|
||||||
|
@ -289,13 +290,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
unsigned int GetTextureIndex(const std::string& filename);
|
unsigned int GetTextureIndex(const std::string& filename);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Computes absolute bone transformations
|
|
||||||
* All output transformations are in worldspace.
|
|
||||||
*/
|
|
||||||
void ComputeAbsoluteBoneTransformations();
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Parse a line in the skeleton section
|
/** Parse a line in the skeleton section
|
||||||
*/
|
*/
|
||||||
|
@ -344,7 +338,9 @@ protected:
|
||||||
*/
|
*/
|
||||||
void CreateOutputMeshes();
|
void CreateOutputMeshes();
|
||||||
void CreateOutputNodes();
|
void CreateOutputNodes();
|
||||||
void CreateOutputAnimations();
|
void CreateOutputAnimations(const std::string &pFile, IOSystem* pIOHandler);
|
||||||
|
void CreateOutputAnimation(int index, const std::string &name);
|
||||||
|
void GetAnimationFileList(const std::string &pFile, IOSystem* pIOHandler, std::vector<std::tuple<std::string, std::string>>& outList);
|
||||||
void CreateOutputMaterials();
|
void CreateOutputMaterials();
|
||||||
|
|
||||||
|
|
||||||
|
@ -413,6 +409,8 @@ private:
|
||||||
*/
|
*/
|
||||||
unsigned int iLineNumber;
|
unsigned int iLineNumber;
|
||||||
|
|
||||||
|
bool bLoadAnimationList = true;
|
||||||
|
bool noSkeletonMesh = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
|
@ -1357,6 +1357,13 @@ inline void Asset::Load(const std::string& pFile, bool isBinary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force reading of skins since they're not always directly referenced
|
||||||
|
if (Value* skinsArray = FindArray(doc, "skins")) {
|
||||||
|
for (unsigned int i = 0; i < skinsArray->Size(); ++i) {
|
||||||
|
skins.Retrieve(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Value* animsArray = FindArray(doc, "animations")) {
|
if (Value* animsArray = FindArray(doc, "animations")) {
|
||||||
for (unsigned int i = 0; i < animsArray->Size(); ++i) {
|
for (unsigned int i = 0; i < animsArray->Size(); ++i) {
|
||||||
animations.Retrieve(i);
|
animations.Retrieve(i);
|
||||||
|
|
|
@ -59,32 +59,10 @@ bool isSeparator( T in ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unsigned char chartype_table[ 256 ] = {
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 32-47
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 48-63
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 64-79
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80-95
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 96-111
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 112-127
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // > 127
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
bool isNumeric( const T in ) {
|
bool isNumeric( const T in ) {
|
||||||
return ( chartype_table[ static_cast<size_t>( in ) ] == 1 );
|
return ( in >= '0' && in <= '9' );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
@ -80,7 +80,9 @@ public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Read from stream
|
// Read from stream
|
||||||
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) {
|
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) {
|
||||||
const size_t cnt = std::min(pCount,(length-pos)/pSize),ofs = pSize*cnt;
|
ai_assert(pvBuffer);
|
||||||
|
ai_assert(pSize);
|
||||||
|
const size_t cnt = std::min(pCount,(length-pos)/pSize), ofs = pSize*cnt;
|
||||||
|
|
||||||
memcpy(pvBuffer,buffer+pos,ofs);
|
memcpy(pvBuffer,buffer+pos,ofs);
|
||||||
pos += ofs;
|
pos += ofs;
|
||||||
|
|
|
@ -63,8 +63,7 @@ public:
|
||||||
aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
|
aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
|
||||||
: r(_r), g(_g), b(_b), a(_a) {}
|
: r(_r), g(_g), b(_b), a(_a) {}
|
||||||
explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
|
explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
|
||||||
aiColor4t (const aiColor4t& o)
|
aiColor4t (const aiColor4t& o) = default;
|
||||||
: r(o.r), g(o.g), b(o.b), a(o.a) {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// combined operators
|
// combined operators
|
||||||
|
|
|
@ -673,6 +673,12 @@ enum aiComponent
|
||||||
#define AI_CONFIG_IMPORT_SMD_KEYFRAME "IMPORT_SMD_KEYFRAME"
|
#define AI_CONFIG_IMPORT_SMD_KEYFRAME "IMPORT_SMD_KEYFRAME"
|
||||||
#define AI_CONFIG_IMPORT_UNREAL_KEYFRAME "IMPORT_UNREAL_KEYFRAME"
|
#define AI_CONFIG_IMPORT_UNREAL_KEYFRAME "IMPORT_UNREAL_KEYFRAME"
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Smd load multiple animations
|
||||||
|
*
|
||||||
|
* Property type: bool. Default value: true.
|
||||||
|
*/
|
||||||
|
#define AI_CONFIG_IMPORT_SMD_LOAD_ANIMATION_LIST "IMPORT_SMD_LOAD_ANIMATION_LIST"
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** @brief Configures the AC loader to collect all surfaces which have the
|
/** @brief Configures the AC loader to collect all surfaces which have the
|
||||||
|
|
|
@ -527,27 +527,25 @@ inline aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::FromEulerAnglesXYZ(TReal x, TRe
|
||||||
{
|
{
|
||||||
aiMatrix4x4t<TReal>& _this = *this;
|
aiMatrix4x4t<TReal>& _this = *this;
|
||||||
|
|
||||||
TReal cr = std::cos( x );
|
TReal cx = std::cos(x);
|
||||||
TReal sr = std::sin( x );
|
TReal sx = std::sin(x);
|
||||||
TReal cp = std::cos( y );
|
TReal cy = std::cos(y);
|
||||||
TReal sp = std::sin( y );
|
TReal sy = std::sin(y);
|
||||||
TReal cy = std::cos( z );
|
TReal cz = std::cos(z);
|
||||||
TReal sy = std::sin( z );
|
TReal sz = std::sin(z);
|
||||||
|
|
||||||
_this.a1 = cp*cy ;
|
// mz*my*mx
|
||||||
_this.a2 = cp*sy;
|
_this.a1 = cz * cy;
|
||||||
_this.a3 = -sp ;
|
_this.a2 = cz * sy * sx - sz * cx;
|
||||||
|
_this.a3 = sz * sx + cz * sy * cx;
|
||||||
|
|
||||||
TReal srsp = sr*sp;
|
_this.b1 = sz * cy;
|
||||||
TReal crsp = cr*sp;
|
_this.b2 = cz * cx + sz * sy * sx;
|
||||||
|
_this.b3 = sz * sy * cx - cz * sx;
|
||||||
|
|
||||||
_this.b1 = srsp*cy-cr*sy ;
|
_this.c1 = -sy;
|
||||||
_this.b2 = srsp*sy+cr*cy ;
|
_this.c2 = cy * sx;
|
||||||
_this.b3 = sr*cp ;
|
_this.c3 = cy * cx;
|
||||||
|
|
||||||
_this.c1 = crsp*cy+sr*sy ;
|
|
||||||
_this.c2 = crsp*sy-sr*cy ;
|
|
||||||
_this.c3 = cr*cp ;
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "./Compiler/pushpack1.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ -62,24 +61,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
template <typename TReal>
|
template <typename TReal>
|
||||||
class aiVector2t
|
class aiVector2t {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
aiVector2t () : x(), y() {}
|
aiVector2t () : x(), y() {}
|
||||||
aiVector2t (TReal _x, TReal _y) : x(_x), y(_y) {}
|
aiVector2t (TReal _x, TReal _y) : x(_x), y(_y) {}
|
||||||
explicit aiVector2t (TReal _xyz) : x(_xyz), y(_xyz) {}
|
explicit aiVector2t (TReal _xyz) : x(_xyz), y(_xyz) {}
|
||||||
aiVector2t (const aiVector2t& o) : x(o.x), y(o.y) {}
|
aiVector2t (const aiVector2t& o) = default;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void Set( TReal pX, TReal pY);
|
void Set( TReal pX, TReal pY);
|
||||||
TReal SquareLength() const ;
|
TReal SquareLength() const ;
|
||||||
TReal Length() const ;
|
TReal Length() const ;
|
||||||
aiVector2t& Normalize();
|
aiVector2t& Normalize();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
const aiVector2t& operator += (const aiVector2t& o);
|
const aiVector2t& operator += (const aiVector2t& o);
|
||||||
const aiVector2t& operator -= (const aiVector2t& o);
|
const aiVector2t& operator -= (const aiVector2t& o);
|
||||||
const aiVector2t& operator *= (TReal f);
|
const aiVector2t& operator *= (TReal f);
|
||||||
|
@ -111,6 +104,4 @@ struct aiVector2D {
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
#include "./Compiler/poppack1.h"
|
|
||||||
|
|
||||||
#endif // AI_VECTOR2D_H_INC
|
#endif // AI_VECTOR2D_H_INC
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
aiVector3t() AI_NO_EXCEPT : x(), y(), z() {}
|
aiVector3t() AI_NO_EXCEPT : x(), y(), z() {}
|
||||||
aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
|
aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
|
||||||
explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
|
explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
|
||||||
aiVector3t( const aiVector3t& o ) : x(o.x), y(o.y), z(o.z) {}
|
aiVector3t( const aiVector3t& o ) = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -82,15 +82,18 @@ void CompressBinaryDump(const char* file, unsigned int head_size)
|
||||||
uint8_t* data = new uint8_t[size];
|
uint8_t* data = new uint8_t[size];
|
||||||
fread(data,1,size,p);
|
fread(data,1,size,p);
|
||||||
|
|
||||||
uLongf out_size = (uLongf)((size-head_size) * 1.001 + 12.);
|
uint32_t uncompressed_size = size-head_size;
|
||||||
|
uLongf out_size = (uLongf)compressBound(uncompressed_size);
|
||||||
uint8_t* out = new uint8_t[out_size];
|
uint8_t* out = new uint8_t[out_size];
|
||||||
|
|
||||||
compress2(out,&out_size,data+head_size,size-head_size,9);
|
int res = compress2(out,&out_size,data+head_size,uncompressed_size,9);
|
||||||
|
if(res != Z_OK)
|
||||||
|
fprintf(stderr, "compress2: error\n");
|
||||||
fclose(p);
|
fclose(p);
|
||||||
p = fopen(file,"w");
|
p = fopen(file,"w");
|
||||||
|
|
||||||
fwrite(data,head_size,1,p);
|
fwrite(data,head_size,1,p);
|
||||||
fwrite(&out_size,4,1,p); // write size of uncompressed data
|
fwrite(&uncompressed_size,4,1,p); // write size of uncompressed data
|
||||||
fwrite(out,out_size,1,p);
|
fwrite(out,out_size,1,p);
|
||||||
|
|
||||||
fclose(p);
|
fclose(p);
|
||||||
|
|
Loading…
Reference in New Issue