-
Notifications
You must be signed in to change notification settings - Fork 2
/
__init__.py
188 lines (136 loc) · 5.66 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import bpy
import os
from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
from bpy_extras.io_utils import ExportHelper, ImportHelper
bl_info = {
"name": "SM256e",
"author": "Josh65536",
"blender": (2, 7, 9),
"description": ("Adds tools for Super Mario 256 development"),
"category": "Import-Export"}
if "bpy" in locals():
import importlib
if "export_bmd" in locals():
importlib.reload(export_bmd) # noqa
class ImportBMD(bpy.types.Operator, ImportHelper):
bl_idname = "import_scene.bmd"
bl_label = "Import BMD"
bl_options = {"PRESET"}
filename_ext = ".bmd"
filter_glob = StringProperty(default="*.bmd", options={"HIDDEN"})
@property
def check_extension(self):
return True
def execute(self, context):
if not self.filepath:
raise Exception("filepath not set")
from . import import_bmd
return import_bmd.load(context, self.filepath)
class ExportBMD(bpy.types.Operator, ExportHelper):
"""Selection to BMD"""
bl_idname = "export_scene.bmd"
bl_label = "Export BMD"
bl_options = {"PRESET"}
filename_ext = ".bmd"
filter_glob = StringProperty(default="*.bmd", options={"HIDDEN"})
sm256 = BoolProperty(name="SM256-specific BMD",
description="Export a SM256-specific BMD, which includes range and range offset Y",
default="SM256_ROOT" in os.environ)
@property
def check_extension(self):
return True
def execute(self, context):
if not self.filepath:
raise Exception("filepath not set")
keywords = self.as_keywords(ignore=("axis_forward",
"axis_up",
"global_scale",
"check_existing",
"filter_glob",
"xna_validate",
))
from . import export_bmd
return export_bmd.save(context, **keywords)
class ExportBCA(bpy.types.Operator, ExportHelper):
"""Selection to BCA"""
bl_idname = "export_scene.bca"
bl_label = "Export BCA"
bl_options = {"PRESET"}
filename_ext = ".bca"
filter_glob = StringProperty(default="*.bca", options={"HIDDEN"})
@property
def check_extension(self):
return True
def execute(self, context):
if not self.filepath:
raise Exception("filepath not set")
from . import export_bca
return export_bca.save(context, self.filepath)
class ImportKCL(bpy.types.Operator, ImportHelper):
bl_idname = "import_scene.kcl"
bl_label = "Import KCL (Debug only!)"
bl_options = {"PRESET"}
filename_ext = ".kcl"
filter_glob = StringProperty(default="*.kcl", options={"HIDDEN"})
@property
def check_extension(self):
return True
def execute(self, context):
if not self.filepath:
raise Exception("filepath not set")
from . import import_kcl
return import_kcl.load(context, self.filepath)
class ExportKCL(bpy.types.Operator, ExportHelper):
"""Selection to KCL"""
bl_idname = "export_scene.kcl"
bl_label = "Export KCL"
bl_options = {"PRESET"}
filename_ext = ".kcl"
filter_glob = StringProperty(default="*.kcl", options={"HIDDEN"})
scale = FloatProperty(name="Scale",
description="Factor to scale the model by",
default=1.0)
one_clps_index = BoolProperty(name="Use CLPS index 0",
description="Have all faces use CLPS index 0",
default=False)
@property
def check_extension(self):
return True
def execute(self, context):
if not self.filepath:
raise Exception("filepath not set")
keywords = self.as_keywords(ignore=("axis_forward",
"axis_up",
"global_scale",
"check_existing",
"filter_glob",
"xna_validate",
))
from . import export_kcl
return export_kcl.save(context, **keywords)
def export_menu_func(self, context):
self.layout.operator(ExportBMD.bl_idname, text="NDS Binary Model Format (.bmd)")
def import_menu_func(self, context):
self.layout.operator(ImportBMD.bl_idname, text="NDS Binary Model Format (.bmd)")
def export_bca_menu_func(self, context):
self.layout.operator(ExportBCA.bl_idname, text="NDS Binary Character Animation (.bca)")
def export_kcl_menu_func(self, context):
self.layout.operator(ExportKCL.bl_idname, text="NDS K. Collision Format (.kcl)")
def import_kcl_menu_func(self, context):
self.layout.operator(ImportKCL.bl_idname, text="NDS K. Collision Format (.kcl)")
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_import.append(import_menu_func)
bpy.types.INFO_MT_file_export.append(export_menu_func)
bpy.types.INFO_MT_file_export.append(export_bca_menu_func)
bpy.types.INFO_MT_file_import.append(import_kcl_menu_func)
bpy.types.INFO_MT_file_export.append(export_kcl_menu_func)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_import.remove(import_menu_func)
bpy.types.INFO_MT_file_export.remove(export_menu_func)
bpy.types.INFO_MT_file_export.remove(export_bca_menu_func)
bpy.types.INFO_MT_file_import.remove(import_kcl_menu_func)
bpy.types.INFO_MT_file_export.remove(export_kcl_menu_func)
if __name__ == "__main__":
register()