[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3937] contrib/py/scripts/addons/ io_scene_ms3d: 1'st step of implementing joints ( base joints still have wrong orientation)

Alexander Nussbaumer alpha-beta-release at gmx.net
Thu Nov 8 20:20:29 CET 2012


Revision: 3937
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3937
Author:   beta-tester
Date:     2012-11-08 19:20:25 +0000 (Thu, 08 Nov 2012)
Log Message:
-----------
1'st step of implementing joints (base joints still have wrong orientation)

Modified Paths:
--------------
    contrib/py/scripts/addons/io_scene_ms3d/__README__.txt
    contrib/py/scripts/addons/io_scene_ms3d/__init__.py
    contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py

Modified: contrib/py/scripts/addons/io_scene_ms3d/__README__.txt
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__README__.txt	2012-11-07 23:40:55 UTC (rev 3936)
+++ contrib/py/scripts/addons/io_scene_ms3d/__README__.txt	2012-11-08 19:20:25 UTC (rev 3937)
@@ -140,16 +140,16 @@
                     .alpha_ref: 100% (only ms3d-properties)
             .joints
                 Ms3dJoint
-                    .name: 0%
-                    .parent_name: 0%
+                    .name: 100%
+                    .parent_name: 100%
                     .rotation: 0%
-                    .position: 0%
+                    .position: 100%
                     .rotation_keyframes: 0%
                     .translation_keyframes: 0%
                     .joint_ex
                         Ms3DJointEx
-                            .color: 0%
-                    .comment: 0%
+                            .color: 100%
+                    .comment: 100%
 ###############################################################################
     importer:
         Ms3dModel

Modified: contrib/py/scripts/addons/io_scene_ms3d/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-11-07 23:40:55 UTC (rev 3936)
+++ contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-11-08 19:20:25 UTC (rev 3937)
@@ -23,10 +23,10 @@
         'description': "Import / Export MilkShape3D MS3D files"\
                 " (conform with v1.8.4)",
         'author': "Alexander Nussbaumer",
-        'version': (0, 4, 8, 4),
+        'version': (0, 4, 8, 5),
         'blender': (2, 6, 3, 0),
         'location': "File > Import & File > Export",
-        'warning': "[2012-11-05] exporter is working, but is incomplete",
+        'warning': "[2012-11-08] exporter is working, but is incomplete",
         'wiki_url': "http://wiki.blender.org/index.php/Extensions:2.6/Py/"\
                 "Scripts/Import-Export/MilkShape3D_MS3D",
         'tracker_url': "http://projects.blender.org/tracker/index.php"\

Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2012-11-07 23:40:55 UTC (rev 3936)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2012-11-08 19:20:25 UTC (rev 3937)
@@ -37,6 +37,7 @@
         )
 from mathutils import (
         Vector,
+        Euler,
         )
 from os import (
         path,
@@ -438,16 +439,24 @@
             blender_bones = None
             for blender_modifier in blender_mesh_object.modifiers:
                 if blender_modifier.type == 'ARMATURE' and blender_modifier.object.pose:
-                    blender_bones = blender_modifier.object.pose.bones
+                    blender_bones = blender_modifier.object.data.bones
                     break
 
             for blender_bone_oject in blender_bones:
                 ms3d_joint = Ms3dJoint()
                 ms3d_joint.__index = len(ms3d_model._joints)
 
-                blender_ms3d_joint = blender_bone_oject.bone.ms3d
+                blender_ms3d_joint = blender_bone_oject.ms3d
                 blender_bone = blender_bone_oject
 
+                ms3d_joint.flags = Ms3dUi.flags_to_ms3d(blender_ms3d_joint.flags)
+                if blender_ms3d_joint.comment:
+                    ms3d_joint._comment_object = Ms3dCommentEx()
+                    ms3d_joint._comment_object.comment = blender_ms3d_joint.comment
+                    ms3d_joint._comment_object.index = ms3d_joint.__index
+
+                ms3d_joint.joint_ex_object._color = blender_ms3d_joint.color[:]
+
                 if blender_ms3d_joint.name:
                     ms3d_joint.name = blender_ms3d_joint.name
                 else:
@@ -455,25 +464,18 @@
 
                 if blender_bone.parent:
                     if blender_ms3d_joint.name:
-                        ms3d_joint.parent_name = blender_bone.parent.bone.ms3d.name
+                        ms3d_joint.parent_name = blender_bone.parent.ms3d.name
                     else:
                         ms3d_joint.parent_name = blender_bone.parent.name
 
-                    ms3d_joint_vector = (blender_bone.head - blender_bone.parent.head) * self.matrix_scaled_coordination_system
-                    ms3d_joint_euler = blender_bone.matrix.to_euler('XZY')
+                    ms3d_joint_vector = blender_bone.head * self.matrix_scaled_coordination_system
+                    blender_bone_euler = blender_bone.matrix.to_euler('XZY')
                 else:
                     ms3d_joint_vector = blender_bone.head * self.matrix_scaled_coordination_system
-                    ms3d_joint_euler = blender_bone.matrix.to_euler('XZY')
-                ms3d_joint._position = ms3d_joint_vector
-                #ms3d_joint._rotation = ms3d_joint_euler
+                    blender_bone_euler = blender_bone.matrix.to_euler('XZY')
+                ms3d_joint._position = ms3d_joint_vector[:]
+                ms3d_joint._rotation = (Vector(blender_bone_euler[:]) * self.matrix_scaled_coordination_system)[:]
 
-                ms3d_joint.flags = Ms3dUi.flags_to_ms3d(blender_ms3d_joint.flags)
-                if blender_ms3d_joint.comment:
-                    ms3d_joint._comment_object = Ms3dCommentEx()
-                    ms3d_joint._comment_object.comment = blender_ms3d_joint.comment
-                    ms3d_joint._comment_object.index = ms3d_joint.__index
-
-
                 ms3d_model._joints.append(ms3d_joint)
                 blender_to_ms3d_bones[blender_bone.name] = ms3d_joint
 
@@ -546,10 +548,10 @@
             else:
                 ms3d_material.name = blender_material.name
 
-            ms3d_material._ambient = blender_ms3d_material.ambient
-            ms3d_material._diffuse = blender_ms3d_material.diffuse
-            ms3d_material._specular = blender_ms3d_material.specular
-            ms3d_material._emissive = blender_ms3d_material.emissive
+            ms3d_material._ambient = blender_ms3d_material.ambient[:]
+            ms3d_material._diffuse = blender_ms3d_material.diffuse[:]
+            ms3d_material._specular = blender_ms3d_material.specular[:]
+            ms3d_material._emissive = blender_ms3d_material.emissive[:]
             ms3d_material.shininess = blender_ms3d_material.shininess
             ms3d_material.transparency = blender_ms3d_material.transparency
             ms3d_material.mode = Ms3dUi.texture_mode_to_ms3d(blender_ms3d_material.mode)



More information about the Bf-extensions-cvs mailing list