2012/8/19 Vincent Knecht <knecht.vinc...@gmail.com>

> 2012/8/19 sueastside <sueasts...@scarlet.be>
>
>>  shift+D duplicates EVERYTHING, so object, mesh and materials and so
>> on(basically creating a complete new hierarchy, great for making variations
>> of meshes not so for instancing).
>>
>> alt+D just duplicates the object (so all of them link to the same mesh),
>> this is the one you want for basic object level instancing
>> (for more advanced instancing use group linking)
>>
>
> Since previous mails I've tried Alt+d but it doesn't seem to help in
> sharing factories.
> Blender "object data" panel for different duplicates show the same name as
> expected,
> but in fact they're all using a distinct file/factory.
> Comparing these files, only the factory name differs (same as mesh object).
> Bug ?
> I'm using Blender 2.63 (r46461), io_scene_cs previous to r38751.
>

Here's what I've come up with to fix the problem, mainly using
self.object.data.name
instead of self.object.name in places related to factories, along with a
new list
to keep track of factories already exported to prevent redundant processing
and
dupe lines in the <library> section of world file.
Works for you ? :-)

Index: io/__init__.py
===================================================================
--- io/__init__.py    (révision 38824)
+++ io/__init__.py    (copie de travail)
@@ -118,6 +118,8 @@
   Write(f)('</world>')
   f.close()

+  Hierarchy.exportedFactories = []
+
   print("\nEXPORTING complete
==================================================")


Index: io/object.py
===================================================================
--- io/object.py    (révision 38824)
+++ io/object.py    (copie de travail)
@@ -11,6 +11,7 @@

 class Hierarchy:
   OBJECTS = {}
+  exportedFactories = []
   def __init__(self, anObject, anEmpty):
     self.object = anObject
     self.empty = anEmpty
@@ -33,8 +34,8 @@
     return "hier" + str(self.id)

   def AsCSRef(self, func, depth=0, dirName='factories/'):
-    if self.object.parent_type != 'BONE':
-      func(' '*depth +'<library>%s%s</library>'%(dirName,self.object.name))
+    if self.object.parent_type != 'BONE' and self.object.data.name not in
Hierarchy.exportedFactories:
+      func(' '*depth +'<library>%s%s</library>'%(dirName,
self.object.data.name))

   def GetDependencies(self):
     dependencies = EmptyDependencies()
@@ -124,8 +125,11 @@
         fi.write(data+'\n')
       return write

+    if self.object.data.name in Hierarchy.exportedFactories:
+      print('Skipping "%s" factory export, already done' % (
self.object.data.name))
+      return
     # Export mesh
-    fa = open(Join(path, 'factories/', self.object.name), 'w')
+    fa = open(Join(path, 'factories/', self.object.data.name), 'w')
     self.WriteCSLibHeader(Write(fa), animesh)
     objectDeps = self.object.GetDependencies()
     use_imposter = not animesh and self.object.data.use_imposter
@@ -134,6 +138,7 @@
       self.WriteCSAnimeshHeader(Write(fa), 2)
     self.WriteCSMeshBuffers(Write(fa), 2, path, animesh, dontClose=False)
     fa.close()
+    Hierarchy.exportedFactories.append(self.object.data.name)

     # Export skeleton and animations
     if self.object.type == 'ARMATURE' and self.object.data.bones:
@@ -331,7 +336,7 @@
   """

   # Write genmesh header
-  func(' '*depth + '<meshfact name=\"%s\">'%(self.name))
+  func(' '*depth + '<meshfact name=\"%s\">'%(self.data.name))
   func(' '*depth + '
<plugin>crystalspace.mesh.loader.factory.genmesh</plugin>')
   if self.data.use_imposter:
     func(' '*depth + '  <imposter range="100.0" tolerance="0.4"
camera_tolerance="0.4" shader="lighting_imposter"/>')
@@ -415,7 +420,7 @@
       else:
         func(' '*depth +'
<plugin>crystalspace.mesh.loader.genmesh</plugin>')
       func(' '*depth +'  <params>')
-      func(' '*depth +'    <factory>%s</factory>'%(self.name))
+      func(' '*depth +'    <factory>%s</factory>'%(self.data.name))
       func(' '*depth +'  </params>')

       if self.parent and self.parent_type == 'BONE':
@@ -469,6 +474,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 +529,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 +549,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-main mailing list
Crystal-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: 
mailto:crystal-main-requ...@lists.sourceforge.net?subject=unsubscribe

Reply via email to