Jelajahi Sumber

Back PretransformVertice Change
Fix Node Name in XFileExport

Madrich 10 tahun lalu
induk
melakukan
edd3ed9e8f
3 mengubah file dengan 15 tambahan dan 5 penghapusan
  1. 1 1
      code/PretransformVertices.cpp
  2. 10 3
      code/XFileExporter.cpp
  3. 4 1
      code/XFileExporter.h

+ 1 - 1
code/PretransformVertices.cpp

@@ -625,7 +625,7 @@ void PretransformVertices::Execute( aiScene* pScene)
 		// flat node graph with a root node and some level 1 children
 		delete pScene->mRootNode;
 		pScene->mRootNode = new aiNode();
-		pScene->mRootNode->mName.Set("dummy_root");
+		pScene->mRootNode->mName.Set("<dummy_root>");
 
 		if (1 == pScene->mNumMeshes && !pScene->mNumLights && !pScene->mNumCameras)
 		{

+ 10 - 3
code/XFileExporter.cpp

@@ -307,7 +307,7 @@ void XFileExporter::WriteNode( aiNode* pNode)
 		ss << "Node_" << pNode;
 		pNode->mName.Set(ss.str());
 	}
-	mOutput << startstr << "Frame " << pNode->mName.C_Str() << " {" << endstr;
+	mOutput << startstr << "Frame " << toXFileString(pNode->mName) << " {" << endstr;
 
 	PushTag();
 
@@ -327,9 +327,9 @@ void XFileExporter::WriteNode( aiNode* pNode)
 	mOutput << startstr << "}" << endstr << endstr;
 }
 
-void XFileExporter::WriteMesh(const aiMesh* mesh)
+void XFileExporter::WriteMesh(aiMesh* mesh)
 {
-	mOutput << startstr << "Mesh " << mesh->mName.C_Str() << "_mShape" << " {" << endstr;
+	mOutput << startstr << "Mesh " << toXFileString(mesh->mName) << "_mShape" << " {" << endstr;
 
 	PushTag();
 
@@ -505,6 +505,13 @@ void XFileExporter::WriteMesh(const aiMesh* mesh)
 
 }
 
+std::string XFileExporter::toXFileString(aiString &name)
+{
+	std::string str = std::string(name.C_Str());
+	std::replace(str.begin(), str.end(), '<', '_');
+	std::replace(str.begin(), str.end(), '>', '_');
+	return str;
+}
 
 void XFileExporter::writePath(aiString path)
 {

+ 4 - 1
code/XFileExporter.h

@@ -80,7 +80,7 @@ protected:
 	void WriteNode( aiNode* pNode );
 
 	/// write a mesh entry of the scene
-	void WriteMesh(const aiMesh* mesh);
+	void WriteMesh( aiMesh* mesh);
 
 	/// Enters a new xml element, which increases the indentation
 	void PushTag() { startstr.append( "  "); }
@@ -94,6 +94,9 @@ public:
 
 protected:
 
+	/// normalize the name to be accepted by xfile readers
+	std::string toXFileString(aiString &name);
+
 	/// hold the properties pointer
 	const ExportProperties* mProperties;