Skip to content

Commit

Permalink
T3D UI (#389)
Browse files Browse the repository at this point in the history
* T3D UI

* black

* some fixes for main and small changes

* personal nitpick

* one more nitpick

* removal of unnecessary checks

* black format

* small typo

* black

* Add rdpq
  • Loading branch information
Lilaa3 authored Nov 10, 2024
1 parent ac5ff61 commit b0bad2f
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 159 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def poll(cls, context):
def draw(self, context):
col = self.layout.column()
col.scale_y = 1.1 # extra padding
prop_split(col, context.scene, "f3d_type", "F3D Microcode")
prop_split(col, context.scene, "f3d_type", "Microcode")
col.prop(context.scene, "saveTextures")
col.prop(context.scene, "f3d_simple", text="Simple Material UI")
col.prop(context.scene, "exportInlineF3D", text="Bleed and Inline Material Exports")
Expand Down
23 changes: 16 additions & 7 deletions fast64_internal/f3d/f3d_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,22 @@
}

enumF3D = [
("F3D", "F3D", "Original microcode used in SM64"),
("F3DEX/LX", "F3DEX/LX", "F3DEX version 1"),
("F3DLX.Rej", "F3DLX.Rej", "F3DLX.Rej"),
("F3DLP.Rej", "F3DLP.Rej", "F3DLP.Rej"),
("F3DEX2/LX2", "F3DEX2/LX2/ZEX", "Family of microcodes used in later N64 games including OoT and MM"),
("F3DEX2.Rej/LX2.Rej", "F3DEX2.Rej/LX2.Rej", "Variant of F3DEX2 family using vertex rejection instead of clipping"),
("F3DEX3", "F3DEX3", "Custom microcode by Sauraen"),
("", "F3D Family", "", 7),
("F3D", "F3D", "Original microcode used in SM64", 0),
("F3DEX/LX", "F3DEX/LX", "F3DEX version 1", 1),
("F3DLX.Rej", "F3DLX.Rej", "F3DLX.Rej", 2),
("F3DLP.Rej", "F3DLP.Rej", "F3DLP.Rej", 3),
("F3DEX2/LX2", "F3DEX2/LX2/ZEX", "Family of microcodes used in later N64 games including OoT and MM", 4),
(
"F3DEX2.Rej/LX2.Rej",
"F3DEX2.Rej/LX2.Rej",
"Variant of F3DEX2 family using vertex rejection instead of clipping",
5,
),
("F3DEX3", "F3DEX3", "Custom microcode by Sauraen", 6),
("", "Homebrew", "", 8),
("RDPQ", "RDPQ", "Base libdragon microcode", 9),
("T3D", "Tiny3D", "Custom libdragon microcode by HailToDodongo", 10),
]

enumLargeEdges = [
Expand Down
22 changes: 20 additions & 2 deletions fast64_internal/f3d/f3d_gbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class GfxMatWriteMethod(enum.Enum):
"F3DEX2/LX2": (32, 32),
"F3DEX2.Rej/LX2.Rej": (64, 64),
"F3DEX3": (56, 56),
"T3D": (70, 70),
}

sm64_default_draw_layers = {
Expand Down Expand Up @@ -144,6 +145,14 @@ def isUcodeF3DEX3(F3D_VER: str) -> bool:
return F3D_VER == "F3DEX3"


def is_ucode_t3d(UCODE_VER: str) -> bool:
return UCODE_VER == "T3D"


def is_ucode_f3d(UCODE_VER: str) -> bool:
return UCODE_VER not in {"T3D", "RDPQ"}


class F3D:
"""NOTE: do not initialize this class manually! use get_F3D_GBI so that the single instance is cached from the microcode type."""

Expand All @@ -154,15 +163,20 @@ def __init__(self, F3D_VER):
F3DEX_GBI_3 = self.F3DEX_GBI_3 = isUcodeF3DEX3(F3D_VER)
F3DLP_GBI = self.F3DLP_GBI = self.F3DEX_GBI
self.F3D_OLD_GBI = not (F3DEX_GBI or F3DEX_GBI_2 or F3DEX_GBI_3)
self.F3D_GBI = is_ucode_f3d(F3D_VER)

# F3DEX2 is F3DEX1 and F3DEX3 is F3DEX2, but F3DEX3 is not F3DEX1
if F3DEX_GBI_2:
F3DEX_GBI = self.F3DEX_GBI = True
elif F3DEX_GBI_3:
F3DEX_GBI_2 = self.F3DEX_GBI_2 = True

self.vert_buffer_size = vertexBufferSize[F3D_VER][0]
self.vert_load_size = vertexBufferSize[F3D_VER][1]
if F3D_VER in vertexBufferSize:
self.vert_buffer_size = vertexBufferSize[F3D_VER][0]
self.vert_load_size = vertexBufferSize[F3D_VER][1]
else:
self.vert_buffer_size = self.vert_load_size = None

self.G_MAX_LIGHTS = 9 if F3DEX_GBI_3 else 7
self.G_INPUT_BUFFER_CMDS = 21

Expand Down Expand Up @@ -2331,6 +2345,10 @@ def __init__(
self.materialRevert: Union[GfxList, None] = None
# F3D library
self.f3d: F3D = get_F3D_GBI()
if not self.f3d.F3D_GBI:
raise PluginError(
f"Current microcode {self.f3d.F3D_VER} is not part of the f3d family of microcodes, fast64 cannot export it"
)
# array of FModel
self.subModels: list[FModel] = []
self.parentModel: Union[FModel, None] = None
Expand Down
Loading

0 comments on commit b0bad2f

Please sign in to comment.