Changeset View
Changeset View
Standalone View
Standalone View
io_scene_vrml2/__init__.py
| Show All 15 Lines | |||||
| # | # | ||||
| # ##### END GPL LICENSE BLOCK ##### | # ##### END GPL LICENSE BLOCK ##### | ||||
| # <pep8-80 compliant> | # <pep8-80 compliant> | ||||
| bl_info = { | bl_info = { | ||||
| "name": "VRML2 (Virtual Reality Modeling Language)", | "name": "VRML2 (Virtual Reality Modeling Language)", | ||||
| "author": "Campbell Barton", | "author": "Campbell Barton", | ||||
| "blender": (2, 74, 0), | "blender": (2, 80, 0), | ||||
| "location": "File > Export", | "location": "File > Export", | ||||
| "description": "Exports mesh objects to VRML2, supporting vertex and material colors", | "description": "Exports mesh objects to VRML2, supporting vertex and material colors", | ||||
| "warning": "", | "warning": "", | ||||
| "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" | "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" | ||||
| "Scripts/Import-Export/VRML2", | "Scripts/Import-Export/VRML2", | ||||
| "support": 'OFFICIAL', | "support": 'OFFICIAL', | ||||
| "category": "Import-Export"} | "category": "Import-Export"} | ||||
| Show All 22 Lines | |||||
| @orientation_helper(axis_forward='Z', axis_up='Y') | @orientation_helper(axis_forward='Z', axis_up='Y') | ||||
| class ExportVRML(bpy.types.Operator, ExportHelper): | class ExportVRML(bpy.types.Operator, ExportHelper): | ||||
| """Export mesh objects as a VRML2, colors and texture coordinates""" | """Export mesh objects as a VRML2, colors and texture coordinates""" | ||||
| bl_idname = "export_scene.vrml2" | bl_idname = "export_scene.vrml2" | ||||
| bl_label = "Export VRML2" | bl_label = "Export VRML2" | ||||
| filename_ext = ".wrl" | filename_ext = ".wrl" | ||||
| filter_glob = StringProperty(default="*.wrl", options={'HIDDEN'}) | filter_glob: StringProperty(default="*.wrl", options={'HIDDEN'}) | ||||
| use_selection = BoolProperty( | use_selection: BoolProperty( | ||||
| name="Selection Only", | name="Selection Only", | ||||
| description="Export selected objects only", | description="Export selected objects only", | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| use_mesh_modifiers = BoolProperty( | use_mesh_modifiers: BoolProperty( | ||||
| name="Apply Modifiers", | name="Apply Modifiers", | ||||
| description="Apply Modifiers to the exported mesh", | description="Apply Modifiers to the exported mesh", | ||||
| default=True, | default=True, | ||||
| ) | ) | ||||
| use_color = BoolProperty( | use_color: BoolProperty( | ||||
| name="Vertex Colors", | name="Vertex Colors", | ||||
| description="Export the active vertex color layer", | description="Export the active vertex color layer", | ||||
| default=True, | default=True, | ||||
| ) | ) | ||||
| color_type = EnumProperty( | color_type: EnumProperty( | ||||
| name='Color', | name='Color', | ||||
| items=( | items=( | ||||
| ('VERTEX', "Vertex Color", ""), | ('VERTEX', "Vertex Color", ""), | ||||
| ('MATERIAL', "Material Color", "")), | ('MATERIAL', "Material Color", "")), | ||||
| ) | ) | ||||
| use_uv = BoolProperty( | use_uv: BoolProperty( | ||||
| name="Texture/UVs", | name="Texture/UVs", | ||||
| description="Export the active texture and UV coords", | description="Export the active texture and UV coords", | ||||
| default=True, | default=True, | ||||
| ) | ) | ||||
| global_scale = FloatProperty( | global_scale: FloatProperty( | ||||
| name="Scale", | name="Scale", | ||||
| min=0.01, max=1000.0, | min=0.01, max=1000.0, | ||||
| default=1.0, | default=1.0, | ||||
| ) | ) | ||||
| path_mode = path_reference_mode | path_mode: path_reference_mode | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| obj = context.active_object | obj = context.active_object | ||||
| return (obj is not None) and obj.type == 'MESH' | return (obj is not None) and obj.type == 'MESH' | ||||
| def execute(self, context): | def execute(self, context): | ||||
| from . import export_vrml2 | from . import export_vrml2 | ||||
| from mathutils import Matrix | from mathutils import Matrix | ||||
| keywords = self.as_keywords(ignore=("axis_forward", | keywords = self.as_keywords(ignore=("axis_forward", | ||||
| "axis_up", | "axis_up", | ||||
| "global_scale", | "global_scale", | ||||
| "check_existing", | "check_existing", | ||||
| "filter_glob", | "filter_glob", | ||||
| )) | )) | ||||
| global_matrix = axis_conversion(to_forward=self.axis_forward, | global_matrix = axis_conversion(to_forward=self.axis_forward, | ||||
| to_up=self.axis_up, | to_up=self.axis_up, | ||||
| ).to_4x4() * Matrix.Scale(self.global_scale, 4) | ).to_4x4() @ Matrix.Scale(self.global_scale, 4) | ||||
| keywords["global_matrix"] = global_matrix | keywords["global_matrix"] = global_matrix | ||||
| filepath = self.filepath | filepath = self.filepath | ||||
| filepath = bpy.path.ensure_ext(filepath, self.filename_ext) | filepath = bpy.path.ensure_ext(filepath, self.filename_ext) | ||||
| return export_vrml2.save(self, context, **keywords) | return export_vrml2.save(self, context, **keywords) | ||||
| def draw(self, context): | def draw(self, context): | ||||
| Show All 14 Lines | def draw(self, context): | ||||
| layout.prop(self, "path_mode") | layout.prop(self, "path_mode") | ||||
| def menu_func_export(self, context): | def menu_func_export(self, context): | ||||
| self.layout.operator(ExportVRML.bl_idname, text="VRML2 (.wrl)") | self.layout.operator(ExportVRML.bl_idname, text="VRML2 (.wrl)") | ||||
| def register(): | def register(): | ||||
| bpy.utils.register_module(__name__) | bpy.utils.register_class(ExportVRML) | ||||
| bpy.types.TOPBAR_MT_file_export.append(menu_func_export) | bpy.types.TOPBAR_MT_file_export.append(menu_func_export) | ||||
| def unregister(): | def unregister(): | ||||
| bpy.utils.unregister_module(__name__) | bpy.utils.unregister_class(ExportVRML) | ||||
| bpy.types.TOPBAR_MT_file_export.remove(menu_func_export) | bpy.types.TOPBAR_MT_file_export.remove(menu_func_export) | ||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| register() | register() | ||||