Skip to content

Commit

Permalink
H2 lightmapper stuff
Browse files Browse the repository at this point in the history
Upgrade version to Blender 4.0
Add config setting for shader generation. 0 is disabled, 1 is simple, and 2 is full
Hide all other BSPs except the BSP we are lighting during lightmapping
Read color plate from bitmap instead of grabbing image from data. Fallback to data if color plate isn't found
Generate Halo 2 bipeds from scenario tag in Blender scene
Generate Halo 2 device control from scenario tag in Blender scene
Generate Halo 2 device machine from scenario tag in Blender scene
Generate Halo 2 equipment from scenario tag in Blender scene
Generate Halo 2 item collection from scenario tag in Blender scene
Generate Halo 2 scenario scenery resource from scenario tag in Blender scene
Generate Halo 2 sky from scenario tag in Blender scene
Generate Halo 2 sound scenery from scenario tag in Blender scene
Generate Halo 2 vehicle from scenario tag in Blender scene
Generate Halo 2 vehicle collection from scenario tag in Blender scene
Generate Halo 2 weapon from scenario tag in Blender scene
Misc cleanup
  • Loading branch information
Steven Garcia committed Dec 6, 2023
1 parent b7367a9 commit e7e4145
Show file tree
Hide file tree
Showing 140 changed files with 8,129 additions and 2,308 deletions.
2 changes: 1 addition & 1 deletion io_scene_halo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"name": "Halo Asset Blender Development Toolset",
"author": "General_101",
"version": (117, 343, 65521),
"blender": (3, 0, 0),
"blender": (4, 0, 0),
"location": "File > Import-Export",
"description": "Import-Export Halo intermediate files Build: BUILD_VERSION_STR",
"warning": "",
Expand Down
1 change: 1 addition & 0 deletions io_scene_halo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
USERNAME = "MissingString"
DEVICE_NAME = "HiddenIntentions"

SHADER_GEN = 2
HALO_1_DATA_PATH = ""
HALO_1_TAG_PATH = ""
HALO_2_DATA_PATH = ""
Expand Down
27 changes: 13 additions & 14 deletions io_scene_halo/file_ass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,24 @@
import bpy

from ..global_functions import global_functions

from bpy_extras.io_utils import (
ImportHelper,
ExportHelper
)
ImportHelper,
ExportHelper
)

from bpy.types import (
Operator,
Panel,
PropertyGroup
)
Operator,
Panel,
PropertyGroup
)

from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
PointerProperty,
StringProperty
)
BoolProperty,
EnumProperty,
FloatProperty,
PointerProperty,
StringProperty
)

def version_settings_callback(self, context):
items=[ ('1', "1", "H2/H3"),
Expand Down
3 changes: 1 addition & 2 deletions io_scene_halo/file_ass/build_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
from getpass import getuser
from .process_scene import process_scene
from ..global_functions import global_functions
from ..global_functions.global_functions import ModelTypeEnum

def build_asset(context, filepath, version, game_version, folder_structure, hidden_geo, nonrender_geo, apply_modifiers, triangulate_faces, loop_normals, edge_split, clean_normalize_weights, custom_scale, report):
ASS = process_scene(context, version, game_version, hidden_geo, nonrender_geo, apply_modifiers, triangulate_faces, loop_normals, edge_split, clean_normalize_weights, custom_scale, report)

filename = os.path.basename(filepath)
root_directory = global_functions.get_directory(context, game_version, ModelTypeEnum.render, folder_structure, True, False, filepath)
root_directory = global_functions.get_directory(context, game_version, global_functions.ModelTypeEnum.render, folder_structure, True, False, filepath)

file = open(os.path.join(root_directory, filename), 'w', encoding='utf_8')

Expand Down
2 changes: 1 addition & 1 deletion io_scene_halo/file_ass/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#
# ##### END MIT LICENSE BLOCK #####

from mathutils import Vector, Quaternion
from mathutils import Vector
from ..global_functions import global_functions

class ASSAsset(global_functions.HaloAsset):
Expand Down
29 changes: 14 additions & 15 deletions io_scene_halo/file_jma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,25 @@
import bpy

from ..global_functions import global_functions

from bpy_extras.io_utils import (
ImportHelper,
ExportHelper
)
ImportHelper,
ExportHelper
)

from bpy.types import (
Operator,
Panel,
PropertyGroup
)
Operator,
Panel,
PropertyGroup
)

from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
PointerProperty,
StringProperty
)
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
PointerProperty,
StringProperty
)

