mirror of https://github.com/AxioDL/metaforce.git
naming corrections
This commit is contained in:
parent
b941440418
commit
20ca4e407f
|
@ -20,7 +20,7 @@ from bpy.app.handlers import persistent
|
||||||
# Appendable list allowing external addons to register additional resource types
|
# Appendable list allowing external addons to register additional resource types
|
||||||
hecl_export_types = [
|
hecl_export_types = [
|
||||||
('NONE', "None", "Active scene not using HECL", None, None),
|
('NONE', "None", "Active scene not using HECL", None, None),
|
||||||
('MESH', "Mesh", "Active scene represents an RWK Mesh", hmdl.panel_draw, hmdl.cook)]
|
('MESH', "Mesh", "Active scene represents an HMDL Mesh", hmdl.panel_draw, hmdl.cook)]
|
||||||
|
|
||||||
# Main Scene Panel
|
# Main Scene Panel
|
||||||
class hecl_scene_panel(bpy.types.Panel):
|
class hecl_scene_panel(bpy.types.Panel):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
'''
|
'''
|
||||||
RMDL Export Blender Addon
|
HMDL Export Blender Addon
|
||||||
By Jack Andersen <jackoalan@gmail.com>
|
By Jack Andersen <jackoalan@gmail.com>
|
||||||
|
|
||||||
This file provides a means to encode animation key-channels
|
This file provides a means to encode animation key-channels
|
||||||
|
@ -55,8 +55,8 @@ def generate_animation_info(action, res_db, rani_db_id, arg_package, endian_char
|
||||||
# Relate fcurves per-frame / per-bone and assemble data
|
# Relate fcurves per-frame / per-bone and assemble data
|
||||||
key_stream = bytearray()
|
key_stream = bytearray()
|
||||||
key_stream += struct.pack(endian_char + 'II', len(frame_set), len(bone_set))
|
key_stream += struct.pack(endian_char + 'II', len(frame_set), len(bone_set))
|
||||||
duration = action.frame_range[1] / action.rwk_fps
|
duration = action.frame_range[1] / action.hecl_fps
|
||||||
interval = 1.0 / action.rwk_fps
|
interval = 1.0 / action.hecl_fps
|
||||||
key_stream += struct.pack(endian_char + 'ff', duration, interval)
|
key_stream += struct.pack(endian_char + 'ff', duration, interval)
|
||||||
|
|
||||||
# Generate keyframe bitmap
|
# Generate keyframe bitmap
|
||||||
|
@ -164,12 +164,12 @@ def generate_animation_info(action, res_db, rani_db_id, arg_package, endian_char
|
||||||
|
|
||||||
# Generate event buffer
|
# Generate event buffer
|
||||||
event_buf = bytearray()
|
event_buf = bytearray()
|
||||||
if hasattr(action, 'rwk_events'):
|
if hasattr(action, 'hecl_events'):
|
||||||
c1 = 0
|
c1 = 0
|
||||||
c2 = 0
|
c2 = 0
|
||||||
c3 = 0
|
c3 = 0
|
||||||
c4 = 0
|
c4 = 0
|
||||||
for event in action.rwk_events:
|
for event in action.hecl_events:
|
||||||
if event.type == 'LOOP':
|
if event.type == 'LOOP':
|
||||||
c1 += 1
|
c1 += 1
|
||||||
elif event.type == 'UEVT':
|
elif event.type == 'UEVT':
|
||||||
|
@ -180,16 +180,16 @@ def generate_animation_info(action, res_db, rani_db_id, arg_package, endian_char
|
||||||
c4 += 1
|
c4 += 1
|
||||||
event_buf += struct.pack(endian_char + 'IIII', c1, c2, c3, c4)
|
event_buf += struct.pack(endian_char + 'IIII', c1, c2, c3, c4)
|
||||||
|
|
||||||
for event in action.rwk_events:
|
for event in action.hecl_events:
|
||||||
if event.type == 'LOOP':
|
if event.type == 'LOOP':
|
||||||
event_buf += struct.pack(endian_char + 'fi', event.time, event.loop_data.bool)
|
event_buf += struct.pack(endian_char + 'fi', event.time, event.loop_data.bool)
|
||||||
|
|
||||||
for event in action.rwk_events:
|
for event in action.hecl_events:
|
||||||
if event.type == 'UEVT':
|
if event.type == 'UEVT':
|
||||||
event_buf += struct.pack(endian_char + 'fii', event.time, event.uevt_data.type,
|
event_buf += struct.pack(endian_char + 'fii', event.time, event.uevt_data.type,
|
||||||
hashbone(event.uevt_data.bone_name))
|
hashbone(event.uevt_data.bone_name))
|
||||||
|
|
||||||
for event in action.rwk_events:
|
for event in action.hecl_events:
|
||||||
if event.type == 'EFFECT':
|
if event.type == 'EFFECT':
|
||||||
effect_db_id, effect_hash = res_db.search_for_resource(event.effect_data.uid, arg_package)
|
effect_db_id, effect_hash = res_db.search_for_resource(event.effect_data.uid, arg_package)
|
||||||
if effect_hash:
|
if effect_hash:
|
||||||
|
@ -201,7 +201,7 @@ def generate_animation_info(action, res_db, rani_db_id, arg_package, endian_char
|
||||||
EFFECT_XF_MODES[event.effect_data.transform_mode])
|
EFFECT_XF_MODES[event.effect_data.transform_mode])
|
||||||
event_buf += effect_hash
|
event_buf += effect_hash
|
||||||
|
|
||||||
for event in action.rwk_events:
|
for event in action.hecl_events:
|
||||||
if event.type == 'SOUND':
|
if event.type == 'SOUND':
|
||||||
sid = int.from_bytes(event.sound_data.sound_id.encode()[:4], byteorder='big', signed=False)
|
sid = int.from_bytes(event.sound_data.sound_id.encode()[:4], byteorder='big', signed=False)
|
||||||
event_buf += struct.pack(endian_char + 'fIff', event.time, sid,
|
event_buf += struct.pack(endian_char + 'fIff', event.time, sid,
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
'''
|
'''
|
||||||
RMDL Export Blender Addon
|
HMDL Export Blender Addon
|
||||||
By Jack Andersen <jackoalan@gmail.com>
|
By Jack Andersen <jackoalan@gmail.com>
|
||||||
|
|
||||||
This file defines the `rmdl_draw_general` class to generate vertex+index
|
|
||||||
buffers and mesh arrays to draw them. `PAR1` files also include bone-weight
|
|
||||||
coefficients per-vertex for vertex-shader-driven skeletal evaluation.
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
|
@ -105,11 +101,11 @@ def _find_polygon_opposite_lvs(mesh, original_triangle, lv_a, lv_b):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class rmdl_mesh:
|
class hmdl_mesh:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
# 4-byte ID string used in generated RMDL file
|
# 4-byte ID string used in generated HMDL file
|
||||||
self.file_identifier = '_GEN'
|
self.file_identifier = '_GEN'
|
||||||
|
|
||||||
# Array that holds collections. A collection is a 16-bit index
|
# Array that holds collections. A collection is a 16-bit index
|
||||||
|
@ -486,10 +482,10 @@ class rmdl_mesh:
|
||||||
|
|
||||||
# C-generation operator
|
# C-generation operator
|
||||||
import bmesh
|
import bmesh
|
||||||
class rmdl_mesh_operator(bpy.types.Operator):
|
class hmdl_mesh_operator(bpy.types.Operator):
|
||||||
bl_idname = "scene.rmdl_mesh"
|
bl_idname = "scene.hmdl_mesh"
|
||||||
bl_label = "RMDL C mesh maker"
|
bl_label = "HMDL C mesh maker"
|
||||||
bl_description = "RMDL Mesh source generation utility"
|
bl_description = "HMDL Mesh source generation utility"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
|
@ -512,7 +508,7 @@ class rmdl_mesh_operator(bpy.types.Operator):
|
||||||
bm.free()
|
bm.free()
|
||||||
|
|
||||||
context.scene.objects.link(copy_obj)
|
context.scene.objects.link(copy_obj)
|
||||||
rmesh = rmdl_mesh()
|
rmesh = hmdl_mesh()
|
||||||
rmesh.add_mesh(copy_mesh, None, 0)
|
rmesh.add_mesh(copy_mesh, None, 0)
|
||||||
|
|
||||||
str_out = '/* Vertex Buffer */\nstatic const float VERT_BUF[] = {\n'
|
str_out = '/* Vertex Buffer */\nstatic const float VERT_BUF[] = {\n'
|
||||||
|
@ -533,51 +529,3 @@ class rmdl_mesh_operator(bpy.types.Operator):
|
||||||
self.report({'INFO'}, "Wrote mesh C to clipboard")
|
self.report({'INFO'}, "Wrote mesh C to clipboard")
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
# 2D C-generation operator
|
|
||||||
import bmesh
|
|
||||||
class rmdl_mesh2d_operator(bpy.types.Operator):
|
|
||||||
bl_idname = "scene.rmdl_mesh2d"
|
|
||||||
bl_label = "RMDL C 2D mesh maker"
|
|
||||||
bl_description = "RMDL 2D Mesh source generation utility"
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return context.object and context.object.type == 'MESH'
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
copy_mesh = context.object.data.copy()
|
|
||||||
copy_obj = context.object.copy()
|
|
||||||
copy_obj.data = copy_mesh
|
|
||||||
|
|
||||||
bm = bmesh.new()
|
|
||||||
bm.from_mesh(copy_mesh)
|
|
||||||
bmesh.ops.triangulate(bm, faces=bm.faces)
|
|
||||||
#to_remove = []
|
|
||||||
#for face in bm.faces:
|
|
||||||
# if face.material_index != 7:
|
|
||||||
# to_remove.append(face)
|
|
||||||
#bmesh.ops.delete(bm, geom=to_remove, context=5)
|
|
||||||
bm.to_mesh(copy_mesh)
|
|
||||||
bm.free()
|
|
||||||
|
|
||||||
context.scene.objects.link(copy_obj)
|
|
||||||
rmesh = rmdl_mesh()
|
|
||||||
rmesh.add_mesh(copy_mesh, None, 0)
|
|
||||||
|
|
||||||
str_out = '/* Vertex Buffer */\nstatic const float VERT_BUF[] = {\n'
|
|
||||||
vert_arr = rmesh.generate_vertex_buffer(0, '<')[3]
|
|
||||||
for v in vert_arr:
|
|
||||||
str_out += ' %f, %f,\n' % (v[0][0], v[0][2])
|
|
||||||
ebuf_arr = rmesh.generate_element_buffer(0, '<')[2]
|
|
||||||
str_out += '};\n\n/* Element Buffer */\n#define ELEM_BUF_COUNT %d\nstatic const u16 ELEM_BUF[] = {\n' % len(ebuf_arr)
|
|
||||||
for e in ebuf_arr:
|
|
||||||
str_out += ' %d,\n' % e
|
|
||||||
str_out += '};\n'
|
|
||||||
|
|
||||||
context.scene.objects.unlink(copy_obj)
|
|
||||||
bpy.data.objects.remove(copy_obj)
|
|
||||||
bpy.data.meshes.remove(copy_mesh)
|
|
||||||
|
|
||||||
context.window_manager.clipboard = str_out
|
|
||||||
self.report({'INFO'}, "Wrote mesh C to clipboard")
|
|
||||||
return {'FINISHED'}
|
|
||||||
|
|
|
@ -38,12 +38,12 @@ def recursive_color_trace(mat_obj, mesh_obj, blend_path, node, socket=None):
|
||||||
elif node.blend_type == 'ADD':
|
elif node.blend_type == 'ADD':
|
||||||
return '(%s + %s)' % (a_input, b_input)
|
return '(%s + %s)' % (a_input, b_input)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("RMDL does not support shaders with '{0}' blending modes".format(node.blend_type))
|
raise RuntimeError("HMDL does not support shaders with '{0}' blending modes".format(node.blend_type))
|
||||||
|
|
||||||
elif node.type == 'TEXTURE':
|
elif node.type == 'TEXTURE':
|
||||||
|
|
||||||
if not node.inputs['Vector'].is_linked:
|
if not node.inputs['Vector'].is_linked:
|
||||||
raise RuntimeError("RMDL texture nodes must have a 'Geometry', 'Group' UV modifier node linked")
|
raise RuntimeError("HMDL texture nodes must have a 'Geometry', 'Group' UV modifier node linked")
|
||||||
|
|
||||||
# Determine matrix generator type
|
# Determine matrix generator type
|
||||||
matrix_str = None
|
matrix_str = None
|
||||||
|
@ -75,7 +75,7 @@ def recursive_color_trace(mat_obj, mesh_obj, blend_path, node, socket=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("RMDL texture nodes must have a 'Geometry', 'Group' UV modifier node linked")
|
raise RuntimeError("HMDL texture nodes must have a 'Geometry', 'Group' UV modifier node linked")
|
||||||
|
|
||||||
if soc_from.node.type != 'GEOMETRY':
|
if soc_from.node.type != 'GEOMETRY':
|
||||||
raise RuntimeError("Matrix animator nodes must connect to 'Geometry' node")
|
raise RuntimeError("Matrix animator nodes must connect to 'Geometry' node")
|
||||||
|
@ -129,7 +129,7 @@ def recursive_color_trace(mat_obj, mesh_obj, blend_path, node, socket=None):
|
||||||
return 'hecl_Lighting'
|
return 'hecl_Lighting'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("RMDL is unable to process '{0}' shader nodes in '{1}'".format(node.type, mat_obj.name))
|
raise RuntimeError("HMDL is unable to process '{0}' shader nodes in '{1}'".format(node.type, mat_obj.name))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,12 +159,12 @@ def recursive_alpha_trace(mat_obj, mesh_obj, blend_path, node, socket=None):
|
||||||
elif node.operation == 'ADD':
|
elif node.operation == 'ADD':
|
||||||
return '(%s + %s)' % (a_input, b_input)
|
return '(%s + %s)' % (a_input, b_input)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("RMDL does not support shaders with '{0}' blending modes".format(node.operation))
|
raise RuntimeError("HMDL does not support shaders with '{0}' blending modes".format(node.operation))
|
||||||
|
|
||||||
elif node.type == 'TEXTURE':
|
elif node.type == 'TEXTURE':
|
||||||
|
|
||||||
if not node.inputs['Vector'].is_linked:
|
if not node.inputs['Vector'].is_linked:
|
||||||
raise RuntimeError("RMDL texture nodes must have a 'Geometry', 'Group' UV modifier node linked")
|
raise RuntimeError("HMDL texture nodes must have a 'Geometry', 'Group' UV modifier node linked")
|
||||||
|
|
||||||
# Determine matrix generator type
|
# Determine matrix generator type
|
||||||
matrix_str = None
|
matrix_str = None
|
||||||
|
@ -196,7 +196,7 @@ def recursive_alpha_trace(mat_obj, mesh_obj, blend_path, node, socket=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("RMDL texture nodes must have a 'Geometry', 'Group' UV modifier node linked")
|
raise RuntimeError("HMDL texture nodes must have a 'Geometry', 'Group' UV modifier node linked")
|
||||||
|
|
||||||
if soc_from.node.type != 'GEOMETRY':
|
if soc_from.node.type != 'GEOMETRY':
|
||||||
raise RuntimeError("Matrix animator nodes must connect to 'Geometry' node")
|
raise RuntimeError("Matrix animator nodes must connect to 'Geometry' node")
|
||||||
|
@ -242,17 +242,17 @@ def recursive_alpha_trace(mat_obj, mesh_obj, blend_path, node, socket=None):
|
||||||
return '1.0'
|
return '1.0'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("RMDL is unable to process '{0}' shader nodes in '{1}'".format(node.type, mat_obj.name))
|
raise RuntimeError("HMDL is unable to process '{0}' shader nodes in '{1}'".format(node.type, mat_obj.name))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def shader(mat_obj, mesh_obj, blend_path):
|
def shader(mat_obj, mesh_obj, blend_path):
|
||||||
|
|
||||||
if not mat_obj.use_nodes:
|
if not mat_obj.use_nodes:
|
||||||
raise RuntimeError("RMDL *requires* that shader nodes are used; '{0}' does not".format(mat_obj.name))
|
raise RuntimeError("HMDL *requires* that shader nodes are used; '{0}' does not".format(mat_obj.name))
|
||||||
|
|
||||||
if 'Output' not in mat_obj.node_tree.nodes or mat_obj.node_tree.nodes['Output'].type != 'OUTPUT':
|
if 'Output' not in mat_obj.node_tree.nodes or mat_obj.node_tree.nodes['Output'].type != 'OUTPUT':
|
||||||
raise RuntimeError("RMDL *requires* that an OUTPUT shader node named 'Output' is present")
|
raise RuntimeError("HMDL *requires* that an OUTPUT shader node named 'Output' is present")
|
||||||
|
|
||||||
# Root (output) node
|
# Root (output) node
|
||||||
output_node = mat_obj.node_tree.nodes['Output']
|
output_node = mat_obj.node_tree.nodes['Output']
|
||||||
|
|
Loading…
Reference in New Issue