Mercurial > touhou-blender
annotate io_scene_touhou/__init__.py @ 0:8265ef6db380
Hello Gensokyo _o/
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 05 Mar 2013 20:10:10 +0100 |
parents | |
children |
rev | line source |
---|---|
0
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 # ##### BEGIN GPL LICENSE BLOCK ##### |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 # |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 # This program is free software; you can redistribute it and/or |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 # modify it under the terms of the GNU General Public License |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 # as published by the Free Software Foundation; either version 2 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 # of the License, or (at your option) any later version. |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 # |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 # This program is distributed in the hope that it will be useful, |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 # GNU General Public License for more details. |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 # |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 # You should have received a copy of the GNU General Public License |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 # along with this program; if not, write to the Free Software Foundation, |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 # |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 # ##### END GPL LICENSE BLOCK ##### |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 # <pep8-80 compliant> |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 bl_info = { |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 "name": "Touhou stage format (.std)", |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 "author": "Emmanuel Gil Peyrot", |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 "version": (0, 0), |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 "blender": (2, 66, 0), |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 "location": "File > Import-Export > Touhou Stage (.std) ", |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 "description": "Import-Export Touhou Stage", |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 "warning": "", |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 "Scripts/Import-Export/Raw_Mesh_IO", |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 "tracker_url": "https://projects.blender.org/tracker/index.php?" |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 "func=detail&aid=25692", |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 "category": "Import-Export"} |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 if "bpy" in locals(): |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 import imp |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 if "import_std" in locals(): |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 imp.reload(import_std) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 else: |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 import bpy |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 from bpy.props import StringProperty |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 class StageImporter(bpy.types.Operator): |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 """Load Touhou triangle mesh data""" |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 bl_idname = "import_mesh.std" |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 bl_label = "Import Touhou" |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 bl_options = {'UNDO'} |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 filepath = StringProperty( |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 subtype='FILE_PATH', |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 ) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 filter_glob = StringProperty(default="stage*.std", options={'HIDDEN'}) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 def execute(self, context): |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 from . import import_std |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 import_std.read(self.filepath) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 return {'FINISHED'} |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 def invoke(self, context, event): |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
63 wm = context.window_manager |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 wm.fileselect_add(self) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 return {'RUNNING_MODAL'} |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
66 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
67 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 def menu_import(self, context): |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 self.layout.operator(StageImporter.bl_idname, text="Touhou Stage (.std)") |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
70 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
71 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 def register(): |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
73 bpy.utils.register_module(__name__) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 bpy.types.INFO_MT_file_import.append(menu_import) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
75 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
76 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
77 def unregister(): |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
78 bpy.utils.unregister_module(__name__) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
79 bpy.types.INFO_MT_file_import.remove(menu_import) |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 if __name__ == "__main__": |
8265ef6db380
Hello Gensokyo _o/
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
82 register() |