From b2f615915eca8530bc6e28459d5f5303d65113c3 Mon Sep 17 00:00:00 2001 From: Johxz Date: Sat, 26 Nov 2016 14:13:54 -0600 Subject: [PATCH 1/4] remove old colladamax format, fixed up bad coordinates, added new collada format, valid against the COLLADA 1.4.1 schema, added to load textures and UVs. --- Engine/source/app/version.h | 2 +- Engine/source/ts/collada/colladaUtils.cpp | 270 ++++++++++++++-------- 2 files changed, 177 insertions(+), 95 deletions(-) diff --git a/Engine/source/app/version.h b/Engine/source/app/version.h index 4a03f5ddc8..a530a7026d 100644 --- a/Engine/source/app/version.h +++ b/Engine/source/app/version.h @@ -44,7 +44,7 @@ #define TORQUE_GAME_ENGINE 3630 /// Human readable engine version string. -#define TORQUE_GAME_ENGINE_VERSION_STRING "3.6.3" +#define TORQUE_GAME_ENGINE_VERSION_STRING "3.10.0" /// Gets the engine version number. The version number is specified as a global in version.cc U32 getVersionNumber(); diff --git a/Engine/source/ts/collada/colladaUtils.cpp b/Engine/source/ts/collada/colladaUtils.cpp index 0c409fc95a..0029534daf 100644 --- a/Engine/source/ts/collada/colladaUtils.cpp +++ b/Engine/source/ts/collada/colladaUtils.cpp @@ -943,14 +943,16 @@ void ColladaUtils::exportColladaHeader(TiXmlElement* rootNode) TiXmlElement* authorNode = new TiXmlElement("author"); contributorNode->LinkEndChild(authorNode); + TiXmlText* authorNodeText = new TiXmlText("Torque3D User"); + authorNode->LinkEndChild(authorNodeText); TiXmlElement* authoringToolNode = new TiXmlElement("authoring_tool"); contributorNode->LinkEndChild(authoringToolNode); TiXmlText* authorText = new TiXmlText(avar("%s %s Object Exporter", getEngineProductString(), getVersionString())); authoringToolNode->LinkEndChild(authorText); - TiXmlElement* commentsNode = new TiXmlElement("comments"); - contributorNode->LinkEndChild(commentsNode); + //TiXmlElement* commentsNode = new TiXmlElement("comments"); + //contributorNode->LinkEndChild(commentsNode); // Get the current time Platform::LocalTime lt; @@ -969,22 +971,23 @@ void ColladaUtils::exportColladaHeader(TiXmlElement* rootNode) TiXmlText* modifiedText = new TiXmlText(avar("%s", localTime.c_str())); modifiedNode->LinkEndChild(modifiedText); - TiXmlElement* revisionNode = new TiXmlElement("revision"); - assetNode->LinkEndChild(revisionNode); + //TiXmlElement* revisionNode = new TiXmlElement("revision"); + //assetNode->LinkEndChild(revisionNode); - TiXmlElement* titleNode = new TiXmlElement("title"); - assetNode->LinkEndChild(titleNode); + //TiXmlElement* titleNode = new TiXmlElement("title"); + //assetNode->LinkEndChild(titleNode); - TiXmlElement* subjectNode = new TiXmlElement("subject"); - assetNode->LinkEndChild(subjectNode); + //TiXmlElement* subjectNode = new TiXmlElement("subject"); + //assetNode->LinkEndChild(subjectNode); - TiXmlElement* keywordsNode = new TiXmlElement("keywords"); - assetNode->LinkEndChild(keywordsNode); + //TiXmlElement* keywordsNode = new TiXmlElement("keywords"); + //assetNode->LinkEndChild(keywordsNode); // Torque uses Z_UP with 1 unit equal to 1 meter by default TiXmlElement* unitNode = new TiXmlElement("unit"); assetNode->LinkEndChild(unitNode); - unitNode->SetAttribute("meter", "1.000000"); + unitNode->SetAttribute("name", "meter"); + unitNode->SetAttribute("meter", "1"); TiXmlElement* axisNode = new TiXmlElement("up_axis"); assetNode->LinkEndChild(axisNode); @@ -1042,35 +1045,14 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize TiXmlElement* imageNode = new TiXmlElement("image"); imgLibNode->LinkEndChild(imageNode); - imageNode->SetAttribute("id", avar("%s-Diffuse", matNames.last().c_str())); - imageNode->SetAttribute("name", avar("%s-Diffuse", matNames.last().c_str())); + imageNode->SetAttribute("id", avar("%s", matNames.last().c_str())); + imageNode->SetAttribute("name", avar("%s", matNames.last().c_str())); TiXmlElement* initNode = new TiXmlElement("init_from"); imageNode->LinkEndChild(initNode); - TiXmlText* initText = new TiXmlText(avar("file://%s", diffuseMap.c_str())); + TiXmlText* initText = new TiXmlText(avar("%s", diffuseMap.c_str())); // need the extension to load the texture initNode->LinkEndChild(initText); - } - - // Next the material library - TiXmlElement* matLibNode = new TiXmlElement("library_materials"); - rootNode->LinkEndChild(matLibNode); - - for (U32 i = 0; i < mesh.mMaterialList.size(); i++) - { - BaseMatInstance* baseInst = mesh.mMaterialList[i]; - Material* mat = dynamic_cast(baseInst->getMaterial()); - if (!mat) - continue; - - TiXmlElement* materialNode = new TiXmlElement("material"); - matLibNode->LinkEndChild(materialNode); - materialNode->SetAttribute("id", matNames[i].c_str()); - materialNode->SetAttribute("name", matNames[i].c_str()); - - TiXmlElement* instEffectNode = new TiXmlElement("instance_effect"); - materialNode->LinkEndChild(instEffectNode); - instEffectNode->SetAttribute("url", avar("#%s-fx", matNames[i].c_str())); } // Finally the effects library @@ -1087,55 +1069,145 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize TiXmlElement* effectNode = new TiXmlElement("effect"); effectLibNode->LinkEndChild(effectNode); - effectNode->SetAttribute("id", avar("%s-fx", matNames[i].c_str())); - effectNode->SetAttribute("name", avar("%s-fx", matNames[i].c_str())); + effectNode->SetAttribute("id", avar("%s-effect", matNames[i].c_str())); + effectNode->SetAttribute("name", avar("%s-effect", matNames[i].c_str())); TiXmlElement* profileNode = new TiXmlElement("profile_COMMON"); effectNode->LinkEndChild(profileNode); + + // --------------------------- + TiXmlElement* newParamNode = new TiXmlElement("newparam"); + profileNode->LinkEndChild(newParamNode); + newParamNode->SetAttribute("sid", avar("%s-surface", matNames[i].c_str())); + + TiXmlElement* surfaceNode = new TiXmlElement("surface"); + newParamNode->LinkEndChild(surfaceNode); + surfaceNode->SetAttribute("type", "2D"); + + TiXmlElement* initNode2 = new TiXmlElement("init_from"); + surfaceNode->LinkEndChild(initNode2); + TiXmlText* init2Text = new TiXmlText(avar("%s", matNames[i].c_str())); + initNode2->LinkEndChild(init2Text); + + // --------------------------- + TiXmlElement* newParam2Node = new TiXmlElement("newparam"); + profileNode->LinkEndChild(newParam2Node); + newParam2Node->SetAttribute("sid", avar("%s-sampler", matNames[i].c_str())); + + TiXmlElement* sampler2DNode = new TiXmlElement("sampler2D"); + newParam2Node->LinkEndChild(sampler2DNode); + + TiXmlElement* sourceSampler2DNode = new TiXmlElement("source"); + sampler2DNode->LinkEndChild(sourceSampler2DNode); + TiXmlText* sourceSampler2DText = new TiXmlText(avar("%s-surface", matNames[i].c_str())); + sourceSampler2DNode->LinkEndChild(sourceSampler2DText); + + // --------------------------- TiXmlElement* techniqueNode = new TiXmlElement("technique"); profileNode->LinkEndChild(techniqueNode); - techniqueNode->SetAttribute("sid", "standard"); + techniqueNode->SetAttribute("sid", "common"); TiXmlElement* phongNode = new TiXmlElement("phong"); techniqueNode->LinkEndChild(phongNode); - - TiXmlElement* diffuseNode = new TiXmlElement("diffuse"); + + // --------------------------- + TiXmlElement* emissionNode = new TiXmlElement("emission"); + phongNode->LinkEndChild(emissionNode); + + TiXmlElement* colorEmissionNode = new TiXmlElement("color"); + emissionNode->LinkEndChild(colorEmissionNode); + colorEmissionNode->SetAttribute("sid", "emission"); + + TiXmlText* colorEmissionNodeText = new TiXmlText("0 0 0 1"); + colorEmissionNode->LinkEndChild(colorEmissionNodeText); + + // --------------------------- + TiXmlElement* ambientNode = new TiXmlElement("ambient"); + phongNode->LinkEndChild(ambientNode); + + TiXmlElement* colorAmbientNode = new TiXmlElement("color"); + ambientNode->LinkEndChild(colorAmbientNode); + colorAmbientNode->SetAttribute("sid", "ambient"); + + TiXmlText* colorAmbientNodeText = new TiXmlText("0 0 0 1"); + colorAmbientNode->LinkEndChild(colorAmbientNodeText); + + // --------------------------- + TiXmlElement* diffuseNode = new TiXmlElement("diffuse"); + phongNode->LinkEndChild(diffuseNode); + TiXmlElement* textureDiffuseNode = new TiXmlElement("texture"); + diffuseNode->LinkEndChild(textureDiffuseNode); + textureDiffuseNode->SetAttribute("texture", avar("%s-sampler", matNames[i].c_str())); + textureDiffuseNode->SetAttribute("texcoord", "UVMap"); + + // --------------------------- + /*TiXmlElement* diffuseNode = new TiXmlElement("diffuse"); phongNode->LinkEndChild(diffuseNode); - TiXmlElement* textureNode = new TiXmlElement("texture"); - diffuseNode->LinkEndChild(textureNode); - textureNode->SetAttribute("texture", avar("%s-Diffuse", matNames[i].c_str())); - textureNode->SetAttribute("texcoord", "CHANNEL0"); - - // Extra info useful for getting the texture to show up correctly in some apps - TiXmlElement* extraNode = new TiXmlElement("extra"); - textureNode->LinkEndChild(extraNode); - - TiXmlElement* extraTechNode = new TiXmlElement("technique"); - extraNode->LinkEndChild(extraTechNode); - extraTechNode->SetAttribute("profile", "MAYA"); - - TiXmlElement* extraWrapUNode = new TiXmlElement("wrapU"); - extraTechNode->LinkEndChild(extraWrapUNode); - extraWrapUNode->SetAttribute("sid", "wrapU0"); + TiXmlElement* colorDiffuseNode = new TiXmlElement("color"); + diffuseNode->LinkEndChild(colorDiffuseNode); + colorDiffuseNode->SetAttribute("sid", "diffuse"); + + TiXmlText* colorDiffuseNodeText = new TiXmlText("0.64 0.64 0.64 1"); + colorDiffuseNode->LinkEndChild(colorDiffuseNodeText);*/ + + // --------------------------- + TiXmlElement* specularNode = new TiXmlElement("specular"); + phongNode->LinkEndChild(specularNode); + + TiXmlElement* colorSpecularNode = new TiXmlElement("color"); + specularNode->LinkEndChild(colorSpecularNode); + colorSpecularNode->SetAttribute("sid", "specular"); + + TiXmlText* colorSpecularNodeText = new TiXmlText("0.5 0.5 0.5 1"); + colorSpecularNode->LinkEndChild(colorSpecularNodeText); + + // --------------------------- + TiXmlElement* shininessNode = new TiXmlElement("shininess"); + phongNode->LinkEndChild(shininessNode); + + TiXmlElement* colorShininessNode = new TiXmlElement("float"); + shininessNode->LinkEndChild(colorShininessNode); + colorShininessNode->SetAttribute("sid", "shininess"); + + TiXmlText* colorShininessNodeText = new TiXmlText("50"); + colorShininessNode->LinkEndChild(colorShininessNodeText); + + // --------------------------- + TiXmlElement* refractionNode = new TiXmlElement("index_of_refraction"); + phongNode->LinkEndChild(refractionNode); + + TiXmlElement* colorRefractionNode = new TiXmlElement("float"); + refractionNode->LinkEndChild(colorRefractionNode); + colorRefractionNode->SetAttribute("sid", "index_of_refraction"); + + TiXmlText* colorRefractionNodeText = new TiXmlText("1"); + colorRefractionNode->LinkEndChild(colorRefractionNodeText); + } - TiXmlText* extraWrapUText = new TiXmlText("TRUE"); - extraWrapUNode->LinkEndChild(extraWrapUText); + // Next the material library + TiXmlElement* matLibNode = new TiXmlElement("library_materials"); + rootNode->LinkEndChild(matLibNode); - TiXmlElement* extraWrapVNode = new TiXmlElement("wrapV"); - extraTechNode->LinkEndChild(extraWrapVNode); - extraWrapVNode->SetAttribute("sid", "wrapV0"); + for (U32 i = 0; i < mesh.mMaterialList.size(); i++) + { + BaseMatInstance* baseInst = mesh.mMaterialList[i]; - TiXmlText* extraWrapVText = new TiXmlText("TRUE"); - extraWrapVNode->LinkEndChild(extraWrapVText); + Material* mat = dynamic_cast(baseInst->getMaterial()); + if (!mat) + continue; - TiXmlElement* extraBlendNode = new TiXmlElement("blend_mode"); - extraTechNode->LinkEndChild(extraBlendNode); + TiXmlElement* materialNode = new TiXmlElement("material"); + matLibNode->LinkEndChild(materialNode); + materialNode->SetAttribute("id", matNames[i].c_str()); + materialNode->SetAttribute("name", matNames[i].c_str()); - TiXmlText* extraBlendText = new TiXmlText("ADD"); - extraBlendNode->LinkEndChild(extraBlendText); - } + TiXmlElement* instEffectNode = new TiXmlElement("instance_effect"); + materialNode->LinkEndChild(instEffectNode); + instEffectNode->SetAttribute("url", avar("#%s-effect", matNames[i].c_str())); + } + } void ColladaUtils::exportColladaTriangles(TiXmlElement* meshNode, const OptimizedPolyList& mesh, const String& meshName, const Vector& matNames) @@ -1178,21 +1250,21 @@ void ColladaUtils::exportColladaTriangles(TiXmlElement* meshNode, const Optimize TiXmlElement* trianglesVertInputNode = new TiXmlElement("input"); trianglesNode->LinkEndChild(trianglesVertInputNode); trianglesVertInputNode->SetAttribute("semantic", "VERTEX"); + trianglesVertInputNode->SetAttribute("source", avar("#%s-mesh-vertices", meshName.c_str())); trianglesVertInputNode->SetAttribute("offset", "0"); - trianglesVertInputNode->SetAttribute("source", avar("#%s-Vertex", meshName.c_str())); TiXmlElement* trianglesNormalInputNode = new TiXmlElement("input"); trianglesNode->LinkEndChild(trianglesNormalInputNode); trianglesNormalInputNode->SetAttribute("semantic", "NORMAL"); + trianglesNormalInputNode->SetAttribute("source", avar("#%s-mesh-normals", meshName.c_str())); trianglesNormalInputNode->SetAttribute("offset", "1"); - trianglesNormalInputNode->SetAttribute("source", avar("#%s-Normal", meshName.c_str())); TiXmlElement* trianglesUV0InputNode = new TiXmlElement("input"); trianglesNode->LinkEndChild(trianglesUV0InputNode); trianglesUV0InputNode->SetAttribute("semantic", "TEXCOORD"); + trianglesUV0InputNode->SetAttribute("source", avar("#%s-mesh-map-0", meshName.c_str())); trianglesUV0InputNode->SetAttribute("offset", "2"); trianglesUV0InputNode->SetAttribute("set", "0"); - trianglesUV0InputNode->SetAttribute("source", avar("#%s-UV0", meshName.c_str())); TiXmlElement* polyNode = new TiXmlElement("p"); trianglesNode->LinkEndChild(polyNode); @@ -1245,7 +1317,7 @@ void ColladaUtils::exportColladaTriangles(TiXmlElement* meshNode, const Optimize const OptimizedPolyList::VertIndex& thirdVertIdx = mesh.mVertexList[thirdIdx]; // Note the reversed winding on the triangles - const char* tri = avar("%d %d %d %d %d %d %d %d %d", + const char* tri = avar("%d %d %d %d %d %d %d %d %d ", thirdVertIdx.vertIdx, thirdVertIdx.normalIdx, thirdVertIdx.uv0Idx, secondVertIdx.vertIdx, secondVertIdx.normalIdx, secondVertIdx.uv0Idx, firstVertIdx.vertIdx, firstVertIdx.normalIdx, firstVertIdx.uv0Idx); @@ -1264,8 +1336,8 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly TiXmlElement* geometryNode = new TiXmlElement("geometry"); libGeomsNode->LinkEndChild(geometryNode); - geometryNode->SetAttribute("id", avar("%s-lib", meshName.c_str())); - geometryNode->SetAttribute("name", avar("%sMesh", meshName.c_str())); + geometryNode->SetAttribute("id", avar("%s-mesh", meshName.c_str())); + geometryNode->SetAttribute("name", avar("%s", meshName.c_str())); TiXmlElement* meshNode = new TiXmlElement("mesh"); geometryNode->LinkEndChild(meshNode); @@ -1273,18 +1345,18 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly // Save out the vertices TiXmlElement* vertsSourceNode = new TiXmlElement("source"); meshNode->LinkEndChild(vertsSourceNode); - vertsSourceNode->SetAttribute("id", avar("%s-Position", meshName.c_str())); + vertsSourceNode->SetAttribute("id", avar("%s-mesh-positions", meshName.c_str())); TiXmlElement* vertsNode = new TiXmlElement("float_array"); vertsSourceNode->LinkEndChild(vertsNode); - vertsNode->SetAttribute("id", avar("%s-Position-array", meshName.c_str())); + vertsNode->SetAttribute("id", avar("%s-mesh-positions-array", meshName.c_str())); vertsNode->SetAttribute("count", avar("%d", mesh.mPoints.size() * 3)); for (U32 i = 0; i < mesh.mPoints.size(); i++) { const Point3F& vert = mesh.mPoints[i]; - TiXmlText* vertText = new TiXmlText(avar("%.4f %.4f %.4f", vert.x, vert.y, vert.z)); + TiXmlText* vertText = new TiXmlText(avar("%.4f %.4f %.4f ", vert.x, vert.y, vert.z)); vertsNode->LinkEndChild(vertText); } @@ -1294,7 +1366,7 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly TiXmlElement* vertsAccNode = new TiXmlElement("accessor"); vertsTechNode->LinkEndChild(vertsAccNode); - vertsAccNode->SetAttribute("source", avar("#%s-Position-array", meshName.c_str())); + vertsAccNode->SetAttribute("source", avar("#%s-mesh-positions-array", meshName.c_str())); vertsAccNode->SetAttribute("count", avar("%d", mesh.mPoints.size())); vertsAccNode->SetAttribute("stride", "3"); @@ -1316,18 +1388,18 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly // Save out the normals TiXmlElement* normalsSourceNode = new TiXmlElement("source"); meshNode->LinkEndChild(normalsSourceNode); - normalsSourceNode->SetAttribute("id", avar("%s-Normal", meshName.c_str())); + normalsSourceNode->SetAttribute("id", avar("%s-mesh-normals", meshName.c_str())); TiXmlElement* normalsNode = new TiXmlElement("float_array"); normalsSourceNode->LinkEndChild(normalsNode); - normalsNode->SetAttribute("id", avar("%s-Normal-array", meshName.c_str())); + normalsNode->SetAttribute("id", avar("%s-mesh-normals-array", meshName.c_str())); normalsNode->SetAttribute("count", avar("%d", mesh.mNormals.size() * 3)); for (U32 i = 0; i < mesh.mNormals.size(); i++) { const Point3F& normal = mesh.mNormals[i]; - TiXmlText* normalText = new TiXmlText(avar("%.4f %.4f %.4f", normal.x, normal.y, normal.z)); + TiXmlText* normalText = new TiXmlText(avar("%.4f %.4f %.4f ", normal.x, normal.y, normal.z)); normalsNode->LinkEndChild(normalText); } @@ -1337,7 +1409,7 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly TiXmlElement* normalsAccNode = new TiXmlElement("accessor"); normalsTechNode->LinkEndChild(normalsAccNode); - normalsAccNode->SetAttribute("source", avar("#%s-Normal-array", meshName.c_str())); + normalsAccNode->SetAttribute("source", avar("#%s-mesh-normals-array", meshName.c_str())); normalsAccNode->SetAttribute("count", avar("%d", mesh.mNormals.size())); normalsAccNode->SetAttribute("stride", "3"); @@ -1359,18 +1431,18 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly // Save out the uvs TiXmlElement* uv0SourceNode = new TiXmlElement("source"); meshNode->LinkEndChild(uv0SourceNode); - uv0SourceNode->SetAttribute("id", avar("%s-UV0", meshName.c_str())); + uv0SourceNode->SetAttribute("id", avar("%s-mesh-map-0", meshName.c_str())); TiXmlElement* uv0Node = new TiXmlElement("float_array"); uv0SourceNode->LinkEndChild(uv0Node); - uv0Node->SetAttribute("id", avar("%s-UV0-array", meshName.c_str())); + uv0Node->SetAttribute("id", avar("%s-mesh-map-0-array", meshName.c_str())); uv0Node->SetAttribute("count", avar("%d", mesh.mUV0s.size() * 2)); for (U32 i = 0; i < mesh.mUV0s.size(); i++) { const Point2F& uv0 = mesh.mUV0s[i]; - TiXmlText* uv0Text = new TiXmlText(avar("%.4f %.4f", uv0.x, 1.0f - uv0.y)); // COLLADA uvs are upside down compared to Torque + TiXmlText* uv0Text = new TiXmlText(avar("%.4f %.4f ", uv0.x, 1.0f - uv0.y)); // COLLADA uvs are upside down compared to Torque uv0Node->LinkEndChild(uv0Text); } @@ -1380,7 +1452,7 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly TiXmlElement* uv0AccNode = new TiXmlElement("accessor"); uv0TechNode->LinkEndChild(uv0AccNode); - uv0AccNode->SetAttribute("source", avar("#%s-UV0-array", meshName.c_str())); + uv0AccNode->SetAttribute("source", avar("#%s-mesh-map-0-array", meshName.c_str())); uv0AccNode->SetAttribute("count", avar("%d", mesh.mUV0s.size())); uv0AccNode->SetAttribute("stride", "2"); @@ -1397,12 +1469,12 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly // Define the vertices position array TiXmlElement* verticesNode = new TiXmlElement("vertices"); meshNode->LinkEndChild(verticesNode); - verticesNode->SetAttribute("id", avar("%s-Vertex", meshName.c_str())); + verticesNode->SetAttribute("id", avar("%s-mesh-vertices", meshName.c_str())); TiXmlElement* verticesInputNode = new TiXmlElement("input"); verticesNode->LinkEndChild(verticesInputNode); verticesInputNode->SetAttribute("semantic", "POSITION"); - verticesInputNode->SetAttribute("source", avar("#%s-Position", meshName.c_str())); + verticesInputNode->SetAttribute("source", avar("#%s-mesh-positions", meshName.c_str())); exportColladaTriangles(meshNode, mesh, meshName, matNames); } @@ -1421,11 +1493,13 @@ void ColladaUtils::exportColladaScene(TiXmlElement* rootNode, const String& mesh visSceneNode->LinkEndChild(nodeNode); nodeNode->SetAttribute("id", avar("%s", meshName.c_str())); nodeNode->SetAttribute("name", avar("%s", meshName.c_str())); - + nodeNode->SetAttribute("type", "NODE"); + TiXmlElement* instanceGeomNode = new TiXmlElement("instance_geometry"); nodeNode->LinkEndChild(instanceGeomNode); - instanceGeomNode->SetAttribute("url", avar("#%s-lib", meshName.c_str())); - + instanceGeomNode->SetAttribute("url", avar("#%s-mesh", meshName.c_str())); + instanceGeomNode->SetAttribute("name", avar("%s", meshName.c_str())); + TiXmlElement* bindMatNode = new TiXmlElement("bind_material"); instanceGeomNode->LinkEndChild(bindMatNode); @@ -1439,8 +1513,16 @@ void ColladaUtils::exportColladaScene(TiXmlElement* rootNode, const String& mesh techniqueNode->LinkEndChild(instMatNode); instMatNode->SetAttribute("symbol", avar("%s", matNames[i].c_str())); instMatNode->SetAttribute("target", avar("#%s", matNames[i].c_str())); - } - + TiXmlElement* bindVertexNode = new TiXmlElement("bind_vertex_input"); + instMatNode->LinkEndChild(bindVertexNode); + //bindVertexNode->SetAttribute("semantic", avar("%s-mesh-map-0", meshName.c_str())); + bindVertexNode->SetAttribute("semantic", "UVMap"); + bindVertexNode->SetAttribute("input_semantic", "TEXCOORD"); + bindVertexNode->SetAttribute("input_set", "0"); + } + + + TiXmlElement* sceneNode = new TiXmlElement("scene"); rootNode->LinkEndChild(sceneNode); @@ -1467,7 +1549,7 @@ void ColladaUtils::exportToCollada(const Torque::Path& colladaFile, const Optimi // Create our Collada root node and populate a couple standard attributes TiXmlElement* rootNode = new TiXmlElement("COLLADA"); rootNode->SetAttribute("xmlns", "http://www.collada.org/2005/11/COLLADASchema"); - rootNode->SetAttribute("version", "1.4.0"); + rootNode->SetAttribute("version", "1.4.1"); // Add the root node to the document doc.LinkEndChild(rootNode); From 6cc1c27fd2ab2760e2747c2c67e0e0632c45e1d7 Mon Sep 17 00:00:00 2001 From: Johxz Date: Tue, 29 Nov 2016 19:49:41 -0600 Subject: [PATCH 2/4] missing to load the texture --- Engine/source/ts/collada/colladaUtils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Engine/source/ts/collada/colladaUtils.cpp b/Engine/source/ts/collada/colladaUtils.cpp index 0029534daf..87cd07b591 100644 --- a/Engine/source/ts/collada/colladaUtils.cpp +++ b/Engine/source/ts/collada/colladaUtils.cpp @@ -1050,12 +1050,12 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize TiXmlElement* initNode = new TiXmlElement("init_from"); imageNode->LinkEndChild(initNode); - TiXmlText* initText = new TiXmlText(avar("%s", diffuseMap.c_str())); // need the extension to load the texture + TiXmlText* initText = new TiXmlText(avar("file://%s", diffuseMap.c_str())); // need the extension to load the texture initNode->LinkEndChild(initText); } - // Finally the effects library + // Next the effects library TiXmlElement* effectLibNode = new TiXmlElement("library_effects"); rootNode->LinkEndChild(effectLibNode); @@ -1186,7 +1186,7 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize colorRefractionNode->LinkEndChild(colorRefractionNodeText); } - // Next the material library + // Finally the material library TiXmlElement* matLibNode = new TiXmlElement("library_materials"); rootNode->LinkEndChild(matLibNode); From c43de8881f7e54f831e4f8be2bc00d203b3eb86d Mon Sep 17 00:00:00 2001 From: Johxz Date: Sat, 3 Dec 2016 16:59:17 -0600 Subject: [PATCH 3/4] added materials, better compatibility with maya and 3ds max, better collada spec for compliance --- Engine/source/app/version.h | 2 +- Engine/source/ts/collada/colladaUtils.cpp | 193 ++++++++++++++++++---- 2 files changed, 164 insertions(+), 31 deletions(-) diff --git a/Engine/source/app/version.h b/Engine/source/app/version.h index a530a7026d..2b7e6b7496 100644 --- a/Engine/source/app/version.h +++ b/Engine/source/app/version.h @@ -41,7 +41,7 @@ /// code version, the game name, and which type of game it is (TGB, TGE, TGEA, etc.). /// /// Version number is major * 1000 + minor * 100 + revision * 10. -#define TORQUE_GAME_ENGINE 3630 +#define TORQUE_GAME_ENGINE 3900 /// Human readable engine version string. #define TORQUE_GAME_ENGINE_VERSION_STRING "3.10.0" diff --git a/Engine/source/ts/collada/colladaUtils.cpp b/Engine/source/ts/collada/colladaUtils.cpp index 87cd07b591..7eb9374a40 100644 --- a/Engine/source/ts/collada/colladaUtils.cpp +++ b/Engine/source/ts/collada/colladaUtils.cpp @@ -943,7 +943,7 @@ void ColladaUtils::exportColladaHeader(TiXmlElement* rootNode) TiXmlElement* authorNode = new TiXmlElement("author"); contributorNode->LinkEndChild(authorNode); - TiXmlText* authorNodeText = new TiXmlText("Torque3D User"); + TiXmlText* authorNodeText = new TiXmlText("Torque3D MIT User"); authorNode->LinkEndChild(authorNodeText); TiXmlElement* authoringToolNode = new TiXmlElement("authoring_tool"); @@ -1050,7 +1050,7 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize TiXmlElement* initNode = new TiXmlElement("init_from"); imageNode->LinkEndChild(initNode); - TiXmlText* initText = new TiXmlText(avar("file://%s", diffuseMap.c_str())); // need the extension to load the texture + TiXmlText* initText = new TiXmlText(avar("file://%s", diffuseMap.c_str())); // "the file://" is needed to load the texture in some old apps (ex: 3ds Max 2009) initNode->LinkEndChild(initText); } @@ -1087,7 +1087,12 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize TiXmlElement* initNode2 = new TiXmlElement("init_from"); surfaceNode->LinkEndChild(initNode2); TiXmlText* init2Text = new TiXmlText(avar("%s", matNames[i].c_str())); - initNode2->LinkEndChild(init2Text); + initNode2->LinkEndChild(init2Text); + + TiXmlElement* formatNode = new TiXmlElement("format"); + surfaceNode->LinkEndChild(formatNode); + TiXmlText* formatText = new TiXmlText("A8R8G8B8"); + formatNode->LinkEndChild(formatText); // --------------------------- TiXmlElement* newParam2Node = new TiXmlElement("newparam"); @@ -1108,75 +1113,137 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize profileNode->LinkEndChild(techniqueNode); techniqueNode->SetAttribute("sid", "common"); - TiXmlElement* phongNode = new TiXmlElement("phong"); - techniqueNode->LinkEndChild(phongNode); + TiXmlElement* blinnNode = new TiXmlElement("blinn"); + techniqueNode->LinkEndChild(blinnNode); // --------------------------- TiXmlElement* emissionNode = new TiXmlElement("emission"); - phongNode->LinkEndChild(emissionNode); + blinnNode->LinkEndChild(emissionNode); TiXmlElement* colorEmissionNode = new TiXmlElement("color"); emissionNode->LinkEndChild(colorEmissionNode); colorEmissionNode->SetAttribute("sid", "emission"); - TiXmlText* colorEmissionNodeText = new TiXmlText("0 0 0 1"); + TiXmlText* colorEmissionNodeText = new TiXmlText("0.0 0.0 0.0 1.0"); colorEmissionNode->LinkEndChild(colorEmissionNodeText); // --------------------------- TiXmlElement* ambientNode = new TiXmlElement("ambient"); - phongNode->LinkEndChild(ambientNode); + blinnNode->LinkEndChild(ambientNode); TiXmlElement* colorAmbientNode = new TiXmlElement("color"); ambientNode->LinkEndChild(colorAmbientNode); colorAmbientNode->SetAttribute("sid", "ambient"); - TiXmlText* colorAmbientNodeText = new TiXmlText("0 0 0 1"); + TiXmlText* colorAmbientNodeText = new TiXmlText("0.0 0.0 0.0 1.0"); colorAmbientNode->LinkEndChild(colorAmbientNodeText); // --------------------------- TiXmlElement* diffuseNode = new TiXmlElement("diffuse"); - phongNode->LinkEndChild(diffuseNode); + blinnNode->LinkEndChild(diffuseNode); TiXmlElement* textureDiffuseNode = new TiXmlElement("texture"); diffuseNode->LinkEndChild(textureDiffuseNode); textureDiffuseNode->SetAttribute("texture", avar("%s-sampler", matNames[i].c_str())); textureDiffuseNode->SetAttribute("texcoord", "UVMap"); - // --------------------------- - /*TiXmlElement* diffuseNode = new TiXmlElement("diffuse"); - phongNode->LinkEndChild(diffuseNode); + // Extra info useful for getting the texture to show up correctly in MAYA and 3DS Max + TiXmlElement* extraNode = new TiXmlElement("extra"); + textureDiffuseNode->LinkEndChild(extraNode); - TiXmlElement* colorDiffuseNode = new TiXmlElement("color"); - diffuseNode->LinkEndChild(colorDiffuseNode); - colorDiffuseNode->SetAttribute("sid", "diffuse"); - - TiXmlText* colorDiffuseNodeText = new TiXmlText("0.64 0.64 0.64 1"); - colorDiffuseNode->LinkEndChild(colorDiffuseNodeText);*/ + TiXmlElement* extraTechNode = new TiXmlElement("technique"); + extraNode->LinkEndChild(extraTechNode); + extraTechNode->SetAttribute("profile", "MAYA"); + + TiXmlElement* extraWrapUNode = new TiXmlElement("wrapU"); + extraTechNode->LinkEndChild(extraWrapUNode); + extraWrapUNode->SetAttribute("sid", "wrapU0"); + + TiXmlText* extraWrapUText = new TiXmlText("TRUE"); + extraWrapUNode->LinkEndChild(extraWrapUText); + + TiXmlElement* extraWrapVNode = new TiXmlElement("wrapV"); + extraTechNode->LinkEndChild(extraWrapVNode); + extraWrapVNode->SetAttribute("sid", "wrapV0"); + + TiXmlText* extraWrapVText = new TiXmlText("TRUE"); + extraWrapVNode->LinkEndChild(extraWrapVText); + + TiXmlElement* extraBlendNode = new TiXmlElement("blend_mode"); + extraTechNode->LinkEndChild(extraBlendNode); + + TiXmlText* extraBlendText = new TiXmlText("ADD"); + extraBlendNode->LinkEndChild(extraBlendText); // --------------------------- TiXmlElement* specularNode = new TiXmlElement("specular"); - phongNode->LinkEndChild(specularNode); + blinnNode->LinkEndChild(specularNode); TiXmlElement* colorSpecularNode = new TiXmlElement("color"); specularNode->LinkEndChild(colorSpecularNode); colorSpecularNode->SetAttribute("sid", "specular"); - TiXmlText* colorSpecularNodeText = new TiXmlText("0.5 0.5 0.5 1"); + TiXmlText* colorSpecularNodeText = new TiXmlText("0.5 0.5 0.5 1.0"); colorSpecularNode->LinkEndChild(colorSpecularNodeText); // --------------------------- TiXmlElement* shininessNode = new TiXmlElement("shininess"); - phongNode->LinkEndChild(shininessNode); + blinnNode->LinkEndChild(shininessNode); TiXmlElement* colorShininessNode = new TiXmlElement("float"); shininessNode->LinkEndChild(colorShininessNode); colorShininessNode->SetAttribute("sid", "shininess"); - TiXmlText* colorShininessNodeText = new TiXmlText("50"); + TiXmlText* colorShininessNodeText = new TiXmlText("1.0"); colorShininessNode->LinkEndChild(colorShininessNodeText); + + // --------------------------- + TiXmlElement* reflectiveNode = new TiXmlElement("reflective"); + blinnNode->LinkEndChild(reflectiveNode); + + TiXmlElement* colorReflectiveNode = new TiXmlElement("color"); + reflectiveNode->LinkEndChild(colorReflectiveNode); + colorReflectiveNode->SetAttribute("sid", "reflective"); + + TiXmlText* colorReflectiveNodeText = new TiXmlText("0.0 0.0 0.0 1.0"); + colorReflectiveNode->LinkEndChild(colorReflectiveNodeText); + + // --------------------------- + TiXmlElement* reflectivityNode = new TiXmlElement("reflectivity"); + blinnNode->LinkEndChild(reflectivityNode); + + TiXmlElement* floatReflectivityNode = new TiXmlElement("float"); + reflectivityNode->LinkEndChild(floatReflectivityNode); + floatReflectivityNode->SetAttribute("sid", "reflectivity"); + + TiXmlText* floatReflectivityText = new TiXmlText("0.5"); + floatReflectivityNode->LinkEndChild(floatReflectivityText); + + // --------------------------- + TiXmlElement* transparentNode = new TiXmlElement("transparent"); + blinnNode->LinkEndChild(transparentNode); + transparentNode->SetAttribute("opaque", "RGB_ZERO"); + + TiXmlElement* colorTransparentNode = new TiXmlElement("color"); + transparentNode->LinkEndChild(colorTransparentNode); + colorTransparentNode->SetAttribute("sid", "transparent"); + + TiXmlText* colorTransparentNodeText = new TiXmlText("0.0 0.0 0.0 1.0"); + colorTransparentNode->LinkEndChild(colorTransparentNodeText); + + // --------------------------- + TiXmlElement* transparencyNode = new TiXmlElement("transparency"); + blinnNode->LinkEndChild(transparencyNode); + + TiXmlElement* floatTransparencyNode = new TiXmlElement("float"); + transparencyNode->LinkEndChild(floatTransparencyNode); + floatTransparencyNode->SetAttribute("sid", "transparency"); + + TiXmlText* floatTransparencyText = new TiXmlText("0.0"); + floatTransparencyNode->LinkEndChild(floatTransparencyText); // --------------------------- TiXmlElement* refractionNode = new TiXmlElement("index_of_refraction"); - phongNode->LinkEndChild(refractionNode); + blinnNode->LinkEndChild(refractionNode); TiXmlElement* colorRefractionNode = new TiXmlElement("float"); refractionNode->LinkEndChild(colorRefractionNode); @@ -1200,7 +1267,7 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize TiXmlElement* materialNode = new TiXmlElement("material"); matLibNode->LinkEndChild(materialNode); - materialNode->SetAttribute("id", matNames[i].c_str()); + materialNode->SetAttribute("id", avar("%s-material", matNames[i].c_str())); materialNode->SetAttribute("name", matNames[i].c_str()); TiXmlElement* instEffectNode = new TiXmlElement("instance_effect"); @@ -1244,7 +1311,7 @@ void ColladaUtils::exportColladaTriangles(TiXmlElement* meshNode, const Optimize TiXmlElement* trianglesNode = new TiXmlElement("triangles"); meshNode->LinkEndChild(trianglesNode); - trianglesNode->SetAttribute("material", ( i > -1 ) ? matNames[i].c_str() : "" ); + trianglesNode->SetAttribute("material", ( i > -1 ) ? avar("%s-material", matNames[i].c_str()) : "" ); trianglesNode->SetAttribute("count", avar("%d", triangleCount)); TiXmlElement* trianglesVertInputNode = new TiXmlElement("input"); @@ -1511,8 +1578,8 @@ void ColladaUtils::exportColladaScene(TiXmlElement* rootNode, const String& mesh { TiXmlElement* instMatNode = new TiXmlElement("instance_material"); techniqueNode->LinkEndChild(instMatNode); - instMatNode->SetAttribute("symbol", avar("%s", matNames[i].c_str())); - instMatNode->SetAttribute("target", avar("#%s", matNames[i].c_str())); + instMatNode->SetAttribute("symbol", avar("%s-material", matNames[i].c_str())); + instMatNode->SetAttribute("target", avar("#%s-material", matNames[i].c_str())); TiXmlElement* bindVertexNode = new TiXmlElement("bind_vertex_input"); instMatNode->LinkEndChild(bindVertexNode); //bindVertexNode->SetAttribute("semantic", avar("%s-mesh-map-0", meshName.c_str())); @@ -1521,8 +1588,73 @@ void ColladaUtils::exportColladaScene(TiXmlElement* rootNode, const String& mesh bindVertexNode->SetAttribute("input_set", "0"); } - - + // Extra info useful for COLLADAMax importer (OpenCOLLADA) + TiXmlElement* extraInsGeoNode = new TiXmlElement("extra"); + nodeNode->LinkEndChild(extraInsGeoNode); + + TiXmlElement* extraInsGeoTechNode = new TiXmlElement("technique"); + extraInsGeoNode->LinkEndChild(extraInsGeoTechNode); + extraInsGeoTechNode->SetAttribute("profile", "OpenCOLLADA"); + + TiXmlElement* castShadowsNode = new TiXmlElement("cast_shadows"); + extraInsGeoTechNode->LinkEndChild(castShadowsNode); + castShadowsNode->SetAttribute("sid", "cast_shadows"); + castShadowsNode->SetAttribute("type", "bool"); + + TiXmlText* castShadowsText = new TiXmlText("1"); + castShadowsNode->LinkEndChild(castShadowsText); + + //----------------------------- + TiXmlElement* receiveShadowsNode = new TiXmlElement("receive_shadows"); + extraInsGeoTechNode->LinkEndChild(receiveShadowsNode); + receiveShadowsNode->SetAttribute("sid", "receive_shadows"); + receiveShadowsNode->SetAttribute("type", "bool"); + + TiXmlText* receiveShadowsText = new TiXmlText("1"); + receiveShadowsNode->LinkEndChild(receiveShadowsText); + + //----------------------------- + TiXmlElement* primaryVisibiltyNode = new TiXmlElement("primary_visibility"); + extraInsGeoTechNode->LinkEndChild(primaryVisibiltyNode); + primaryVisibiltyNode->SetAttribute("sid", "primary_visibility"); + primaryVisibiltyNode->SetAttribute("type", "int"); + + TiXmlText* primaryVisibiltyText = new TiXmlText("1"); + primaryVisibiltyNode->LinkEndChild(primaryVisibiltyText); + + //----------------------------- + TiXmlElement* secondaryVisibilityNode = new TiXmlElement("secondary_visibility"); + extraInsGeoTechNode->LinkEndChild(secondaryVisibilityNode); + secondaryVisibilityNode->SetAttribute("sid", "secondary_visibility"); + secondaryVisibilityNode->SetAttribute("type", "int"); + + TiXmlText* secondaryVisibilityText = new TiXmlText("1"); + secondaryVisibilityNode->LinkEndChild(secondaryVisibilityText); + + // Extra info useful for COLLADAMaya importer (OpenCOLLADA) + TiXmlElement* extra2InsGeoNode = new TiXmlElement("extra"); + nodeNode->LinkEndChild(extra2InsGeoNode); + + TiXmlElement* extra2InsGeoTechNode = new TiXmlElement("technique"); + extra2InsGeoNode->LinkEndChild(extra2InsGeoTechNode); + extra2InsGeoTechNode->SetAttribute("profile", "OpenCOLLADAMaya"); + + TiXmlElement* mayaNodeId = new TiXmlElement("originalMayaNodeId"); + extra2InsGeoTechNode->LinkEndChild(mayaNodeId); + mayaNodeId->SetAttribute("sid", "originalMayaNodeId"); + mayaNodeId->SetAttribute("type", "string"); + + TiXmlText* mayaNodeIdMesh = new TiXmlText(avar("%s", meshName.c_str())); + mayaNodeId->LinkEndChild(mayaNodeIdMesh); + + TiXmlElement* paramExtraNode = new TiXmlElement("param"); + extra2InsGeoTechNode->LinkEndChild(paramExtraNode); + paramExtraNode->SetAttribute("sid", "colladaId"); + paramExtraNode->SetAttribute("type", "string"); + + TiXmlText* mayaParamMesh = new TiXmlText(avar("%s", meshName.c_str())); + paramExtraNode->LinkEndChild(mayaParamMesh); + TiXmlElement* sceneNode = new TiXmlElement("scene"); rootNode->LinkEndChild(sceneNode); @@ -1550,6 +1682,7 @@ void ColladaUtils::exportToCollada(const Torque::Path& colladaFile, const Optimi TiXmlElement* rootNode = new TiXmlElement("COLLADA"); rootNode->SetAttribute("xmlns", "http://www.collada.org/2005/11/COLLADASchema"); rootNode->SetAttribute("version", "1.4.1"); + rootNode->SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); // Add the root node to the document doc.LinkEndChild(rootNode); From f610c7ab2418fa0c74224675d3a904312ed2db9a Mon Sep 17 00:00:00 2001 From: Johxz Date: Fri, 9 Dec 2016 16:29:23 -0600 Subject: [PATCH 4/4] fix atlas texture, extra info for opencollada --- Engine/source/ts/collada/colladaUtils.cpp | 39 +++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/Engine/source/ts/collada/colladaUtils.cpp b/Engine/source/ts/collada/colladaUtils.cpp index 7eb9374a40..e88abe3720 100644 --- a/Engine/source/ts/collada/colladaUtils.cpp +++ b/Engine/source/ts/collada/colladaUtils.cpp @@ -1013,8 +1013,8 @@ void ColladaUtils::exportColladaMaterials(TiXmlElement* rootNode, const Optimize String diffuseMap; - if (mat->getName() && mat->getName()[0]) - matNames.last() = String(mat->getName()); + if (mat->getName() && mat->getName()[0]) + matNames.last() = mat->mMapTo; // Handle an auto-generated "Default Material" specially if (mat->isAutoGenerated()) @@ -1544,6 +1544,36 @@ void ColladaUtils::exportColladaMesh(TiXmlElement* rootNode, const OptimizedPoly verticesInputNode->SetAttribute("source", avar("#%s-mesh-positions", meshName.c_str())); exportColladaTriangles(meshNode, mesh, meshName, matNames); + + // Extra info useful for COLLADAMaya importer (OpenCOLLADA) + TiXmlElement* extraGeoNode = new TiXmlElement("extra"); + libGeomsNode->LinkEndChild(extraGeoNode); + + TiXmlElement* extraGeoNodeTech = new TiXmlElement("technique"); + extraGeoNode->LinkEndChild(extraGeoNodeTech); + extraGeoNodeTech->SetAttribute("profile", "OpenCOLLADAMaya"); + + TiXmlElement* mayaNode2Id = new TiXmlElement("originalMayaNodeId"); + extraGeoNodeTech->LinkEndChild(mayaNode2Id); + mayaNode2Id->SetAttribute("sid", "originalMayaNodeId"); + TiXmlText* mayaIdMesh = new TiXmlText(avar("%s", meshName.c_str())); + mayaNode2Id->LinkEndChild(mayaIdMesh); + + TiXmlElement* doubleSidedId = new TiXmlElement("double_sided"); + extraGeoNodeTech->LinkEndChild(doubleSidedId); + doubleSidedId->SetAttribute("sid", "double_sided"); + TiXmlText* doubleSideIdText = new TiXmlText("1"); + doubleSidedId->LinkEndChild(doubleSideIdText); + + TiXmlElement* paramExtraNode = new TiXmlElement("param"); + extraGeoNodeTech->LinkEndChild(paramExtraNode); + paramExtraNode->SetAttribute("sid", "colladaId"); + paramExtraNode->SetAttribute("type", "string"); + + TiXmlText* mayaParamMesh = new TiXmlText(avar("%s-mesh", meshName.c_str())); + paramExtraNode->LinkEndChild(mayaParamMesh); + + } void ColladaUtils::exportColladaScene(TiXmlElement* rootNode, const String& meshName, const Vector& matNames) @@ -1655,6 +1685,8 @@ void ColladaUtils::exportColladaScene(TiXmlElement* rootNode, const String& mesh TiXmlText* mayaParamMesh = new TiXmlText(avar("%s", meshName.c_str())); paramExtraNode->LinkEndChild(mayaParamMesh); + //----------------------------- + TiXmlElement* sceneNode = new TiXmlElement("scene"); rootNode->LinkEndChild(sceneNode); @@ -1682,7 +1714,8 @@ void ColladaUtils::exportToCollada(const Torque::Path& colladaFile, const Optimi TiXmlElement* rootNode = new TiXmlElement("COLLADA"); rootNode->SetAttribute("xmlns", "http://www.collada.org/2005/11/COLLADASchema"); rootNode->SetAttribute("version", "1.4.1"); - rootNode->SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + //rootNode->SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); //T3D Collada loader complaint about this. + // Add the root node to the document doc.LinkEndChild(rootNode);