Last active
December 3, 2019 17:39
-
-
Save matyklug18/3d58bd576581d7fc7ed22b826a6fae47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(Input.isButtonDown(GLFW.GLFW_MOUSE_BUTTON_MIDDLE)) { | |
double x, y = 0, z; | |
float x0 = camera.getRotation().getX(); | |
float y0 = camera.getRotation().getY(); | |
x0 = (float) (x0-(360*Math.floor(x0/360))); | |
y0 = (float) (y0-(360*Math.floor(y0/360))); | |
//0=0, 90=1, 180 = 0, 270=-1 | |
x = sin(Math.toRadians(y0)) * cos(Math.toRadians(x0)); | |
//y = sin(Math.toRadians(y0)) * sin(Math.toRadians(x0)); | |
z = cos(Math.toRadians(y0)); | |
if(x0 <= 90) { | |
y = map(x0, 0, 90, 0, 1); | |
} else if(x0 > 90 && x0 <= 180) { | |
y = map(x0, 90, 180, 1, 0); | |
} else if(x0 > 180 && x0 <= 270) { | |
y = map(x0, 180, 270, 0, -1); | |
} else if(x0 > 270 && x0 <= 360) { | |
y = map(x0, 270, 360, -1, 0); | |
} | |
x *= -1; | |
z *= -1; | |
//camera.getPosition().add(new Vector3f(x,y,z)); | |
Vector3f vec = camera.getPosition().clone(); | |
for(int i = 0; i < 500; i++) { | |
vec.add(new Vector3f(x,y,z).div(new Vector3f(100,100,100))); | |
if(!(allBlocks[Math.round(vec.getX())][Math.round(vec.getY())][Math.round(vec.getZ())] instanceof BlockAir)) { | |
allBlocks[Math.round(vec.getX())][Math.round(vec.getY())][Math.round(vec.getZ())] = new BlockAir(); | |
reconstrucMesh(); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment