More models (beds, etc), proper fence support, lighting fixes for steps and slabs

This commit is contained in:
Mike Primm 2011-07-12 23:32:18 -05:00
parent 9c1479b922
commit c81c8cbaa6
4 changed files with 492 additions and 45 deletions

View File

@ -20,11 +20,13 @@ rotate:id=53,data=0,rot=90
block:id=53,id=67,data=3,scale=2 block:id=53,id=67,data=3,scale=2
rotate:id=53,data=0,rot=270 rotate:id=53,data=0,rot=270
# Slab (stone, sandstone, wood, cobblestone) # Slab (stone, sandstone, wood, cobblestone)
block:id=44,data=*,scale=2 block:id=44,data=*,scale=4
layer:0 layer:0,1
** ****
** ****
layer:1 ****
****
layer:2,3
-- --
-- --
# Snow # Snow
@ -93,26 +95,236 @@ rotate:id=50,data=1,rot=90
# Redstone torch off - pointing east # Redstone torch off - pointing east
block:id=50,id=75,id=76,data=4,scale=8 block:id=50,id=75,id=76,data=4,scale=8
rotate:id=50,data=1,rot=270 rotate:id=50,data=1,rot=270
# Fence # Fence - (data is faked: 1=north,2=east,4=south,8=west)
block:id=85,data=*,scale=8 # Fence - no neighbors
layer:0,1,3,4,6 block:id=85,data=0,scale=16
-------- layer:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
-------- ----------------
-------- ----------------
---**--- ----------------
---**--- ----------------
-------- ----------------
-------- ----------------
-------- ------****------
layer:2,5 ------****------
---**--- ------****------
---**--- ------****------
---**--- ----------------
******** ----------------
******** ----------------
---**--- ----------------
---**--- ----------------
---**--- ----------------
# Fence - just north neighbor
block:id=85,data=1,scale=16
layer:0,1,2,3,4,5,9,10,11,15
----------------
----------------
----------------
----------------
----------------
----------------
------****------
------****------
------****------
------****------
----------------
----------------
----------------
----------------
----------------
----------------
layer:6,7,8,12,13,14
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
------****------
------****------
------****------
------****------
----------------
----------------
----------------
----------------
----------------
----------------
# Fence - just east neighbor
block:id=85,data=2,scale=16
rotate:id=85,data=1,rot=90
# Fence - just south neighbor
block:id=85,data=4,scale=16
rotate:id=85,data=1,rot=180
# Fence - just south neighbor
block:id=85,data=8,scale=16
rotate:id=85,data=1,rot=270
# Fence - north and east neighbor
block:id=85,data=3,scale=16
layer:0,1,2,3,4,5,9,10,11,15
----------------
----------------
----------------
----------------
----------------
----------------
------****------
------****------
------****------
------****------
----------------
----------------
----------------
----------------
----------------
----------------
layer:6,7,8,12,13,14
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
------****------
------**********
------**********
------****------
----------------
----------------
----------------
----------------
----------------
----------------
# Fence - east and south neighbor
block:id=85,data=6,scale=16
rotate:id=85,data=3,rot=90
# Fence - south and west neighbor
block:id=85,data=12,scale=16
rotate:id=85,data=3,rot=180
# Fence - west and north neighbor
block:id=85,data=9,scale=16
rotate:id=85,data=3,rot=270
# Fence - north and south neighbor
block:id=85,data=5,scale=16
layer:0,1,2,3,4,5,9,10,11,15
----------------
----------------
----------------
----------------
----------------
----------------
------****------
------****------
------****------
------****------
----------------
----------------
----------------
----------------
----------------
----------------
layer:6,7,8,12,13,14
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
------****------
------****------
------****------
------****------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
# Fence - east and west neighbor
block:id=85,data=10,scale=16
rotate:id=85,data=5,rot=90
# Fence - north, east and south neighbor
block:id=85,data=7,scale=16
layer:0,1,2,3,4,5,9,10,11,15
----------------
----------------
----------------
----------------
----------------
----------------
------****------
------****------
------****------
------****------
----------------
----------------
----------------
----------------
----------------
----------------
layer:6,7,8,12,13,14
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
------****------
------**********
------**********
------****------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
# Fence - east, south and west neighbor
block:id=85,data=14,scale=16
rotate:id=85,data=7,rot=90
# Fence - south, west and north neighbor
block:id=85,data=13,scale=16
rotate:id=85,data=7,rot=180
# Fence - west, north and east neighbor
block:id=85,data=11,scale=16
rotate:id=85,data=7,rot=270
# Fence - north, south, east, west neightbors
block:id=85,data=15,scale=16
layer:0,1,2,3,4,5,9,10,11,15
----------------
----------------
----------------
----------------
----------------
----------------
------****------
------****------
------****------
------****------
----------------
----------------
----------------
----------------
----------------
----------------
layer:6,7,8,12,13,14
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
------****------
****************
****************
------****------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
-------**-------
# Trapdoor # Trapdoor
# Stone pressure plate # Stone pressure plate
# Wooden pressure plate # Wooden pressure plate
@ -606,12 +818,16 @@ rotate:id=65,data=2,rot=270
block:id=65,data=5,scale=16 block:id=65,data=5,scale=16
rotate:id=65,data=2,rot=90 rotate:id=65,data=2,rot=90
# Wall sign - facing east # Wall sign - facing east
block:id=68,data=2,scale=4 block:id=68,data=2,scale=8
layer:1,2 layer:2,3,4,5
*--- *-------
*--- *-------
*--- *-------
*--- *-------
*-------
*-------
*-------
*-------
# Wall sign - facing west # Wall sign - facing west
block:id=68,data=3,scale=4 block:id=68,data=3,scale=4
rotate:id=68,data=2,rot=180 rotate:id=68,data=2,rot=180
@ -996,7 +1212,7 @@ layer:3
--**-**- --**-**-
--**---- --**----
-------- --------
layer:4 layer:4,5
-------- --------
--*----- --*-----
--*--**- --*--**-
@ -1005,12 +1221,188 @@ layer:4
-**--*-- -**--*--
-----*-- -----*--
-------- --------
layer:6,7
--------
--------
--*--*--
--------
--------
--*--*--
--------
--------
Tall grass
block:id=31,data=1,scale=16
layer:0,1
-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-
-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-
-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-
-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-
-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-
-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-
-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-
-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-
layer:2,3
---*---*---*---*
-*---*---*---*--
---*---*---*---*
-*---*---*---*--
---*---*---*---*
-*---*---*---*--
---*---*---*---*
-*---*---*---*--
---*---*---*---*
-*---*---*---*--
---*---*---*---*
-*---*---*---*--
---*---*---*---*
-*---*---*---*--
---*---*---*---*
-*---*---*---*--
layer:4
-----*-------*--
-*-------*------
-----*-------*--
-*-------*------
-----*-------*--
-*-------*------
-----*-------*--
-*-------*------
-----*-------*--
-*-------*------
-----*-------*--
-*-------*------
-----*-------*--
-*-------*------
-----*-------*--
-*-------*------
# Sapling
block:id=6,data=*,scale=8
layer:0
--------
--------
--------
---**---
---**---
--------
--------
--------
layer:1
--------
--------
---*----
---**---
---***--
--*-----
--------
--------
layer:2
--------
---*----
--------
--***---
---**-*-
----*---
-*------
--------
layer:3
--------
---*----
--------
-*-**---
---**-*-
--------
-*---*--
--------
layer:4
--------
---**---
-*-*-*--
**--**--
---*----
-*--**--
-**--*--
--------
layer:5 layer:5
-------- --------
---**---
**-***--
**--**--
---*----
-**-**--
-**-**--
-------- --------
--*--*-- # Bed - head - pointing west
block:id=26,data=8,scale=8
layer:0,1
-------- --------
*-------
*-------
*-------
*-------
*-------
*-------
-------- --------
--*--*-- layer:2,3
-------- --------
********
********
********
********
********
********
-------- --------
layer:4
--------
*-------
*-**----
*-**----
*-**----
*-**----
*-------
--------
# Bed - head - pointing north
block:id=26,data=9,scale=8
rotate:id=26,data=8,rot=90
# Bed - head - pointing east
block:id=26,data=10,scale=8
rotate:id=26,data=8,rot=180
# Bed - head - pointing south
block:id=26,data=11,scale=8
rotate:id=26,data=8,rot=270
# Bed - foot - pointing west
block:id=26,data=0,scale=8
layer:0,1
--------
------*-
------*-
------*-
------*-
------*-
------*-
--------
layer:2,3
--------
*******-
*******-
*******-
*******-
*******-
*******-
--------
# Bed - foot - pointing north
block:id=26,data=1,scale=8
rotate:id=26,data=0,rot=90
# Bed - foot - pointing east
block:id=26,data=2,scale=8
rotate:id=26,data=0,rot=180
# Bed - foot - pointing south
block:id=26,data=3,scale=8
rotate:id=26,data=0,rot=270

