From 20ca4e407f6da861dca4d10c3d07980844450aed Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 23 May 2015 12:06:31 -1000 Subject: [PATCH] naming corrections --- hecl/blender/addon/__init__.py | 2 +- hecl/blender/addon/hmdl/hmdl_anim.py | 18 +++---- hecl/blender/addon/hmdl/hmdl_mesh.py | 68 +++----------------------- hecl/blender/addon/hmdl/hmdl_shader.py | 20 ++++---- 4 files changed, 28 insertions(+), 80 deletions(-) diff --git a/hecl/blender/addon/__init__.py b/hecl/blender/addon/__init__.py index b33dd31bd..90325f9f9 100644 --- a/hecl/blender/addon/__init__.py +++ b/hecl/blender/addon/__init__.py @@ -20,7 +20,7 @@ from bpy.app.handlers import persistent # Appendable list allowing external addons to register additional resource types hecl_export_types = [ ('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 class hecl_scene_panel(bpy.types.Panel): diff --git a/hecl/blender/addon/hmdl/hmdl_anim.py b/hecl/blender/addon/hmdl/hmdl_anim.py index 8480f5f9f..ee5e76068 100644 --- a/hecl/blender/addon/hmdl/hmdl_anim.py +++ b/hecl/blender/addon/hmdl/hmdl_anim.py @@ -1,5 +1,5 @@ ''' -RMDL Export Blender Addon +HMDL Export Blender Addon By Jack Andersen 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 key_stream = bytearray() key_stream += struct.pack(endian_char + 'II', len(frame_set), len(bone_set)) - duration = action.frame_range[1] / action.rwk_fps - interval = 1.0 / action.rwk_fps + duration = action.frame_range[1] / action.hecl_fps + interval = 1.0 / action.hecl_fps key_stream += struct.pack(endian_char + 'ff', duration, interval) # Generate keyframe bitmap @@ -164,12 +164,12 @@ def generate_animation_info(action, res_db, rani_db_id, arg_package, endian_char # Generate event buffer event_buf = bytearray() - if hasattr(action, 'rwk_events'): + if hasattr(action, 'hecl_events'): c1 = 0 c2 = 0 c3 = 0 c4 = 0 - for event in action.rwk_events: + for event in action.hecl_events: if event.type == 'LOOP': c1 += 1 elif event.type == 'UEVT': @@ -180,16 +180,16 @@ def generate_animation_info(action, res_db, rani_db_id, arg_package, endian_char c4 += 1 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': 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': event_buf += struct.pack(endian_char + 'fii', event.time, event.uevt_data.type, hashbone(event.uevt_data.bone_name)) - for event in action.rwk_events: + for event in action.hecl_events: if event.type == 'EFFECT': effect_db_id, effect_hash = res_db.search_for_resource(event.effect_data.uid, arg_package) 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]) event_buf += effect_hash - for event in action.rwk_events: + for event in action.hecl_events: if event.type == 'SOUND': 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, diff --git a/hecl/blender/addon/hmdl/hmdl_mesh.py b/hecl/blender/addon/hmdl/hmdl_mesh.py index 9c1283bfb..b9fd105d4 100644 --- a/hecl/blender/addon/hmdl/hmdl_mesh.py +++ b/hecl/blender/addon/hmdl/hmdl_mesh.py @@ -1,10 +1,6 @@ ''' -RMDL Export Blender Addon +HMDL Export Blender Addon By Jack Andersen - -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 @@ -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): - # 4-byte ID string used in generated RMDL file + # 4-byte ID string used in generated HMDL file self.file_identifier = '_GEN' # Array that holds collections. A collection is a 16-bit index @@ -486,10 +482,10 @@ class rmdl_mesh: # C-generation operator import bmesh -class rmdl_mesh_operator(bpy.types.Operator): - bl_idname = "scene.rmdl_mesh" - bl_label = "RMDL C mesh maker" - bl_description = "RMDL Mesh source generation utility" +class hmdl_mesh_operator(bpy.types.Operator): + bl_idname = "scene.hmdl_mesh" + bl_label = "HMDL C mesh maker" + bl_description = "HMDL Mesh source generation utility" @classmethod def poll(cls, context): @@ -512,7 +508,7 @@ class rmdl_mesh_operator(bpy.types.Operator): bm.free() context.scene.objects.link(copy_obj) - rmesh = rmdl_mesh() + rmesh = hmdl_mesh() rmesh.add_mesh(copy_mesh, None, 0) 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") 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'} diff --git a/hecl/blender/addon/hmdl/hmdl_shader.py b/hecl/blender/addon/hmdl/hmdl_shader.py index fc25f2385..0a208dca4 100644 --- a/hecl/blender/addon/hmdl/hmdl_shader.py +++ b/hecl/blender/addon/hmdl/hmdl_shader.py @@ -38,12 +38,12 @@ def recursive_color_trace(mat_obj, mesh_obj, blend_path, node, socket=None): elif node.blend_type == 'ADD': return '(%s + %s)' % (a_input, b_input) 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': 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 matrix_str = None @@ -75,7 +75,7 @@ def recursive_color_trace(mat_obj, mesh_obj, blend_path, node, socket=None): pass 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': 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' 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': return '(%s + %s)' % (a_input, b_input) 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': 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 matrix_str = None @@ -196,7 +196,7 @@ def recursive_alpha_trace(mat_obj, mesh_obj, blend_path, node, socket=None): pass 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': 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' 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): 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': - 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 output_node = mat_obj.node_tree.nodes['Output']