[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2720] contrib/py/scripts/addons/ io_scene_ms3d: importer adds comments as custom properties, ...
Alexander Nussbaumer
alpha-beta-release at gmx.net
Mon Dec 5 00:42:21 CET 2011
Revision: 2720
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2720
Author: beta-tester
Date: 2011-12-04 23:42:20 +0000 (Sun, 04 Dec 2011)
Log Message:
-----------
importer adds comments as custom properties, ...
changed: (0, 3, 4, "beta (2011-12-04 00:00)"),
add: importer adds ms3d_comment custom properties for modelComment (to a blender empty), groupComments (to its blender meshes), materialComments (to its blender materials) and jointComments (to its blender bones)
add: importer adds raw data ms3d_ambient and ms3d_emissive custom properties to material, because blender does not have an exact similar color definition
fix: ms3d_spec, modelComment, only one comment is allowed and a modelComment does not have an index value
mod: dropped most of the DEBUG_... code
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 2011-12-04 12:05:56 UTC (rev 2719)
+++ contrib/py/scripts/addons/io_scene_ms3d/__README__.txt 2011-12-04 23:42:20 UTC (rev 2720)
@@ -73,7 +73,6 @@
- does not import bones
- does not import joints
- does not import keyframes
- - does not import comments (will never be supported - blender doesn't have similar stuff)
exporter issues:
- does only export the first existing material, if more than one material is used per mesh
@@ -92,7 +91,11 @@
changelog:
-changed: (0, 3, 3, "beta (2011-12-03 00:00)")
+changed: (0, 3, 4, "beta (2011-12-04 00:00)"),
+add: importer adds ms3d_comment custom properties for modelComment (to a blender empty), groupComments (to its blender meshes), materialComments (to its blender materials) and jointComments (to its blender bones)
+add: importer adds raw data ms3d_ambient and ms3d_emissive custom properties to material, because blender does not have an exact similar color definition
+fix: ms3d_spec, modelComment, only one comment is allowed and a modelComment does not have an index value
+mod: droped most of DEBUG_... code
mod: class __init__(self, ...) default parameter handling
mod: droped some tuple constructions: replaced with regular expression "tuple[(].*[[](.*)[]].*[)]" with "(\1)"
@@ -161,3 +164,23 @@
- open blender
- File | User Preferences | Addons | Import-Export
- enable "Import-Export: MilkShape3D MS3D format (.ms3d)"
+
+# To support reload properly, try to access a package var, if it's there, reload everything
+if ("bpy" in locals()):
+ import imp
+ #if "ms3d_export" in locals():
+ # imp.reload(ms3d_export)
+ #if "ms3d_import" in locals():
+ # imp.reload(ms3d_import)
+ #if "ms3d_spec" in locals():
+ # imp.reload(ms3d_spec)
+ #if "ms3d_utils" in locals():
+ # imp.reload(ms3d_utils)
+ pass
+
+else:
+ #from . import ms3d_export
+ #from . import ms3d_import
+ #from . import ms3d_spec
+ #from . import ms3d_utils
+ pass
Modified: contrib/py/scripts/addons/io_scene_ms3d/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__init__.py 2011-12-04 12:05:56 UTC (rev 2719)
+++ contrib/py/scripts/addons/io_scene_ms3d/__init__.py 2011-12-04 23:42:20 UTC (rev 2720)
@@ -37,19 +37,11 @@
imp.reload(ms3d_export)
if "ms3d_import" in locals():
imp.reload(ms3d_import)
- #if "ms3d_spec" in locals():
- # imp.reload(ms3d_spec)
- #if "ms3d_utils" in locals():
- # imp.reload(ms3d_utils)
- #print("__init__.MS3D-add-on Reloaded")
pass
else:
from . import ms3d_export
from . import ms3d_import
- #from . import ms3d_spec
- #from . import ms3d_utils
- #print("__init__.MS3D-add-on Imported")
pass
@@ -62,7 +54,7 @@
"name": "MilkShape3D MS3D format (.ms3d)",
"description": "Import / Export MilkShape3D MS3D files (conform with v1.8.4)",
"author": "Alexander Nussbaumer",
- "version": (0, 3, 3, "beta (2011-12-03 00:00)"),
+ "version": (0, 3, 4, "beta (2011-12-04 00:00)"),
"blender": (2, 6, 0),
"api": 41226,
"location": "File > Import-Export",
@@ -73,19 +65,9 @@
}
-#
-# DEBUG
-#
-def DEBUG_print(s):
- if (ms3d_utils._DEBUG):
- print("ms3d__init__.{0}".format(s))
- pass
-
-
###############################################################################
# registration
def menu_func_import(self, context):
- #DEBUG_print("menu_func_import")
self.layout.operator(
ms3d_import.ImportMS3D.bl_idname,
text = ms3d_utils.TEXT_OPERATOR
@@ -93,7 +75,6 @@
def menu_func_export(self, context):
- #DEBUG_print("menu_func_export")
self.layout.operator(
ms3d_export.ExportMS3D.bl_idname,
text = ms3d_utils.TEXT_OPERATOR
@@ -101,7 +82,6 @@
def register():
- #DEBUG_print("register build{0}".format(bl_info["version"]))
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_export.append(menu_func_export)
@@ -109,7 +89,6 @@
def unregister():
- #DEBUG_print("unregister")
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
@@ -119,7 +98,6 @@
###############################################################################
# global entry point
if (__name__ == "__main__"):
- #DEBUG_print("__name__ == __main__")
register()
Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py 2011-12-04 12:05:56 UTC (rev 2719)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py 2011-12-04 23:42:20 UTC (rev 2720)
@@ -42,23 +42,15 @@
# To support reload properly, try to access a package var, if it's there, reload everything
if ("bpy" in locals()):
import imp
- #if "ms3d_export" in locals():
- # imp.reload(ms3d_export)
- #if "ms3d_import" in locals():
- # imp.reload(ms3d_import)
if "ms3d_spec" in locals():
imp.reload(ms3d_spec)
if "ms3d_utils" in locals():
imp.reload(ms3d_utils)
- #print("ms3d_export.MS3D-add-on Reloaded")
pass
else:
- #from . import ms3d_export
- #from . import ms3d_import
from . import ms3d_spec
from . import ms3d_utils
- #print("ms3d_export.MS3D-add-on Imported")
pass
@@ -69,17 +61,6 @@
from bpy.props import *
-#
-# DEBUG
-#
-def DEBUG_print(s):
- if(ms3d_utils._DEBUG):
- print("ms3d_export.{0}".format(s))
- pass
-
-
-
-
# registered entry point export
class ExportMS3D(
bpy.types.Operator,
@@ -89,8 +70,6 @@
Save a MilkShape3D MS3D File
"""
- #DEBUG_print("ExportMS3D")
-
bl_idname = "io_scene_ms3d.ms3d_export"
bl_label = "Export MS3D"
bl_description = "Export to a MS3D file format (.ms3d)"
@@ -106,14 +85,6 @@
filepath = bpy.props.StringProperty(subtype='FILE_PATH')
-
- prop_debug = bpy.props.BoolProperty(
- name = ms3d_utils.PROP_NAME_DEBUG,
- description = ms3d_utils.PROP_DESC_DEBUG,
- default = ms3d_utils.PROP_DEFAULT_DEBUG,
- options = ms3d_utils.PROP_OPT_DEBUG,
- )
-
prop_verbose = bpy.props.BoolProperty(
name = ms3d_utils.PROP_NAME_VERBOSE,
description = ms3d_utils.PROP_DESC_VERBOSE,
@@ -180,12 +151,10 @@
"""
start executing
"""
- #DEBUG_print("ExportMS3D.execute")
return self.WriteMs3d(blenderContext)
#
def invoke(self, blenderContext, event):
- #DEBUG_print("ExportMS3D.invoke")
blenderContext.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}
@@ -196,7 +165,6 @@
"""
convert bender content to ms3d content and write it to file
"""
- #DEBUG_print("WriteMs3d")
t1 = time.time()
t2 = None
@@ -205,30 +173,21 @@
# setup environment
ms3d_utils.PreSetupEnvironment(self)
- #DEBUG_print("WriteMs3d - entering try block")
- #DEBUG_print(self.properties.filepath)
-
# create an empty ms3d template
ms3dTemplate = ms3d_spec.ms3d_file_t()
- #DEBUG_print("WriteMs3d - empty ms3d template created")
# inject blender data to ms3d file
- #DEBUG_print("WriteMs3d - traverse and inject blender data")
self.Ms3dFromBlender(blenderContext, ms3dTemplate)
- #DEBUG_print("WriteMs3d - data injected")
t2 = time.time()
# write ms3d file to disk
self.file = io.FileIO(self.filepath, "w")
- #DEBUG_print("WriteMs3d - file opend to write")
ms3dTemplate.write(self.file)
- #DEBUG_print("WriteMs3d - data written to file")
self.file.flush()
self.file.close()
- #DEBUG_print("WriteMs3d - file closed")
# finalize/restore environment
ms3d_utils.PostSetupEnvironment(self, False)
@@ -243,7 +202,6 @@
raise
else:
- #DEBUG_print("WriteMs3d - passed try block")
pass
t3 = time.time()
@@ -264,7 +222,6 @@
- interpreating a blender-mesh-objects as ms3d-group
- only one material allowed per group in ms3d, maybe sub-split a mesh in to material groups???
"""
- #DEBUG_print("Ms3dFromBlender")
blender = blenderContext.blend_data
@@ -369,7 +326,6 @@
tmpMaterial2 = ms3dMaterials[ms3dGroup.materialIndex]
if (tmpMaterial1.texture) and (not tmpMaterial2.texture):
tmpMaterial2.texture = tmpMaterial1.texture
- #print("inject texture")
# put group
ms3dGroups.append(ms3dGroup)
@@ -394,16 +350,6 @@
else:
continue
- #meshObjects = [o for o in blenderContext.scene.objects
- # if o.type in {TYPE_MESH}
- # and o.parent is None
- # and o.users > 0]
-
- #bones = [o for o in blenderContext.scene.objects
- # if o.type in {TYPE_ARMATURE}
- # and o.parent is None
- # and o.users > 0]
-
if (self.prop_verbose):
ms3dTemplate.print_internal()
@@ -414,9 +360,7 @@
print(statistics)
print("######################################################################")
- #DEBUG_print("Ms3dFromBlender #finished")
-
###############################################################################
def CreateMaterial(self, blenderMaterial, blenderUvLayer):
if (not blenderMaterial):
@@ -512,7 +456,6 @@
mathVector = mathVector * self.matrixSwapAxis
ms3dNormal = tuple(mathVector)
- #DEBUG_print("ms3dNormal: {0}".format(ms3dNormal))
return ms3dNormal
@@ -563,8 +506,6 @@
# it is any unhandled geometry
return None
- #DEBUG_print("tx={0}".format(tx))
-
# take blender-vertex from blender-mesh
# to get its vertex and normal coordinates
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list