|
@@ -121,6 +121,30 @@ aiMatrix4x4 Read<aiMatrix4x4>(IOStream * stream)
|
|
|
return m;
|
|
|
}
|
|
|
|
|
|
+template <>
|
|
|
+aiVectorKey Read<aiVectorKey>(IOStream * stream)
|
|
|
+{
|
|
|
+ aiVectorKey v;
|
|
|
+ v.mTime = Read<double>(stream);
|
|
|
+ v.mValue = Read<aiVector3D>(stream);
|
|
|
+ return v;
|
|
|
+}
|
|
|
+
|
|
|
+template <>
|
|
|
+aiQuatKey Read<aiQuatKey>(IOStream * stream)
|
|
|
+{
|
|
|
+ aiQuatKey v;
|
|
|
+ v.mTime = Read<double>(stream);
|
|
|
+ v.mValue = Read<aiQuaternion>(stream);
|
|
|
+ return v;
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+void ReadArray(IOStream * stream, T * out, unsigned int size)
|
|
|
+{
|
|
|
+ for (unsigned int i=0; i<size; i++) out[i] = Read<T>(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.
|
|
@@ -176,7 +200,7 @@ void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b )
|
|
|
else
|
|
|
{
|
|
|
b->mWeights = new aiVertexWeight[b->mNumWeights];
|
|
|
- stream->Read(b->mWeights,1,b->mNumWeights*sizeof(aiVertexWeight));
|
|
|
+ ReadArray<aiVertexWeight>(stream,b->mWeights,b->mNumWeights);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -203,7 +227,7 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|
|
else
|
|
|
{
|
|
|
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
|
|
- stream->Read(mesh->mVertices,1,12*mesh->mNumVertices);
|
|
|
+ ReadArray<aiVector3D>(stream,mesh->mVertices,mesh->mNumVertices);
|
|
|
}
|
|
|
}
|
|
|
if (c & ASSBIN_MESH_HAS_NORMALS)
|
|
@@ -214,7 +238,7 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|
|
else
|
|
|
{
|
|
|
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
|
|
|
- stream->Read(mesh->mNormals,1,12*mesh->mNumVertices);
|
|
|
+ ReadArray<aiVector3D>(stream,mesh->mNormals,mesh->mNumVertices);
|
|
|
}
|
|
|
}
|
|
|
if (c & ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS)
|
|
@@ -226,9 +250,9 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|
|
else
|
|
|
{
|
|
|
mesh->mTangents = new aiVector3D[mesh->mNumVertices];
|
|
|
- stream->Read(mesh->mTangents,1,12*mesh->mNumVertices);
|
|
|
+ ReadArray<aiVector3D>(stream,mesh->mTangents,mesh->mNumVertices);
|
|
|
mesh->mBitangents = new aiVector3D[mesh->mNumVertices];
|
|
|
- stream->Read(mesh->mBitangents,1,12*mesh->mNumVertices);
|
|
|
+ ReadArray<aiVector3D>(stream,mesh->mBitangents,mesh->mNumVertices);
|
|
|
}
|
|
|
}
|
|
|
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n)
|
|
@@ -243,7 +267,7 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|
|
else
|
|
|
{
|
|
|
mesh->mColors[n] = new aiColor4D[mesh->mNumVertices];
|
|
|
- stream->Read(mesh->mColors[n],16*mesh->mNumVertices,1);
|
|
|
+ ReadArray<aiColor4D>(stream,mesh->mColors[n],mesh->mNumVertices);
|
|
|
}
|
|
|
}
|
|
|
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n)
|
|
@@ -260,7 +284,7 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
|
|
else
|
|
|
{
|
|
|
mesh->mTextureCoords[n] = new aiVector3D[mesh->mNumVertices];
|
|
|
- stream->Read(mesh->mTextureCoords[n],12*mesh->mNumVertices,1);
|
|
|
+ ReadArray<aiVector3D>(stream,mesh->mTextureCoords[n],mesh->mNumVertices);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -361,7 +385,7 @@ 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));
|
|
|
+ ReadArray<aiVectorKey>(stream,nd->mPositionKeys,nd->mNumPositionKeys);
|
|
|
}
|
|
|
}
|
|
|
if (nd->mNumRotationKeys) {
|
|
@@ -372,7 +396,7 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
|
|
else
|
|
|
{
|
|
|
nd->mRotationKeys = new aiQuatKey[nd->mNumRotationKeys];
|
|
|
- stream->Read(nd->mRotationKeys,1,nd->mNumRotationKeys*sizeof(aiQuatKey));
|
|
|
+ ReadArray<aiQuatKey>(stream,nd->mRotationKeys,nd->mNumRotationKeys);
|
|
|
}
|
|
|
}
|
|
|
if (nd->mNumScalingKeys) {
|
|
@@ -383,7 +407,7 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
|
|
else
|
|
|
{
|
|
|
nd->mScalingKeys = new aiVectorKey[nd->mNumScalingKeys];
|
|
|
- stream->Read(nd->mScalingKeys,1,nd->mNumScalingKeys*sizeof(aiVectorKey));
|
|
|
+ ReadArray<aiVectorKey>(stream,nd->mScalingKeys,nd->mNumScalingKeys);
|
|
|
}
|
|
|
}
|
|
|
}
|