1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
22 "name": "Web3D X3D/VRML2 format",
23 "author": "Campbell Barton, Bart, Bastien Montagne, Seva Alekseyev",
25 "blender": (2, 76, 0),
26 "location": "File > Import-Export",
27 "description": "Import-Export X3D, Import VRML2",
29 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Web3D",
30 "support": 'OFFICIAL',
31 "category": "Import-Export",
36 if "import_x3d" in locals():
37 importlib
.reload(import_x3d
)
38 if "export_x3d" in locals():
39 importlib
.reload(export_x3d
)
42 from bpy
.props
import (
48 from bpy_extras
.io_utils
import (
51 orientation_helper_factory
,
57 IOX3DOrientationHelper
= orientation_helper_factory("IOX3DOrientationHelper", axis_forward
='Z', axis_up
='Y')
60 class ImportX3D(bpy
.types
.Operator
, ImportHelper
, IOX3DOrientationHelper
):
61 """Import an X3D or VRML2 file"""
62 bl_idname
= "import_scene.x3d"
63 bl_label
= "Import X3D/VRML2"
64 bl_options
= {'PRESET', 'UNDO'}
67 filter_glob
= StringProperty(default
="*.x3d;*.wrl", options
={'HIDDEN'})
69 def execute(self
, context
):
70 from . import import_x3d
72 keywords
= self
.as_keywords(ignore
=("axis_forward",
76 global_matrix
= axis_conversion(from_forward
=self
.axis_forward
,
79 keywords
["global_matrix"] = global_matrix
81 return import_x3d
.load(context
, **keywords
)
84 class ExportX3D(bpy
.types
.Operator
, ExportHelper
, IOX3DOrientationHelper
):
85 """Export selection to Extensible 3D file (.x3d)"""
86 bl_idname
= "export_scene.x3d"
87 bl_label
= 'Export X3D'
88 bl_options
= {'PRESET'}
91 filter_glob
= StringProperty(default
="*.x3d", options
={'HIDDEN'})
93 use_selection
= BoolProperty(
94 name
="Selection Only",
95 description
="Export selected objects only",
98 use_mesh_modifiers
= BoolProperty(
99 name
="Apply Modifiers",
100 description
="Use transformed mesh data from each object",
103 use_triangulate
= BoolProperty(
105 description
="Write quads into 'IndexedTriangleSet'",
108 use_normals
= BoolProperty(
110 description
="Write normals with geometry",
113 use_compress
= BoolProperty(
115 description
="Compress the exported file",
118 use_hierarchy
= BoolProperty(
120 description
="Export parent child relationships",
123 name_decorations
= BoolProperty(
124 name
="Name decorations",
125 description
=("Add prefixes to the names of exported nodes to "
126 "indicate their type"),
129 use_h3d
= BoolProperty(
130 name
="H3D Extensions",
131 description
="Export shaders for H3D",
135 global_scale
= FloatProperty(
137 min=0.01, max=1000.0,
141 path_mode
= path_reference_mode
143 def execute(self
, context
):
144 from . import export_x3d
146 from mathutils
import Matrix
148 keywords
= self
.as_keywords(ignore
=("axis_forward",
154 global_matrix
= axis_conversion(to_forward
=self
.axis_forward
,
156 ).to_4x4() * Matrix
.Scale(self
.global_scale
, 4)
157 keywords
["global_matrix"] = global_matrix
159 return export_x3d
.save(context
, **keywords
)
162 def menu_func_import(self
, context
):
163 self
.layout
.operator(ImportX3D
.bl_idname
,
164 text
="X3D Extensible 3D (.x3d/.wrl)")
167 def menu_func_export(self
, context
):
168 self
.layout
.operator(ExportX3D
.bl_idname
,
169 text
="X3D Extensible 3D (.x3d)")
173 bpy
.utils
.register_module(__name__
)
175 bpy
.types
.INFO_MT_file_import
.append(menu_func_import
)
176 bpy
.types
.INFO_MT_file_export
.append(menu_func_export
)
180 bpy
.utils
.unregister_module(__name__
)
182 bpy
.types
.INFO_MT_file_import
.remove(menu_func_import
)
183 bpy
.types
.INFO_MT_file_export
.remove(menu_func_export
)
186 # - blender version is hardcoded
188 if __name__
== "__main__":