From c4021fbaafff951fab9258e6bf834ba77a565839 Mon Sep 17 00:00:00 2001 From: Madrich Date: Mon, 9 Jun 2014 15:17:45 +0200 Subject: [PATCH] Fix Collada export validated by Schema --- code/AssimpPCH.cpp | 2 +- code/ColladaExporter.cpp | 24 ++++++++++++++++-------- code/ColladaExporter.h | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/code/AssimpPCH.cpp b/code/AssimpPCH.cpp index 2d74e3b00..2ee9e4b95 100644 --- a/code/AssimpPCH.cpp +++ b/code/AssimpPCH.cpp @@ -89,7 +89,7 @@ ASSIMP_API aiScene::aiScene() , mCameras(NULL) , mPrivate(new Assimp::ScenePrivateData()) , author("Assimp") - , authoringTool("Assimp Importer/Exporter") + , authoringTool("Assimp Importer-Exporter") { } diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index f753124e3..da208c27b 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -124,7 +124,7 @@ ColladaExporter::~ColladaExporter() void ColladaExporter::WriteFile() { // write the DTD - mOutput << "" << endstr; + mOutput << "" << endstr; // COLLADA element start mOutput << "" << endstr; PushTag(); @@ -646,7 +646,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) // lines if (countLines) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; mOutput << startstr << "

"; @@ -662,13 +662,13 @@ void ColladaExporter::WriteGeometry( size_t pIndex) mOutput << startstr << "" << endstr; } - // triangles + // triangles, note for collada, triangles are defined in a right hand system if (countTriangles) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; mOutput << startstr << "

"; for( size_t a = 0; a < mesh->mNumFaces; ++a ) { @@ -694,7 +694,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) // polygons if (countPoly) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; @@ -838,8 +838,16 @@ void ColladaExporter::WriteSceneLibrary() // ------------------------------------------------------------------------------------------------ // Recursively writes the given node -void ColladaExporter::WriteNode( const aiNode* pNode) +void ColladaExporter::WriteNode(aiNode* pNode) { + // the must have a name + if (pNode->mName.length == 0) + { + std::stringstream ss; + ss << "Node_" << pNode; + pNode->mName.Set(ss.str()); + } + mOutput << startstr << "mName.data << "\" name=\"" << pNode->mName.data << "\">" << endstr; PushTag(); @@ -867,7 +875,7 @@ void ColladaExporter::WriteNode( const aiNode* pNode) PushTag(); mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "mMaterialIndex].name << "\" />" << endstr; + mOutput << startstr << "mMaterialIndex].name << "\" />" << endstr; PopTag(); mOutput << startstr << "" << endstr; PopTag(); diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h index f96671c40..47b8405e0 100644 --- a/code/ColladaExporter.h +++ b/code/ColladaExporter.h @@ -92,7 +92,7 @@ protected: void WriteSceneLibrary(); /// Recursively writes the given node - void WriteNode( const aiNode* pNode); + void WriteNode( aiNode* pNode); /// Enters a new xml element, which increases the indentation void PushTag() { startstr.append( " "); }