[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2908] contrib/py/scripts/addons/ io_scene_ms3d: changed matrix handling
Alexander Nussbaumer
alpha-beta-release at gmx.net
Tue Jan 17 15:14:34 CET 2012
Revision: 2908
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2908
Author: beta-tester
Date: 2012-01-17 14:14:30 +0000 (Tue, 17 Jan 2012)
Log Message:
-----------
changed matrix handling
mod: changed matrix handling, in account to matrix changes since blender rev.42816; for a while with side-by-side implementation by checking 'bpy.app.build_revision'
del: removed unused option for export FuturePinball animation script (i will make an extra addon future_pinball_tool collection)
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
contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py
contrib/py/scripts/addons/io_scene_ms3d/ms3d_spec.py
contrib/py/scripts/addons/io_scene_ms3d/ms3d_utils.py
Modified: contrib/py/scripts/addons/io_scene_ms3d/__README__.txt
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__README__.txt 2012-01-17 11:01:49 UTC (rev 2907)
+++ contrib/py/scripts/addons/io_scene_ms3d/__README__.txt 2012-01-17 14:14:30 UTC (rev 2908)
@@ -16,11 +16,11 @@
#
# ##### END GPL LICENSE BLOCK #####
+# <pep8 compliant>
###############################################################################
#234567890123456789012345678901234567890123456789012345678901234567890123456789
#--------1---------2---------3---------4---------5---------6---------7---------
-# <pep8 compliant>
# ##### BEGIN COPYRIGHT BLOCK #####
@@ -89,6 +89,10 @@
changelog:
+changed: (0, 3, 8),
+mod: changed matrix handling, in account to matrix changes since blender rev.42816; for a while with side-by-side implementation by checking 'bpy.app.build_revision'
+del: removed unused option for export FuturePinball animation script (i will make an extra addon future_pinball_tool collection)
+
changed: (0, 3, 6, "beta (2011-12-13 00:00)"),
mod: exporter use an other logic to reduces the total number of smooth groups
mod: correct "version" and "blender" in __init__.py
Modified: contrib/py/scripts/addons/io_scene_ms3d/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__init__.py 2012-01-17 11:01:49 UTC (rev 2907)
+++ contrib/py/scripts/addons/io_scene_ms3d/__init__.py 2012-01-17 14:14:30 UTC (rev 2908)
@@ -23,11 +23,10 @@
"description": "Import / Export MilkShape3D MS3D files"
" (conform with v1.8.4)",
"author": "Alexander Nussbaumer",
- "version": (0, 3, 6),
+ "version": (0, 3, 8),
"blender": (2, 60, 0),
"location": "File > Import-Export",
- "warning": "imports and exports only geometry and material of ms3d"\
- " file. (poor performance)",
+ "warning": "[2012-01-17] side-by-side implementation for Matrix handling around rev.42816",
"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"\
@@ -39,6 +38,7 @@
#234567890123456789012345678901234567890123456789012345678901234567890123456789
#--------1---------2---------3---------4---------5---------6---------7---------
+
# ##### BEGIN COPYRIGHT BLOCK #####
#
# initial script copyright (c)2011 Alexander Nussbaumer
@@ -50,6 +50,8 @@
# if it's there, reload everything
if ("bpy" in locals()):
import imp
+ if "ms3d_utils" in locals():
+ imp.reload(ms3d_utils)
if "ms3d_export" in locals():
imp.reload(ms3d_export)
if "ms3d_import" in locals():
@@ -57,6 +59,7 @@
pass
else:
+ from . import ms3d_utils
from . import ms3d_export
from . import ms3d_import
pass
@@ -66,6 +69,7 @@
import bpy
import bpy_extras
+
###############################################################################
# registration
def menu_func_import(self, context):
Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py 2012-01-17 11:01:49 UTC (rev 2907)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py 2012-01-17 14:14:30 UTC (rev 2908)
@@ -16,11 +16,11 @@
#
# ##### END GPL LICENSE BLOCK #####
+# <pep8 compliant>
###############################################################################
#234567890123456789012345678901234567890123456789012345678901234567890123456789
#--------1---------2---------3---------4---------5---------6---------7---------
-# <pep8 compliant>
# ##### BEGIN COPYRIGHT BLOCK #####
@@ -59,11 +59,12 @@
import bpy
import bpy_extras.io_utils
-from bpy.props import (StringProperty,
- BoolProperty,
- EnumProperty,
- FloatProperty,
- )
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ StringProperty,
+ )
# registered entry point export
@@ -136,14 +137,7 @@
options=ms3d_utils.PROP_OPT_ANIMATION,
)
- prop_animation_fp = BoolProperty(
- name=ms3d_utils.PROP_NAME_ANIMATION_FP,
- description=ms3d_utils.PROP_DESC_ANIMATION_FP,
- default=ms3d_utils.PROP_DEFAULT_ANIMATION_FP,
- options=ms3d_utils.PROP_OPT_ANIMATION_FP,
- )
-
# draw the option panel
def draw(self, context):
layout = self.layout
Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py 2012-01-17 11:01:49 UTC (rev 2907)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py 2012-01-17 14:14:30 UTC (rev 2908)
@@ -16,11 +16,11 @@
#
# ##### END GPL LICENSE BLOCK #####
+# <pep8 compliant>
###############################################################################
#234567890123456789012345678901234567890123456789012345678901234567890123456789
#--------1---------2---------3---------4---------5---------6---------7---------
-# <pep8 compliant>
# ##### BEGIN COPYRIGHT BLOCK #####
@@ -60,12 +60,14 @@
import bpy_extras.io_utils
from bpy_extras.image_utils import load_image
-from bpy.props import (StringProperty,
- BoolProperty,
- EnumProperty,
- FloatProperty,
- )
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ StringProperty,
+ )
+
###############################################################################
def prop(name):
return "ms3d_{0}".format(name)
@@ -81,6 +83,15 @@
###############################################################################
+_idb_ms3d = 0
+_idb_blender = 1
+_idb_roll = 2
+
+_bone_dummy = 1.0
+_bone_distort = 0.00001 # sys.float_info.epsilon
+
+
+###############################################################################
# registered entry point import
class ImportMS3D(
bpy.types.Operator,
@@ -205,6 +216,7 @@
# handle internal ms3d names to external blender names
# to prevent potential name collisions on multiple imports
# with same names but different content
+ self.dict_actions = {}
self.dict_armatures = {}
self.dict_armature_objects = {}
self.dict_groups = {}
@@ -257,24 +269,17 @@
ms3dTemplate.modelComment.comment
if (ms3d_utils.PROP_ITEM_OBJECT_JOINT in self.prop_objects):
- dict_bones = self.CreateArmature(blenderContext, ms3dTemplate)
+ dict_bones, blenderArmatureObject = self.CreateArmature(
+ blenderContext, ms3dTemplate)
if self.prop_animation:
- bpy.context.scene.render.fps = ms3dTemplate.fAnimationFPS
- if ms3dTemplate.fAnimationFPS:
- bpy.context.scene.render.fps_base = (
- bpy.context.scene.render.fps /
- ms3dTemplate.fAnimationFPS)
- bpy.context.scene.frame_start = 1
- bpy.context.scene.frame_end = (ms3dTemplate.iTotalFrames
- + bpy.context.scene.frame_start) - 1
- bpy.context.scene.frame_current = (
- ms3dTemplate.fCurrentTime
- * bpy.context.scene.render.fps)
+ self.CreateAnimation(blenderContext, ms3dTemplate,
+ dict_bones, blenderArmatureObject)
+ pass
for ms3dGroupIndex, ms3dGroup in enumerate(ms3dTemplate.groups):
blenderMesh = self.CreateMesh(blenderContext, ms3dTemplate,
- ms3dGroup, ms3dGroupIndex, dict_bones)
+ ms3dGroup, ms3dGroupIndex)
# apply material if available
if ((ms3d_utils.PROP_ITEM_OBJECT_MATERIAL in self.prop_objects)
@@ -330,7 +335,7 @@
###########################################################################
def CreateArmature(self, blenderContext, ms3dTemplate):
if (ms3dTemplate.nNumJoints <= 0):
- return None
+ return None, None
blenderScene = blenderContext.scene
@@ -353,8 +358,8 @@
dict_bones = {}
for iBone, ms3dJoint in enumerate(ms3dTemplate.joints):
-
blenderBone = blenderArmature.edit_bones.new(ms3dJoint.name)
+ blenderBone[prop(ms3d_spec.PROP_NAME_NAME)] = ms3dJoint.name
blenderBone[prop(ms3d_spec.PROP_NAME_FLAGS)] = ms3dJoint.flags
ms3dComment = ms3dTemplate.get_joint_comment_by_key(iBone)
@@ -370,8 +375,8 @@
blenderBone.select = True
blenderArmature.edit_bones.active = blenderBone
- # [blender bone, ms3d bone, number of references, roll vector]
- dict_bones[ms3dJoint.name] = [blenderBone, ms3dJoint, 0, None]
+ # [ms3d bone, number of references, blender bone, roll vector]
+ dict_bones[ms3dJoint.name] = [ms3dJoint, blenderBone, None]
mathVector = mathutils.Vector(ms3dJoint.position)
mathVector = mathVector * self.matrixViewport
@@ -382,14 +387,16 @@
#dummy tail
blenderBone.tail = blenderBone.head + mathutils.Vector(
- (0.00001, 0.0, 0.0))
+ (_bone_dummy, 0.0, 0.0))
else:
boneItem = dict_bones[ms3dJoint.parentName]
- boneItem[2] += 1
- blenderBoneParent = boneItem[0]
+ blenderBoneParent = boneItem[_idb_blender]
blenderBone.parent = blenderBoneParent
+ if self.prop_animation:
+ blenderBone.use_inherit_rotation = False
+ blenderBone.use_inherit_scale = False
matrixRotation = mathutils.Matrix()
for blenderBoneParent in blenderBone.parent_recursive:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list