io_scene_cs : adding map nodes export

Vincent Knecht <[email protected]>
Newsgroups gmane.comp.graphics.crystalspace.devel
Message-ID <CAGsPR3gf1pk-SQGpdHYw-nfA+TnpSGhnbopXXkCPPJp+OkTH_w@mail.gmail.com>
Hello,

  here's a patch for io_scene_cs to export Blender "Empties" as CS map
nodes (iMapNode)
without changing exporting behaviour for empties marked as dupli-groups.
Does it look correct ? At least it does what I need, but I don't use
dupligroups (yet).

It only supports exporting position, not [xyz]vector nor key tags.

Index: scripts/blender/io_scene_cs/io/object.py
===================================================================
--- scripts/blender/io_scene_cs/io/object.py    (révision 38824)
+++ scripts/blender/io_scene_cs/io/object.py    (copie de travail)
@@ -469,6 +469,10 @@
         for ob in self.dupli_group.objects:
           if not ob.parent:
             ob.AsCS(func, depth, transform=self.relative_matrix,
name=self.uname)
+    else:
+      func(' '*depth +'<node name="%s">'%(name))
+      func(' '*depth +'  <position x="%f" z="%f" y="%f" />'%
tuple(self.relative_matrix.to_translation()))
+      func(' '*depth +'</node>')

     #Handle children: translate to top level.
     for obj in self.children:
@@ -520,7 +524,7 @@
       return True
     return False

-  # The export of Empty objects depends of their componants
+  # The export of Empty objects depends of their components
   if self.type == 'EMPTY':
     # Groups of objects are exported if the group itself and
     # all its composing elements are visible
@@ -540,9 +544,9 @@
             if not gr.dupli_group.CheckVisibility():
               return False
     else:
-      # Empty objects which are not groups are not exported
-      # (notice that each of their componants can be individually exported)
-      return False
+      # Empty objects which are not groups are exported as map nodes
+      # (notice that each of their components can be individually exported)
+      return True

   # All other types of objects are always exportable (if they are visible)
   return True

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
Crystal-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-develop
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.