-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path__init__.py
More file actions
148 lines (111 loc) · 4.04 KB
/
__init__.py
File metadata and controls
148 lines (111 loc) · 4.04 KB
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
bl_info = {
"name": "Glacier 2 Engine Tools",
"description": "Tools for the Glacier 2 Engine",
"version": (0, 7, 2),
"blender": (3, 0, 0),
"doc_url": "https://glaciermodding.org/docs/blender/",
"tracker_url": "https://github.com/glacier-modding/io_scene_glacier/issues",
"category": "Import-Export",
}
import bpy
from . import file_prim
from . import file_aloc
from . import file_mjba
from . import file_borg
from bpy.props import (
BoolVectorProperty,
PointerProperty,
)
from bpy.types import (
PropertyGroup,
)
# ------------------------------------------------------------------------
# Scene Properties
# ------------------------------------------------------------------------
class GlacierSettings(PropertyGroup):
def show_lod_update(self, context):
mesh_obs = [o for o in bpy.context.scene.objects if o.type == "MESH"]
for obj in mesh_obs:
should_show = False
for bit in range(8):
if self.show_lod[bit]:
if obj.data.prim_properties.lod[bit] == self.show_lod[bit]:
should_show = True
obj.hide_set(not should_show)
return None
show_lod: BoolVectorProperty(
name="show_lod",
description="Set which LOD levels should be shown",
default=(True, True, True, True, True, True, True, True),
size=8,
subtype="LAYER",
update=show_lod_update,
)
def show_collision_type_update(self, context):
mesh_obs = [o for o in bpy.context.scene.objects if o.type == "MESH"]
for obj in mesh_obs:
should_show = False
for bit in range(6):
if self.show_collision_type[bit]:
if obj.data.aloc_properties.collision_type[bit] == self.show_collision_type[bit]:
should_show = True
obj.hide_set(not should_show)
return None
show_collision_type: BoolVectorProperty(
name="show_collision_type",
description="Set which Collision types should be shown",
default=(True, True, True, True, True, True),
size=6,
subtype="LAYER",
update=show_collision_type_update,
)
# ------------------------------------------------------------------------
# Panels
# ------------------------------------------------------------------------
class GLACIER_PT_settingsPanel(bpy.types.Panel):
bl_idname = "GLACIER_PT_settingsPanel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Glacier"
bl_label = "Settings"
def draw(self, context):
glacier_settings = context.scene.glacier_settings
layout = self.layout
layout.label(text="show LOD:")
row = layout.row(align=True)
for i, name in enumerate(
["high", " ", " ", " ", " ", " ", " ", "low"]
):
row.prop(glacier_settings, "show_lod", index=i, text=name, toggle=True)
layout.label(text="show Collision Types:")
row = layout.row(align=True)
for i, name in enumerate(
["N", "S", "R", "ShL", "KiL", "BC"]
):
row.prop(glacier_settings, "show_collision_type", index=i, text=name, toggle=True)
# ------------------------------------------------------------------------
# Registration
# ------------------------------------------------------------------------
classes = [GlacierSettings, GLACIER_PT_settingsPanel]
modules = [
file_prim,
file_aloc,
# file_mjba, # WIP module. enable at own risk
file_borg,
]
def register():
from bpy.utils import register_class
for module in modules:
module.register()
for cls in classes:
register_class(cls)
bpy.types.Scene.glacier_settings = PointerProperty(type=GlacierSettings)
def unregister():
from bpy.utils import unregister_class
for module in reversed(modules):
module.unregister()
for cls in classes:
unregister_class(cls)
del bpy.types.Scene.glacier_settings
if __name__ == "__main__":
register()