Fixed lighting graphical issues
This commit is contained in:
parent
afd16a7389
commit
55ea5e6c55
|
|
@ -8,7 +8,7 @@ import projectzombie.Main;
|
||||||
|
|
||||||
public class Camera
|
public class Camera
|
||||||
{
|
{
|
||||||
public int cx, cy;
|
public double x, y;
|
||||||
public double angle = 45;
|
public double angle = 45;
|
||||||
private Matrix4 matrix;
|
private Matrix4 matrix;
|
||||||
|
|
||||||
|
|
@ -20,11 +20,9 @@ public class Camera
|
||||||
Vec3d pos = Main.player.getPos();
|
Vec3d pos = Main.player.getPos();
|
||||||
angle = Main.player.angle;
|
angle = Main.player.angle;
|
||||||
|
|
||||||
cx = MathHelpers.floor((pos.x - 0.5) / 16.0) + 1;
|
x = pos.x - 0.5;
|
||||||
cy = MathHelpers.floor((pos.z - 0.5) / 16.0) + 1;
|
y = pos.z - 0.5;
|
||||||
|
|
||||||
identity = Matrix4.multiply(identity, Matrix4.translate(
|
|
||||||
MathHelpers.mod(-pos.x + 0.5, 16), 0, MathHelpers.mod(-pos.z + 0.5, 16)));
|
|
||||||
identity = Matrix4.multiply(identity, Matrix4.rotate(angle + 180, 0, 1, 0));
|
identity = Matrix4.multiply(identity, Matrix4.rotate(angle + 180, 0, 1, 0));
|
||||||
identity = Matrix4.multiply(identity, Matrix4.rotate(-45, 1, 0, 0));
|
identity = Matrix4.multiply(identity, Matrix4.rotate(-45, 1, 0, 0));
|
||||||
identity = Matrix4.multiply(identity, Matrix4.translate(0, 0, -16));
|
identity = Matrix4.multiply(identity, Matrix4.translate(0, 0, -16));
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,8 @@ public class DisplayLighting
|
||||||
}
|
}
|
||||||
|
|
||||||
Main.worker.processLighting(lights, size, size,
|
Main.worker.processLighting(lights, size, size,
|
||||||
MathHelpers.floor(ppos.x / 16) - Chunk.RENDER_DISTANCE,
|
MathHelpers.floor(ppos.x / 16.0) - Chunk.RENDER_DISTANCE,
|
||||||
MathHelpers.floor(ppos.y / 16) - Chunk.RENDER_DISTANCE);
|
MathHelpers.floor(ppos.y / 16.0) - Chunk.RENDER_DISTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void calculateLight(Layer layer, Lighting lighting, float[] pixels, int x, int y, float level)
|
private static void calculateLight(Layer layer, Lighting lighting, float[] pixels, int x, int y, float level)
|
||||||
|
|
@ -299,16 +299,19 @@ public class DisplayLighting
|
||||||
|
|
||||||
GL33.glGenerateMipmap(GL33.GL_TEXTURE_2D);
|
GL33.glGenerateMipmap(GL33.GL_TEXTURE_2D);
|
||||||
|
|
||||||
int cx = 0, cy = 0;
|
// Set the texture location data
|
||||||
|
GL33.glUniform2f(Main.window.glsl_lightmap_size, lighting.w, lighting.h);
|
||||||
|
|
||||||
if(Camera.camera != null) {
|
if(Camera.camera != null) {
|
||||||
cx = Camera.camera.cx;
|
GL33.glUniform2f(Main.window.glsl_lightmap_offset,
|
||||||
cy = Camera.camera.cy;
|
(float)(lighting.x * 16 - Camera.camera.x - 0.5),
|
||||||
|
(float)(lighting.y * 16 - Camera.camera.y - 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
System.out.println("CAMERA IS NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the texture location data
|
|
||||||
GL33.glUniform2f(Main.window.glsl_lightmap_offset, (lighting.x - cx) * 16 - 0.5f, (lighting.y - cy) * 16 - 0.5f);
|
|
||||||
GL33.glUniform2f(Main.window.glsl_lightmap_size, lighting.w, lighting.h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearLighting()
|
public static void clearLighting()
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,8 @@ public class DisplayRender
|
||||||
{
|
{
|
||||||
Model model = player.getModel();
|
Model model = player.getModel();
|
||||||
model.setModel(Matrix4.translate(
|
model.setModel(Matrix4.translate(
|
||||||
(ppos.x - Camera.camera.cx * 16) - 0.5, ppos.y,
|
ppos.x - Camera.camera.x - 0.5, ppos.y,
|
||||||
(ppos.z - Camera.camera.cy * 16) - 0.5));
|
ppos.z - Camera.camera.y - 0.5));
|
||||||
model.render();
|
model.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package projectzombie.world.chunk;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL33;
|
||||||
|
|
||||||
import bdf.classes.IBdfClassManager;
|
import bdf.classes.IBdfClassManager;
|
||||||
import bdf.types.BdfArray;
|
import bdf.types.BdfArray;
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
|
|
@ -206,8 +208,8 @@ public class Chunk implements IBdfClassManager
|
||||||
|
|
||||||
// Render the model
|
// Render the model
|
||||||
model.setModel(Matrix4.translate(
|
model.setModel(Matrix4.translate(
|
||||||
(pos.x - Camera.camera.cx * 16) - 0.5, pos.y,
|
pos.x - Camera.camera.x - 0.5, pos.y,
|
||||||
(pos.z - Camera.camera.cy * 16) - 0.5));
|
pos.z - Camera.camera.y - 0.5));
|
||||||
model.render();
|
model.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -290,7 +292,7 @@ public class Chunk implements IBdfClassManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render all the tiles in the chunk as a block
|
// Render all the tiles in the chunk as a block
|
||||||
model.setModel(Matrix4.translate((c_pos.x - Camera.camera.cx) * 16, 0, (c_pos.y - Camera.camera.cy) * 16));
|
model.setModel(Matrix4.translate(c_pos.x * 16 - Camera.camera.x, 0, c_pos.y * 16 - Camera.camera.y));
|
||||||
model.render();
|
model.render();
|
||||||
|
|
||||||
renderEntities(entities.toArray());
|
renderEntities(entities.toArray());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue