Explorar o código

Merge pull request #1315 from Palmer-JC/master

Blender Exporter 5.0.2
David Catuhe %!s(int64=9) %!d(string=hai) anos
pai
achega
fb27cbea11

BIN=BIN
Exporters/Blender/Blender2Babylon-5.0.zip


+ 1 - 1
Exporters/Blender/src/__init__.py

@@ -1,7 +1,7 @@
 bl_info = {
     'name': 'Babylon.js',
     'author': 'David Catuhe, Jeff Palmer',
-    'version': (5, 0, 1),
+    'version': (5, 0, 2),
     'blender': (2, 76, 0),
     'location': 'File > Export > Babylon.js (.babylon)',
     'description': 'Export Babylon.js scenes (.babylon)',

+ 9 - 7
Exporters/Blender/src/mesh.py

@@ -113,7 +113,7 @@ class Mesh(FCurveAnimatable):
                 instRot = scale_vector(rot.to_euler('XYZ'), -1)
                 instRotq = None
 
-            instance = MeshInstance(self.name, self.position, instRot, instRotq, self.scaling, self.freezeWorldMatrix)
+            instance = MeshInstance(self, instRot, instRotq)
             sourceMesh.instances.append(instance)
             Logger.log('mesh is an instance of :  ' + sourceMesh.name + '.  Processing halted.', 2)
             return
@@ -600,19 +600,21 @@ class Mesh(FCurveAnimatable):
         self.alreadyExported = True
 #===============================================================================
 class MeshInstance:
-     def __init__(self, name, position, rotation, rotationQuaternion, scaling, freezeWorldMatrix):
-        self.name = name
-        self.position = position
+     def __init__(self, instancedMesh, rotation, rotationQuaternion):
+        self.name = instancedMesh.name
+        if hasattr(instancedMesh, 'parentId'): self.parentId = instancedMesh.parentId
+        self.position = instancedMesh.position
         if rotation is not None:
             self.rotation = rotation
         if rotationQuaternion is not None:
             self.rotationQuaternion = rotationQuaternion
-        self.scaling = scaling
-        self.freezeWorldMatrix = freezeWorldMatrix
+        self.scaling = instancedMesh.scaling
+        self.freezeWorldMatrix = instancedMesh.freezeWorldMatrix
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      def to_scene_file(self, file_handler):
         file_handler.write('{')
         write_string(file_handler, 'name', self.name, True)
+        if hasattr(self, 'parentId'): write_string(file_handler, 'parentId', self.parentId)
         write_vector(file_handler, 'position', self.position)
         if hasattr(self, 'rotation'):
             write_vector(file_handler, 'rotation', self.rotation)
@@ -647,7 +649,7 @@ class Node(FCurveAnimatable):
         self.billboardMode = BILLBOARDMODE_NONE
         self.castShadows = False
         self.receiveShadows = False
-        self.layer = getLayer(object) # used only for lights with 'This Layer Only' checked, not exported
+        self.layer = -1 # nodes do not have layers attribute
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     def to_scene_file(self, file_handler):
         file_handler.write('{')

+ 2 - 0
Exporters/Blender/src/package_level.py

@@ -56,6 +56,8 @@ def getNameSpace(filepathMinusExtension):
         return legal_js_identifier(filepathMinusExtension.rpartition('/')[2])
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 def getLayer(obj):
+    # empties / nodes do not have layers
+    if not hasattr(object, 'layers') : return -1;
     for idx, layer in enumerate(obj.layers):
         if layer:
             return idx