mirror of https://github.com/webbukkit/dynmap.git
implemented new hight ranges of later MC versions
This commit is contained in:
parent
5f67179413
commit
04eef5bd61
|
@ -6,10 +6,7 @@ import java.io.IOException;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dynmap.Color;
|
import org.dynmap.*;
|
||||||
import org.dynmap.ConfigurationNode;
|
|
||||||
import org.dynmap.DynmapCore;
|
|
||||||
import org.dynmap.MapManager;
|
|
||||||
import org.dynmap.common.DynmapCommandSender;
|
import org.dynmap.common.DynmapCommandSender;
|
||||||
import org.dynmap.exporter.OBJExport;
|
import org.dynmap.exporter.OBJExport;
|
||||||
import org.dynmap.renderer.DynmapBlockState;
|
import org.dynmap.renderer.DynmapBlockState;
|
||||||
|
@ -26,14 +23,13 @@ public class TopoHDShader implements HDShader {
|
||||||
private final Color watercolor;
|
private final Color watercolor;
|
||||||
private BitSet hiddenids;
|
private BitSet hiddenids;
|
||||||
private final int linespacing;
|
private final int linespacing;
|
||||||
|
private int worldheight = 384;
|
||||||
public TopoHDShader(DynmapCore core, ConfigurationNode configuration) {
|
public TopoHDShader(DynmapCore core, ConfigurationNode configuration) {
|
||||||
name = (String) configuration.get("name");
|
name = (String) configuration.get("name");
|
||||||
|
fillcolor = new Color[worldheight]; /* Color by Y, must be range of total world height, offset by +64*/
|
||||||
fillcolor = new Color[256]; /* Color by Y */
|
|
||||||
/* Load defined colors from parameters */
|
/* Load defined colors from parameters */
|
||||||
for(int i = 0; i < 256; i++) {
|
for(int i = 0; i < worldheight; i++) {
|
||||||
fillcolor[i] = configuration.getColor("color" + i, null);
|
fillcolor[i] = configuration.getColor("color" + (i - 64), null); /* need to substract by 64 because Color does not accept <0 indexes*/
|
||||||
}
|
}
|
||||||
linecolor = configuration.getColor("linecolor", null);
|
linecolor = configuration.getColor("linecolor", null);
|
||||||
watercolor = configuration.getColor("watercolor", null);
|
watercolor = configuration.getColor("watercolor", null);
|
||||||
|
@ -45,11 +41,11 @@ public class TopoHDShader implements HDShader {
|
||||||
if(fillcolor[0] == null) {
|
if(fillcolor[0] == null) {
|
||||||
fillcolor[0] = new Color(0, 0, 0);
|
fillcolor[0] = new Color(0, 0, 0);
|
||||||
}
|
}
|
||||||
if(fillcolor[255] == null) {
|
if(fillcolor[worldheight-1] == null) {
|
||||||
fillcolor[255] = new Color(255, 255, 255);
|
fillcolor[worldheight-1] = new Color(255, 255, 255);
|
||||||
}
|
}
|
||||||
int starty = 0;
|
int starty = 0;
|
||||||
for(int i = 1; i < 256; i++) {
|
for(int i = 0; i < worldheight; i++) {
|
||||||
if(fillcolor[i] != null) { /* Found color? */
|
if(fillcolor[i] != null) { /* Found color? */
|
||||||
int delta = i - starty;
|
int delta = i - starty;
|
||||||
Color c0 = fillcolor[starty];
|
Color c0 = fillcolor[starty];
|
||||||
|
@ -73,7 +69,7 @@ public class TopoHDShader implements HDShader {
|
||||||
}
|
}
|
||||||
linespacing = configuration.getInteger("linespacing", 1);
|
linespacing = configuration.getInteger("linespacing", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHidden(String bn) {
|
private void setHidden(String bn) {
|
||||||
DynmapBlockState bs = DynmapBlockState.getBaseStateByName(bn);
|
DynmapBlockState bs = DynmapBlockState.getBaseStateByName(bn);
|
||||||
for (int i = 0; i < bs.getStateCount(); i++) {
|
for (int i = 0; i < bs.getStateCount(); i++) {
|
||||||
|
@ -81,17 +77,17 @@ public class TopoHDShader implements HDShader {
|
||||||
hiddenids.set(b.globalStateIndex);
|
hiddenids.set(b.globalStateIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBiomeDataNeeded() {
|
public boolean isBiomeDataNeeded() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRawBiomeDataNeeded() {
|
public boolean isRawBiomeDataNeeded() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isHightestBlockYDataNeeded() {
|
public boolean isHightestBlockYDataNeeded() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -116,7 +112,7 @@ public class TopoHDShader implements HDShader {
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OurShaderState implements HDShaderState {
|
private class OurShaderState implements HDShaderState {
|
||||||
private Color color[];
|
private Color color[];
|
||||||
private Color tmpcolor[];
|
private Color tmpcolor[];
|
||||||
|
@ -128,7 +124,7 @@ public class TopoHDShader implements HDShader {
|
||||||
private int heightshift; /* Divide to keep in 0-127 range of colors */
|
private int heightshift; /* Divide to keep in 0-127 range of colors */
|
||||||
private boolean inWater;
|
private boolean inWater;
|
||||||
final int[] lightingTable;
|
final int[] lightingTable;
|
||||||
|
|
||||||
private OurShaderState(MapIterator mapiter, HDMap map, MapChunkCache cache, int scale) {
|
private OurShaderState(MapIterator mapiter, HDMap map, MapChunkCache cache, int scale) {
|
||||||
this.mapiter = mapiter;
|
this.mapiter = mapiter;
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
@ -171,14 +167,14 @@ public class TopoHDShader implements HDShader {
|
||||||
public HDMap getMap() {
|
public HDMap getMap() {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get our lighting
|
* Get our lighting
|
||||||
*/
|
*/
|
||||||
public HDLighting getLighting() {
|
public HDLighting getLighting() {
|
||||||
return lighting;
|
return lighting;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset renderer state for new ray
|
* Reset renderer state for new ray
|
||||||
*/
|
*/
|
||||||
|
@ -187,18 +183,18 @@ public class TopoHDShader implements HDShader {
|
||||||
color[i].setTransparent();
|
color[i].setTransparent();
|
||||||
inWater = false;
|
inWater = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean isHidden(DynmapBlockState blk) {
|
private final boolean isHidden(DynmapBlockState blk) {
|
||||||
return hiddenids.get(blk.globalStateIndex);
|
return hiddenids.get(blk.globalStateIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process next ray step - called for each block on route
|
* Process next ray step - called for each block on route
|
||||||
* @return true if ray is done, false if ray needs to continue
|
* @return true if ray is done, false if ray needs to continue
|
||||||
*/
|
*/
|
||||||
public boolean processBlock(HDPerspectiveState ps) {
|
public boolean processBlock(HDPerspectiveState ps) {
|
||||||
DynmapBlockState blocktype = ps.getBlockState();
|
DynmapBlockState blocktype = ps.getBlockState();
|
||||||
|
|
||||||
if (isHidden(blocktype)) {
|
if (isHidden(blocktype)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -208,56 +204,56 @@ public class TopoHDShader implements HDShader {
|
||||||
int[] xyz = ps.getSubblockCoord();
|
int[] xyz = ps.getSubblockCoord();
|
||||||
// Only color lines when spacing is matched
|
// Only color lines when spacing is matched
|
||||||
Color lcolor = ((y % linespacing) == 0)?linecolor:null;
|
Color lcolor = ((y % linespacing) == 0)?linecolor:null;
|
||||||
|
|
||||||
/* See which face we're on (only do lines on top face) */
|
/* See which face we're on (only do lines on top face) */
|
||||||
switch(ps.getLastBlockStep()) {
|
switch(ps.getLastBlockStep()) {
|
||||||
case Y_MINUS:
|
case Y_MINUS:
|
||||||
case Y_PLUS:
|
case Y_PLUS:
|
||||||
if((lcolor != null) &&
|
if((lcolor != null) &&
|
||||||
(((xyz[0] == 0) && (isHidden(mapiter.getBlockTypeAt(BlockStep.X_MINUS)))) ||
|
(((xyz[0] == 0) && (isHidden(mapiter.getBlockTypeAt(BlockStep.X_MINUS)))) ||
|
||||||
((xyz[0] == (scale-1)) && (isHidden(mapiter.getBlockTypeAt(BlockStep.X_PLUS)))) ||
|
((xyz[0] == (scale-1)) && (isHidden(mapiter.getBlockTypeAt(BlockStep.X_PLUS)))) ||
|
||||||
((xyz[2] == 0) && (isHidden(mapiter.getBlockTypeAt(BlockStep.Z_MINUS)))) ||
|
((xyz[2] == 0) && (isHidden(mapiter.getBlockTypeAt(BlockStep.Z_MINUS)))) ||
|
||||||
((xyz[2] == (scale-1)) && (isHidden(mapiter.getBlockTypeAt(BlockStep.Z_PLUS)))))) {
|
((xyz[2] == (scale-1)) && (isHidden(mapiter.getBlockTypeAt(BlockStep.Z_PLUS)))))) {
|
||||||
c.setColor(lcolor);
|
c.setColor(lcolor);
|
||||||
inWater = false;
|
inWater = false;
|
||||||
}
|
}
|
||||||
else if ((watercolor != null) && blocktype.isWater()) {
|
else if ((watercolor != null) && blocktype.isWater()) {
|
||||||
if (!inWater) {
|
if (!inWater) {
|
||||||
c.setColor(watercolor);
|
c.setColor(watercolor);
|
||||||
inWater = true;
|
inWater = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
c.setColor(fillcolor[y >> heightshift]);
|
||||||
|
inWater = false;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else {
|
default:
|
||||||
c.setColor(fillcolor[y >> heightshift]);
|
if((lcolor != null) && (xyz[1] == (scale-1))) {
|
||||||
inWater = false;
|
c.setColor(lcolor);
|
||||||
}
|
inWater = false;
|
||||||
break;
|
}
|
||||||
default:
|
else if ((watercolor != null) && blocktype.isWater()) {
|
||||||
if((lcolor != null) && (xyz[1] == (scale-1))) {
|
if (!inWater) {
|
||||||
c.setColor(lcolor);
|
c.setColor(watercolor);
|
||||||
inWater = false;
|
inWater = true;
|
||||||
}
|
}
|
||||||
else if ((watercolor != null) && blocktype.isWater()) {
|
else {
|
||||||
if (!inWater) {
|
return false;
|
||||||
c.setColor(watercolor);
|
}
|
||||||
inWater = true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
c.setColor(fillcolor[y >> heightshift]);
|
||||||
|
inWater = false;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else {
|
|
||||||
c.setColor(fillcolor[y >> heightshift]);
|
|
||||||
inWater = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* Handle light level, if needed */
|
/* Handle light level, if needed */
|
||||||
lighting.applyLighting(ps, this, c, tmpcolor);
|
lighting.applyLighting(ps, this, c, tmpcolor);
|
||||||
|
|
||||||
/* If no previous color contribution, use new color */
|
/* If no previous color contribution, use new color */
|
||||||
if(color[0].isTransparent()) {
|
if(color[0].isTransparent()) {
|
||||||
for(int i = 0; i < color.length; i++)
|
for(int i = 0; i < color.length; i++)
|
||||||
|
@ -272,15 +268,15 @@ public class TopoHDShader implements HDShader {
|
||||||
if(talpha > 0)
|
if(talpha > 0)
|
||||||
for(int i = 0; i < color.length; i++)
|
for(int i = 0; i < color.length; i++)
|
||||||
color[i].setRGBA((tmpcolor[i].getRed()*alpha2 + color[i].getRed()*alpha) / talpha,
|
color[i].setRGBA((tmpcolor[i].getRed()*alpha2 + color[i].getRed()*alpha) / talpha,
|
||||||
(tmpcolor[i].getGreen()*alpha2 + color[i].getGreen()*alpha) / talpha,
|
(tmpcolor[i].getGreen()*alpha2 + color[i].getGreen()*alpha) / talpha,
|
||||||
(tmpcolor[i].getBlue()*alpha2 + color[i].getBlue()*alpha) / talpha, talpha);
|
(tmpcolor[i].getBlue()*alpha2 + color[i].getBlue()*alpha) / talpha, talpha);
|
||||||
else
|
else
|
||||||
for(int i = 0; i < color.length; i++)
|
for(int i = 0; i < color.length; i++)
|
||||||
color[i].setTransparent();
|
color[i].setTransparent();
|
||||||
|
|
||||||
return (talpha >= 254); /* If only one short, no meaningful contribution left */
|
return (talpha >= 254); /* If only one short, no meaningful contribution left */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Ray ended - used to report that ray has exited map (called if renderer has not reported complete)
|
* Ray ended - used to report that ray has exited map (called if renderer has not reported complete)
|
||||||
*/
|
*/
|
||||||
|
@ -324,7 +320,7 @@ public class TopoHDShader implements HDShader {
|
||||||
public HDShaderState getStateInstance(HDMap map, MapChunkCache cache, MapIterator mapiter, int scale) {
|
public HDShaderState getStateInstance(HDMap map, MapChunkCache cache, MapIterator mapiter, int scale) {
|
||||||
return new OurShaderState(mapiter, map, cache, scale);
|
return new OurShaderState(mapiter, map, cache, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add shader's contributions to JSON for map object */
|
/* Add shader's contributions to JSON for map object */
|
||||||
public void addClientConfiguration(JSONObject mapObject) {
|
public void addClientConfiguration(JSONObject mapObject) {
|
||||||
s(mapObject, "shader", name);
|
s(mapObject, "shader", name);
|
||||||
|
|
Loading…
Reference in New Issue