Actually got something rendering
This commit is contained in:
parent
7dbe75a497
commit
95bd4df7ef
|
|
@ -72,6 +72,10 @@ public class Main
|
||||||
Tiles.init();
|
Tiles.init();
|
||||||
LayerGenerators.init();
|
LayerGenerators.init();
|
||||||
|
|
||||||
|
// Create the display
|
||||||
|
window = new DisplayWindow("Project Zombie");
|
||||||
|
window.init();
|
||||||
|
|
||||||
// Load the resources
|
// Load the resources
|
||||||
Resources.loadResources();
|
Resources.loadResources();
|
||||||
|
|
||||||
|
|
@ -83,26 +87,21 @@ public class Main
|
||||||
AudioSources.init();
|
AudioSources.init();
|
||||||
Sounds.init();
|
Sounds.init();
|
||||||
|
|
||||||
// Create the mainloop
|
|
||||||
mainloop = new MainloopManager(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
|
|
||||||
mainloop.register(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
|
|
||||||
mainloop.register(ChunkEventHandler.CHUNK_EVENT_HANDLER);
|
|
||||||
mainloop.register(DisplayStatsEventHandler.DISPLAY_STATS_EVENT_HANDLER);
|
|
||||||
mainloop.register(JoystickCallback.JOYSTICK_CALLBACK);
|
|
||||||
mainloop.register(new GameTimer());
|
|
||||||
mainloop.register(new KeyCallback());
|
|
||||||
mainloop.register(new NoSleep());
|
|
||||||
mainloop.register(new MainloopHelpers());
|
|
||||||
|
|
||||||
// Create the display
|
|
||||||
window = new DisplayWindow("Project Zombie");
|
|
||||||
window.init();
|
|
||||||
|
|
||||||
// Initialize the gamepad
|
// Initialize the gamepad
|
||||||
JoystickCallback.JOYSTICK_CALLBACK.init();
|
JoystickCallback.JOYSTICK_CALLBACK.init();
|
||||||
|
|
||||||
// Initialise the entities
|
// Create the mainloop
|
||||||
|
mainloop = new MainloopManager(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
|
||||||
|
mainloop.register(DisplayStatsEventHandler.DISPLAY_STATS_EVENT_HANDLER);
|
||||||
|
mainloop.register(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
|
||||||
mainloop.register(EntityEventHandler.ENTITY_EVENT_HANDLER);
|
mainloop.register(EntityEventHandler.ENTITY_EVENT_HANDLER);
|
||||||
|
mainloop.register(ChunkEventHandler.CHUNK_EVENT_HANDLER);
|
||||||
|
mainloop.register(JoystickCallback.JOYSTICK_CALLBACK);
|
||||||
|
mainloop.register(new MainloopHelpers());
|
||||||
|
mainloop.register(new KeyCallback());
|
||||||
|
mainloop.register(new GameTimer());
|
||||||
|
mainloop.register(new NoSleep());
|
||||||
|
mainloop.register(window);
|
||||||
|
|
||||||
// Start the mainloop
|
// Start the mainloop
|
||||||
menu = new MenuMain();
|
menu = new MenuMain();
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,10 @@ import org.lwjgl.stb.STBVorbis;
|
||||||
import org.lwjgl.system.MemoryStack;
|
import org.lwjgl.system.MemoryStack;
|
||||||
|
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
|
import projectzombie.display.Camera;
|
||||||
import projectzombie.resources.Resource;
|
import projectzombie.resources.Resource;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
|
import gl_engine.matrix.Matrix4;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
|
|
||||||
|
|
@ -30,6 +32,7 @@ public class AudioObject
|
||||||
{
|
{
|
||||||
int bufferPointer;
|
int bufferPointer;
|
||||||
Resource resource;
|
Resource resource;
|
||||||
|
boolean error;
|
||||||
int channels;
|
int channels;
|
||||||
int sample_rate;
|
int sample_rate;
|
||||||
int output;
|
int output;
|
||||||
|
|
@ -38,6 +41,7 @@ public class AudioObject
|
||||||
{
|
{
|
||||||
// Store the argument values
|
// Store the argument values
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
|
this.error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
|
|
@ -51,6 +55,11 @@ public class AudioObject
|
||||||
ByteBuffer resource_buffer = resource.getByteBuffer();
|
ByteBuffer resource_buffer = resource.getByteBuffer();
|
||||||
ShortBuffer audio = STBVorbis.stb_vorbis_decode_memory(resource_buffer, channels_buf, sample_rate_buf);
|
ShortBuffer audio = STBVorbis.stb_vorbis_decode_memory(resource_buffer, channels_buf, sample_rate_buf);
|
||||||
|
|
||||||
|
if(audio == null) {
|
||||||
|
error = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the channels and the sample rate
|
// Get the channels and the sample rate
|
||||||
channels = channels_buf.get();
|
channels = channels_buf.get();
|
||||||
sample_rate = sample_rate_buf.get();
|
sample_rate = sample_rate_buf.get();
|
||||||
|
|
@ -65,6 +74,7 @@ public class AudioObject
|
||||||
|
|
||||||
// Send the data to OpenAL
|
// Send the data to OpenAL
|
||||||
bufferPointer = alGenBuffers();
|
bufferPointer = alGenBuffers();
|
||||||
|
|
||||||
alBufferData(bufferPointer, format, audio, sample_rate);
|
alBufferData(bufferPointer, format, audio, sample_rate);
|
||||||
|
|
||||||
// Free some c buffers
|
// Free some c buffers
|
||||||
|
|
@ -74,28 +84,19 @@ public class AudioObject
|
||||||
|
|
||||||
public void play(Vec3d pos, double volume)
|
public void play(Vec3d pos, double volume)
|
||||||
{
|
{
|
||||||
// Get the player pos
|
if(error) {
|
||||||
Vec2d p_pos = Main.player.pos;
|
return;
|
||||||
|
}
|
||||||
// Convert the angle to radians
|
|
||||||
double angle_r = Math.toRadians(Main.player.angle + 90);
|
|
||||||
|
|
||||||
// Calculate the translation
|
|
||||||
double x = ( pos.x - p_pos.x );
|
|
||||||
double y = ( pos.y - p_pos.y );
|
|
||||||
double z = pos.z;
|
|
||||||
|
|
||||||
// Calculate the rotation
|
// Calculate the rotation
|
||||||
Vec2d rotated = MathHelpers.rotate2(new Vec2d(x, y), -angle_r);
|
Vec3d vec = Matrix4.multiply(Camera.camera.getMatrix(), pos);
|
||||||
x = rotated.x;
|
|
||||||
y = rotated.y;
|
|
||||||
|
|
||||||
// Play the sound with a new source
|
// Play the sound with a new source
|
||||||
int source = AudioSources.getSource();
|
int source = AudioSources.getSource();
|
||||||
alSourceStop(source);
|
alSourceStop(source);
|
||||||
alSourcei(source, AL_BUFFER, bufferPointer);
|
alSourcei(source, AL_BUFFER, bufferPointer);
|
||||||
alSourcef(source, AL_GAIN, (float)volume);
|
alSourcef(source, AL_GAIN, (float)volume);
|
||||||
alSource3f(source, AL_POSITION, (float)x, (float)y, (float)z);
|
alSource3f(source, AL_POSITION, (float)vec.x, (float)vec.y, (float)vec.z);
|
||||||
alSourcePlay(source);
|
alSourcePlay(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,30 @@
|
||||||
package projectzombie.display;
|
package projectzombie.display;
|
||||||
|
|
||||||
import gl_engine.matrix.Matrix4;
|
import gl_engine.matrix.Matrix4;
|
||||||
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
|
import projectzombie.Main;
|
||||||
|
|
||||||
public class Camera
|
public class Camera
|
||||||
{
|
{
|
||||||
public double angle = 45;
|
public double angle = 45;
|
||||||
public int renderDistance;
|
public int renderDistance = 3;
|
||||||
private Matrix4 matrix;
|
private Matrix4 matrix;
|
||||||
|
|
||||||
public static Camera camera;
|
public static Camera camera;
|
||||||
|
|
||||||
public Camera(Vec3d pos)
|
public Camera()
|
||||||
{
|
{
|
||||||
Matrix4 identity = Matrix4.identity();
|
Matrix4 identity = Matrix4.identity();
|
||||||
|
Vec2d pos = Main.player.pos;
|
||||||
|
angle = Main.player.angle;
|
||||||
|
|
||||||
identity = Matrix4.multiply(identity, Matrix4.translate(pos.x, 0, pos.y));
|
identity = Matrix4.multiply(identity, Matrix4.translate(-pos.x, 0, -pos.y));
|
||||||
identity = Matrix4.multiply(identity, Matrix4.rotate(angle, 0, 1, 0));
|
identity = Matrix4.multiply(identity, Matrix4.rotate(angle, 0, 1, 0));
|
||||||
identity = Matrix4.multiply(identity, Matrix4.rotate(-50, 1, 0, 0));
|
identity = Matrix4.multiply(identity, Matrix4.rotate(-50, 1, 0, 0));
|
||||||
identity = Matrix4.multiply(identity, Matrix4.translate(0, 0, -8));
|
identity = Matrix4.multiply(identity, Matrix4.translate(0, 0, -12));
|
||||||
|
|
||||||
|
matrix = identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matrix4 getMatrix() {
|
public Matrix4 getMatrix() {
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,16 @@ import static org.lwjgl.opengl.GL11.glMatrixMode;
|
||||||
import static org.lwjgl.opengl.GL11.glViewport;
|
import static org.lwjgl.opengl.GL11.glViewport;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
|
import org.lwjgl.opengl.GL33;
|
||||||
import org.lwjgl.system.MemoryStack;
|
import org.lwjgl.system.MemoryStack;
|
||||||
|
|
||||||
|
import gl_engine.graphics.GraphicsShader;
|
||||||
import gl_engine.matrix.Matrix4;
|
import gl_engine.matrix.Matrix4;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.display.lighting.DynamicLighting;
|
import projectzombie.display.lighting.DynamicLighting;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.gl.GlHelpers;
|
import projectzombie.util.gl.GlHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
|
|
@ -29,10 +32,6 @@ public class DisplayRender
|
||||||
{
|
{
|
||||||
public static void render(int w, int h)
|
public static void render(int w, int h)
|
||||||
{
|
{
|
||||||
// Set the width and the height
|
|
||||||
Main.window.setWidth(w);
|
|
||||||
Main.window.setHeight(h);
|
|
||||||
|
|
||||||
// Setup GL and clear the colour
|
// Setup GL and clear the colour
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
|
|
@ -41,24 +40,35 @@ public class DisplayRender
|
||||||
{
|
{
|
||||||
if(ChunkEventHandler.loaded)
|
if(ChunkEventHandler.loaded)
|
||||||
{
|
{
|
||||||
// Create the projection matrix
|
|
||||||
Matrix4 projection = Matrix4.projection((double)w / (double)h, 45, 1, 32);
|
|
||||||
|
|
||||||
EntityPlayer player = Main.player;
|
EntityPlayer player = Main.player;
|
||||||
Camera camera = new Camera(new Vec3d(player.pos.x, 0, player.pos.y));
|
Camera camera = new Camera();
|
||||||
Camera.camera = camera;
|
Camera.camera = camera;
|
||||||
|
|
||||||
|
// Create the projection matrix
|
||||||
|
Matrix4 projection = Matrix4.projection((double)w / (double)h, 45, 0.1, 1000);
|
||||||
|
Matrix4 rotated = Matrix4.rotate(-camera.angle, 0, 1, 0);
|
||||||
|
|
||||||
// Process all the light sources
|
// Process all the light sources
|
||||||
DynamicLighting.update();
|
//DynamicLighting.update();
|
||||||
|
|
||||||
|
Main.window.environmentRenderer.use();
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_camera, true, camera.getMatrix().getArray());
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_projection, true, projection.getArray());
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_rotated, true, rotated.getArray());
|
||||||
|
|
||||||
// Render the world and the player
|
// Render the world and the player
|
||||||
Main.world.render(camera);
|
Main.world.render(camera);
|
||||||
player.chunk = Main.world.getLayer().getChunk(player.pos);
|
player.chunk = Main.world.getLayer().getChunk(player.pos);
|
||||||
player.doRender(player.pos, camera);
|
|
||||||
|
Model model = player.getModel();
|
||||||
|
Matrix4 matrix = Matrix4.translate(player.pos.x, 0, player.pos.y);
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_model, true, matrix.getArray());
|
||||||
|
model.bind();
|
||||||
|
model.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the user interface
|
// Render the user interface
|
||||||
DisplayRenderUI.render();
|
//DisplayRenderUI.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class DisplayRenderUI
|
||||||
|
|
||||||
public static void render()
|
public static void render()
|
||||||
{
|
{
|
||||||
double s = GlHelpers.getScale() / 10.0;
|
/*double s = GlHelpers.getScale() / 10.0;
|
||||||
|
|
||||||
// Get some text settings
|
// Get some text settings
|
||||||
Vec2d text_size = new Vec2d(0.5, 0.5);
|
Vec2d text_size = new Vec2d(0.5, 0.5);
|
||||||
|
|
@ -186,6 +186,6 @@ public class DisplayRenderUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the loaded menu
|
// Render the loaded menu
|
||||||
Main.menu.render();
|
Main.menu.render();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,15 @@ import java.nio.IntBuffer;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
|
import org.lwjgl.opengl.GL33;
|
||||||
|
|
||||||
import gl_engine.graphics.GraphicsHelpers;
|
import gl_engine.graphics.GraphicsHelpers;
|
||||||
|
import gl_engine.graphics.GraphicsShader;
|
||||||
|
import gl_engine.matrix.Matrix4;
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.init.Resources;
|
||||||
import projectzombie.input.CursorEnterCallback;
|
import projectzombie.input.CursorEnterCallback;
|
||||||
import projectzombie.input.CursorPosCallback;
|
import projectzombie.input.CursorPosCallback;
|
||||||
import projectzombie.input.JoystickCallback;
|
import projectzombie.input.JoystickCallback;
|
||||||
|
|
@ -33,6 +38,13 @@ public class DisplayWindow implements IMainloopTask
|
||||||
private boolean fullscreen = true;
|
private boolean fullscreen = true;
|
||||||
private boolean mouseVisibility_last = false;
|
private boolean mouseVisibility_last = false;
|
||||||
|
|
||||||
|
public GraphicsShader environmentRenderer;
|
||||||
|
|
||||||
|
public int glsl_model;
|
||||||
|
public int glsl_projection;
|
||||||
|
public int glsl_rotated;
|
||||||
|
public int glsl_camera;
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return this.width;
|
return this.width;
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +84,7 @@ public class DisplayWindow implements IMainloopTask
|
||||||
window = GraphicsHelpers.initWindow("Project Zombie", width, height, monitor);
|
window = GraphicsHelpers.initWindow("Project Zombie", width, height, monitor);
|
||||||
|
|
||||||
// Make the context current
|
// Make the context current
|
||||||
GLFW.glfwMakeContextCurrent(this.window);
|
//GLFW.glfwMakeContextCurrent(this.window);
|
||||||
|
|
||||||
// Set the key handlers
|
// Set the key handlers
|
||||||
GLFW.glfwSetCursorPosCallback(this.window, new CursorPosCallback());
|
GLFW.glfwSetCursorPosCallback(this.window, new CursorPosCallback());
|
||||||
|
|
@ -87,10 +99,17 @@ public class DisplayWindow implements IMainloopTask
|
||||||
GLFW.glfwSetInputMode(this.window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_HIDDEN);
|
GLFW.glfwSetInputMode(this.window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_HIDDEN);
|
||||||
|
|
||||||
// Show the window
|
// Show the window
|
||||||
GLFW.glfwShowWindow(this.window);
|
//GLFW.glfwShowWindow(this.window);
|
||||||
|
|
||||||
// Register the display event loop
|
GL33.glEnable(GL33.GL_DEPTH_TEST);
|
||||||
Main.mainloop.register(this);
|
|
||||||
|
environmentRenderer = new GraphicsShader("/resources/shader/environmentRenderer");
|
||||||
|
environmentRenderer.use();
|
||||||
|
|
||||||
|
glsl_model = GL33.glGetUniformLocation(environmentRenderer.program, "model");
|
||||||
|
glsl_camera = GL33.glGetUniformLocation(environmentRenderer.program, "camera");
|
||||||
|
glsl_rotated = GL33.glGetUniformLocation(environmentRenderer.program, "rotated");
|
||||||
|
glsl_projection = GL33.glGetUniformLocation(environmentRenderer.program, "projection");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render()
|
public void render()
|
||||||
|
|
@ -99,16 +118,21 @@ public class DisplayWindow implements IMainloopTask
|
||||||
int w[] = {0};
|
int w[] = {0};
|
||||||
int h[] = {0};
|
int h[] = {0};
|
||||||
GLFW.glfwGetFramebufferSize(this.window, w, h);
|
GLFW.glfwGetFramebufferSize(this.window, w, h);
|
||||||
|
width = w[0];
|
||||||
|
height = h[0];
|
||||||
|
|
||||||
|
// Bind the texture atlas
|
||||||
|
Resources.ATLAS.bind();
|
||||||
|
|
||||||
// Render everything
|
// Render everything
|
||||||
DisplayRender.render(w[0], h[0]);
|
DisplayRender.render(w[0], h[0]);
|
||||||
|
|
||||||
// Check if the matrix count is ok
|
// Check if the matrix count is ok
|
||||||
GlHelpers.checkMatrixCount();
|
//GlHelpers.checkMatrixCount();
|
||||||
|
|
||||||
// Swap the framebuffers and poll events
|
// Swap the framebuffers and poll events
|
||||||
this.swapBuffers();
|
GLFW.glfwSwapBuffers(window);
|
||||||
this.pollEvents();
|
GLFW.glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleFullscreen() {
|
public void toggleFullscreen() {
|
||||||
|
|
@ -132,14 +156,6 @@ public class DisplayWindow implements IMainloopTask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void swapBuffers() {
|
|
||||||
GLFW.glfwSwapBuffers(this.window);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pollEvents() {
|
|
||||||
GLFW.glfwPollEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldClose() {
|
public boolean shouldClose() {
|
||||||
return GLFW.glfwWindowShouldClose(this.window);
|
return GLFW.glfwWindowShouldClose(this.window);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public class BossBars
|
||||||
|
|
||||||
public static void render()
|
public static void render()
|
||||||
{
|
{
|
||||||
TextureReference health_fg = Models.UI_HEALTH_FG;
|
/*TextureReference health_fg = Models.UI_HEALTH_FG;
|
||||||
TextureReference health_bg = Models.UI_HEALTH_BG;
|
TextureReference health_bg = Models.UI_HEALTH_BG;
|
||||||
ArrayList<IBossBar> toRemove = new ArrayList<IBossBar>();
|
ArrayList<IBossBar> toRemove = new ArrayList<IBossBar>();
|
||||||
|
|
||||||
|
|
@ -54,6 +54,6 @@ public class BossBars
|
||||||
|
|
||||||
for(IBossBar bossbar : toRemove) {
|
for(IBossBar bossbar : toRemove) {
|
||||||
bossbars.remove(bossbar);
|
bossbars.remove(bossbar);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ public class TileLighting implements IMainloopTask
|
||||||
cx + MathHelpers.floor(player.pos.x / 16),
|
cx + MathHelpers.floor(player.pos.x / 16),
|
||||||
cy + MathHelpers.floor(player.pos.y / 16));
|
cy + MathHelpers.floor(player.pos.y / 16));
|
||||||
Chunk chunk = layer.chunks.get(cpos);
|
Chunk chunk = layer.chunks.get(cpos);
|
||||||
if(chunk.light_dirty) {
|
/*if(chunk.light_dirty) {
|
||||||
chunk.light_dirty = false;
|
chunk.light_dirty = false;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ public class EntityItem extends Entity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
return Models.ITEM_NONE;
|
return stack.item.getModel(stack.meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.settings.SettingQuality;
|
import projectzombie.settings.SettingQuality;
|
||||||
import projectzombie.tiles.TileVertical;
|
|
||||||
import projectzombie.util.gl.GlHelpers;
|
import projectzombie.util.gl.GlHelpers;
|
||||||
import projectzombie.util.gl.texture.IHasTexture;
|
import projectzombie.util.gl.texture.IHasTexture;
|
||||||
import projectzombie.util.gl.texture.TextureReference;
|
import projectzombie.util.gl.texture.TextureReference;
|
||||||
|
|
@ -52,9 +51,7 @@ public class ParticleBreak extends EntityParticle
|
||||||
|
|
||||||
int height = 1;
|
int height = 1;
|
||||||
|
|
||||||
if(s.tile instanceof TileVertical) {
|
|
||||||
height = MathHelpers.floor(((TileVertical)s.tile).size.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0;i<50 * height;i++) {
|
for(int i=0;i<50 * height;i++) {
|
||||||
chunk.spawnEntity(new ParticleBreak(pos.copy(), s));
|
chunk.spawnEntity(new ParticleBreak(pos.copy(), s));
|
||||||
|
|
@ -98,12 +95,6 @@ public class ParticleBreak extends EntityParticle
|
||||||
|
|
||||||
double angle = RandomHelpers.randrange(rand, 360);
|
double angle = RandomHelpers.randrange(rand, 360);
|
||||||
|
|
||||||
if(ts.tile instanceof TileVertical) {
|
|
||||||
TileVertical ts_v = (TileVertical) ts.tile;
|
|
||||||
|
|
||||||
height = RandomHelpers.randrange(rand, 0, MathHelpers.floor(ts_v.size.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec2d side_v = MathHelpers.moveTowards2(0.01, Math.toRadians(angle));
|
Vec2d side_v = MathHelpers.moveTowards2(0.01, Math.toRadians(angle));
|
||||||
velocity = new Vec3d(
|
velocity = new Vec3d(
|
||||||
side_v.x, side_v.y,
|
side_v.x, side_v.y,
|
||||||
|
|
@ -170,7 +161,7 @@ public class ParticleBreak extends EntityParticle
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
return Models.ENTITY_NONE;
|
return Models.PARTICLE_BULLET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
|
|
||||||
|
import gl_engine.vec.Vec2d;
|
||||||
import projectzombie.display.DisplayWindow;
|
import projectzombie.display.DisplayWindow;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
import projectzombie.model.ModelEmpty;
|
||||||
import projectzombie.model.ModelGui;
|
import projectzombie.model.ModelGui;
|
||||||
import projectzombie.model.ModelRandom;
|
import projectzombie.model.ModelRandom;
|
||||||
import projectzombie.model.ModelTile;
|
import projectzombie.model.ModelTile;
|
||||||
|
|
@ -16,15 +18,13 @@ import projectzombie.util.gl.texture.TextureReferenceRandom;
|
||||||
|
|
||||||
public class Models
|
public class Models
|
||||||
{
|
{
|
||||||
public static final Model TILE_NONE = new ModelTile(Resources.ATLAS.get("NONE"));
|
public static final Model EMPTY = new ModelEmpty();
|
||||||
public static final Model ENTITY_NONE = new ModelTile(Resources.ATLAS.get("NONE"));
|
|
||||||
public static final Model ITEM_NONE = new ModelTile(Resources.ATLAS.get("NONE"));
|
|
||||||
|
|
||||||
public static final Model TILE_GRASS = new ModelTile(Resources.ATLAS.get("/tile/grass.png"));
|
public static final Model TILE_GRASS = new ModelTile(Resources.ATLAS.get("/tile/grass.png"));
|
||||||
public static final Model TILE_SAND = new ModelTile(Resources.ATLAS.get("/tile/sand.png"));
|
public static final Model TILE_SAND = new ModelTile(Resources.ATLAS.get("/tile/sand.png"));
|
||||||
public static final Model TILE_STONE = new ModelTile(Resources.ATLAS.get("/tile/stone.png"));
|
public static final Model TILE_STONE = new ModelTile(Resources.ATLAS.get("/tile/stone.png"));
|
||||||
public static final Model TILE_DIRT = new ModelTile(Resources.ATLAS.get("/tile/dirt.png"));
|
public static final Model TILE_DIRT = new ModelTile(Resources.ATLAS.get("/tile/dirt.png"));
|
||||||
public static final Model TILE_TREE = new ModelVertical(Resources.ATLAS.get("/tile/tree.png"));
|
public static final Model TILE_TREE = new ModelVertical(Resources.ATLAS.get("/tile/tree.png"), new Vec2d(1, 4));
|
||||||
public static final Model TILE_ROCK = new ModelVertical(Resources.ATLAS.get("/tile/rock.png"));
|
public static final Model TILE_ROCK = new ModelVertical(Resources.ATLAS.get("/tile/rock.png"));
|
||||||
public static final Model TILE_LADDER = new ModelVertical(Resources.ATLAS.get("/tile/ladder.png"));
|
public static final Model TILE_LADDER = new ModelVertical(Resources.ATLAS.get("/tile/ladder.png"));
|
||||||
public static final Model TILE_PORTAL = new ModelVertical(Resources.ATLAS.get("/tile/portal.png"));
|
public static final Model TILE_PORTAL = new ModelVertical(Resources.ATLAS.get("/tile/portal.png"));
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import projectzombie.tiles.TileVoid;
|
||||||
import projectzombie.tiles.TileWall;
|
import projectzombie.tiles.TileWall;
|
||||||
import projectzombie.tiles.TileWallUnbreakable;
|
import projectzombie.tiles.TileWallUnbreakable;
|
||||||
import projectzombie.tiles.TileWater;
|
import projectzombie.tiles.TileWater;
|
||||||
import projectzombie.tiles.TileWaterFlow;
|
|
||||||
|
|
||||||
public class Tiles
|
public class Tiles
|
||||||
{
|
{
|
||||||
|
|
@ -50,7 +49,6 @@ public class Tiles
|
||||||
register(LAVA);
|
register(LAVA);
|
||||||
register(WATER);
|
register(WATER);
|
||||||
register(LAVA_FLOW);
|
register(LAVA_FLOW);
|
||||||
register(WATER_FLOW);
|
|
||||||
register(LADDER);
|
register(LADDER);
|
||||||
register(PORTAL_DOWN);
|
register(PORTAL_DOWN);
|
||||||
register(WALL);
|
register(WALL);
|
||||||
|
|
@ -71,7 +69,6 @@ public class Tiles
|
||||||
public static final Tile LAVA = new TileLava();
|
public static final Tile LAVA = new TileLava();
|
||||||
public static final Tile WATER = new TileWater();
|
public static final Tile WATER = new TileWater();
|
||||||
public static final Tile LAVA_FLOW = new TileLavaFlow();
|
public static final Tile LAVA_FLOW = new TileLavaFlow();
|
||||||
public static final Tile WATER_FLOW = new TileWaterFlow();
|
|
||||||
public static final Tile LADDER = new TileLadder();
|
public static final Tile LADDER = new TileLadder();
|
||||||
public static final Tile PORTAL_DOWN = new TilePortalDown();
|
public static final Tile PORTAL_DOWN = new TilePortalDown();
|
||||||
public static final Tile WALL = new TileWall();
|
public static final Tile WALL = new TileWall();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityInventory;
|
import projectzombie.entity.EntityInventory;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.inventory.Inventory;
|
import projectzombie.inventory.Inventory;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.gl.GlHelpers;
|
import projectzombie.util.gl.GlHelpers;
|
||||||
import projectzombie.util.gl.texture.TextureReference;
|
import projectzombie.util.gl.texture.TextureReference;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
@ -11,23 +12,11 @@ import gl_engine.vec.Vec2d;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class Item
|
public abstract class Item
|
||||||
{
|
{
|
||||||
public TextureReference texture;
|
public TextureReference texture;
|
||||||
public int id;
|
public int id;
|
||||||
|
|
||||||
public void render(Vec2d pos, Vec2d size)
|
|
||||||
{
|
|
||||||
GlHelpers.begin();
|
|
||||||
|
|
||||||
texture.texCoord(0, 1); GlHelpers.vertex2(pos.x+size.x , pos.y );
|
|
||||||
texture.texCoord(0, 0); GlHelpers.vertex2(pos.x+size.x , pos.y+size.y );
|
|
||||||
texture.texCoord(1, 0); GlHelpers.vertex2(pos.x , pos.y+size.y );
|
|
||||||
texture.texCoord(1, 1); GlHelpers.vertex2(pos.x , pos.y );
|
|
||||||
|
|
||||||
GlHelpers.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
||||||
stack.count -= 1;
|
stack.count -= 1;
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +29,8 @@ public class Item
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract Model getModel(short meta);
|
||||||
|
|
||||||
public void onPickedUp(ItemStack stack, Layer layer, Chunk chunk, Entity entity)
|
public void onPickedUp(ItemStack stack, Layer layer, Chunk chunk, Entity entity)
|
||||||
{
|
{
|
||||||
// Update the stacks count
|
// Update the stacks count
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.items;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -10,9 +11,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemAmmo extends Item
|
public class ItemAmmo extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemAmmo() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.ITEM_AMMO_BOX;
|
return Models.ITEM_AMMO_BOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.items;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -10,9 +11,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemDefenceUpgrade extends Item
|
public class ItemDefenceUpgrade extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemDefenceUpgrade() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.ITEM_DEFENCE_UPGRADE;
|
return Models.ITEM_DEFENCE_UPGRADE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
@ -22,7 +23,8 @@ public class ItemEmpty extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Vec2d pos, Vec2d size) {
|
public Model getModel(short meta) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.items;
|
||||||
import projectzombie.entity.EntityFlare;
|
import projectzombie.entity.EntityFlare;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -10,9 +11,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemFlare extends Item
|
public class ItemFlare extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemFlare() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.ENTITY_FLARE;
|
return Models.ENTITY_FLARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.items;
|
||||||
import projectzombie.entity.EntityGrapplingHook;
|
import projectzombie.entity.EntityGrapplingHook;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
|
@ -12,9 +13,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemGrapplingHook extends Item
|
public class ItemGrapplingHook extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemGrapplingHook() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.ITEM_GRAPPLING_HOOK;
|
return Models.ITEM_GRAPPLING_HOOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.items;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -10,9 +11,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemGunUpgrade extends Item
|
public class ItemGunUpgrade extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemGunUpgrade() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.ITEM_GUN_UPGRADE;
|
return Models.ITEM_GUN_UPGRADE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -9,9 +10,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemHealthPotion extends Item
|
public class ItemHealthPotion extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemHealthPotion() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.ITEM_HEALTH_POTION;
|
return Models.ITEM_HEALTH_POTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.items;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.init.Tiles;
|
import projectzombie.init.Tiles;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
|
@ -12,9 +13,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemLantern extends Item
|
public class ItemLantern extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemLantern() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.TILE_LANTERN;
|
return Models.TILE_LANTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -9,9 +10,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemRock extends Item
|
public class ItemRock extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemRock() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.TILE_ROCK;
|
return Models.ITEM_ROCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,8 @@ import gl_engine.vec.Vec2d;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class ItemSpawn extends Item
|
public abstract class ItemSpawn extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
||||||
super.onPlayerAction(stack, layer, chunk, player);
|
super.onPlayerAction(stack, layer, chunk, player);
|
||||||
|
|
@ -19,7 +18,4 @@ public class ItemSpawn extends Item
|
||||||
public void spawnEntity(Layer layer, Chunk chunk, Vec2d pos) {
|
public void spawnEntity(Layer layer, Chunk chunk, Vec2d pos) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@ package projectzombie.items;
|
||||||
import projectzombie.entity.EntityTnt;
|
import projectzombie.entity.EntityTnt;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class ItemTnt extends Item
|
public class ItemTnt extends Item
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public ItemTnt() {
|
public Model getModel(short meta) {
|
||||||
|
return Models.ENTITY_TNT;
|
||||||
this.texture = Models.ENTITY_TNT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.items.spawner;
|
||||||
import projectzombie.entity.EntityZombie;
|
import projectzombie.entity.EntityZombie;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.items.ItemSpawn;
|
import projectzombie.items.ItemSpawn;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -10,9 +11,9 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemSpawnZombie extends ItemSpawn
|
public class ItemSpawnZombie extends ItemSpawn
|
||||||
{
|
{
|
||||||
|
|
||||||
public ItemSpawnZombie() {
|
@Override
|
||||||
|
public Model getModel(short meta) {
|
||||||
this.texture = Models.ENTITY_ZOMBIE_B;
|
return Models.ENTITY_ZOMBIE_B;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ package projectzombie.menu.gui;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.input.InputMode;
|
import projectzombie.input.InputMode;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.text.Text;
|
import projectzombie.text.Text;
|
||||||
import projectzombie.util.gl.GlHelpers;
|
import projectzombie.util.gl.GlHelpers;
|
||||||
import projectzombie.util.gl.texture.TextureReference;
|
import projectzombie.util.gl.texture.TextureReference;
|
||||||
|
import gl_engine.matrix.Matrix4;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
|
||||||
public class Button implements GUIComponent, GUISelectable
|
public class Button implements GUIComponent, GUISelectable
|
||||||
|
|
@ -33,10 +35,8 @@ public class Button implements GUIComponent, GUISelectable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Vec2d mousePos) {
|
public void render(Vec2d mousePos)
|
||||||
GlHelpers.pushMatrix();
|
{
|
||||||
GlHelpers.translate2(pos.x, pos.y);
|
|
||||||
|
|
||||||
double m = 3;
|
double m = 3;
|
||||||
double w = textSize.x * m * 8;
|
double w = textSize.x * m * 8;
|
||||||
double h = textSize.x * m / 2;
|
double h = textSize.x * m / 2;
|
||||||
|
|
@ -63,37 +63,24 @@ public class Button implements GUIComponent, GUISelectable
|
||||||
wt = -w/2;
|
wt = -w/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureReference tex;
|
Model model;
|
||||||
boolean mouseHover = InputMode.Controller ? this.selected : this.checkMouseHover(mousePos);
|
boolean mouseHover = InputMode.Controller ? this.selected : this.checkMouseHover(mousePos);
|
||||||
if(mouseHover) {
|
if(mouseHover) {
|
||||||
tex = Models.BUTTON_HOVER;
|
model = Models.BUTTON_HOVER;
|
||||||
} else {
|
} else {
|
||||||
tex = Models.BUTTON;
|
model = Models.BUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlHelpers.color4(1, 1, 1, 1);
|
Matrix4 matrix = Matrix4.translate(pos.x, pos.y, 0);
|
||||||
GlHelpers.begin();
|
|
||||||
{
|
|
||||||
tex.texCoord(0, 0); GlHelpers.vertex2(w1, -h);
|
|
||||||
tex.texCoord(1, 0); GlHelpers.vertex2(w2, -h);
|
|
||||||
tex.texCoord(1, 1); GlHelpers.vertex2(w2, h);
|
|
||||||
tex.texCoord(0, 1); GlHelpers.vertex2(w1, h);
|
|
||||||
}
|
|
||||||
GlHelpers.end();
|
|
||||||
|
|
||||||
GlHelpers.translate2(
|
model.bind();
|
||||||
(-textSize.x * text.length() / 2 + wt)/GlHelpers.getAspectRatio(),
|
|
||||||
-textSize.y / 2
|
|
||||||
);
|
|
||||||
|
|
||||||
if(mouseHover) {
|
if(mouseHover) {
|
||||||
GlHelpers.color3(0.8, 0.8, 0.8);
|
//GlHelpers.color3(0.8, 0.8, 0.8);
|
||||||
} else {
|
} else {
|
||||||
GlHelpers.color3(0.68, 0.68, 0.68);
|
//GlHelpers.color3(0.68, 0.68, 0.68);
|
||||||
}
|
}
|
||||||
Text.render(text, textSize);
|
Text.render(text, textSize);
|
||||||
|
|
||||||
GlHelpers.popMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,14 @@ import gl_engine.texture.TextureRef3D;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL33.*;
|
import static org.lwjgl.opengl.GL33.*;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL33;
|
||||||
|
|
||||||
public abstract class Model
|
public abstract class Model
|
||||||
{
|
{
|
||||||
int vao, size;
|
int vao, size;
|
||||||
boolean loaded = false;
|
boolean loaded = false;
|
||||||
private static final int SIZE = 9;
|
private static final int SIZE = 9;
|
||||||
|
private float[] verticies;
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return size;
|
return size;
|
||||||
|
|
@ -19,6 +22,10 @@ public abstract class Model
|
||||||
protected abstract float[] getVerticies();
|
protected abstract float[] getVerticies();
|
||||||
protected abstract TextureRef3D[] getTextures();
|
protected abstract TextureRef3D[] getTextures();
|
||||||
|
|
||||||
|
public float[] getLoadedVerticies() {
|
||||||
|
return verticies;
|
||||||
|
}
|
||||||
|
|
||||||
public void bind()
|
public void bind()
|
||||||
{
|
{
|
||||||
if(loaded) {
|
if(loaded) {
|
||||||
|
|
@ -27,7 +34,7 @@ public abstract class Model
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float[] verticies = this.getVerticies();
|
verticies = this.getVerticies();
|
||||||
TextureRef3D[] refs = this.getTextures();
|
TextureRef3D[] refs = this.getTextures();
|
||||||
|
|
||||||
if(verticies.length % SIZE != 0 || refs.length * 3 != verticies.length / SIZE) {
|
if(verticies.length % SIZE != 0 || refs.length * 3 != verticies.length / SIZE) {
|
||||||
|
|
@ -53,10 +60,20 @@ public abstract class Model
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||||
glBufferData(GL_ARRAY_BUFFER, verticies, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, verticies, GL_STATIC_DRAW);
|
||||||
|
|
||||||
glVertexAttribPointer(0, SIZE, GL_FLOAT, false, Float.BYTES * SIZE, 0);
|
glVertexAttribPointer(0, 3, GL_FLOAT, false, Float.BYTES * SIZE, 0);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
|
|
||||||
|
glVertexAttribPointer(1, 3, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 3);
|
||||||
|
glEnableVertexAttribArray(1);
|
||||||
|
|
||||||
|
glVertexAttribPointer(2, 3, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 6);
|
||||||
|
glEnableVertexAttribArray(2);
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void render() {
|
||||||
|
GL33.glDrawArrays(GL33.GL_TRIANGLES, 0, getSize());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package projectzombie.model;
|
||||||
|
|
||||||
|
import gl_engine.texture.TextureRef3D;
|
||||||
|
|
||||||
|
public class ModelEmpty extends Model
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected TextureRef3D[] getTextures() {
|
||||||
|
return new TextureRef3D[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float[] getVerticies() {
|
||||||
|
return new float[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bind() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSize() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float[] getLoadedVerticies() {
|
||||||
|
return new float[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,10 @@ public class Resource
|
||||||
return "/resources/"+path;
|
return "/resources/"+path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return filePath(path);
|
||||||
|
}
|
||||||
|
|
||||||
public Resource(String path)
|
public Resource(String path)
|
||||||
{
|
{
|
||||||
// Set the specified data
|
// Set the specified data
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
package projectzombie.tiles;
|
package projectzombie.tiles;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
|
|
||||||
public class TileSand extends TileFlat
|
public class TileSand extends Tile
|
||||||
{
|
{
|
||||||
|
|
||||||
public TileSand() {
|
@Override
|
||||||
super(Models.TILE_SAND);
|
public Model getModel(byte meta) {
|
||||||
|
return Models.TILE_SAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
package projectzombie.tiles;
|
package projectzombie.tiles;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
|
|
||||||
public class TileStone extends TileFlatFaded
|
public class TileStone extends Tile
|
||||||
{
|
{
|
||||||
|
|
||||||
public TileStone() {
|
@Override
|
||||||
super(Models.TILE_STONE);
|
public Model getModel(byte meta) {
|
||||||
|
return Models.TILE_STONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
package projectzombie.tiles;
|
package projectzombie.tiles;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
|
||||||
public class TileTree extends TileVertical implements TileBulletBreakable
|
public class TileTree extends Tile implements TileBulletBreakable
|
||||||
{
|
{
|
||||||
public TileTree() {
|
public TileTree() {
|
||||||
super(Models.TILE_TREE, new Vec2d(1, 4));
|
|
||||||
|
|
||||||
// Set some settings
|
// Set some settings
|
||||||
this.opaqueTile = true;
|
|
||||||
this.tileSolid = true;
|
this.tileSolid = true;
|
||||||
this.tileHitbox = 0.3;
|
this.tileHitbox = 0.3;
|
||||||
}
|
}
|
||||||
|
|
@ -25,4 +24,9 @@ public class TileTree extends TileVertical implements TileBulletBreakable
|
||||||
return 35;
|
return 35;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getModel(byte meta) {
|
||||||
|
return Models.TILE_TREE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package projectzombie.tiles;
|
package projectzombie.tiles;
|
||||||
|
|
||||||
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
|
|
||||||
public class TileVoid extends Tile {
|
public class TileVoid extends Tile {
|
||||||
|
|
||||||
public TileVoid() {
|
public TileVoid() {
|
||||||
|
|
@ -9,4 +12,9 @@ public class TileVoid extends Tile {
|
||||||
this.tileWalkable = true;
|
this.tileWalkable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getModel(byte meta) {
|
||||||
|
return Models.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package projectzombie.tiles;
|
package projectzombie.tiles;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
|
|
||||||
public class TileWall extends TileFlat
|
public class TileWall extends Tile
|
||||||
{
|
{
|
||||||
|
|
||||||
public TileWall() {
|
public TileWall() {
|
||||||
super(Models.TILE_WALL);
|
|
||||||
|
|
||||||
this.tileWalkable = false;
|
this.tileWalkable = false;
|
||||||
this.tileSolid = true;
|
this.tileSolid = true;
|
||||||
|
|
@ -21,4 +21,9 @@ public class TileWall extends TileFlat
|
||||||
return 1/2.0;
|
return 1/2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getModel(byte meta) {
|
||||||
|
return Models.TILE_WALL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import projectzombie.display.Camera;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.particle.ParticleWater;
|
import projectzombie.entity.particle.ParticleWater;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.gl.GlHelpers;
|
import projectzombie.util.gl.GlHelpers;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
|
@ -11,24 +12,14 @@ import gl_engine.vec.Vec2i;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class TileWater extends TileFlat
|
public class TileWater extends Tile
|
||||||
{
|
{
|
||||||
|
|
||||||
public TileWater() {
|
public TileWater() {
|
||||||
super(Models.TILE_WATER);
|
|
||||||
this.slowness = 0.5;
|
this.slowness = 0.5;
|
||||||
this.rotates = true;
|
|
||||||
this.unbreakable = true;
|
this.unbreakable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(Vec2d pos, Camera camera, TileState state) {
|
|
||||||
GlHelpers.pushMatrix();
|
|
||||||
GlHelpers.translate3(0, 0, 0.001);
|
|
||||||
super.render(pos, camera, state);
|
|
||||||
GlHelpers.popMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity, TileState state)
|
public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity, TileState state)
|
||||||
{
|
{
|
||||||
|
|
@ -41,4 +32,9 @@ public class TileWater extends TileFlat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getModel(byte meta) {
|
||||||
|
return Models.TILE_WATER;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
package projectzombie.tiles;
|
|
||||||
|
|
||||||
import projectzombie.display.Camera;
|
|
||||||
import projectzombie.init.Models;
|
|
||||||
import projectzombie.util.gl.GlHelpers;
|
|
||||||
import projectzombie.util.math.TileState;
|
|
||||||
import gl_engine.vec.Vec2d;
|
|
||||||
|
|
||||||
public class TileWaterFlow extends TileFlat
|
|
||||||
{
|
|
||||||
|
|
||||||
public TileWaterFlow() {
|
|
||||||
super(Models.TILE_WATER_FLOW);
|
|
||||||
|
|
||||||
this.unbreakable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(Vec2d pos, Camera camera, TileState state) {
|
|
||||||
GlHelpers.pushMatrix();
|
|
||||||
GlHelpers.translate3(0, 0, 0.001);
|
|
||||||
super.render(pos, camera, state);
|
|
||||||
GlHelpers.popMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -4,20 +4,25 @@ import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
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;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
|
import projectzombie.Main;
|
||||||
import projectzombie.display.Camera;
|
import projectzombie.display.Camera;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityAlive;
|
import projectzombie.entity.EntityAlive;
|
||||||
import projectzombie.entity.EntityKillWithParticles;
|
import projectzombie.entity.EntityKillWithParticles;
|
||||||
import projectzombie.entity.particle.ParticleBreak;
|
import projectzombie.entity.particle.ParticleBreak;
|
||||||
|
import projectzombie.init.Models;
|
||||||
import projectzombie.init.Tiles;
|
import projectzombie.init.Tiles;
|
||||||
|
import projectzombie.model.Model;
|
||||||
import projectzombie.tiles.Tile;
|
import projectzombie.tiles.Tile;
|
||||||
import projectzombie.util.gl.GlHelpers;
|
import projectzombie.util.gl.GlHelpers;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
|
import gl_engine.matrix.Matrix4;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
import projectzombie.util.math.random.RandomHelpers;
|
import projectzombie.util.math.random.RandomHelpers;
|
||||||
import gl_engine.range.Range2i;
|
import gl_engine.range.Range2i;
|
||||||
|
|
@ -48,8 +53,21 @@ public class Chunk implements IBdfClassManager
|
||||||
public ArrayList<Entity> entities = new ArrayList<Entity>();
|
public ArrayList<Entity> entities = new ArrayList<Entity>();
|
||||||
private Layer layer;
|
private Layer layer;
|
||||||
public Vec2i c_pos;
|
public Vec2i c_pos;
|
||||||
public boolean dirty;
|
private boolean dirty;
|
||||||
public boolean light_dirty;
|
private boolean light_dirty;
|
||||||
|
|
||||||
|
public boolean isDirty()
|
||||||
|
{
|
||||||
|
if(entities.size() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearDirty() {
|
||||||
|
dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BdfClassLoad(BdfObject bdf)
|
public void BdfClassLoad(BdfObject bdf)
|
||||||
|
|
@ -152,66 +170,31 @@ public class Chunk implements IBdfClassManager
|
||||||
|
|
||||||
public void render(Camera camera)
|
public void render(Camera camera)
|
||||||
{
|
{
|
||||||
// Loop over all the tiles
|
for(int i=0;i<256;i++)
|
||||||
for(int i=0;i<CHUNK_INDEX;i++)
|
|
||||||
{
|
{
|
||||||
// Get the tile pos
|
int x = i / 16;
|
||||||
Vec2i t_pos = Vec2i.fromId(CHUNK_SIZE, i);
|
int y = i % 16;
|
||||||
|
|
||||||
// Render the tiles
|
TileState tile_f = getFrontTile(i);
|
||||||
TileState tsb = getBackTile(i);
|
TileState tile_b = getBackTile(i);
|
||||||
TileState tsf = getFrontTile(i);
|
|
||||||
tiles_back[i].doRender(new Vec2d(t_pos.x + c_pos.x * 16, t_pos.y + c_pos.y * 16), camera, tsb);
|
|
||||||
tiles_front[i].doRender(new Vec2d(t_pos.x + c_pos.x * 16, t_pos.y + c_pos.y * 16), camera, tsf);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render all the entities
|
Model model_f = tile_f.tile.getModel(tile_f.meta);
|
||||||
for(int i=0;i<entities.size();i++) {
|
Model model_b = tile_b.tile.getModel(tile_b.meta);
|
||||||
Entity e = entities.get(i);
|
|
||||||
e.doRender(e.pos, camera);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw chunk boundaries
|
Matrix4 matrix = Matrix4.translate(x + c_pos.x * 16, 0, y + c_pos.y * 16);
|
||||||
if(SHOW_CHUNKS)
|
GL33.glUniformMatrix4fv(Main.window.glsl_model, true, matrix.getArray());
|
||||||
{
|
|
||||||
GlHelpers.disableTexture2d();
|
|
||||||
GlHelpers.color3(1, 0, 0);
|
|
||||||
GL11.glBegin(GL11.GL_LINES);
|
|
||||||
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0) * 16, (c_pos.y + 0) * 16, 0.1);
|
model_f.bind();
|
||||||
GlHelpers.vertex3((c_pos.x + 1) * 16, (c_pos.y + 0) * 16, 0.1);
|
model_f.render();
|
||||||
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0) * 16, (c_pos.y + 0) * 16, 0.1);
|
model_b.bind();
|
||||||
GlHelpers.vertex3((c_pos.x + 0) * 16, (c_pos.y + 1) * 16, 0.1);
|
model_b.render();
|
||||||
|
|
||||||
GlHelpers.color3(0, 0, 1);
|
|
||||||
|
|
||||||
int l = 1000;
|
|
||||||
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0) * 16, (c_pos.y + 0) * 16, -l);
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0) * 16, (c_pos.y + 0) * 16, l);
|
|
||||||
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0.5) * 16, (c_pos.y + 0) * 16, -l);
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0.5) * 16, (c_pos.y + 0) * 16, l);
|
|
||||||
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0) * 16, (c_pos.y + 0.5) * 16, -l);
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0) * 16, (c_pos.y + 0.5) * 16, l);
|
|
||||||
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0.5) * 16, (c_pos.y + 0.5) * 16, -l);
|
|
||||||
GlHelpers.vertex3((c_pos.x + 0.5) * 16, (c_pos.y + 0.5) * 16, l);
|
|
||||||
|
|
||||||
GlHelpers.vertex3((c_pos.x + 1) * 16, (c_pos.y + 0) * 16, -l);
|
|
||||||
GlHelpers.vertex3((c_pos.x + 1) * 16, (c_pos.y + 0) * 16, l);
|
|
||||||
|
|
||||||
GL11.glEnd();
|
|
||||||
GlHelpers.enableTexture2d();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnEntity(Entity e) {
|
public void spawnEntity(Entity e) {
|
||||||
e.chunk = this;
|
e.chunk = this;
|
||||||
entities.add(e);
|
entities.add(e);
|
||||||
this.dirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tickEntities()
|
public void tickEntities()
|
||||||
|
|
@ -478,7 +461,6 @@ public class Chunk implements IBdfClassManager
|
||||||
}
|
}
|
||||||
|
|
||||||
entities.remove(e);
|
entities.remove(e);
|
||||||
this.dirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Entity> getNearbyEntities(Vec2d pos, double distance)
|
public ArrayList<Entity> getNearbyEntities(Vec2d pos, double distance)
|
||||||
|
|
|
||||||
|
|
@ -155,4 +155,13 @@ public class ChunkEmpty extends Chunk
|
||||||
@Override
|
@Override
|
||||||
public void setDaylightLevel(double light, Vec2i pos) {
|
public void setDaylightLevel(double light, Vec2i pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearDirty() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDirty() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ public class Layer implements IBdfClassManager
|
||||||
Chunk chunk = new Chunk(this, pos, rand);
|
Chunk chunk = new Chunk(this, pos, rand);
|
||||||
chunks.set(pos, chunk);
|
chunks.set(pos, chunk);
|
||||||
layergen.generateChunk(chunk, this, new Random(cseed), pos);
|
layergen.generateChunk(chunk, this, new Random(cseed), pos);
|
||||||
chunk.dirty = false;
|
chunk.clearDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,7 +230,7 @@ public class Layer implements IBdfClassManager
|
||||||
{
|
{
|
||||||
// Store the chunk if its a dirty chunk
|
// Store the chunk if its a dirty chunk
|
||||||
Chunk chunk = chunks.get(pos);
|
Chunk chunk = chunks.get(pos);
|
||||||
if(chunk.dirty) {
|
if(chunk.isDirty()) {
|
||||||
dirty_chunks.set(pos, chunk);
|
dirty_chunks.set(pos, chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -321,7 +321,7 @@ public class Layer implements IBdfClassManager
|
||||||
for(Map2DElement<Chunk> chunk : chunks) {
|
for(Map2DElement<Chunk> chunk : chunks) {
|
||||||
if(dirty_chunks.contains(chunk.pos))
|
if(dirty_chunks.contains(chunk.pos))
|
||||||
continue;
|
continue;
|
||||||
if(!chunk.o.dirty)
|
if(!chunk.o.isDirty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BdfNamedList chunk_nl = new BdfNamedList();
|
BdfNamedList chunk_nl = new BdfNamedList();
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,28 @@
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
layout (location = 0) in float[9] vertices;
|
layout (location = 0) in vec3 aPos;
|
||||||
|
layout (location = 1) in vec3 aTex;
|
||||||
|
layout (location = 2) in vec3 aFlags;
|
||||||
|
|
||||||
out vec3 pTexture;
|
out vec3 pTexture;
|
||||||
|
|
||||||
uniform mat4 projection;
|
uniform mat4 projection;
|
||||||
uniform mat4 model;
|
uniform mat4 model;
|
||||||
uniform mat4 camera;
|
uniform mat4 camera;
|
||||||
uniform float cameraAngle;
|
uniform mat4 rotated;
|
||||||
|
|
||||||
mat4 rotate(float angle, float x, float y, float z)
|
|
||||||
{
|
|
||||||
mat4 result = mat4(1);
|
|
||||||
|
|
||||||
float csin = sin(angle);
|
|
||||||
float ccos = cos(angle);
|
|
||||||
float iccos = 1 - ccos;
|
|
||||||
|
|
||||||
result[0][0] = ccos + x * x * iccos;
|
|
||||||
result[0][1] = x * y * iccos - z * csin;
|
|
||||||
result[0][2] = x * z * iccos + y * csin;
|
|
||||||
result[1][0] = y * x * iccos + z * csin;
|
|
||||||
result[1][1] = ccos + y * y * iccos;
|
|
||||||
result[1][2] = y * z * iccos - x * csin;
|
|
||||||
result[2][0] = z * x * iccos - y * csin;
|
|
||||||
result[2][1] = z * y * iccos + x * csin;
|
|
||||||
result[2][2] = ccos + z * z * iccos;
|
|
||||||
result[3][3] = 1;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
int type = int(vertices[8]);
|
int type = int(aFlags.z);
|
||||||
|
|
||||||
mat4 do_rotation = rotate(cameraAngle, 0, 1, 0);
|
float animate_count = aFlags.x;
|
||||||
|
float animate_speed = aFlags.y;
|
||||||
|
|
||||||
|
mat4 do_rotation = rotated;
|
||||||
mat4 no_rotation = mat4(1);
|
mat4 no_rotation = mat4(1);
|
||||||
|
|
||||||
gl_Position = vec4(vertices[0], vertices[1], vertices[2], 1) *
|
gl_Position = vec4(aPos, 1) * (type == 1 ? do_rotation : no_rotation) * model * camera * projection;
|
||||||
(type == 1 ? do_rotation : no_rotation) * model * camera * projection;
|
|
||||||
|
|
||||||
pTexture = vec3(vertices[3], vertices[4], vertices[5]);
|
pTexture = vec3(aTex.x, aTex.y, aTex.z);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue