Skip to content
Open
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
28 changes: 18 additions & 10 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,30 @@ def draw(self, context):
col = self.layout.column()
col.scale_y = 1.1 # extra padding

col.prop(context.scene, "f3d_simple", text="Simple Material UI")
scene = context.scene
fast64_settings: Fast64Settings_Properties = scene.fast64.settings

col.prop(scene, "f3d_simple", text="Simple Material UI")
col.separator()

col.label(text="Saved to Repo Settings file", icon="PROPERTIES")
prop_split(col, context.scene, "f3d_type", "Microcode")
prop_split(col, scene, "f3d_type", "Microcode")
gbi = get_F3D_GBI()

if context.scene.f3d_type in {"F3DEX3", "T3D"}:
prop_split(col, context.scene, "packed_normals_algorithm", "Packed normals alg")
col.prop(context.scene, "saveTextures")
col.prop(context.scene, "exportInlineF3D", text="Bleed and Inline Material Exports")
if context.scene.exportInlineF3D:
if scene.f3d_type in {"F3DEX3", "T3D"}:
prop_split(col, scene, "packed_normals_algorithm", "Packed normals alg")
col.prop(scene, "saveTextures")
if scene.saveTextures:
col.prop(fast64_settings, "texture_name_includes_ci_format")
col.prop(scene, "exportInlineF3D", text="Bleed and Inline Material Exports")
if scene.exportInlineF3D:
multilineLabel(
col.box(),
"While inlining, all meshes will be restored to world default values.\n You can configure these values in the world properties tab.",
icon="INFO",
)
col.prop(context.scene, "ignoreTextureRestrictions")
if context.scene.ignoreTextureRestrictions:
col.prop(scene, "ignoreTextureRestrictions")
if scene.ignoreTextureRestrictions:
col.box().label(text="Width/height must be < 1024. Must be png format.")


Expand Down Expand Up @@ -228,6 +233,7 @@ class Fast64Settings_Properties(bpy.types.PropertyGroup):
description="When enabled, fast64 will default colored textures's format to RGBA even if they fit CI requirements, with the exception of textures that would not fit into TMEM otherwise",
)
dont_ask_color_management: bpy.props.BoolProperty(name="Don't ask to set color management properties")
texture_name_includes_ci_format: bpy.props.BoolProperty(name="Include CI Format In File Name", default=False)

repo_settings_tab: bpy.props.BoolProperty(default=True, name="Repo Settings")
repo_settings_path: bpy.props.StringProperty(name="Path", subtype="FILE_PATH", update=repo_path_update)
Expand All @@ -244,13 +250,15 @@ def to_repo_settings(self):
data = {}
data["autoLoad"] = self.auto_repo_load_settings
data["autoPickTextureFormat"] = self.auto_pick_texture_format
data["textureNameIncludesCiFormat"] = self.texture_name_includes_ci_format
if self.auto_pick_texture_format:
data["preferRGBAOverCI"] = self.prefer_rgba_over_ci
return data

def from_repo_settings(self, data: dict):
set_prop_if_in_data(self, "auto_repo_load_settings", data, "autoLoad")
set_prop_if_in_data(self, "auto_pick_texture_format", data, "autoPickTextureFormat")
set_prop_if_in_data(self, "texture_name_includes_ci_format", data, "textureNameIncludesCiFormat")
set_prop_if_in_data(self, "prefer_rgba_over_ci", data, "preferRGBAOverCI")


