Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 46 additions & 25 deletions fast64_internal/f3d/f3d_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,9 @@ def ui_scale(self, material, layout):
return inputGroup

def ui_dynamic_cosmetic_entry(self, f3dMat, layout, enabledProp, nameProp, categoryProp):
if not is_hm64_feature_set():
return

layout.prop(f3dMat, enabledProp, text="Dynamic Cosmetic Entry")
if getattr(f3dMat, enabledProp):
dynamicEntry = layout.column()
Expand Down Expand Up @@ -3262,10 +3265,11 @@ def to_dict(self):
}
if self.use_tex_reference:
data["reference"] = self.reference_to_dict()
if self.custom_palette_name:
data["customTLUTName"] = self.custom_palette_name
data["paletteColorCount"] = self.palette_color_count
data["isVanillaTexture"] = self.is_vanilla_texture
if is_hm64_feature_set():
if self.custom_palette_name:
data["customTLUTName"] = self.custom_palette_name
data["paletteColorCount"] = self.palette_color_count
data["isVanillaTexture"] = self.is_vanilla_texture
if self.texture_internal_path:
data["internalPath"] = self.texture_internal_path
return data
Expand All @@ -3285,9 +3289,10 @@ def from_dict(self, data: dict):
self.use_tex_reference = "reference" in data
if self.use_tex_reference:
self.reference_from_dict(data["reference"])
self.custom_palette_name = data.get("customTLUTName", self.custom_palette_name)
self.palette_color_count = data.get("paletteColorCount", self.palette_color_count)
self.is_vanilla_texture = data.get("isVanillaTexture", self.is_vanilla_texture)
if is_hm64_feature_set():
self.custom_palette_name = data.get("customTLUTName", self.custom_palette_name)
self.palette_color_count = data.get("paletteColorCount", self.palette_color_count)
self.is_vanilla_texture = data.get("isVanillaTexture", self.is_vanilla_texture)
self.texture_internal_path = data.get("internalPath", self.texture_internal_path)

