Fix a rounding error to remove gridlines that appear around blocks.
This commit is contained in:
parent
90d55de494
commit
27fd83af6d
@ -159,6 +159,19 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
|||||||
for (int x=0;x<64;x++) {
|
for (int x=0;x<64;x++) {
|
||||||
for (int z=0;z<64;z++) {
|
for (int z=0;z<64;z++) {
|
||||||
addBlock(new Vector(x,0,z),BlockType.GRASS);
|
addBlock(new Vector(x,0,z),BlockType.GRASS);
|
||||||
|
if (r.nextInt(2)<1) {
|
||||||
|
switch (r.nextInt(7)) {
|
||||||
|
case 1:{
|
||||||
|
addBlock(new Vector(x,1,z),BlockType.FURNACE);
|
||||||
|
}break;
|
||||||
|
case 2:{
|
||||||
|
addBlock(new Vector(x,1,z),BlockType.PUMPKIN);
|
||||||
|
}break;
|
||||||
|
case 3:{
|
||||||
|
addBlock(new Vector(x,1,z),BlockType.CRAFTING_TABLE);
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
if (Math.random()<=0.5) {
|
if (Math.random()<=0.5) {
|
||||||
addBlock(new Vector(x,y,z),BlockType.GLASS);
|
addBlock(new Vector(x,y,z),BlockType.GLASS);
|
||||||
@ -170,11 +183,12 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
|||||||
|
|
||||||
for (int x=0;x<64;x++) {
|
for (int x=0;x<64;x++) {
|
||||||
for (int y=1;y<5;y++) {
|
for (int y=1;y<5;y++) {
|
||||||
|
/*
|
||||||
if (x%8>2&&x%8<6&&y>1&&y<4) {
|
if (x%8>2&&x%8<6&&y>1&&y<4) {
|
||||||
addBlock(new Vector(x,y,16),BlockType.GLASS);
|
addBlock(new Vector(x,y,16),BlockType.GLASS);
|
||||||
} else {
|
} else {
|
||||||
addBlock(new Vector(x,y,16),BlockType.FURNACE);
|
addBlock(new Vector(x,y,16),BlockType.FURNACE);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ public class Texture{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getColor(float u,float v,float mult) {
|
public int getColor(float u,float v,float mult) {
|
||||||
int sx = (int)(u*width-1f);
|
int sx = (int)Math.min(width-0.1f,(u*width-0.1f));
|
||||||
int sy = (int)(v*height-1f);
|
int sy = (int)Math.min(height-0.1f,(v*height-0.1f));
|
||||||
if (sx<0||sx>=width||sy<0||sy>=height) {
|
if (sx<0||sx>=width||sy<0||sy>=height) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
int indice = (int)(u*width-1)+(int)(v*height-1)*width;
|
int indice = sx+sy*width;
|
||||||
//return tex[indice];
|
//return tex[indice];
|
||||||
return (int)((tex[indice]&0xFF)*mult) + ((int)(((tex[indice]&0xFF00)>>>8)*mult)<<8) + ((int)(((tex[indice]&0xFF0000)>>>16)*mult)<<16) + ((((tex[indice]&0xFF000000)>>>24))<<24);
|
return (int)((tex[indice]&0xFF)*mult) + ((int)(((tex[indice]&0xFF00)>>>8)*mult)<<8) + ((int)(((tex[indice]&0xFF0000)>>>16)*mult)<<16) + ((((tex[indice]&0xFF000000)>>>24))<<24);
|
||||||
/*Color newCol = new Color(tex.getRGB(sx,sy));
|
/*Color newCol = new Color(tex.getRGB(sx,sy));
|
||||||
|
@ -85,10 +85,10 @@ public class DrawUtils {
|
|||||||
tex_v=tex_sv;
|
tex_v=tex_sv;
|
||||||
tex_w=tex_sw;
|
tex_w=tex_sw;
|
||||||
|
|
||||||
float tstep = 1.0f/((float)(bx-ax));
|
float tstep = 1.0f/(float)(bx-ax);
|
||||||
float t=0.0f;
|
float t=0.0f;
|
||||||
|
|
||||||
for (int j=ax;j<bx;j++) {
|
for (int j=ax;j<=bx;j++) {
|
||||||
tex_u=(1.0f-t)*tex_su+t*tex_eu;
|
tex_u=(1.0f-t)*tex_su+t*tex_eu;
|
||||||
tex_v=(1.0f-t)*tex_sv+t*tex_ev;
|
tex_v=(1.0f-t)*tex_sv+t*tex_ev;
|
||||||
tex_w=(1.0f-t)*tex_sw+t*tex_ew;
|
tex_w=(1.0f-t)*tex_sw+t*tex_ew;
|
||||||
@ -161,10 +161,10 @@ public class DrawUtils {
|
|||||||
tex_v=tex_sv;
|
tex_v=tex_sv;
|
||||||
tex_w=tex_sw;
|
tex_w=tex_sw;
|
||||||
|
|
||||||
float tstep = 1.0f/((float)(bx-ax));
|
float tstep = 1.0f/(float)(bx-ax);
|
||||||
float t=0.0f;
|
float t=0.0f;
|
||||||
|
|
||||||
for (int j=ax;j<bx;j++) {
|
for (int j=ax;j<=bx;j++) {
|
||||||
tex_u=(1.0f-t)*tex_su+t*tex_eu;
|
tex_u=(1.0f-t)*tex_su+t*tex_eu;
|
||||||
tex_v=(1.0f-t)*tex_sv+t*tex_ev;
|
tex_v=(1.0f-t)*tex_sv+t*tex_ev;
|
||||||
tex_w=(1.0f-t)*tex_sw+t*tex_ew;
|
tex_w=(1.0f-t)*tex_sw+t*tex_ew;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user