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",
24 "blender": (2, 57, 0),
25 "location": "File > Import-Export",
26 "description": "Import-Export X3D, Import VRML2",
28 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
29 "Scripts/Import-Export/Web3D",
30 "support": 'OFFICIAL',
31 "category": "Import-Export"}
35 if "import_x3d" in locals():
36 imp
.reload(import_x3d
)
37 if "export_x3d" in locals():
38 imp
.reload(export_x3d
)
41 from bpy
.props
import StringProperty
, BoolProperty
, EnumProperty
, FloatProperty
42 from bpy_extras
.io_utils
import (ImportHelper
,
49 class ImportX3D(bpy
.types
.Operator
, ImportHelper
):
50 """Import an X3D or VRML2 file"""
51 bl_idname
= "import_scene.x3d"
52 bl_label
= "Import X3D/VRML2"
53 bl_options
= {'PRESET', 'UNDO'}
56 filter_glob
= StringProperty(default
="*.x3d;*.wrl", options
={'HIDDEN'})
58 axis_forward
= EnumProperty(
60 items
=(('X', "X Forward", ""),
61 ('Y', "Y Forward", ""),
62 ('Z', "Z Forward", ""),
63 ('-X', "-X Forward", ""),
64 ('-Y', "-Y Forward", ""),
65 ('-Z', "-Z Forward", ""),
70 axis_up
= EnumProperty(
72 items
=(('X', "X Up", ""),
82 def execute(self
, context
):
83 from . import import_x3d
85 keywords
= self
.as_keywords(ignore
=("axis_forward",
89 global_matrix
= axis_conversion(from_forward
=self
.axis_forward
,
92 keywords
["global_matrix"] = global_matrix
94 return import_x3d
.load(self
, context
, **keywords
)
97 class ExportX3D(bpy
.types
.Operator
, ExportHelper
):
98 """Export selection to Extensible 3D file (.x3d)"""
99 bl_idname
= "export_scene.x3d"
100 bl_label
= 'Export X3D'
101 bl_options
= {'PRESET'}
103 filename_ext
= ".x3d"
104 filter_glob
= StringProperty(default
="*.x3d", options
={'HIDDEN'})
106 use_selection
= BoolProperty(
107 name
="Selection Only",
108 description
="Export selected objects only",
111 use_mesh_modifiers
= BoolProperty(
112 name
="Apply Modifiers",
113 description
="Use transformed mesh data from each object",
116 use_triangulate
= BoolProperty(
118 description
="Write quads into 'IndexedTriangleSet'",
121 use_normals
= BoolProperty(
123 description
="Write normals with geometry",
126 use_compress
= BoolProperty(
128 description
="Compress the exported file",
131 use_hierarchy
= BoolProperty(
133 description
="Export parent child relationships",
136 name_decorations
= BoolProperty(
137 name
="Name decorations",
138 description
=("Add prefixes to the names of exported nodes to "
139 "indicate their type"),
142 use_h3d
= BoolProperty(
143 name
="H3D Extensions",
144 description
="Export shaders for H3D",
148 axis_forward
= EnumProperty(
150 items
=(('X', "X Forward", ""),
151 ('Y', "Y Forward", ""),
152 ('Z', "Z Forward", ""),
153 ('-X', "-X Forward", ""),
154 ('-Y', "-Y Forward", ""),
155 ('-Z', "-Z Forward", ""),
159 axis_up
= EnumProperty(
161 items
=(('X', "X Up", ""),
170 global_scale
= FloatProperty(
172 min=0.01, max=1000.0,
176 path_mode
= path_reference_mode
178 def execute(self
, context
):
179 from . import export_x3d
181 from mathutils
import Matrix
183 keywords
= self
.as_keywords(ignore
=("axis_forward",
189 global_matrix
= axis_conversion(to_forward
=self
.axis_forward
,
191 ).to_4x4() * Matrix
.Scale(self
.global_scale
, 4)
192 keywords
["global_matrix"] = global_matrix
194 return export_x3d
.save(self
, context
, **keywords
)
197 def menu_func_import(self
, context
):
198 self
.layout
.operator(ImportX3D
.bl_idname
,
199 text
="X3D Extensible 3D (.x3d/.wrl)")
202 def menu_func_export(self
, context
):
203 self
.layout
.operator(ExportX3D
.bl_idname
,
204 text
="X3D Extensible 3D (.x3d)")
208 bpy
.utils
.register_module(__name__
)
210 bpy
.types
.INFO_MT_file_import
.append(menu_func_import
)
211 bpy
.types
.INFO_MT_file_export
.append(menu_func_export
)
215 bpy
.utils
.unregister_module(__name__
)
217 bpy
.types
.INFO_MT_file_import
.remove(menu_func_import
)
218 bpy
.types
.INFO_MT_file_export
.remove(menu_func_export
)
221 # - blender version is hardcoded
223 if __name__
== "__main__":