Skip to content

Commit

Permalink
Add LOD selection dialog (#117)
Browse files Browse the repository at this point in the history
RE6 has a problem: unlike other games it uses LOD3 for storing hands, so just to import them a user needs to enable all LODs, so this PR adds an option to import all LODs and uses per game presets for loading main LODs.
  • Loading branch information
HenryOfCarim authored Aug 4, 2024
1 parent 042cc78 commit 83f5a9e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
22 changes: 22 additions & 0 deletions albam/blender_ui/import_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,26 @@ def draw(self, context):
self.layout.separator()
row = self.layout.row()
row.operator("albam.import_vfile", text="Import")
row.operator("wm.import_options", icon="OPTIONS", text="")
self.layout.row()


@blender_registry.register_blender_type
class ALBAM_WM_OT_ImportOptions(bpy.types.Operator):
"""Set settings for importing"""
bl_label = "Import Options"
bl_idname = "wm.import_options"

import_main_lods_bool = bpy.props.BoolProperty(
name="Import main LODs only",
description="Allows to import only the most detailed meshes",
default=True)
import_only_main_lods: import_main_lods_bool

def execute(self, context):
import_settings = context.scene.albam.import_settings
import_settings.import_only_main_lods = self.import_only_main_lods
return {'FINISHED'}

def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
12 changes: 10 additions & 2 deletions albam/engines/mtfw/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,14 @@
VERSIONS_USE_BONE_PALETTES = {156}
VERSIONS_BONES_BBOX_AFFECTED = {210, 211}
VERSIONS_USE_TRISTRIPS = {156}
MAIN_LODS = {1, 255}
MAIN_LODS = {
"re0": [1, 255],
"re1": [1, 255],
"re5": [1, 255],
"re6": [1, 3, 255],
"rev1": [1, 255],
"rev2": [1, 255],
}


@blender_registry.register_import_function(app_id="re0", extension="mod", file_category="MESH")
Expand All @@ -307,9 +314,10 @@ def build_blender_model(file_list_item, context):
bl_object = skeleton or bpy.data.objects.new(bl_object_name, None)
materials = build_blender_materials(
file_list_item, context, mod, bl_object_name)
imported_lods = MAIN_LODS.get(app_id)

for i, mesh in enumerate(mod.meshes_data.meshes):
if import_settings.import_only_main_lods and mesh.level_of_detail not in MAIN_LODS:
if import_settings.import_only_main_lods and mesh.level_of_detail not in imported_lods:
continue
try:
name = f"{bl_object_name}_{str(i).zfill(4)}"
Expand Down
2 changes: 1 addition & 1 deletion albam/engines/mtfw/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def assign_textures(mtfw_material, bl_material, textures, mrl):
if texture_target is not None:
texture_node.image = texture_target
texture_code_to_blender_texture(tex_type_blender.value, texture_node, bl_material, None)
if tex_type_blender.value in NON_SRGB_IMAGE_TYPE:
if tex_index and tex_type_blender.value in NON_SRGB_IMAGE_TYPE:
texture_node.image.colorspace_settings.name = "Non-Color"
except IndexError:
print(f"tex_index {tex_index} not found. Texture len(): {len(textures)}")
Expand Down

0 comments on commit 83f5a9e

Please sign in to comment.