Fix [#26475] <instance_material> wrong in COLLADA export.
authorNathan Letwory <nathan@letworyinteractive.com>
Tue, 22 Mar 2011 22:51:02 +0000 (22:51 +0000)
committerNathan Letwory <nathan@letworyinteractive.com>
Tue, 22 Mar 2011 22:51:02 +0000 (22:51 +0000)
reported by Juan Linietsky
fix by Imran Syed (freakabcd)

Use material index suffixed to material name to create symbolic name.

source/blender/collada/GeometryExporter.cpp
source/blender/collada/InstanceWriter.cpp

index 9edfbe14a71b9f415eaedb9557fbe28a274115d0..332df0318e9bd4298c334e6ef7e16e3b006c47b1 100644 (file)
@@ -28,6 +28,8 @@
  */
 
 
+#include <sstream>
+
 #include "COLLADASWPrimitves.h"
 #include "COLLADASWSource.h"
 #include "COLLADASWVertices.h"
@@ -167,7 +169,9 @@ void GeometryExporter::createPolylist(int material_index,
                
        // sets material name
        if (ma) {
-               polylist.setMaterial(translate_id(id_name(ma)));
+               std::ostringstream ostr;
+               ostr << translate_id(id_name(ma)) << material_index+1;
+               polylist.setMaterial(ostr.str());
        }
                        
        COLLADASW::InputList &til = polylist.getInputList();
index f822db0f39b6c7ca31bffda8b858805c220676ca..a069e72fbbd665de096df69a42b2832021f367cc 100644 (file)
@@ -29,6 +29,7 @@
 
 
 #include <string>
+#include <sstream>
 
 #include "COLLADASWInstanceMaterial.h"
 
@@ -52,7 +53,9 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia
                if (ma) {
                        std::string matid(get_material_id(ma));
                        matid = translate_id(matid);
-                       COLLADASW::InstanceMaterial im(matid, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid));
+                       std::ostringstream ostr;
+                       ostr << translate_id(id_name(ma)) << a+1;
+                       COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid));
                        
                        // create <bind_vertex_input> for each uv layer
                        Mesh *me = (Mesh*)ob->data;