View File

@ -154,9 +154,10 @@ public class DefaultHDShader implements HDShader {
seq = 0; seq = 0;
break; break;
default: default:
if(subalpha >= 0) /* We hit a block in a model */ //if(subalpha >= 0) /* We hit a block in a model */
seq = 4; /* Use smooth top */ // seq = 4; /* Use smooth top */
else if(((pixelodd + mapiter.getY()) & 0x03) == 0) //else
if(((pixelodd + mapiter.getY()) & 0x03) == 0)
seq = 3; seq = 3;
else else
seq = 1; seq = 1;

View File

@ -162,6 +162,8 @@ public class HDBlockModels {
} }
} }
map[off] = (short)((255*raw_w) / (nativeres*nativeres*nativeres)); map[off] = (short)((255*raw_w) / (nativeres*nativeres*nativeres));
if(map[off] > 255) map[off] = 255;
if(map[off] < 0) map[off] = 0;
} }
} }
} }
@ -214,6 +216,8 @@ public class HDBlockModels {
} }
for(int i = 0; i < map.length; i++) { for(int i = 0; i < map.length; i++) {
map[i] = (short)(255*map[i]/(nativeres*nativeres*nativeres)); map[i] = (short)(255*map[i]/(nativeres*nativeres*nativeres));
if(map[i] > 255) map[i] = 255;
if(map[i] < 0) map[i] = 0;
} }
} }
scaledblocks.put(Integer.valueOf(res), map); scaledblocks.put(Integer.valueOf(res), map);

