Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[F3D] Material Ordered By Slot #285

Merged
merged 6 commits into from
Jan 26, 2024
Merged
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
21 changes: 9 additions & 12 deletions fast64_internal/f3d/f3d_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,17 @@ def saveStaticModel(

# checkForF3DMaterial(obj)

facesByMat = {}
faces_by_mat = {}
for face in obj.data.loop_triangles:
if face.material_index not in facesByMat:
facesByMat[face.material_index] = []
facesByMat[face.material_index].append(face)
if face.material_index not in faces_by_mat:
faces_by_mat[face.material_index] = []
faces_by_mat[face.material_index].append(face)

# sort by material slot
faces_by_mat = {mat_index: faces_by_mat[mat_index] for mat_index, _ in enumerate(obj.material_slots)}
jesusyoshi54 marked this conversation as resolved.
Show resolved Hide resolved

fMeshes = {}
for material_index, faces in facesByMat.items():
for material_index, faces in faces_by_mat.items():
material = obj.material_slots[material_index].material

if drawLayerField is not None and material.mat_ver > 3:
Expand Down Expand Up @@ -407,13 +410,7 @@ def addCullCommand(obj, fMesh, transformMatrix, matWriteMethod):
# if the object has a specifically set culling bounds, use that instead
for vertexPos in obj.get("culling_bounds", obj.bound_box):
fMesh.cullVertexList.vertices.append(
F3DVert(
Vector(vertexPos),
[0, 0],
Vector([0, 0, 0]),
None,
0.0,
).toVtx(
F3DVert(Vector(vertexPos), [0, 0], Vector([0, 0, 0]), None, 0.0,).toVtx(
jesusyoshi54 marked this conversation as resolved.
Show resolved Hide resolved
obj.data,
[32, 32],
transformMatrix,
Expand Down
Loading