Skip to content

Commit

Permalink
box_uv support for bbmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
Thutmose committed Apr 29, 2023
1 parent 3e1abfc commit ad5f7c1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ else if (phase.type != null)

// Handle customTextures
texturer.init(texs);
if (texs.defaults != null) holder.texture = new ResourceLocation(
holder.texture.toString().replace(holder.name, texs.defaults));
if (texs.defaults != null) holder.texture = new ResourceLocation(texs.defaults);
texturer.init(texs);

// Apply texture phases (ie texture animations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ private static List<Mesh> makeShapes(BBModelTemplate t, Element b, float[] origi
m.name = ThutCore.trim(key);
Material mat = new Material(m.name);
mats.put(m.name, mat);
if (b.box_uv) mat.cull = true;
m.setMaterial(mat);
shapes.add(m);
});

tris_materials.forEach((key, lists) -> {
List<Object> order = lists.get(0);
List<Object> verts = lists.get(1);
Expand All @@ -138,6 +139,7 @@ private static List<Mesh> makeShapes(BBModelTemplate t, Element b, float[] origi
tex.toArray(new TextureCoordinate[0]));
m.name = ThutCore.trim(key);
Material mat = mats.getOrDefault(m.name, new Material(m.name));
if (b.box_uv) mat.cull = true;
m.setMaterial(mat);
shapes.add(m);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ public static class Element implements IBBPart
public float[] origin;
public float[] rotation;
public int color;
public boolean box_uv = false;
public float inflate = 0.0f;
public Map<String, JsonObject> faces;
public Map<String, float[]> vertices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class Material
public float shininess;
public float alpha = 1;
public boolean transluscent = false;
public boolean cull = true;
public boolean cull = false;
public boolean flat = true;
public int[] rgbabro = new int[6];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public RenderType makeRenderType(Material material, ResourceLocation tex, Mode m

final boolean transp = material.alpha < 1 || material.transluscent;
// disable culling entirely
if (material.alpha >= 1)
if (!material.cull)
{
builder.setCullState(RenderStateShard.NO_CULL);
}
Expand Down

0 comments on commit ad5f7c1

Please sign in to comment.