Commits

Anonymous committed e0c08a9

Add find material
Rename findObject to findNode
Fix Typo when writing update callback of StateAttribute
Add debug info
Fix traceback when the material has no texture named

  • Participants
  • Parent commits 4435f13

Comments (0)

Files changed (2)

File blenderExporter/osg/osgdata.py

                 uv_layer =  texture_list[i].uvlayer
 
                 if len(uv_layer) > 0 and not uvs.has_key(uv_layer):
-                    log("WARNING your material '%s' with texture '%s' use an uv layer '%s' that does not exist on the mesh '%s', use the first uv channel as fallback" % (mat_source.getName(), texture_list[i], uv_layer, geom.name))
+                    log("WARNING your material '%s' with texture '%s' use an uv layer '%s' that does not exist on the mesh '%s', use the first uv channel as fallback" % (material.getName(), texture_list[i], uv_layer, geom.name))
                 if len(uv_layer) > 0 and uvs.has_key(uv_layer):
                     if DEBUG: debug("texture %s use uv layer %s" % (i, uv_layer))
                     geom.uvs[i] = TexCoordArray()
         self.animation = None
 
     def getTypeOfIpo(self, ipo):
+        if DEBUG: debug("%s curvs consts %s" % (ipo.name, str(ipo.curveConsts)))
         try:
             ipo.curveConsts['MA_R']
             return "Material"
         ipos_baked = ipo
         if self.config.anim_bake.lower() == "force":
             ipotype = self.getTypeOfIpo(ipo)
+            if DEBUG: debug("createAnimationFromIpo ipo %s of type %s" % (str(name), str(ipotype)))
             if ipotype == "Object":
                 obj = findObjectForIpo(ipo)
                 baker = BakeIpoForObject(object = obj, ipo = ipo, config = None)

File blenderExporter/osg/osgobject.py

 INDENT    = 2
 
 
-def findObject(name, root):
+def findNode(name, root):
     if root.name == name:
         return root
     if isinstance(root, Group) is False:
         return None
     for i in root.children:
-        found = findObject(name, i)
+        found = findNode(name, i)
         if found is not None:
             return found
     return None
 
+def findMaterial(name, root):
+    if root.stateset is not None:
+        for i in root.stateset.attributes:
+            if isinstance(i, Material) is True and i.name == name:
+                return i
+    if isinstance(root, Geode) is True:
+        for i in root.drawables:
+            found = findMaterial(name, i)
+            if found is not None:
+                return found
+    if isinstance(root, Group) is True:
+        for i in root.children:
+            found = findMaterial(name, i)
+            if found is not None:
+                return found
+    return None
+
 class Writer(object):
     def __init__(self, comment = None):
         object.__init__(self)
     def printContent(self):
         text = Object.printContent(self)
         if len(self.update_callbacks) > 0:
-            text += "$#UpdateCallbacks {\n"
+            text += "$#UpdateCallback {\n"
             for i in self.update_callbacks:
                 i.indent_level = self.indent_level + 2
                 text += str(i)