|
@@ -1228,6 +1228,40 @@ void ColladaExporter::WriteSceneLibrary()
|
|
|
for( size_t a = 0; a < mScene->mRootNode->mNumChildren; ++a )
|
|
|
WriteNode( mScene, mScene->mRootNode->mChildren[a]);
|
|
|
|
|
|
+ for( size_t a = 0; a < mScene->mNumMeshes; ++a )
|
|
|
+ {
|
|
|
+ const aiMesh* mesh = mScene->mMeshes[a];
|
|
|
+ const std::string idstr = GetMeshId( a);
|
|
|
+ const std::string idstrEscaped = XMLEscape(idstr);
|
|
|
+
|
|
|
+ if ( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
|
|
+ continue;
|
|
|
+
|
|
|
+ if ( mesh->mNumBones == 0 )
|
|
|
+ continue;
|
|
|
+
|
|
|
+ const std::string mesh_name_escaped = XMLEscape(mesh->mName.C_Str());
|
|
|
+ mOutput << startstr
|
|
|
+ << "<node id=\"" << mesh_name_escaped << "_armature"
|
|
|
+ << "\" name=\"" << mesh_name_escaped << "_armature"
|
|
|
+ << "\" type=\"NODE\">"
|
|
|
+ << endstr;
|
|
|
+ PushTag();
|
|
|
+
|
|
|
+ mOutput << startstr
|
|
|
+ << "<instance_controller url=\"#" << idstrEscaped << "-skin\">"
|
|
|
+ << endstr;
|
|
|
+ PushTag();
|
|
|
+
|
|
|
+ mOutput << startstr << "<skeleton>#skeleton_root</skeleton>" << endstr;
|
|
|
+
|
|
|
+ PopTag();
|
|
|
+ mOutput << startstr << "</instance_controller>" << endstr;
|
|
|
+
|
|
|
+ PopTag();
|
|
|
+ mOutput << startstr << "</node>" << endstr;
|
|
|
+ }
|
|
|
+
|
|
|
PopTag();
|
|
|
mOutput << startstr << "</visual_scene>" << endstr;
|
|
|
PopTag();
|
|
@@ -1264,15 +1298,23 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
|
|
|
// If the node is associated with a bone, it is a joint node (JOINT)
|
|
|
// otherwise it is a normal node (NODE)
|
|
|
const char * node_type;
|
|
|
+ bool is_joint, is_skeleton_root = false;
|
|
|
if (NULL == findBone(pScene, pNode->mName.C_Str())) {
|
|
|
node_type = "NODE";
|
|
|
+ is_joint = false;
|
|
|
} else {
|
|
|
node_type = "JOINT";
|
|
|
+ is_joint = true;
|
|
|
+ if(!pNode->mParent || NULL == findBone(pScene, pNode->mParent->mName.C_Str()))
|
|
|
+ is_skeleton_root = true;
|
|
|
}
|
|
|
|
|
|
const std::string node_name_escaped = XMLEscape(pNode->mName.data);
|
|
|
mOutput << startstr
|
|
|
- << "<node id=\"" << node_name_escaped
|
|
|
+ << "<node ";
|
|
|
+ if(is_skeleton_root)
|
|
|
+ mOutput << "id=\"" << "#skeleton_root" << "\" "; // For now, only support one skeleton in a scene.
|
|
|
+ mOutput << (is_joint ? "s" : "") << "id=\"" << node_name_escaped
|
|
|
<< "\" name=\"" << node_name_escaped
|
|
|
<< "\" type=\"" << node_type
|
|
|
<< "\">" << endstr;
|