View File

@ -216,14 +216,39 @@ public class IsoHDPerspective implements HDPerspective {
*/ */
private boolean visit_block(MapIterator mapiter, HDShaderState[] shaderstate, boolean[] shaderdone) { private boolean visit_block(MapIterator mapiter, HDShaderState[] shaderstate, boolean[] shaderdone) {
blocktypeid = mapiter.getBlockTypeID(); blocktypeid = mapiter.getBlockTypeID();
boolean skip_light_update = false;
if(nonairhit || (blocktypeid != 0)) { if(nonairhit || (blocktypeid != 0)) {
blockdata = mapiter.getBlockData(); blockdata = mapiter.getBlockData();
if(blocktypeid == 85) { /* Special case for fence - need to fake data so we can render properly */
mapiter.decrementX(); /* Look north */
blockdata = 0;
if(mapiter.getBlockTypeID() == 85) { /* Fence? */
blockdata |= 1;
}
mapiter.incrementX();
mapiter.decrementZ(); /* Look east */
if(mapiter.getBlockTypeID() == 85) { /* Fence? */
blockdata |= 2;
}
mapiter.incrementZ();
mapiter.incrementX(); /* Look south */
if(mapiter.getBlockTypeID() == 85) { /* Fence? */
blockdata |= 4;
}
mapiter.decrementX(); /* Look west */
mapiter.incrementZ();
if(mapiter.getBlockTypeID() == 85) { /* Fence? */
blockdata |= 8;
}
mapiter.decrementZ();
}
boolean missed = false; boolean missed = false;
/* Look up to see if block is modelled */ /* Look up to see if block is modelled */
short[] model = scalemodels.getScaledModel(blocktypeid, blockdata); short[] model = scalemodels.getScaledModel(blocktypeid, blockdata);
if(model != null) { if(model != null) {
missed = raytraceSubblock(model); missed = raytraceSubblock(model);
skip_light_update = true; /* Some blocks are light blocking, but not fully blocking - this sucks */
} }
else { else {
subalpha = -1; subalpha = -1;
@ -241,10 +266,26 @@ public class IsoHDPerspective implements HDPerspective {
nonairhit = true; nonairhit = true;
} }
} }
if(need_skylightlevel) if(skip_light_update) { /* If considering skipping, do so if block is unlit */
skylightlevel = mapiter.getBlockSkyLight(); int ll;
if(need_emittedlightlevel) if(need_skylightlevel) {
emittedlightlevel = mapiter.getBlockEmittedLight(); ll = mapiter.getBlockSkyLight();
if(ll > 0)
skylightlevel = ll;
}
if(need_emittedlightlevel) {
ll = mapiter.getBlockEmittedLight();
if(ll > 0) {
emittedlightlevel = ll;
}
}
}
else {
if(need_skylightlevel)
skylightlevel = mapiter.getBlockSkyLight();
if(need_emittedlightlevel)
emittedlightlevel = mapiter.getBlockEmittedLight();
}
return false; return false;
} }
/** /**
@ -314,7 +355,7 @@ public class IsoHDPerspective implements HDPerspective {
private boolean raytraceSubblock(short[] model) { private boolean raytraceSubblock(short[] model) {
int mx = 0, my = 0, mz = 0; int mx = 0, my = 0, mz = 0;
double xx, yy, zz; double xx, yy, zz;
double mt = t + 0.00000001; double mt = t + 0.0000001;
xx = top.x + mt *(bottom.x - top.x); xx = top.x + mt *(bottom.x - top.x);
yy = top.y + mt *(bottom.y - top.y); yy = top.y + mt *(bottom.y - top.y);
zz = top.z + mt *(bottom.z - top.z); zz = top.z + mt *(bottom.z - top.z);
@ -357,11 +398,14 @@ public class IsoHDPerspective implements HDPerspective {
mt_next_x += mdt_dx; mt_next_x += mdt_dx;
if(x_inc > 0) { if(x_inc > 0) {
laststep = BlockStep.X_PLUS; laststep = BlockStep.X_PLUS;
if(mx >= modscale)
return true;
} }
else { else {
laststep = BlockStep.X_MINUS; laststep = BlockStep.X_MINUS;
if(mx < 0) if(mx < 0)
mx += modscale; //mx += modscale;
return true;
} }
} }
/* If Y step is next best */ /* If Y step is next best */
@ -371,11 +415,14 @@ public class IsoHDPerspective implements HDPerspective {
mt_next_y += mdt_dy; mt_next_y += mdt_dy;
if(y_inc > 0) { if(y_inc > 0) {
laststep = BlockStep.Y_PLUS; laststep = BlockStep.Y_PLUS;
if(my >= modscale)
return true;
} }
else { else {
laststep = BlockStep.Y_MINUS; laststep = BlockStep.Y_MINUS;
if(my < 0) if(my < 0)
my += modscale; //my += modscale;
return true;
} }
} }
/* Else, Z step is next best */ /* Else, Z step is next best */
@ -385,11 +432,14 @@ public class IsoHDPerspective implements HDPerspective {
mt_next_z += mdt_dz; mt_next_z += mdt_dz;
if(z_inc > 0) { if(z_inc > 0) {
laststep = BlockStep.Z_PLUS; laststep = BlockStep.Z_PLUS;
if(mz >= modscale)
return true;
} }
else { else {
laststep = BlockStep.Z_MINUS; laststep = BlockStep.Z_MINUS;
if(mz < 0) if(mz < 0)
mz += modscale; //mz += modscale;
return true;
} }
} }
} }