use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.
the class FluidStateRenderer method getFullCulledModel.
// Get culled full model
private static final RenderPatch[] getFullCulledModel(MapDataContext ctx, DynmapBlockState bs_0_0_0, DynmapBlockState bs_0_1_0) {
DynmapBlockState bs_n1_0_0 = getFluidState(ctx, -1, 0, 0);
DynmapBlockState bs_1_0_0 = getFluidState(ctx, 1, 0, 0);
DynmapBlockState bs_0_0_n1 = getFluidState(ctx, 0, 0, -1);
DynmapBlockState bs_0_0_1 = getFluidState(ctx, 0, 0, 1);
return getFullCulledModel(ctx, bs_0_0_0, bs_0_1_0, bs_n1_0_0, bs_1_0_0, bs_0_0_n1, bs_0_0_1);
}
use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.
the class FrameRenderer method getRenderPatchList.
@Override
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
int textureIdx = 0;
if ((map_id != null) && (txtCount == 0)) {
txtCount = ctx.getPatchFactory().getTextureCountFromMap(map_id);
}
/* See if we have texture index */
if (idx_attrib != null) {
Object idxv = ctx.getBlockTileEntityField(idx_attrib);
if (idxv instanceof Number) {
int val = ((Number) idxv).intValue();
if (map_id != null) {
/* If texture map, look up value there */
textureIdx = ctx.getPatchFactory().getTextureIndexFromMap(map_id, val - txtOffset);
if ((textureIdx < 0) && (txtDefIndex >= 0))
textureIdx = ctx.getPatchFactory().getTextureIndexFromMap(map_id, txtDefIndex);
if (textureIdx < 0)
textureIdx = 0;
} else {
for (int i = 0; i < txtIndex.length; i++) {
if (val == txtIndex[i]) {
textureIdx = i;
break;
}
}
}
}
}
int idx = base_index;
for (int i = 0; i < x_off.length; i++) {
if ((idx & (1 << i)) != 0)
continue;
DynmapBlockState blk = ctx.getBlockTypeAt(x_off[i], y_off[i], z_off[i]);
if (linked_ids.get(blk.globalStateIndex)) {
idx |= (1 << i);
}
}
RenderPatch[][] row = models[idx];
/* If row not found, add it */
if (row == null) {
row = new RenderPatch[txtCount][];
models[idx] = row;
}
/* If model not found, create it */
RenderPatch[] model = null;
if (textureIdx < row.length)
model = row[textureIdx];
if (model == null) {
model = buildModel(ctx.getPatchFactory(), idx, textureIdx);
if (textureIdx >= row.length) {
row = Arrays.copyOf(row, textureIdx + 1);
models[idx] = row;
}
row[textureIdx] = model;
}
return model;
}
use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.
the class FrameRenderer method addIDs.
private void addIDs(String blkname) {
DynmapBlockState bbs = DynmapBlockState.getBaseStateByName(blkname);
if (bbs.isNotAir()) {
for (int i = 0; i < bbs.getStateCount(); i++) {
DynmapBlockState bs = bbs.getState(i);
linked_ids.set(bs.globalStateIndex);
}
}
}
use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.
the class BoxStateRenderer method initializeRenderer.
@Override
public boolean initializeRenderer(RenderPatchFactory rpf, String blkname, BitSet blockdatamask, Map<String, String> custparm) {
if (!super.initializeRenderer(rpf, blkname, blockdatamask, custparm))
return false;
double xmin = 0.0, xmax = 1.0;
double ymin = 0.0, ymax = 1.0;
double zmin = 0.0, zmax = 1.0;
/* Check limits */
String lim = custparm.get("xmin");
if (lim != null) {
xmin = Double.valueOf(lim);
if (xmin < 0.0)
xmin = 0.0;
}
lim = custparm.get("xmax");
if (lim != null) {
xmax = Double.valueOf(lim);
if (xmax > 1.0)
xmax = 1.0;
}
lim = custparm.get("ymin");
if (lim != null) {
ymin = Double.valueOf(lim);
if (ymin < 0.0)
ymin = 0.0;
}
lim = custparm.get("ymax");
if (lim != null) {
ymax = Double.valueOf(lim);
if (ymax > 1.0)
ymax = 1.0;
}
lim = custparm.get("zmin");
if (lim != null) {
zmin = Double.valueOf(lim);
if (zmin < 0.0)
zmin = 0.0;
}
lim = custparm.get("zmax");
if (lim != null) {
zmax = Double.valueOf(lim);
if (zmax > 1.0)
zmax = 1.0;
}
// Look up block
DynmapBlockState bs = DynmapBlockState.getBaseStateByName(blkname);
/* Now, build box models */
models = new RenderPatch[bs.getStateCount()][];
int[] patchlist = new int[6];
for (int i = 0; i < models.length; i++) {
DynmapBlockState cbs = bs.getState(i);
ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
String[] states = cbs.stateList;
// Produce patch list
patchlist[0] = Arrays.binarySearch(states, "down=true") >= 0 ? 1 : 0;
patchlist[1] = Arrays.binarySearch(states, "up=true") >= 0 ? 3 : 2;
patchlist[2] = Arrays.binarySearch(states, "west=true") >= 0 ? 5 : 4;
patchlist[3] = Arrays.binarySearch(states, "east=true") >= 0 ? 7 : 6;
patchlist[4] = Arrays.binarySearch(states, "north=true") >= 0 ? 9 : 8;
patchlist[5] = Arrays.binarySearch(states, "south=true") >= 0 ? 11 : 10;
CustomRenderer.addBox(rpf, list, xmin, xmax, ymin, ymax, zmin, zmax, patchlist);
models[i] = list.toArray(new RenderPatch[patchlist.length]);
}
return true;
}
use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.
the class CTMVertTextureRenderer method getRenderPatchList.
@Override
public RenderPatch[] getRenderPatchList(MapDataContext mapDataCtx) {
DynmapBlockState bs = mapDataCtx.getBlockType();
int meta = bs.stateIndex;
boolean above = false;
DynmapBlockState id_above = mapDataCtx.getBlockTypeAt(0, 1, 0);
if (id_above.baseState == blk) {
/* MIght match */
int id_meta = id_above.stateIndex;
if (meta == id_meta) {
above = true;
}
}
boolean below = false;
DynmapBlockState id_below = mapDataCtx.getBlockTypeAt(0, -1, 0);
if (id_below.baseState == blk) {
/* MIght match */
int id_meta = id_below.stateIndex;
if (meta == id_meta) {
below = true;
}
}
RenderPatch[] mesh;
if (above) {
if (below) {
mesh = this.mesh_both_neighbor;
} else {
mesh = this.mesh_above_neighbor;
}
} else {
if (below) {
mesh = this.mesh_below_neighbor;
} else {
mesh = this.mesh_no_neighbor;
}
}
return mesh;
}
Aggregations