class JMS_RestPositionsADialog(Operator):
"""Set rest positions from a JMS file"""
Expand Down
2 changes: 1 addition & 1 deletion io_scene_halo/file_jma/import_jma.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
from .format import JMAAsset
from .build_scene import build_scene
from ..file_jms.format import JMSAsset
from ..global_functions import mesh_processing, global_functions
from .process_file_retail import process_file_retail
from ..global_functions import mesh_processing, global_functions
from ..file_jms.process_file_retail import process_file_retail as jms_process_file_retail

def load_file(context, filepath, game_title, fix_parents, fix_rotations, jms_path_a, jms_path_b, report):
Expand Down
1 change: 1 addition & 0 deletions io_scene_halo/file_jma/process_file_retail.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# ##### END MIT LICENSE BLOCK #####

import math

from .format import JMAAsset
from ..global_functions import global_functions

Expand Down
2 changes: 0 additions & 2 deletions io_scene_halo/file_jmi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
import bpy

from ..global_functions import global_functions

from bpy_extras.io_utils import ExportHelper

from bpy.types import (
Operator,
Panel,
Expand Down
1 change: 0 additions & 1 deletion io_scene_halo/file_jms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import bpy

from ..global_functions import global_functions

from bpy_extras.io_utils import (
ImportHelper,
ExportHelper
Expand Down
36 changes: 8 additions & 28 deletions io_scene_halo/file_jms/build_scene_retail.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,14 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
object_mesh.data.ass_jms.XREF_path = xref_path
object_mesh.data.ass_jms.XREF_name = xref_path

mesh_processing.select_object(context, object_mesh)
mesh_processing.select_object(context, armature)
bpy.ops.object.parent_set(type='ARMATURE', keep_transform=True)
object_mesh.parent = armature

matrix_translate = Matrix.Translation(xref_marker.translation)
matrix_rotation = xref_marker.rotation.to_matrix().to_4x4()

transform_matrix = matrix_translate @ matrix_rotation

object_mesh.matrix_world = transform_matrix
object_mesh.select_set(False)
armature.select_set(False)

#generate mesh object
if not len(JMS.vertices) == 0:
Expand Down Expand Up @@ -563,8 +559,7 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
object_empty.rigid_body_constraint.object1 = ragdoll_attached_object
object_empty.rigid_body_constraint.object2 = ragdoll_referenced_object

mesh_processing.select_object(context, armature)
bpy.ops.object.parent_set(type='ARMATURE', keep_transform=True)
object_empty.parent = armature
transform_matrix = Euler((0, 0, 0)).to_matrix().to_4x4()

ragdoll_origin_index = None
Expand Down Expand Up @@ -596,7 +591,6 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix

object_empty.matrix_world = transform_matrix
object_empty.select_set(False)
armature.select_set(False)

for hinge in JMS.hinges:
name = hinge.name
Expand Down Expand Up @@ -654,8 +648,7 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
object_empty.rigid_body_constraint.object1 = hinge_body_a_object
object_empty.rigid_body_constraint.object2 = hinge_body_b_object

mesh_processing.select_object(context, armature)
bpy.ops.object.parent_set(type='ARMATURE', keep_transform=True)
object_empty.parent = armature
transform_matrix = Euler((0, 0, 0)).to_matrix().to_4x4()

hinge_origin_index = None
Expand Down Expand Up @@ -687,7 +680,6 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix

object_empty.matrix_world = transform_matrix
object_empty.select_set(False)
armature.select_set(False)

for car_wheel in JMS.car_wheels:
name = car_wheel.name
Expand Down Expand Up @@ -733,8 +725,7 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
object_empty.empty_display_type = 'ARROWS'

mesh_processing.select_object(context, object_empty)
mesh_processing.select_object(context, armature)
bpy.ops.object.parent_set(type='ARMATURE', keep_transform=True)
object_empty.parent = armature
transform_matrix = Euler((0, 0, 0)).to_matrix().to_4x4()

car_wheel_origin_index = None
Expand Down Expand Up @@ -766,7 +757,6 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix

object_empty.matrix_world = transform_matrix
object_empty.select_set(False)
armature.select_set(False)

for point_to_point in JMS.point_to_points:
name = point_to_point.name
Expand Down Expand Up @@ -818,8 +808,7 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
object_empty.rigid_body_constraint.object1 = point_to_point_body_a_object
object_empty.rigid_body_constraint.object2 = point_to_point_body_b_object

mesh_processing.select_object(context, armature)
bpy.ops.object.parent_set(type='ARMATURE', keep_transform=True)
object_empty.parent = armature
transform_matrix = Euler((0, 0, 0)).to_matrix().to_4x4()

point_to_point_origin_index = None
Expand Down Expand Up @@ -851,7 +840,6 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix

object_empty.matrix_world = transform_matrix
object_empty.select_set(False)
armature.select_set(False)

for prismatic in JMS.prismatics:
name = prismatic.name
Expand All @@ -872,8 +860,7 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
object_empty.empty_display_type = 'ARROWS'

mesh_processing.select_object(context, object_empty)
mesh_processing.select_object(context, armature)
bpy.ops.object.parent_set(type='ARMATURE', keep_transform=True)
object_empty.parent = armature
matrix_translate = Matrix.Translation(prismatic.body_a_translation)
matrix_rotation = prismatic.body_a_rotation.to_matrix().to_4x4()

Expand All @@ -888,7 +875,6 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix

object_empty.matrix_world = transform_matrix
object_empty.select_set(False)
armature.select_set(False)

for idx, bounding_sphere in enumerate(JMS.bounding_spheres):
name = 'bounding_sphere_%s' % idx
Expand All @@ -903,9 +889,7 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
bm.to_mesh(mesh)
bm.free()

mesh_processing.select_object(context, object_mesh)
mesh_processing.select_object(context, armature)
bpy.ops.object.parent_set(type='ARMATURE', keep_transform=True)
object_mesh.parent = armature

matrix_translate = Matrix.Translation(bounding_sphere.translation)

Expand All @@ -916,8 +900,6 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
object_mesh.data.ass_jms.bounding_radius = True
object_scale = radius
object_mesh.scale = (object_scale, object_scale, object_scale)
object_mesh.select_set(False)
armature.select_set(False)

for idx, skylight in enumerate(JMS.skylights):
name = 'skylight_%s' % idx
Expand All @@ -930,9 +912,7 @@ def build_scene_retail(context, JMS, filepath, game_version, reuse_armature, fix
object_mesh.data.color = (skylight.radiant_intensity)
object_mesh.data.energy = (skylight.solid_angle)

mesh_processing.select_object(context, object_mesh)
mesh_processing.select_object(context, armature)
bpy.ops.object.parent_set(type='ARMATURE', keep_transform=True)
object_mesh.parent = armature

object_mesh.select_set(False)
armature.select_set(False)
1 change: 1 addition & 0 deletions io_scene_halo/file_jms/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, filepath=None):
if filepath:
super().__init__(filepath)

self.is_prerelease = False
self.version = 0
self.game_version = "halo1"
self.node_checksum = 0
Expand Down
50 changes: 4 additions & 46 deletions io_scene_halo/file_qua/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,11 @@

import bpy

from bpy.types import Operator
from bpy_extras.io_utils import ExportHelper
from ..global_functions import global_functions

from bpy_extras.io_utils import (
ImportHelper,
ExportHelper
)

from bpy.types import (
Operator,
Panel,
PropertyGroup
)

from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
PointerProperty,
StringProperty
)

Expand Down Expand Up @@ -75,45 +62,16 @@ def execute(self, context):

return global_functions.run_code("export_qua.write_file(context, self.filepath, self.report, self.qua_version)")

class ImportQUA(Operator, ImportHelper):
"""Import a QUA file"""
bl_idname = "import_scene.qua"
bl_label = "Import QUA"
filename_ext = '.QUA'

filter_glob: StringProperty(
default="*.qua",
options={'HIDDEN'},
)

def execute(self, context):
from ..file_qua import import_qua

return global_functions.run_code("import_qua.load_file(context, self.filepath, self.report)")

def menu_func_export(self, context):
self.layout.operator(ExportQUA.bl_idname, text='Halo Ubercam Animation (.qua)')

def menu_func_import(self, context):
self.layout.operator(ImportQUA.bl_idname, text="Halo Ubercam Animation (.qua)")

classeshalo = (
ImportQUA,
ExportQUA,
)

def register():
for clshalo in classeshalo:
bpy.utils.register_class(clshalo)

bpy.utils.register_class(ExportQUA)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
#bpy.types.TOPBAR_MT_file_import.append(menu_func_import)

def unregister():
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
#bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
for clshalo in classeshalo:
bpy.utils.unregister_class(clshalo)
bpy.utils.unregister_class(ExportQUA)

if __name__ == '__main__':
register()
2 changes: 0 additions & 2 deletions io_scene_halo/file_qua/export_qua.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
#
# ##### END MIT LICENSE BLOCK #####

import os
import bpy


from decimal import *
from mathutils import Vector
from math import degrees, atan
Expand Down
Loading

0 comments on commit e7e4145

Please sign in to comment.