Fix lantern render details

This commit is contained in:
Mike Primm 2021-12-30 16:55:43 -06:00
parent 7225edc1d6
commit 2f3f2350b3
4 changed files with 54 additions and 11 deletions

View file

@ -97,7 +97,7 @@ public abstract class CustomRenderer {
* @param zmax - maximum for Z axis
* @param patchids - patch IDs for each face (bottom,top,xmin,xmax,zmin,zmax)
*/
public static void addBox(RenderPatchFactory rpf, List<RenderPatch> list, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, int[] patchids) {
public static void addBox(RenderPatchFactory rpf, List<RenderPatch> list, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, int[] patchids) {
if(patchids == null) {
patchids = default_patches;
}
@ -120,6 +120,42 @@ public abstract class CustomRenderer {
if(patchids[5] >= 0)
addIfNonNull(list, rpf.getPatch(0, 0, zmax, 1, 0, zmax, 0, 1, zmax, xmin, xmax, ymin, ymax, SideVisible.TOP, patchids[5]));
}
/**
* Utility method: add simple box to give list
* @param rpf - patch factory
* @param list - list to add patches to
* @param xmin - minimum for X axis
* @param xmax - maximum for X axis
* @param ymin - minimum for Y axis
* @param ymax - maximum for Y axis
* @param zmin - minimum for Z axis
* @param zmax - maximum for Z axis
* @param yrot - rotation of box around Y axis (degrees)
* @param patchids - patch IDs for each face (bottom,top,xmin,xmax,zmin,zmax)
*/
public static void addBox(RenderPatchFactory rpf, List<RenderPatch> list, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, int[] patchids, int yrot) {
if(patchids == null) {
patchids = default_patches;
}
/* Add bottom */
if(patchids[0] >= 0)
addIfNonNull(list, rpf.getRotatedPatch(rpf.getPatch(0, ymin, 0, 1, ymin, 0, 0, ymin, 1, xmin, xmax, zmin, zmax, SideVisible.TOP, patchids[0]), 0, yrot, 0, -1));
/* Add top */
if(patchids[1] >= 0)
addIfNonNull(list, rpf.getRotatedPatch(rpf.getPatch(0, ymax, 1, 1, ymax, 1, 0, ymax, 0, xmin, xmax, 1-zmax, 1-zmin, SideVisible.TOP, patchids[1]), 0, yrot, 0, -1));
/* Add minX side */
if(patchids[2] >= 0)
addIfNonNull(list, rpf.getRotatedPatch(rpf.getPatch(xmin, 0, 0, xmin, 0, 1, xmin, 1, 0, zmin, zmax, ymin, ymax, SideVisible.TOP, patchids[2]), 0, yrot, 0, -1));
/* Add maxX side */
if(patchids[3] >= 0)
addIfNonNull(list, rpf.getRotatedPatch(rpf.getPatch(xmax, 0, 1, xmax, 0, 0, xmax, 1, 1, 1-zmax, 1-zmin, ymin, ymax, SideVisible.TOP, patchids[3]), 0, yrot, 0, -1));
/* Add minZ side */
if(patchids[4] >= 0)
addIfNonNull(list, rpf.getRotatedPatch(rpf.getPatch(1, 0, zmin, 0, 0, zmin, 1, 1, zmin, 1-xmax, 1-xmin, ymin, ymax, SideVisible.TOP, patchids[4]), 0, yrot, 0, -1));
/* Add maxZ side */
if(patchids[5] >= 0)
addIfNonNull(list, rpf.getRotatedPatch(rpf.getPatch(0, 0, zmax, 1, 0, zmax, 0, 1, zmax, xmin, xmax, ymin, ymax, SideVisible.TOP, patchids[5]), 0, yrot, 0, -1));
}
/**
* Get patch corresponding to side N (per MC side index: 0=bottom (y-), 1=top (y+), 2=z-, 3=z+, 4=x-, 5=x+)
* @param rpf - patch factory