Fill in mParent for each node in Assbin Loader
parent
5bf974ae3b
commit
845d206959
|
@ -196,7 +196,7 @@ template <typename T> void ReadBounds( IOStream * stream, T* /*p*/, unsigned int
|
||||||
stream->Seek( sizeof(T) * n, aiOrigin_CUR );
|
stream->Seek( sizeof(T) * n, aiOrigin_CUR );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node )
|
void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent )
|
||||||
{
|
{
|
||||||
uint32_t chunkID = Read<uint32_t>(stream);
|
uint32_t chunkID = Read<uint32_t>(stream);
|
||||||
ai_assert(chunkID == ASSBIN_CHUNK_AINODE);
|
ai_assert(chunkID == ASSBIN_CHUNK_AINODE);
|
||||||
|
@ -208,6 +208,10 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node )
|
||||||
(*node)->mTransformation = Read<aiMatrix4x4>(stream);
|
(*node)->mTransformation = Read<aiMatrix4x4>(stream);
|
||||||
(*node)->mNumChildren = Read<unsigned int>(stream);
|
(*node)->mNumChildren = Read<unsigned int>(stream);
|
||||||
(*node)->mNumMeshes = Read<unsigned int>(stream);
|
(*node)->mNumMeshes = Read<unsigned int>(stream);
|
||||||
|
if(parent)
|
||||||
|
{
|
||||||
|
(*node)->mParent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
if ((*node)->mNumMeshes)
|
if ((*node)->mNumMeshes)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +225,7 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node )
|
||||||
{
|
{
|
||||||
(*node)->mChildren = new aiNode*[(*node)->mNumChildren];
|
(*node)->mChildren = new aiNode*[(*node)->mNumChildren];
|
||||||
for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) {
|
for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) {
|
||||||
ReadBinaryNode( stream, &(*node)->mChildren[i] );
|
ReadBinaryNode( stream, &(*node)->mChildren[i], *node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +573,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene )
|
||||||
|
|
||||||
// Read node graph
|
// Read node graph
|
||||||
scene->mRootNode = new aiNode[1];
|
scene->mRootNode = new aiNode[1];
|
||||||
ReadBinaryNode( stream, &scene->mRootNode );
|
ReadBinaryNode( stream, &scene->mRootNode, (aiNode*)NULL );
|
||||||
|
|
||||||
// Read all meshes
|
// Read all meshes
|
||||||
if (scene->mNumMeshes)
|
if (scene->mNumMeshes)
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
IOSystem* pIOHandler
|
IOSystem* pIOHandler
|
||||||
);
|
);
|
||||||
void ReadBinaryScene( IOStream * stream, aiScene* pScene );
|
void ReadBinaryScene( IOStream * stream, aiScene* pScene );
|
||||||
void ReadBinaryNode( IOStream * stream, aiNode** mRootNode );
|
void ReadBinaryNode( IOStream * stream, aiNode** mRootNode, aiNode* parent );
|
||||||
void ReadBinaryMesh( IOStream * stream, aiMesh* mesh );
|
void ReadBinaryMesh( IOStream * stream, aiMesh* mesh );
|
||||||
void ReadBinaryBone( IOStream * stream, aiBone* bone );
|
void ReadBinaryBone( IOStream * stream, aiBone* bone );
|
||||||
void ReadBinaryMaterial(IOStream * stream, aiMaterial* mat);
|
void ReadBinaryMaterial(IOStream * stream, aiMaterial* mat);
|
||||||
|
|
|
@ -804,7 +804,7 @@ void ColladaExporter::WriteControllerLibrary()
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Writes a skin controller of the given mesh
|
// Writes a skin controller of the given mesh
|
||||||
void WriteController( size_t pIndex)
|
void ColladaExporter::WriteController( size_t pIndex)
|
||||||
{
|
{
|
||||||
const aiMesh* mesh = mScene->mMeshes[pIndex];
|
const aiMesh* mesh = mScene->mMeshes[pIndex];
|
||||||
const std::string idstr = GetMeshId( pIndex);
|
const std::string idstr = GetMeshId( pIndex);
|
||||||
|
@ -820,7 +820,7 @@ void WriteController( size_t pIndex)
|
||||||
mOutput << "name=\"skinCluster" << pIndex << "\">"<< endstr;
|
mOutput << "name=\"skinCluster" << pIndex << "\">"<< endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
mOutput << startstr << "<skin source=\"#" << idstrEscaped \">" << endstr;
|
mOutput << startstr << "<skin source=\"#" << idstrEscaped << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
// bind pose matrix
|
// bind pose matrix
|
||||||
|
@ -828,7 +828,7 @@ void WriteController( size_t pIndex)
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
// I think it is identity in general cases.
|
// I think it is identity in general cases.
|
||||||
aiMatrix4x4 mat();
|
aiMatrix4x4 mat;
|
||||||
mOutput << startstr;
|
mOutput << startstr;
|
||||||
mOutput << mat.a1 << " " << mat.a2 << " " << mat.a3 << " " << mat.a4;
|
mOutput << mat.a1 << " " << mat.a2 << " " << mat.a3 << " " << mat.a4;
|
||||||
mOutput << mat.b1 << " " << mat.b2 << " " << mat.b3 << " " << mat.b4;
|
mOutput << mat.b1 << " " << mat.b2 << " " << mat.b3 << " " << mat.b4;
|
||||||
|
@ -842,7 +842,7 @@ void WriteController( size_t pIndex)
|
||||||
mOutput << startstr << "<Name_array id=\"" << idstrEscaped << "-skin-joints-array\" " << "count=\"" << mesh->mNumBones << "\">";
|
mOutput << startstr << "<Name_array id=\"" << idstrEscaped << "-skin-joints-array\" " << "count=\"" << mesh->mNumBones << "\">";
|
||||||
|
|
||||||
for( size_t i = 0; i < mesh->mNumBones; ++i )
|
for( size_t i = 0; i < mesh->mNumBones; ++i )
|
||||||
mOutput << XMLEscape(mesh->mBones[i].mName) << " ";
|
mOutput << XMLEscape(mesh->mBones[i]->mName.C_Str()) << " ";
|
||||||
|
|
||||||
mOutput << "</Name_array>" << endstr;
|
mOutput << "</Name_array>" << endstr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue