code style
parent
1aeaef2037
commit
fb546b694e
|
@ -55,58 +55,58 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
using namespace Assimp;
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
".assbin Importer",
|
||||
"Gargaj / Conspiracy",
|
||||
"",
|
||||
"",
|
||||
aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_SupportCompressedFlavour,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"assbin"
|
||||
".assbin Importer",
|
||||
"Gargaj / Conspiracy",
|
||||
"",
|
||||
"",
|
||||
aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_SupportCompressedFlavour,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"assbin"
|
||||
};
|
||||
|
||||
const aiImporterDesc* AssbinImporter::GetInfo() const
|
||||
{
|
||||
return &desc;
|
||||
return &desc;
|
||||
}
|
||||
|
||||
bool AssbinImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const
|
||||
{
|
||||
IOStream * in = pIOHandler->Open(pFile);
|
||||
if (!in)
|
||||
return false;
|
||||
IOStream * in = pIOHandler->Open(pFile);
|
||||
if (!in)
|
||||
return false;
|
||||
|
||||
char s[32];
|
||||
in->Read( s, sizeof(char), 32 );
|
||||
char s[32];
|
||||
in->Read( s, sizeof(char), 32 );
|
||||
|
||||
pIOHandler->Close(in);
|
||||
pIOHandler->Close(in);
|
||||
|
||||
return strncmp( s, "ASSIMP.binary-dump.", 19 ) == 0;
|
||||
return strncmp( s, "ASSIMP.binary-dump.", 19 ) == 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Read(IOStream * stream)
|
||||
{
|
||||
T t;
|
||||
stream->Read( &t, sizeof(T), 1 );
|
||||
return t;
|
||||
T t;
|
||||
stream->Read( &t, sizeof(T), 1 );
|
||||
return t;
|
||||
}
|
||||
|
||||
template <>
|
||||
aiString Read<aiString>(IOStream * stream)
|
||||
{
|
||||
aiString s;
|
||||
aiString s;
|
||||
stream->Read(&s.length,4,1);
|
||||
stream->Read(s.data,s.length,1);
|
||||
return s;
|
||||
stream->Read(s.data,s.length,1);
|
||||
return s;
|
||||
}
|
||||
|
||||
template <>
|
||||
aiMatrix4x4 Read<aiMatrix4x4>(IOStream * stream)
|
||||
{
|
||||
aiMatrix4x4 m;
|
||||
aiMatrix4x4 m;
|
||||
for (unsigned int i = 0; i < 4;++i) {
|
||||
for (unsigned int i2 = 0; i2 < 4;++i2) {
|
||||
m[i][i2] = Read<float>(stream);
|
||||
|
@ -117,37 +117,37 @@ aiMatrix4x4 Read<aiMatrix4x4>(IOStream * stream)
|
|||
|
||||
template <typename T> void ReadBounds( IOStream * stream, T* p, unsigned int n )
|
||||
{
|
||||
// not sure what to do here, the data isn't really useful.
|
||||
// not sure what to do here, the data isn't really useful.
|
||||
stream->Seek( sizeof(T) * n, aiOrigin_CUR );
|
||||
}
|
||||
|
||||
void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AINODE);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
*node = new aiNode();
|
||||
*node = new aiNode();
|
||||
|
||||
(*node)->mName = Read<aiString>(stream);
|
||||
(*node)->mTransformation = Read<aiMatrix4x4>(stream);
|
||||
(*node)->mNumChildren = Read<unsigned int>(stream);
|
||||
(*node)->mNumMeshes = Read<unsigned int>(stream);
|
||||
|
||||
if ((*node)->mNumMeshes)
|
||||
{
|
||||
(*node)->mMeshes = new unsigned int[(*node)->mNumMeshes];
|
||||
for (unsigned int i = 0; i < (*node)->mNumMeshes; ++i) {
|
||||
(*node)->mMeshes[i] = Read<unsigned int>(stream);
|
||||
}
|
||||
}
|
||||
if ((*node)->mNumMeshes)
|
||||
{
|
||||
(*node)->mMeshes = new unsigned int[(*node)->mNumMeshes];
|
||||
for (unsigned int i = 0; i < (*node)->mNumMeshes; ++i) {
|
||||
(*node)->mMeshes[i] = Read<unsigned int>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
if ((*node)->mNumChildren)
|
||||
{
|
||||
(*node)->mChildren = new aiNode*[(*node)->mNumChildren];
|
||||
for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) {
|
||||
ReadBinaryNode( stream, &(*node)->mChildren[i] );
|
||||
}
|
||||
}
|
||||
if ((*node)->mNumChildren)
|
||||
{
|
||||
(*node)->mChildren = new aiNode*[(*node)->mNumChildren];
|
||||
for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) {
|
||||
ReadBinaryNode( stream, &(*node)->mChildren[i] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node )
|
|||
void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIBONE );
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
b->mName = Read<aiString>(stream);
|
||||
b->mNumWeights = Read<unsigned int>(stream);
|
||||
|
@ -164,21 +164,21 @@ void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b )
|
|||
// for the moment we write dumb min/max values for the bones, too.
|
||||
// maybe I'll add a better, hash-like solution later
|
||||
if (shortened)
|
||||
{
|
||||
{
|
||||
ReadBounds(stream,b->mWeights,b->mNumWeights);
|
||||
} // else write as usual
|
||||
else
|
||||
{
|
||||
b->mWeights = new aiVertexWeight[b->mNumWeights];
|
||||
stream->Read(b->mWeights,1,b->mNumWeights*sizeof(aiVertexWeight));
|
||||
}
|
||||
{
|
||||
b->mWeights = new aiVertexWeight[b->mNumWeights];
|
||||
stream->Read(b->mWeights,1,b->mNumWeights*sizeof(aiVertexWeight));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIMESH);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
mesh->mPrimitiveTypes = Read<unsigned int>(stream);
|
||||
mesh->mNumVertices = Read<unsigned int>(stream);
|
||||
|
@ -190,57 +190,58 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|||
unsigned int c = Read<unsigned int>(stream);
|
||||
|
||||
if (c & ASSBIN_MESH_HAS_POSITIONS)
|
||||
{
|
||||
{
|
||||
if (shortened) {
|
||||
ReadBounds(stream,mesh->mVertices,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else
|
||||
{
|
||||
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mVertices,1,12*mesh->mNumVertices);
|
||||
}
|
||||
{
|
||||
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mVertices,1,12*mesh->mNumVertices);
|
||||
}
|
||||
}
|
||||
if (c & ASSBIN_MESH_HAS_NORMALS)
|
||||
{
|
||||
{
|
||||
if (shortened) {
|
||||
ReadBounds(stream,mesh->mNormals,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else
|
||||
{
|
||||
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mNormals,1,12*mesh->mNumVertices);
|
||||
}
|
||||
{
|
||||
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mNormals,1,12*mesh->mNumVertices);
|
||||
}
|
||||
}
|
||||
if (c & ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS)
|
||||
{
|
||||
{
|
||||
if (shortened) {
|
||||
ReadBounds(stream,mesh->mTangents,mesh->mNumVertices);
|
||||
ReadBounds(stream,mesh->mBitangents,mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else {
|
||||
mesh->mTangents = new aiVector3D[mesh->mNumVertices];
|
||||
else
|
||||
{
|
||||
mesh->mTangents = new aiVector3D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mTangents,1,12*mesh->mNumVertices);
|
||||
mesh->mBitangents = new aiVector3D[mesh->mNumVertices];
|
||||
mesh->mBitangents = new aiVector3D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mBitangents,1,12*mesh->mNumVertices);
|
||||
}
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n)
|
||||
{
|
||||
{
|
||||
if (!(c & ASSBIN_MESH_HAS_COLOR(n)))
|
||||
break;
|
||||
|
||||
if (shortened)
|
||||
{
|
||||
{
|
||||
ReadBounds(stream,mesh->mColors[n],mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else
|
||||
{
|
||||
mesh->mColors[n] = new aiColor4D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mColors[n],16*mesh->mNumVertices,1);
|
||||
}
|
||||
{
|
||||
mesh->mColors[n] = new aiColor4D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mColors[n],16*mesh->mNumVertices,1);
|
||||
}
|
||||
}
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n)
|
||||
{
|
||||
{
|
||||
if (!(c & ASSBIN_MESH_HAS_TEXCOORD(n)))
|
||||
break;
|
||||
|
||||
|
@ -251,10 +252,10 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|||
ReadBounds(stream,mesh->mTextureCoords[n],mesh->mNumVertices);
|
||||
} // else write as usual
|
||||
else
|
||||
{
|
||||
mesh->mTextureCoords[n] = new aiVector3D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mTextureCoords[n],12*mesh->mNumVertices,1);
|
||||
}
|
||||
{
|
||||
mesh->mTextureCoords[n] = new aiVector3D[mesh->mNumVertices];
|
||||
stream->Read(mesh->mTextureCoords[n],12*mesh->mNumVertices,1);
|
||||
}
|
||||
}
|
||||
|
||||
// write faces. There are no floating-point calculations involved
|
||||
|
@ -267,30 +268,30 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|||
else // else write as usual
|
||||
{
|
||||
// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
|
||||
mesh->mFaces = new aiFace[mesh->mNumFaces];
|
||||
mesh->mFaces = new aiFace[mesh->mNumFaces];
|
||||
for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
|
||||
aiFace& f = mesh->mFaces[i];
|
||||
|
||||
BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff);
|
||||
f.mNumIndices = Read<uint16_t>(stream);
|
||||
f.mIndices = new unsigned int[f.mNumIndices];
|
||||
f.mIndices = new unsigned int[f.mNumIndices];
|
||||
|
||||
for (unsigned int a = 0; a < f.mNumIndices;++a) {
|
||||
if (mesh->mNumVertices < (1u<<16))
|
||||
{
|
||||
{
|
||||
f.mIndices[a] = Read<uint16_t>(stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
f.mIndices[a] = Read<unsigned int>(stream);
|
||||
}
|
||||
{
|
||||
f.mIndices[a] = Read<unsigned int>(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write bones
|
||||
if (mesh->mNumBones) {
|
||||
mesh->mBones = new C_STRUCT aiBone*[mesh->mNumBones];
|
||||
mesh->mBones = new C_STRUCT aiBone*[mesh->mNumBones];
|
||||
for (unsigned int a = 0; a < mesh->mNumBones;++a) {
|
||||
mesh->mBones[a] = new aiBone();
|
||||
ReadBinaryBone(stream,mesh->mBones[a]);
|
||||
|
@ -301,7 +302,7 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|||
void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop)
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIMATERIALPROPERTY);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
prop->mKey = Read<aiString>(stream);
|
||||
prop->mSemantic = Read<unsigned int>(stream);
|
||||
|
@ -309,7 +310,7 @@ void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialPro
|
|||
|
||||
prop->mDataLength = Read<unsigned int>(stream);
|
||||
prop->mType = (aiPropertyTypeInfo)Read<unsigned int>(stream);
|
||||
prop->mData = new char [ prop->mDataLength ];
|
||||
prop->mData = new char [ prop->mDataLength ];
|
||||
stream->Read(prop->mData,1,prop->mDataLength);
|
||||
}
|
||||
|
||||
|
@ -317,28 +318,28 @@ void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialPro
|
|||
void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat)
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == 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);
|
||||
if (mat->mNumProperties)
|
||||
{
|
||||
if (mat->mProperties)
|
||||
{
|
||||
delete[] mat->mProperties;
|
||||
}
|
||||
mat->mProperties = new aiMaterialProperty*[mat->mNumProperties];
|
||||
for (unsigned int i = 0; i < mat->mNumProperties;++i) {
|
||||
mat->mProperties[i] = new aiMaterialProperty();
|
||||
ReadBinaryMaterialProperty( stream, mat->mProperties[i]);
|
||||
}
|
||||
}
|
||||
if (mat->mNumProperties)
|
||||
{
|
||||
if (mat->mProperties)
|
||||
{
|
||||
delete[] mat->mProperties;
|
||||
}
|
||||
mat->mProperties = new aiMaterialProperty*[mat->mNumProperties];
|
||||
for (unsigned int i = 0; i < mat->mNumProperties;++i) {
|
||||
mat->mProperties[i] = new aiMaterialProperty();
|
||||
ReadBinaryMaterialProperty( stream, mat->mProperties[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AINODEANIM);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
nd->mNodeName = Read<aiString>(stream);
|
||||
nd->mNumPositionKeys = Read<unsigned int>(stream);
|
||||
|
@ -353,9 +354,9 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
|||
|
||||
} // else write as usual
|
||||
else {
|
||||
nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys];
|
||||
stream->Read(nd->mPositionKeys,1,nd->mNumPositionKeys*sizeof(aiVectorKey));
|
||||
}
|
||||
nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys];
|
||||
stream->Read(nd->mPositionKeys,1,nd->mNumPositionKeys*sizeof(aiVectorKey));
|
||||
}
|
||||
}
|
||||
if (nd->mNumRotationKeys) {
|
||||
if (shortened) {
|
||||
|
@ -363,10 +364,10 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
|||
|
||||
} // else write as usual
|
||||
else
|
||||
{
|
||||
nd->mRotationKeys = new aiQuatKey[nd->mNumRotationKeys];
|
||||
stream->Read(nd->mRotationKeys,1,nd->mNumRotationKeys*sizeof(aiQuatKey));
|
||||
}
|
||||
{
|
||||
nd->mRotationKeys = new aiQuatKey[nd->mNumRotationKeys];
|
||||
stream->Read(nd->mRotationKeys,1,nd->mNumRotationKeys*sizeof(aiQuatKey));
|
||||
}
|
||||
}
|
||||
if (nd->mNumScalingKeys) {
|
||||
if (shortened) {
|
||||
|
@ -374,10 +375,10 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
|||
|
||||
} // else write as usual
|
||||
else
|
||||
{
|
||||
nd->mScalingKeys = new aiVectorKey[nd->mNumScalingKeys];
|
||||
stream->Read(nd->mScalingKeys,1,nd->mNumScalingKeys*sizeof(aiVectorKey));
|
||||
}
|
||||
{
|
||||
nd->mScalingKeys = new aiVectorKey[nd->mNumScalingKeys];
|
||||
stream->Read(nd->mScalingKeys,1,nd->mNumScalingKeys*sizeof(aiVectorKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,27 +387,27 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
|||
void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIANIMATION);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
anim->mName = Read<aiString> (stream);
|
||||
anim->mDuration = Read<double> (stream);
|
||||
anim->mTicksPerSecond = Read<double> (stream);
|
||||
anim->mNumChannels = Read<unsigned int>(stream);
|
||||
|
||||
if (anim->mNumChannels)
|
||||
{
|
||||
anim->mChannels = new aiNodeAnim*[ anim->mNumChannels ];
|
||||
for (unsigned int a = 0; a < anim->mNumChannels;++a) {
|
||||
anim->mChannels[a] = new aiNodeAnim();
|
||||
ReadBinaryNodeAnim(stream,anim->mChannels[a]);
|
||||
}
|
||||
}
|
||||
if (anim->mNumChannels)
|
||||
{
|
||||
anim->mChannels = new aiNodeAnim*[ anim->mNumChannels ];
|
||||
for (unsigned int a = 0; a < anim->mNumChannels;++a) {
|
||||
anim->mChannels[a] = new aiNodeAnim();
|
||||
ReadBinaryNodeAnim(stream,anim->mChannels[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex)
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AITEXTURE);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
tex->mWidth = Read<unsigned int>(stream);
|
||||
tex->mHeight = Read<unsigned int>(stream);
|
||||
|
@ -414,11 +415,11 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex)
|
|||
|
||||
if(!shortened) {
|
||||
if (!tex->mHeight) {
|
||||
tex->pcData = new aiTexel[ tex->mWidth ];
|
||||
tex->pcData = new aiTexel[ tex->mWidth ];
|
||||
stream->Read(tex->pcData,1,tex->mWidth);
|
||||
}
|
||||
else {
|
||||
tex->pcData = new aiTexel[ tex->mWidth*tex->mHeight ];
|
||||
tex->pcData = new aiTexel[ tex->mWidth*tex->mHeight ];
|
||||
stream->Read(tex->pcData,1,tex->mWidth*tex->mHeight*4);
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +430,7 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex)
|
|||
void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AILIGHT);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
l->mName = Read<aiString>(stream);
|
||||
l->mType = (aiLightSourceType)Read<unsigned int>(stream);
|
||||
|
@ -455,7 +456,7 @@ void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l )
|
|||
void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AICAMERA);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
cam->mName = Read<aiString>(stream);
|
||||
cam->mPosition = Read<aiVector3D>(stream);
|
||||
|
@ -470,7 +471,7 @@ void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam )
|
|||
void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AISCENE);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
uint32_t size = Read<uint32_t>(stream);
|
||||
|
||||
scene->mFlags = Read<unsigned int>(stream);
|
||||
scene->mNumMeshes = Read<unsigned int>(stream);
|
||||
|
@ -481,68 +482,68 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene )
|
|||
scene->mNumCameras = Read<unsigned int>(stream);
|
||||
|
||||
// Read node graph
|
||||
scene->mRootNode = new aiNode[1];
|
||||
scene->mRootNode = new aiNode[1];
|
||||
ReadBinaryNode( stream, &scene->mRootNode );
|
||||
|
||||
// Read all meshes
|
||||
if (scene->mNumMeshes)
|
||||
{
|
||||
scene->mMeshes = new aiMesh*[scene->mNumMeshes];
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||
scene->mMeshes[i] = new aiMesh();
|
||||
ReadBinaryMesh( stream,scene->mMeshes[i]);
|
||||
}
|
||||
}
|
||||
if (scene->mNumMeshes)
|
||||
{
|
||||
scene->mMeshes = new aiMesh*[scene->mNumMeshes];
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||
scene->mMeshes[i] = new aiMesh();
|
||||
ReadBinaryMesh( stream,scene->mMeshes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Read materials
|
||||
if (scene->mNumMaterials)
|
||||
{
|
||||
scene->mMaterials = new aiMaterial*[scene->mNumMaterials];
|
||||
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
||||
scene->mMaterials[i] = new aiMaterial();
|
||||
ReadBinaryMaterial(stream,scene->mMaterials[i]);
|
||||
}
|
||||
}
|
||||
if (scene->mNumMaterials)
|
||||
{
|
||||
scene->mMaterials = new aiMaterial*[scene->mNumMaterials];
|
||||
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
|
||||
scene->mMaterials[i] = new aiMaterial();
|
||||
ReadBinaryMaterial(stream,scene->mMaterials[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Read all animations
|
||||
if (scene->mNumAnimations)
|
||||
{
|
||||
scene->mAnimations = new aiAnimation*[scene->mNumAnimations];
|
||||
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
||||
scene->mAnimations[i] = new aiAnimation();
|
||||
ReadBinaryAnim(stream,scene->mAnimations[i]);
|
||||
}
|
||||
}
|
||||
if (scene->mNumAnimations)
|
||||
{
|
||||
scene->mAnimations = new aiAnimation*[scene->mNumAnimations];
|
||||
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
|
||||
scene->mAnimations[i] = new aiAnimation();
|
||||
ReadBinaryAnim(stream,scene->mAnimations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Read all textures
|
||||
if (scene->mNumTextures)
|
||||
{
|
||||
scene->mTextures = new aiTexture*[scene->mNumTextures];
|
||||
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
||||
scene->mTextures[i] = new aiTexture();
|
||||
ReadBinaryTexture(stream,scene->mTextures[i]);
|
||||
}
|
||||
}
|
||||
if (scene->mNumTextures)
|
||||
{
|
||||
scene->mTextures = new aiTexture*[scene->mNumTextures];
|
||||
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
|
||||
scene->mTextures[i] = new aiTexture();
|
||||
ReadBinaryTexture(stream,scene->mTextures[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Read lights
|
||||
if (scene->mNumLights)
|
||||
{
|
||||
scene->mLights = new aiLight*[scene->mNumLights];
|
||||
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
||||
scene->mLights[i] = new aiLight();
|
||||
ReadBinaryLight(stream,scene->mLights[i]);
|
||||
}
|
||||
}
|
||||
if (scene->mNumLights)
|
||||
{
|
||||
scene->mLights = new aiLight*[scene->mNumLights];
|
||||
for (unsigned int i = 0; i < scene->mNumLights;++i) {
|
||||
scene->mLights[i] = new aiLight();
|
||||
ReadBinaryLight(stream,scene->mLights[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Read cameras
|
||||
if (scene->mNumCameras)
|
||||
{
|
||||
scene->mCameras = new aiCamera*[scene->mNumCameras];
|
||||
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
||||
scene->mCameras[i] = new aiCamera();
|
||||
ReadBinaryCamera(stream,scene->mCameras[i]);
|
||||
}
|
||||
}
|
||||
if (scene->mNumCameras)
|
||||
{
|
||||
scene->mCameras = new aiCamera*[scene->mNumCameras];
|
||||
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
|
||||
scene->mCameras[i] = new aiCamera();
|
||||
ReadBinaryCamera(stream,scene->mCameras[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -550,9 +551,9 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
|
|||
{
|
||||
IOStream * stream = pIOHandler->Open(pFile,"rb");
|
||||
if (!stream)
|
||||
return;
|
||||
return;
|
||||
|
||||
stream->Seek( 44, aiOrigin_CUR ); // signature
|
||||
stream->Seek( 44, aiOrigin_CUR ); // signature
|
||||
|
||||
unsigned int versionMajor = Read<unsigned int>(stream);
|
||||
unsigned int versionMinor = Read<unsigned int>(stream);
|
||||
|
@ -562,20 +563,20 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
|
|||
shortened = Read<uint16_t>(stream) > 0;
|
||||
compressed = Read<uint16_t>(stream) > 0;
|
||||
|
||||
stream->Seek( 256, aiOrigin_CUR ); // original filename
|
||||
stream->Seek( 128, aiOrigin_CUR ); // options
|
||||
stream->Seek( 64, aiOrigin_CUR ); // padding
|
||||
stream->Seek( 256, aiOrigin_CUR ); // original filename
|
||||
stream->Seek( 128, aiOrigin_CUR ); // options
|
||||
stream->Seek( 64, aiOrigin_CUR ); // padding
|
||||
|
||||
if (compressed)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadBinaryScene(stream,pScene);
|
||||
}
|
||||
|
||||
pIOHandler->Close(stream);
|
||||
if (compressed)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadBinaryScene(stream,pScene);
|
||||
}
|
||||
|
||||
pIOHandler->Close(stream);
|
||||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_ASSBIN_IMPORTER
|
||||
|
|
Loading…
Reference in New Issue