diff --git a/Engine/source/ts/collada/colladaUtils.cpp b/Engine/source/ts/collada/colladaUtils.cpp index 7eb9374a4..e88abe372 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);