diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-12 11:32:25 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-12 11:32:25 +0400 |
commit | 7658df0733d75fa96a3838b53ff60c9a0d29c5bd (patch) | |
tree | d7d9eeafb8eaedfedca4620b8455fc9e78fdaebd | |
parent | 11c7855371439e85bd8b6fbfb4329e8eed6bd585 (diff) |
add axis conversion to wrl export.
-rw-r--r-- | io_scene_vrml2/__init__.py | 39 | ||||
-rw-r--r-- | io_scene_vrml2/export_vrml2.py | 9 | ||||
-rw-r--r-- | io_scene_x3d/__init__.py | 1 |
3 files changed, 43 insertions, 6 deletions
diff --git a/io_scene_vrml2/__init__.py b/io_scene_vrml2/__init__.py index 977df531..470bc8b0 100644 --- a/io_scene_vrml2/__init__.py +++ b/io_scene_vrml2/__init__.py @@ -40,7 +40,7 @@ if "bpy" in locals(): import os import bpy from bpy.props import CollectionProperty, StringProperty, BoolProperty, EnumProperty -from bpy_extras.io_utils import ExportHelper, path_reference_mode +from bpy_extras.io_utils import ExportHelper, path_reference_mode, axis_conversion class ExportVRML(bpy.types.Operator, ExportHelper): """Export mesh objects as a VRML2, """ \ @@ -80,6 +80,29 @@ class ExportVRML(bpy.types.Operator, ExportHelper): default=True, ) + axis_forward = EnumProperty( + name="Forward", + items=(('X', "X Forward", ""), + ('Y', "Y Forward", ""), + ('Z', "Z Forward", ""), + ('-X', "-X Forward", ""), + ('-Y', "-Y Forward", ""), + ('-Z', "-Z Forward", ""), + ), + default='Z', + ) + axis_up = EnumProperty( + name="Up", + items=(('X', "X Up", ""), + ('Y', "Y Up", ""), + ('Z', "Z Up", ""), + ('-X', "-X Up", ""), + ('-Y', "-Y Up", ""), + ('-Z', "-Z Up", ""), + ), + default='Y', + ) + path_mode = path_reference_mode @classmethod @@ -91,7 +114,17 @@ class ExportVRML(bpy.types.Operator, ExportHelper): filepath = self.filepath filepath = bpy.path.ensure_ext(filepath, self.filename_ext) from . import export_vrml2 - keywords = self.as_keywords(ignore=("check_existing", "filter_glob")) + + keywords = self.as_keywords(ignore=("axis_forward", + "axis_up", + "check_existing", + "filter_glob", + )) + global_matrix = axis_conversion(to_forward=self.axis_forward, + to_up=self.axis_up, + ).to_4x4() + keywords["global_matrix"] = global_matrix + return export_vrml2.save(self, context, **keywords) def draw(self, context): @@ -106,6 +139,8 @@ class ExportVRML(bpy.types.Operator, ExportHelper): row = layout.row() row.active = self.use_color row.prop(self, "color_type") + layout.prop(self, "axis_forward") + layout.prop(self, "axis_up") layout.prop(self, "path_mode") diff --git a/io_scene_vrml2/export_vrml2.py b/io_scene_vrml2/export_vrml2.py index a3370a3a..50230bc2 100644 --- a/io_scene_vrml2/export_vrml2.py +++ b/io_scene_vrml2/export_vrml2.py @@ -165,7 +165,8 @@ def detect_default_image(obj, bm): return None -def save_object(fw, scene, obj, +def save_object(fw, global_matrix, + scene, obj, use_mesh_modifiers, use_color, color_type, use_uv, @@ -193,7 +194,7 @@ def save_object(fw, scene, obj, bm = bmesh.new() bm.from_mesh(me) - bm.transform(obj.matrix_world) + bm.transform(global_matrix * obj.matrix_world) bmesh.ops.triangulate(bm, faces=bm.faces, use_beauty=True) # default empty @@ -232,6 +233,7 @@ def save_object(fw, scene, obj, def save(operator, context, filepath="", + global_matrix=None, use_selection=False, use_mesh_modifiers=True, use_color=True, @@ -257,7 +259,8 @@ def save(operator, for obj in objects: if obj.type == 'MESH': fw("\n# %r\n" % obj.name) - save_object(fw, scene, obj, + save_object(fw, global_matrix, + scene, obj, use_mesh_modifiers, use_color, color_type, use_uv, diff --git a/io_scene_x3d/__init__.py b/io_scene_x3d/__init__.py index 6bf64017..f87bd428 100644 --- a/io_scene_x3d/__init__.py +++ b/io_scene_x3d/__init__.py @@ -157,7 +157,6 @@ class ExportX3D(bpy.types.Operator, ExportHelper): ), default='Z', ) - axis_up = EnumProperty( name="Up", items=(('X', "X Up", ""), |