Browse Source

added quaternion normalization to rest export

repsac 10 years ago
parent
commit
48be885e6e

+ 6 - 4
utils/exporters/blender/addons/io_three/__init__.py

@@ -42,7 +42,7 @@ SETTINGS_FILE_EXPORT = 'three_settings_export.js'
 bl_info = {
     'name': "Three.js Format",
     'author': "repsac, mrdoob, yomotsu, mpk, jpweeks",
-    'version': (1, 2, 4),
+    'version': (1, 3, 0),
     'blender': (2, 7, 3),
     'location': "File > Export",
     'description': "Export Three.js formatted JSON files.",
@@ -623,8 +623,10 @@ class ExportThree(bpy.types.Operator, ExportHelper):
         description="Copy textures",
         default=constants.EXPORT_OPTIONS[constants.COPY_TEXTURES])
 
-    option_texture_folder = StringProperty(name="Texture folder",
-        description="add this folder to textures path", default="")
+    option_texture_folder = StringProperty(
+        name="Texture folder",
+        description="add this folder to textures path",
+        default=constants.EXPORT_OPTIONS[constants.TEXTURE_FOLDER])
 
     option_lights = BoolProperty(
         name="Lights",
@@ -822,7 +824,7 @@ class ExportThree(bpy.types.Operator, ExportHelper):
         row.prop(self.properties, 'option_copy_textures')
 
         row = layout.row()
-        row.prop(self.properties, "option_texture_folder")
+        row.prop(self.properties, 'option_texture_folder')
 
         row = layout.row()
         row.prop(self.properties, 'option_scale')

+ 5 - 4
utils/exporters/blender/addons/io_three/constants.py

@@ -63,7 +63,7 @@ LIGHTS = 'lights'
 FACE_MATERIALS = 'faceMaterials'
 SKINNING = 'skinning'
 COPY_TEXTURES = 'copyTextures'
-TEXTURE_FOLDER = "textureFolder"
+TEXTURE_FOLDER = 'textureFolder'
 ENABLE_PRECISION = 'enablePrecision'
 PRECISION = 'precision'
 DEFAULT_PRECISION = 6
@@ -111,7 +111,7 @@ EXPORT_OPTIONS = {
     CAMERAS: False,
     LIGHTS: False,
     COPY_TEXTURES: True,
-    TEXTURE_FOLDER: "",
+    TEXTURE_FOLDER: '',
     LOGGING: DEBUG,
     ENABLE_PRECISION: True,
     PRECISION: DEFAULT_PRECISION,
@@ -173,7 +173,7 @@ UUID = 'uuid'
 MATRIX = 'matrix'
 POSITION = 'position'
 QUATERNION = 'quaternion'
-ROTATION ='rotation'
+ROTATION = 'rotation'
 SCALE = 'scale'
 
 UV = 'uv'
@@ -321,7 +321,8 @@ BASIC = 'basic'
 
 NORMAL_BLENDING = 'NormalBlending'
 
-DBG_COLORS = (0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee)
+DBG_COLORS = (0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee,
+              0xeeee00, 0x00eeee, 0xee00ee)
 
 DOUBLE_SIDED = 'doubleSided'
 

+ 2 - 2
utils/exporters/blender/addons/io_three/exporter/api/__init__.py

@@ -18,10 +18,10 @@ def batch_mode():
 
     :return: Whether or not the session is interactive
     :rtype: bool
-       
+
     """
     return bpy.context.area is None
-      
+
 
 def init():
     """Initializing the api module. Required first step before

+ 1 - 0
utils/exporters/blender/addons/io_three/exporter/api/animation.py

@@ -89,6 +89,7 @@ def _parse_rest_action(action, armature, options, round_off, round_val):
                                      action, armature.matrix_world)
             rot, rchange = _rotation(bone, computed_frame,
                                      action, rotation_matrix)
+            rot = _normalize_quaternion(rot)
 
             if round_off:
                 pos_x, pos_y, pos_z = utilities.round_off(

+ 8 - 6
utils/exporters/blender/addons/io_three/exporter/geometry.py

@@ -115,7 +115,7 @@ class Geometry(base_classes.BaseNode):
     def copy(self, scene=True):
         """Copy the geometry definitions to a standard dictionary.
 
-        :param scene: toggle for scene formatting 
+        :param scene: toggle for scene formatting
                       (Default value = True)
         :type scene: bool
         :rtype: dict
@@ -135,16 +135,17 @@ class Geometry(base_classes.BaseNode):
 
         return data
 
-    def copy_textures(self, texture_folder=""):
+    def copy_textures(self, texture_folder=''):
         """Copy the textures to the destination directory."""
         logger.debug("Geometry().copy_textures()")
         if self.options.get(constants.COPY_TEXTURES):
             texture_registration = self.register_textures()
             if texture_registration:
                 logger.info("%s has registered textures", self.node)
+                dirname = os.path.dirname(self.scene.filepath)
+                full_path = os.path.join(dirname, texture_folder)
                 io.copy_registered_textures(
-                    os.path.join(os.path.dirname(self.scene.filepath), texture_folder),
-                    texture_registration)
+                    full_path, texture_registration)
 
     def parse(self):
         """Parse the current node"""
@@ -169,7 +170,7 @@ class Geometry(base_classes.BaseNode):
         """Write the geometry definitions to disk. Uses the
         desitnation path of the scene.
 
-        :param filepath: optional output file path 
+        :param filepath: optional output file path
                         (Default value = None)
         :type filepath: str
 
@@ -307,7 +308,8 @@ class Geometry(base_classes.BaseNode):
                     pass
                 continue
 
-            if key in skip: continue
+            if key in skip:
+                continue
 
             metadata[key] = len(self[key])