mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-01-12 02:40:56 +01:00
Finish fence gate renderer
This commit is contained in:
parent
a50005ebe4
commit
6998675b38
@ -16,6 +16,14 @@ public class FenceGateBlockStateRenderer extends CustomRenderer {
|
|||||||
private static final int TEXTURE_TOP = 1;
|
private static final int TEXTURE_TOP = 1;
|
||||||
private static final int TEXTURE_BOTTOM = 2;
|
private static final int TEXTURE_BOTTOM = 2;
|
||||||
|
|
||||||
|
private static final int IDX_OPEN = 0;
|
||||||
|
private static final int IDX_CLOSED = 1;
|
||||||
|
private static final int IDX_INWALL = 0;
|
||||||
|
private static final int IDX_NOTINWALL = 2;
|
||||||
|
private static final int IDX_NORTH = 0;
|
||||||
|
private static final int IDX_SOUTH = 4;
|
||||||
|
private static final int IDX_WEST = 8;
|
||||||
|
private static final int IDX_EAST = 12;
|
||||||
// Meshes, indexed by idx%2=open/closed, (idx/2)%2=in-wall/not-in-wall, (idx/4)%4=n/s/w/e
|
// Meshes, indexed by idx%2=open/closed, (idx/2)%2=in-wall/not-in-wall, (idx/4)%4=n/s/w/e
|
||||||
protected RenderPatch[][] meshes = new RenderPatch[16][];
|
protected RenderPatch[][] meshes = new RenderPatch[16][];
|
||||||
|
|
||||||
@ -37,70 +45,73 @@ public class FenceGateBlockStateRenderer extends CustomRenderer {
|
|||||||
private void addBox(RenderPatchFactory rpf, List<RenderPatch> list, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) {
|
private void addBox(RenderPatchFactory rpf, List<RenderPatch> list, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) {
|
||||||
addBox(rpf, list, xmin, xmax, ymin, ymax, zmin, zmax, patchlist);
|
addBox(rpf, list, xmin, xmax, ymin, ymax, zmin, zmax, patchlist);
|
||||||
}
|
}
|
||||||
|
private void rotateModel(RenderPatchFactory rpf, int srcidx, int destidx, int rot) {
|
||||||
|
meshes[destidx] = new RenderPatch[meshes[srcidx].length];
|
||||||
|
for (int i = 0; i < meshes[destidx].length; i++) {
|
||||||
|
meshes[destidx][i] = rpf.getRotatedPatch(meshes[srcidx][i], 0, rot, 0, patchlist[i%6]);
|
||||||
|
}
|
||||||
|
}
|
||||||
private void buildMeshes(RenderPatchFactory rpf) {
|
private void buildMeshes(RenderPatchFactory rpf) {
|
||||||
ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
|
ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
|
||||||
for(int dat = 0; dat < 8; dat++) {
|
// Build model for closed fence gate facing south (default)
|
||||||
// Add posts
|
addBox(rpf, list, 0.0, 0.125, 0.3125, 1.0, 0.4375, 0.5625);
|
||||||
if ((dat & 1) == 0) {
|
addBox(rpf, list, 0.875, 1.0, 0.3125, 1.0, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.0, 0.125, 0.3125, 1.0, 0.4375, 0.5625);
|
addBox(rpf, list, 0.375, 0.5, 0.375, 0.9375, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.875, 1.0, 0.3125, 1.0, 0.4375, 0.5625);
|
addBox(rpf, list, 0.5, 0.625, 0.375, 0.9375, 0.4375, 0.5625);
|
||||||
if ((dat & 4) == 0) { // If closed
|
addBox(rpf, list, 0.125, 0.375, 0.375, 0.5625, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.375, 0.625, 0.375, 0.9375, 0.4375, 0.5625);
|
addBox(rpf, list, 0.125, 0.375, 0.75, 0.9375, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.625, 0.875, 0.375, 0.5625, 0.4375, 0.5625);
|
addBox(rpf, list, 0.625, 0.875, 0.375, 0.5625, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.625, 0.875, 0.75, 0.9375, 0.4375, 0.5625);
|
addBox(rpf, list, 0.625, 0.875, 0.75, 0.9375, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.125, 0.375, 0.375f, 0.5625, 0.4375, 0.5625);
|
meshes[IDX_SOUTH | IDX_CLOSED | IDX_NOTINWALL] = list.toArray(new RenderPatch[list.size()]);
|
||||||
addBox(rpf, list, 0.125, 0.375, 0.75, 0.9375, 0.4375, 0.5625);
|
list.clear();
|
||||||
}
|
// Build rotated versions
|
||||||
else if ((dat & 3) == 0) {
|
rotateModel(rpf, IDX_SOUTH | IDX_CLOSED | IDX_NOTINWALL, IDX_NORTH | IDX_CLOSED | IDX_NOTINWALL, 180);
|
||||||
addBox(rpf, list, 0.0, 0.125, 0.375, 0.9375, 0.8125, 0.9375);
|
rotateModel(rpf, IDX_SOUTH | IDX_CLOSED | IDX_NOTINWALL, IDX_WEST | IDX_CLOSED | IDX_NOTINWALL, 90);
|
||||||
addBox(rpf, list, 0.875, 1.0, 0.375, 0.9375, 0.8125, 0.9375);
|
rotateModel(rpf, IDX_SOUTH | IDX_CLOSED | IDX_NOTINWALL, IDX_EAST | IDX_CLOSED | IDX_NOTINWALL, 270);
|
||||||
addBox(rpf, list, 0.0, 0.125, 0.375, 0.5625, 0.5625, 0.8125);
|
// Build model for open fence gate facing south (default)
|
||||||
addBox(rpf, list, 0.875, 1.0, 0.375, 0.5625, 0.5625, 0.8125);
|
addBox(rpf, list, 0.0, 0.125, 0.3125, 1.0, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.0, 0.125, 0.75, 0.9375, 0.5625, 0.8125);
|
addBox(rpf, list, 0.875, 1.0, 0.3125, 1.0, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.875, 1.0, 0.75, 0.9375, 0.5625, 0.8125);
|
addBox(rpf, list, 0.0, 0.125, 0.375, 0.9375, 0.8125, 0.9375);
|
||||||
}
|
addBox(rpf, list, 0.875, 1.0, 0.375, 0.9375, 0.8125, 0.9375);
|
||||||
else {
|
addBox(rpf, list, 0.0, 0.125, 0.75, 0.5625, 0.5625, 0.8125);
|
||||||
addBox(rpf, list, 0.0, 0.125, 0.375, 0.9375, 0.0625, 0.1875);
|
addBox(rpf, list, 0.0, 0.125, 0.75, 0.9375, 0.5625, 0.8125);
|
||||||
addBox(rpf, list, 0.875, 1.0, 0.375, 0.9375, 0.0625, 0.1875);
|
addBox(rpf, list, 0.875, 1.0, 0.375, 0.5625, 0.5625, 0.8125);
|
||||||
addBox(rpf, list, 0.0, 0.125, 0.375, 0.5625, 0.1875, 0.4375);
|
addBox(rpf, list, 0.875, 1.0, 0.75, 0.9375, 0.5625, 0.8125);
|
||||||
addBox(rpf, list, 0.875, 1.0, 0.375, 0.5625, 0.1875, 0.4375);
|
meshes[IDX_SOUTH | IDX_OPEN | IDX_NOTINWALL] = list.toArray(new RenderPatch[list.size()]);
|
||||||
addBox(rpf, list, 0.0, 0.125, 0.75, 0.9375, 0.1875, 0.4375);
|
list.clear();
|
||||||
addBox(rpf, list, 0.875, 1.0, 0.75, 0.9375, 0.1875, 0.4375);
|
// Build rotated versions
|
||||||
}
|
rotateModel(rpf, IDX_SOUTH | IDX_OPEN | IDX_NOTINWALL, IDX_NORTH | IDX_OPEN | IDX_NOTINWALL, 180);
|
||||||
}
|
rotateModel(rpf, IDX_SOUTH | IDX_OPEN | IDX_NOTINWALL, IDX_WEST | IDX_OPEN | IDX_NOTINWALL, 90);
|
||||||
else {
|
rotateModel(rpf, IDX_SOUTH | IDX_OPEN | IDX_NOTINWALL, IDX_EAST | IDX_OPEN | IDX_NOTINWALL, 270);
|
||||||
addBox(rpf, list, 0.4375, 0.5625, 0.3125, 1.0, 0.0, 0.125);
|
// Build model for closed fence gate facing south in-wall (default)
|
||||||
addBox(rpf, list, 0.4375, 0.5625, 0.3125, 1.0, 0.875, 1.0);
|
addBox(rpf, list, 0.0, 0.125, 0.125, 0.8125, 0.4375, 0.5625);
|
||||||
if ((dat & 4) == 0) { // If closed
|
addBox(rpf, list, 0.875, 1.0, 0.125, 0.8125, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.9375, 0.375, 0.625);
|
addBox(rpf, list, 0.375, 0.5, 0.1875, 0.75, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.5625, 0.625, 0.875);
|
addBox(rpf, list, 0.5, 0.625, 0.1875, 0.75, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.4375, 0.5625, 0.75, 0.9375, 0.625, 0.875);
|
addBox(rpf, list, 0.125, 0.375, 0.1875, 0.375, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.5625, 0.125, 0.375);
|
addBox(rpf, list, 0.125, 0.375, 0.5625, 0.75, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.4375, 0.5625, 0.75, 0.9375, 0.125, 0.375);
|
addBox(rpf, list, 0.625, 0.875, 0.1875, 0.375, 0.4375, 0.5625);
|
||||||
}
|
addBox(rpf, list, 0.625, 0.875, 0.5625, 0.75, 0.4375, 0.5625);
|
||||||
else if ((dat & 3) == 3) {
|
meshes[IDX_SOUTH | IDX_CLOSED | IDX_INWALL] = list.toArray(new RenderPatch[list.size()]);
|
||||||
addBox(rpf, list, 0.8125, 0.9375, 0.375, 0.9375, 0.0, 0.125);
|
list.clear();
|
||||||
addBox(rpf, list, 0.8125, 0.9375, 0.375, 0.9375, 0.875, 1.0);
|
// Build rotated versions
|
||||||
addBox(rpf, list, 0.5625, 0.8125, 0.375, 0.5625, 0.0, 0.125);
|
rotateModel(rpf, IDX_SOUTH | IDX_CLOSED | IDX_INWALL, IDX_NORTH | IDX_CLOSED | IDX_INWALL, 180);
|
||||||
addBox(rpf, list, 0.5625, 0.8125, 0.375, 0.5625, 0.875, 1.0);
|
rotateModel(rpf, IDX_SOUTH | IDX_CLOSED | IDX_INWALL, IDX_WEST | IDX_CLOSED | IDX_INWALL, 90);
|
||||||
addBox(rpf, list, 0.5625, 0.8125, 0.75, 0.9375, 0.0, 0.125);
|
rotateModel(rpf, IDX_SOUTH | IDX_CLOSED | IDX_INWALL, IDX_EAST | IDX_CLOSED | IDX_INWALL, 270);
|
||||||
addBox(rpf, list, 0.5625, 0.8125, 0.75, 0.9375, 0.875, 1.0);
|
// Build model for open fence gate facing south in-wall (default)
|
||||||
}
|
addBox(rpf, list, 0.0, 0.125, 0.125, 0.8125, 0.4375, 0.5625);
|
||||||
else {
|
addBox(rpf, list, 0.875, 1.0, 0.125, 0.8125, 0.4375, 0.5625);
|
||||||
addBox(rpf, list, 0.0625, 0.1875, 0.375, 0.9375, 0.0, 0.125);
|
addBox(rpf, list, 0.0, 0.125, 0.1875, 0.75, 0.8125, 0.9375);
|
||||||
addBox(rpf, list, 0.0625, 0.1875, 0.375, 0.9375, 0.875, 1.0);
|
addBox(rpf, list, 0.875, 1.0, 0.1875, 0.75, 0.8125, 0.9375);
|
||||||
addBox(rpf, list, 0.1875, 0.4375, 0.375, 0.5625, 0.0, 0.125);
|
addBox(rpf, list, 0.0, 0.125, 0.1875, 0.375, 0.5625, 0.8125);
|
||||||
addBox(rpf, list, 0.1875, 0.4375, 0.375, 0.5625, 0.875, 1.0);
|
addBox(rpf, list, 0.0, 0.125, 0.5625, 0.75, 0.5625, 0.8125);
|
||||||
addBox(rpf, list, 0.1875, 0.4375, 0.75, 0.9375, 0.0, 0.125);
|
addBox(rpf, list, 0.875, 1.0, 0.1875, 0.375, 0.5625, 0.8125);
|
||||||
addBox(rpf, list, 0.1875, 0.4375, 0.75, 0.9375, 0.875, 1.0);
|
addBox(rpf, list, 0.875, 1.0, 0.5625, 0.75, 0.5625, 0.8125);
|
||||||
}
|
meshes[IDX_SOUTH | IDX_OPEN | IDX_INWALL] = list.toArray(new RenderPatch[list.size()]);
|
||||||
}
|
rotateModel(rpf, IDX_SOUTH | IDX_OPEN | IDX_INWALL, IDX_NORTH | IDX_OPEN | IDX_INWALL, 180);
|
||||||
|
rotateModel(rpf, IDX_SOUTH | IDX_OPEN | IDX_INWALL, IDX_WEST | IDX_OPEN | IDX_INWALL, 90);
|
||||||
meshes[dat] = list.toArray(new RenderPatch[list.size()]);
|
rotateModel(rpf, IDX_SOUTH | IDX_OPEN | IDX_INWALL, IDX_EAST | IDX_OPEN | IDX_INWALL, 270);
|
||||||
|
list.clear();
|
||||||
list.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user