Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def draw(self, context):
if context.scene.f3d_type in {"F3DEX3", "T3D"}:
prop_split(col, context.scene, "packed_normals_algorithm", "Packed normals alg")
col.prop(context.scene, "saveTextures")
if context.scene.saveTextures:
col.prop(context.scene, "textureNameIncludesCiFormat")
col.prop(context.scene, "exportInlineF3D", text="Bleed and Inline Material Exports")
if context.scene.exportInlineF3D:
multilineLabel(
Expand Down Expand Up @@ -492,7 +494,10 @@ 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.textureNameIncludesCiFormat = bpy.props.BoolProperty(
Comment thread
LucretiaArc marked this conversation as resolved.
Outdated
name="Include CI Format In File Name", default=False
)
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 Expand Up @@ -529,6 +534,7 @@ def unregister():
del bpy.types.Scene.fullTraceback
del bpy.types.Scene.ignoreTextureRestrictions
del bpy.types.Scene.saveTextures
del bpy.types.Scene.textureNameIncludesCiFormat
del bpy.types.Scene.gameEditorMode
del bpy.types.Scene.exportHiddenGeometry
del bpy.types.Scene.blenderF3DScale
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
2 changes: 2 additions & 0 deletions fast64_internal/repo_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def load_repo_settings(scene: Scene, path: os.PathLike, skip_if_no_auto_load=Fal
fast64_settings.from_repo_settings(data)
set_prop_if_in_data(scene, "f3d_type", data, "microcode")
set_prop_if_in_data(scene, "saveTextures", data, "saveTextures")
set_prop_if_in_data(scene, "textureNameIncludesCiFormat", data, "textureNameIncludesCiFormat")
set_prop_if_in_data(scene, "exportInlineF3D", data, "bleedAndInline")
set_prop_if_in_data(scene, "ignoreTextureRestrictions", data, "ignoreTextureRestrictions")
set_prop_if_in_data(scene, "packed_normals_algorithm", data, "packedNormalsAlgorithm")
Expand All @@ -107,6 +108,7 @@ def save_repo_settings(scene: Scene, path: os.PathLike, game: str = ""):
data["packedNormalsAlgorithm"] = scene.packed_normals_algorithm
data["bleedAndInline"] = scene.exportInlineF3D
data["saveTextures"] = scene.saveTextures
data["textureNameIncludesCiFormat"] = scene.textureNameIncludesCiFormat
data["ignoreTextureRestrictions"] = scene.ignoreTextureRestrictions
rdp_defaults: RDPSettings = scene.world.rdp_defaults
data["rdpDefaults"] = rdp_defaults.to_dict()
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.textureNameIncludesCiFormat:
if ciFmt:
fmtName = f"{texFmt}-{ciFmt}"
Comment thread
LucretiaArc marked this conversation as resolved.
Outdated
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