Expand Down Expand Up @@ -492,7 +500,7 @@ def register():
bpy.types.Scene.gameEditorMode = bpy.props.EnumProperty(
name="Game", default="SM64", items=gameEditorEnum, update=gameEditorUpdate
)
bpy.types.Scene.saveTextures = bpy.props.BoolProperty(name="Save Textures As PNGs (Breaks CI Textures)")
bpy.types.Scene.saveTextures = bpy.props.BoolProperty(name="Save Textures As PNGs (May Break CI Textures)")
bpy.types.Scene.exportHiddenGeometry = bpy.props.BoolProperty(name="Export Hidden Geometry", default=True)
bpy.types.Scene.exportInlineF3D = bpy.props.BoolProperty(
name="Bleed and Inline Material Exports",
Expand Down
19 changes: 13 additions & 6 deletions fast64_internal/f3d/f3d_texture_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ def loadOneOrTwoS(tmemBase, tidxBase, TL, TH):
# Functions for texture and palette definitions


def getTextureNamesFromBasename(baseName: str, texOrPalFormat: str, parent: Union[FModel, FTexRect], isPalette: bool):
suffix = getTextureSuffixFromFormat(texOrPalFormat)
def getTextureNamesFromBasename(
baseName: str, texFmt: str, ciFmt: Union[str, None], parent: Union[FModel, FTexRect], isPalette: bool
):
suffix = getTextureSuffixFromFormat(texFmt, ciFmt, isPalette)
imageName = parent.name + "_" + baseName + "_"
if isPalette:
imageName += "pal_"
Expand All @@ -297,14 +299,19 @@ def getImageName(image: bpy.types.Image):
return getNameFromPath(image.filepath, True)


def getTextureNamesFromImage(image: bpy.types.Image, texFormat: str, parent: Union[FModel, FTexRect]):
return getTextureNamesFromBasename(getImageName(image), texFormat, parent, False)
def getTextureNamesFromImage(
image: bpy.types.Image, texFmt: str, ciFmt: Union[str, None], parent: Union[FModel, FTexRect]
):
return getTextureNamesFromBasename(getImageName(image), texFmt, ciFmt, parent, False)


def getTextureNamesFromProp(texProp: TextureProperty, parent: Union[FModel, FTexRect]):
if texProp.use_tex_reference:
raise PluginError("Internal error, invalid use of getTextureNamesFromProp")
return getTextureNamesFromImage(texProp.tex, texProp.tex_format, parent)

return getTextureNamesFromImage(
texProp.tex, texProp.tex_format, texProp.ci_format if texProp.is_ci else None, parent
)


def checkDuplicateTextureName(parent: Union[FModel, FTexRect], name):
Expand Down Expand Up @@ -340,7 +347,7 @@ def saveOrGetPaletteDefinition(
# print(f"Palette already exists")
return paletteKey, fPalette

paletteName, filename = getTextureNamesFromBasename(palBaseName, palFmt, parent, True)
paletteName, filename = getTextureNamesFromBasename(palBaseName, texFmt, palFmt, parent, True)
fPalette = FImage(paletteName, palFormat, "G_IM_SIZ_16b", 1, palLen, filename)

parent.addTexture(paletteKey, fPalette, fMaterial)
Expand Down
19 changes: 15 additions & 4 deletions fast64_internal/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -1813,10 +1813,21 @@ def ootGetBaseOrCustomLight(prop, idx, toExport: bool, errIfMissing: bool):
return col, dir


def getTextureSuffixFromFormat(texFmt):
# if texFmt == "RGBA16":
# return "rgb5a1"
return texFmt.lower()
def getTextureSuffixFromFormat(texFmt: str, ciFmt: str | None, isPalette: bool):
if bpy.context.scene.fast64.settings.texture_name_includes_ci_format:
if ciFmt:
fmtName = f"{texFmt}_{ciFmt}"
else:
fmtName = texFmt
else:
if isPalette:
if ciFmt is None:
raise PluginError("Internal error, getTextureSuffixFromFormat required ciFmt but wasn't specified")
fmtName = ciFmt
else:
fmtName = texFmt

return fmtName.lower()


# https://stackoverflow.com/a/241506
Expand Down
6 changes: 4 additions & 2 deletions fast64_internal/z64/model_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ def processTexRefCITextures(self, fMaterial: FMaterial, material: bpy.types.Mate
allImages = self.validateImages(material, index)
for flipbookTexture in flipbookProp.textures:
# print(f"Texture: {str(flipbookTexture.image)}")
imageName, filename = getTextureNamesFromImage(flipbookTexture.image, texProp.tex_format, model)
imageName, filename = getTextureNamesFromImage(
flipbookTexture.image, texProp.tex_format, texProp.ci_format, model
)
if flipbookProp.exportMode == "Individual":
imageName = flipbookTexture.name

Expand Down Expand Up @@ -300,7 +302,7 @@ def processTexRefNonCITextures(self, fMaterial: FMaterial, material: bpy.types.M
imageKey = FImageKey(flipbookTexture.image, texProp.tex_format, texProp.ci_format, [flipbookTexture.image])
fImage = model.getTextureAndHandleShared(imageKey)
if fImage is None:
imageName, filename = getTextureNamesFromImage(flipbookTexture.image, texProp.tex_format, model)
imageName, filename = getTextureNamesFromImage(flipbookTexture.image, texProp.tex_format, None, model)
if flipbookProp.exportMode == "Individual":
imageName = flipbookTexture.name
fImage = FImage(
Expand Down