def key(self):
Expand Down Expand Up @@ -3371,14 +3376,15 @@ def ui_image(
if tex is not None:
prop_input.label(text="Size: " + str(tex.size[0]) + " x " + str(tex.size[1]))

if not textureProp.use_tex_reference and textureProp.tex_format[:2] == "CI":
if is_hm64_feature_set() and not textureProp.use_tex_reference and textureProp.tex_format[:2] == "CI":
row = prop_input.row(align=True)
row.prop(textureProp, "custom_palette_name", text="TLUT Name")
row = prop_input.row(align=True)
row.prop(textureProp, "palette_color_count", text="Color Count")
if not textureProp.use_tex_reference:
row = prop_input.row(align=True)
row.prop(textureProp, "is_vanilla_texture", text="Is Vanilla Texture?")
if is_hm64_feature_set():
row = prop_input.row(align=True)
row.prop(textureProp, "is_vanilla_texture", text="Is Vanilla Texture?")
row = prop_input.row(align=True)
row.prop(textureProp, "texture_internal_path", text="Internal Path")

Expand Down Expand Up @@ -5185,23 +5191,35 @@ def f3d_colors_from_dict(self, data: dict):
def n64_colors_to_dict(self, use_dict: dict[str]):
data = {}
if use_dict["Environment"]:
data["environment"] = {
environment = {
"set": self.set_env,
"color": get_clean_color(self.env_color, include_alpha=True),
"dynamicEntry": self.env_dynamic_entry,
"dynamicEntryName": self.env_dynamic_entry_name,
"dynamicEntryCategory": self.env_dynamic_entry_category,
}
if is_hm64_feature_set():
environment.update(
{
"dynamicEntry": self.env_dynamic_entry,
"dynamicEntryName": self.env_dynamic_entry_name,
"dynamicEntryCategory": self.env_dynamic_entry_category,
}
)
data["environment"] = environment
if use_dict["Primitive"]:
data["primitive"] = {
primitive = {
"set": self.set_prim,
"color": get_clean_color(self.prim_color, include_alpha=True),
"minLoDRatio": self.prim_lod_min,
"loDFraction": self.prim_lod_frac,
"dynamicEntry": self.prim_dynamic_entry,
"dynamicEntryName": self.prim_dynamic_entry_name,
"dynamicEntryCategory": self.prim_dynamic_entry_category,
}
if is_hm64_feature_set():
primitive.update(
{
"dynamicEntry": self.prim_dynamic_entry,
"dynamicEntryName": self.prim_dynamic_entry_name,
"dynamicEntryCategory": self.prim_dynamic_entry_category,
}
)
data["primitive"] = primitive
if use_dict["Key"]:
data["chromaKey"] = {
"set": self.set_key,
Expand Down Expand Up @@ -5233,9 +5251,10 @@ def n64_colors_from_dict(self, data: dict):
self.set_env = enviroment.get("set", self.set_env)
if "color" in enviroment:
self.env_color = enviroment.get("color")
self.env_dynamic_entry = enviroment.get("dynamicEntry", self.env_dynamic_entry)
self.env_dynamic_entry_name = enviroment.get("dynamicEntryName", self.env_dynamic_entry_name)
self.env_dynamic_entry_category = enviroment.get("dynamicEntryCategory", self.env_dynamic_entry_category)
if is_hm64_feature_set():
self.env_dynamic_entry = enviroment.get("dynamicEntry", self.env_dynamic_entry)
self.env_dynamic_entry_name = enviroment.get("dynamicEntryName", self.env_dynamic_entry_name)
self.env_dynamic_entry_category = enviroment.get("dynamicEntryCategory", self.env_dynamic_entry_category)
primitive = data.get("primitive", {})
self.set_prim = primitive.get("set", self.set_prim)
if "color" in primitive:
Expand All @@ -5244,9 +5263,12 @@ def n64_colors_from_dict(self, data: dict):
primitive.get("minLoDRatio", self.prim_lod_min),
primitive.get("loDFraction", self.prim_lod_frac),
)
self.prim_dynamic_entry = primitive.get("dynamicEntry", self.prim_dynamic_entry)
self.prim_dynamic_entry_name = primitive.get("dynamicEntryName", self.prim_dynamic_entry_name)
self.prim_dynamic_entry_category = primitive.get("dynamicEntryCategory", self.prim_dynamic_entry_category)
if is_hm64_feature_set():
self.prim_dynamic_entry = primitive.get("dynamicEntry", self.prim_dynamic_entry)
self.prim_dynamic_entry_name = primitive.get("dynamicEntryName", self.prim_dynamic_entry_name)
self.prim_dynamic_entry_category = primitive.get(
"dynamicEntryCategory", self.prim_dynamic_entry_category
)
key = data.get("chromaKey", {})
self.set_key = key.get("set", self.set_key)
if "center" in key:
Expand Down Expand Up @@ -5635,4 +5657,3 @@ def mat_unregister():
"Vertex Colored Texture (No Vertex Alpha)",
),
]

20 changes: 13 additions & 7 deletions fast64_internal/f3d/f3d_texture_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def saveOrGetPaletteDefinition(
if texProp and texProp.texture_internal_path:
fPalette.internal_path = sanitize_internal_asset_path(texProp.texture_internal_path)
if texProp:
fPalette.skip_export = texProp.is_vanilla_texture
fPalette.skip_export = is_hm64_feature_set() and texProp.is_vanilla_texture
return paletteKey, fPalette

paletteName, filename = getTextureNamesFromBasename(
Expand All @@ -430,7 +430,7 @@ def saveOrGetPaletteDefinition(
if texProp:
fPalette.internal_path = sanitize_internal_asset_path(texProp.texture_internal_path)
if texProp:
fPalette.skip_export = texProp.is_vanilla_texture
fPalette.skip_export = is_hm64_feature_set() and texProp.is_vanilla_texture

parent.addTexture(paletteKey, fPalette, fMaterial)
return paletteKey, fPalette
Expand Down Expand Up @@ -461,7 +461,7 @@ def saveOrGetTextureDefinition(
if texProp and texProp.texture_internal_path:
fImage.internal_path = sanitize_internal_asset_path(texProp.texture_internal_path)
if texProp:
fImage.skip_export = texProp.is_vanilla_texture
fImage.skip_export = is_hm64_feature_set() and texProp.is_vanilla_texture
return imageKey, fImage

imageName, filename = getTextureNamesFromProp(texProp, parent)
Expand All @@ -470,7 +470,7 @@ def saveOrGetTextureDefinition(
if texProp:
fImage.internal_path = sanitize_internal_asset_path(texProp.texture_internal_path)
if texProp:
fImage.skip_export = texProp.is_vanilla_texture
fImage.skip_export = is_hm64_feature_set() and texProp.is_vanilla_texture

parent.addTexture(imageKey, fImage, fMaterial)
return imageKey, fImage
Expand Down Expand Up @@ -627,7 +627,7 @@ def getPaletteName(self):
if not self.useTex or self.isPalRef:
return None
self.custom_palette_requested = False
if self.texProp is not None:
if is_hm64_feature_set() and self.texProp is not None:
custom_name = getattr(self.texProp, "custom_palette_name", "")
if custom_name:
stripped = custom_name.strip()
Expand Down Expand Up @@ -697,7 +697,11 @@ def writeAll(
f3d = fModel.f3d
palette_load_cmd = None
if self.loadPal:
override = self.texProp.palette_color_count if self.texProp is not None else None
override = (
self.texProp.palette_color_count
if is_hm64_feature_set() and self.texProp is not None
else None
)
palette_load_cmd = savePaletteLoad(
loadGfx,
fPalette,
Expand All @@ -722,7 +726,9 @@ def writeAll(

# Write texture data
texProp = self.texProp
should_write_data = convertTextureData and not (texProp and texProp.is_vanilla_texture)
should_write_data = convertTextureData and not (
is_hm64_feature_set() and texProp and texProp.is_vanilla_texture
)
if should_write_data:
if self.isTexRef:
if self.loadPal and not self.isPalRef:
Expand Down
24 changes: 20 additions & 4 deletions fast64_internal/f3d/f3d_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,16 @@ def saveOrGetF3DMaterial(material, fModel, _obj, drawLayer, convertTextureData):
scaleToU8(f3dMat.prim_lod_min),
scaleToU8(f3dMat.prim_lod_frac),
*color,
cosmeticEntry=f3dMat.prim_dynamic_entry_name if f3dMat.prim_dynamic_entry else "",
cosmeticCategory=f3dMat.prim_dynamic_entry_category if f3dMat.prim_dynamic_entry else "",
cosmeticEntry=(
f3dMat.prim_dynamic_entry_name
if is_hm64_feature_set() and f3dMat.prim_dynamic_entry
else ""
),
cosmeticCategory=(
f3dMat.prim_dynamic_entry_category
if is_hm64_feature_set() and f3dMat.prim_dynamic_entry
else ""
),
)
)

Expand All @@ -1476,8 +1484,16 @@ def saveOrGetF3DMaterial(material, fModel, _obj, drawLayer, convertTextureData):
fMaterial.mat_only_DL.commands.append(
DPSetEnvColor(
*color,
cosmeticEntry=f3dMat.env_dynamic_entry_name if f3dMat.env_dynamic_entry else "",
cosmeticCategory=f3dMat.env_dynamic_entry_category if f3dMat.env_dynamic_entry else "",
cosmeticEntry=(
f3dMat.env_dynamic_entry_name
if is_hm64_feature_set() and f3dMat.env_dynamic_entry
else ""
),
cosmeticCategory=(
f3dMat.env_dynamic_entry_category
if is_hm64_feature_set() and f3dMat.env_dynamic_entry
else ""
),
)
)

Expand Down
4 changes: 4 additions & 0 deletions fast64_internal/hm64/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
def hm64_register():
from .f3d.soh_xml_exporter import register as register_soh_xml
from .z64.panels import register as register_z64_panels
from .mm.skeleton.operators import mm_skeleton_ops_register

register_soh_xml()
register_z64_panels()
mm_skeleton_ops_register()


def hm64_unregister():
from .f3d.soh_xml_exporter import unregister as unregister_soh_xml
from .z64.panels import unregister as unregister_z64_panels
from .mm.skeleton.operators import mm_skeleton_ops_unregister

mm_skeleton_ops_unregister()
unregister_z64_panels()
unregister_soh_xml()
25 changes: 20 additions & 5 deletions fast64_internal/hm64/mm/mm_f3d_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,8 +1471,16 @@ def saveOrGetF3DMaterial(material, fModel, obj, drawLayer, convertTextureData):
scaleToU8(f3dMat.prim_lod_min),
scaleToU8(f3dMat.prim_lod_frac),
*color,
cosmeticEntry=f3dMat.prim_dynamic_entry_name if f3dMat.prim_dynamic_entry else "",
cosmeticCategory=f3dMat.prim_dynamic_entry_category if f3dMat.prim_dynamic_entry else "",
cosmeticEntry=(
f3dMat.prim_dynamic_entry_name
if is_hm64_feature_set() and f3dMat.prim_dynamic_entry
else ""
),
cosmeticCategory=(
f3dMat.prim_dynamic_entry_category
if is_hm64_feature_set() and f3dMat.prim_dynamic_entry
else ""
),
)
)

Expand All @@ -1481,8 +1489,16 @@ def saveOrGetF3DMaterial(material, fModel, obj, drawLayer, convertTextureData):
fMaterial.mat_only_DL.commands.append(
DPSetEnvColor(
*color,
cosmeticEntry=f3dMat.env_dynamic_entry_name if f3dMat.env_dynamic_entry else "",
cosmeticCategory=f3dMat.env_dynamic_entry_category if f3dMat.env_dynamic_entry else "",
cosmeticEntry=(
f3dMat.env_dynamic_entry_name
if is_hm64_feature_set() and f3dMat.env_dynamic_entry
else ""
),
cosmeticCategory=(
f3dMat.env_dynamic_entry_category
if is_hm64_feature_set() and f3dMat.env_dynamic_entry
else ""
),
)
)

Expand Down Expand Up @@ -1993,4 +2009,3 @@ def f3d_writer_unregister():
unregister_class(cls)

del bpy.types.Scene.matWriteMethod

6 changes: 5 additions & 1 deletion fast64_internal/hm64/mm/skeleton/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ....f3d.f3d_gbi import DLFormat
from ....z64.skeleton.properties import OOTSkeletonExportSettings
from ....z64.utility import getOOTScale
from ....z64.utility import getOOTScale, is_hm64
from ....utility import ExportUtils, PluginError, raisePluginError
from .functions import ootConvertArmatureToO2R

Expand All @@ -16,6 +16,10 @@ class MM_ExportSkeleton(Operator):
bl_label = "Export MM Skeleton"
bl_options = {"REGISTER", "UNDO", "PRESET"}

@classmethod
def poll(cls, context):
return context.scene.gameEditorMode == "MM" and is_hm64()

def execute(self, context):
with ExportUtils() as export_utils:
armatureObj = None
Expand Down
2 changes: 1 addition & 1 deletion fast64_internal/hm64/z64/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def ootConvertMeshToXML(
):
folderName = settings.folder
exportPath = resolve_custom_export_base(settings)
isCustomExport = settings.isCustom
isCustomExport = True
name = resolve_dl_export_name(originalObj, settings)
overlayName = settings.actorOverlayName
flipbookUses2DArray = settings.flipbookUses2DArray
Expand Down
Loading
Loading