Added dynamic break particles, improved the particle system
This commit is contained in:
parent
4f7b499217
commit
3838754611
|
|
@ -1,7 +1,6 @@
|
||||||
package projectzombie.display;
|
package projectzombie.display;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.GL33;
|
import org.lwjgl.opengl.GL33;
|
||||||
|
|
@ -9,7 +8,6 @@ import org.lwjgl.opengl.GL33;
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.range.Range2i;
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
|
|
@ -267,8 +265,8 @@ public class DisplayLighting
|
||||||
Vec2i tpos = new Vec2i(x + lighting.x * 16, y + lighting.y * 16);
|
Vec2i tpos = new Vec2i(x + lighting.x * 16, y + lighting.y * 16);
|
||||||
|
|
||||||
// Store light level data from the image
|
// Store light level data from the image
|
||||||
layer.setDaylightLevel(lighting.p[i+0], tpos);
|
layer.setDaylightLevel(lighting.p[i*4+0], tpos);
|
||||||
layer.setLightLevel(lighting.p[i+1], tpos);
|
layer.setLightLevel(lighting.p[i*4+1], tpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
lighting_new = false;
|
lighting_new = false;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import org.lwjgl.opengl.GL33;
|
||||||
import gl_engine.matrix.Matrix4;
|
import gl_engine.matrix.Matrix4;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Layers;
|
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ColorRange;
|
import projectzombie.util.math.ColorRange;
|
||||||
import projectzombie.world.chunk.ChunkEventHandler;
|
import projectzombie.world.chunk.ChunkEventHandler;
|
||||||
|
|
@ -45,11 +44,13 @@ public class DisplayRender
|
||||||
projection = Matrix4.multiply(camera.getMatrix(), projection);
|
projection = Matrix4.multiply(camera.getMatrix(), projection);
|
||||||
|
|
||||||
Matrix4 rotated = Matrix4.rotate(-camera.angle, 0, 1, 0);
|
Matrix4 rotated = Matrix4.rotate(-camera.angle, 0, 1, 0);
|
||||||
|
Matrix4 billboard = Matrix4.multiply(Matrix4.rotate(-45, 1, 0, 0), rotated);
|
||||||
|
|
||||||
// Process all the light sources
|
// Process all the light sources
|
||||||
//DynamicLighting.update();
|
//DynamicLighting.update();
|
||||||
|
|
||||||
Main.window.environmentRenderer.use();
|
Main.window.environmentRenderer.use();
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_billboard, true, billboard.getArray());
|
||||||
GL33.glUniformMatrix4fv(Main.window.glsl_projection, true, projection.getArray());
|
GL33.glUniformMatrix4fv(Main.window.glsl_projection, true, projection.getArray());
|
||||||
GL33.glUniformMatrix4fv(Main.window.glsl_rotated, true, rotated.getArray());
|
GL33.glUniformMatrix4fv(Main.window.glsl_rotated, true, rotated.getArray());
|
||||||
GL33.glUniform1i(Main.window.glsl_time, (int)((System.currentTimeMillis() / 10) % 1000));
|
GL33.glUniform1i(Main.window.glsl_time, (int)((System.currentTimeMillis() / 10) % 1000));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
package projectzombie.display;
|
package projectzombie.display;
|
||||||
|
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_FLOAT;
|
||||||
|
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
|
||||||
|
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
|
|
@ -9,6 +13,7 @@ import org.lwjgl.opengl.GL33;
|
||||||
import gl_engine.graphics.GraphicsHelpers;
|
import gl_engine.graphics.GraphicsHelpers;
|
||||||
import gl_engine.graphics.GraphicsShader;
|
import gl_engine.graphics.GraphicsShader;
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
|
import projectzombie.Main;
|
||||||
import projectzombie.init.Resources;
|
import projectzombie.init.Resources;
|
||||||
import projectzombie.input.CursorEnterCallback;
|
import projectzombie.input.CursorEnterCallback;
|
||||||
import projectzombie.input.CursorPosCallback;
|
import projectzombie.input.CursorPosCallback;
|
||||||
|
|
@ -31,12 +36,17 @@ public class DisplayWindow implements IMainloopTask
|
||||||
public static int fps = 0;
|
public static int fps = 0;
|
||||||
|
|
||||||
public GraphicsShader environmentRenderer;
|
public GraphicsShader environmentRenderer;
|
||||||
|
public GraphicsShader effectRenderer;
|
||||||
|
|
||||||
|
public int effect_vao;
|
||||||
|
|
||||||
public int glsl_color;
|
public int glsl_color;
|
||||||
|
public int glsl_contrast;
|
||||||
public int glsl_tex_cut;
|
public int glsl_tex_cut;
|
||||||
public int glsl_model;
|
public int glsl_model;
|
||||||
public int glsl_projection;
|
public int glsl_projection;
|
||||||
public int glsl_rotated;
|
public int glsl_rotated;
|
||||||
|
public int glsl_billboard;
|
||||||
public int glsl_time;
|
public int glsl_time;
|
||||||
|
|
||||||
public int glsl_day_low;
|
public int glsl_day_low;
|
||||||
|
|
@ -45,6 +55,13 @@ public class DisplayWindow implements IMainloopTask
|
||||||
public int glsl_lightmap_offset;
|
public int glsl_lightmap_offset;
|
||||||
public int glsl_lightmap_size;
|
public int glsl_lightmap_size;
|
||||||
|
|
||||||
|
public int glsl_effect_time;
|
||||||
|
public int glsl_effect_red;
|
||||||
|
public int glsl_effect_vortex;
|
||||||
|
public int glsl_effect_vsnow;
|
||||||
|
public int glsl_effect_red_freq;
|
||||||
|
public int glsl_effect_chill;
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return this.width;
|
return this.width;
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +127,8 @@ public class DisplayWindow implements IMainloopTask
|
||||||
glsl_time = GL33.glGetUniformLocation(environmentRenderer.program, "time");
|
glsl_time = GL33.glGetUniformLocation(environmentRenderer.program, "time");
|
||||||
glsl_tex_cut = GL33.glGetUniformLocation(environmentRenderer.program, "tex_cut");
|
glsl_tex_cut = GL33.glGetUniformLocation(environmentRenderer.program, "tex_cut");
|
||||||
glsl_color = GL33.glGetUniformLocation(environmentRenderer.program, "color");
|
glsl_color = GL33.glGetUniformLocation(environmentRenderer.program, "color");
|
||||||
|
glsl_contrast = GL33.glGetUniformLocation(environmentRenderer.program, "contrast");
|
||||||
|
glsl_billboard = GL33.glGetUniformLocation(environmentRenderer.program, "billboard");
|
||||||
|
|
||||||
glsl_day_low = GL33.glGetUniformLocation(environmentRenderer.program, "lighting_day_low");
|
glsl_day_low = GL33.glGetUniformLocation(environmentRenderer.program, "lighting_day_low");
|
||||||
glsl_day_high = GL33.glGetUniformLocation(environmentRenderer.program, "lighting_day_high");
|
glsl_day_high = GL33.glGetUniformLocation(environmentRenderer.program, "lighting_day_high");
|
||||||
|
|
@ -122,6 +141,34 @@ public class DisplayWindow implements IMainloopTask
|
||||||
|
|
||||||
GL33.glUniform1i(glsl_atlas, 0);
|
GL33.glUniform1i(glsl_atlas, 0);
|
||||||
GL33.glUniform1i(glsl_lightmap, 1);
|
GL33.glUniform1i(glsl_lightmap, 1);
|
||||||
|
|
||||||
|
effectRenderer = new GraphicsShader("/resources/shader/effectRenderer");
|
||||||
|
effectRenderer.use();
|
||||||
|
|
||||||
|
glsl_effect_time = GL33.glGetUniformLocation(effectRenderer.program, "time");
|
||||||
|
glsl_effect_red = GL33.glGetUniformLocation(effectRenderer.program, "red");
|
||||||
|
glsl_effect_vsnow = GL33.glGetUniformLocation(effectRenderer.program, "vsnow");
|
||||||
|
glsl_effect_vortex = GL33.glGetUniformLocation(effectRenderer.program, "vortex");
|
||||||
|
glsl_effect_red_freq = GL33.glGetUniformLocation(effectRenderer.program, "red_freq");
|
||||||
|
glsl_effect_chill = GL33.glGetUniformLocation(effectRenderer.program, "chill");
|
||||||
|
|
||||||
|
effect_vao = GL33.glGenVertexArrays();
|
||||||
|
GL33.glBindVertexArray(effect_vao);
|
||||||
|
|
||||||
|
int effect_vbo = GL33.glGenBuffers();
|
||||||
|
GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, effect_vbo);
|
||||||
|
GL33.glBufferData(GL33.GL_ARRAY_BUFFER, new float[] {
|
||||||
|
-1, -1,
|
||||||
|
-1, 1,
|
||||||
|
1, 1,
|
||||||
|
|
||||||
|
-1, -1,
|
||||||
|
1, -1,
|
||||||
|
1, 1,
|
||||||
|
}, GL33.GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
glVertexAttribPointer(0, 2, GL_FLOAT, false, Float.BYTES * 2, 0);
|
||||||
|
glEnableVertexAttribArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render()
|
public void render()
|
||||||
|
|
@ -136,6 +183,12 @@ public class DisplayWindow implements IMainloopTask
|
||||||
environmentRenderer.use();
|
environmentRenderer.use();
|
||||||
DisplayLighting.updateLighting();
|
DisplayLighting.updateLighting();
|
||||||
|
|
||||||
|
if(Main.player.getHydration() < 0.2) {
|
||||||
|
GL33.glUniform1f(glsl_contrast, (float)(0.2 - Main.player.getHydration()) * 1.6f);
|
||||||
|
} else {
|
||||||
|
GL33.glUniform1f(glsl_contrast, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Bind the texture atlas
|
// Bind the texture atlas
|
||||||
GL33.glActiveTexture(GL33.GL_TEXTURE0);
|
GL33.glActiveTexture(GL33.GL_TEXTURE0);
|
||||||
Resources.ATLAS.bind();
|
Resources.ATLAS.bind();
|
||||||
|
|
@ -147,6 +200,41 @@ public class DisplayWindow implements IMainloopTask
|
||||||
// Render everything
|
// Render everything
|
||||||
DisplayRender.render(w[0], h[0]);
|
DisplayRender.render(w[0], h[0]);
|
||||||
|
|
||||||
|
// Use the effect shader
|
||||||
|
effectRenderer.use();
|
||||||
|
|
||||||
|
// Send extra data to the shader
|
||||||
|
if(!Main.player.dead && Main.menu.doGameloop) {
|
||||||
|
GL33.glUniform1i(glsl_effect_time, (int)System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Main.player.getHydration() < 0.2) {
|
||||||
|
GL33.glUniform1f(glsl_effect_vsnow, (float)(0.2 - Main.player.getHydration()));
|
||||||
|
GL33.glUniform1f(glsl_effect_vortex, (float)(0.2 - Main.player.getHydration()) / 10);
|
||||||
|
} else {
|
||||||
|
GL33.glUniform1f(glsl_effect_vsnow, 0);
|
||||||
|
GL33.glUniform1f(glsl_effect_vortex, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
double player_health = Main.player.getHealth() / Main.player.maxHealth();
|
||||||
|
|
||||||
|
if(player_health < 0.5) {
|
||||||
|
GL33.glUniform1f(glsl_effect_red, (float)(0.5 - player_health));
|
||||||
|
GL33.glUniform1i(glsl_effect_red_freq, 20);
|
||||||
|
} else {
|
||||||
|
GL33.glUniform1f(glsl_effect_red, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Main.player.getTemperature() < 0.3) {
|
||||||
|
GL33.glUniform1f(glsl_effect_chill, (float)(0.3 - Main.player.getTemperature()) / 3 * 10);
|
||||||
|
} else {
|
||||||
|
GL33.glUniform1f(glsl_effect_chill, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a quad to the whole screen for the effects
|
||||||
|
GL33.glBindVertexArray(effect_vao);
|
||||||
|
GL33.glDrawArrays(GL33.GL_TRIANGLES, 0, 6);
|
||||||
|
|
||||||
// Swap the framebuffers and poll events
|
// Swap the framebuffers and poll events
|
||||||
GLFW.glfwSwapBuffers(window);
|
GLFW.glfwSwapBuffers(window);
|
||||||
GLFW.glfwPollEvents();
|
GLFW.glfwPollEvents();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import gl_engine.vec.Vec2i;
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.init.Entities;
|
import projectzombie.init.Entities;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.IModel;
|
||||||
import projectzombie.tiles.Tile;
|
import projectzombie.tiles.Tile;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
@ -36,7 +36,7 @@ public abstract class Entity implements IBdfClassManager
|
||||||
public int stepOnTileCooldown = 0;
|
public int stepOnTileCooldown = 0;
|
||||||
private boolean dead = false;
|
private boolean dead = false;
|
||||||
|
|
||||||
public abstract Model getModel();
|
public abstract IModel getModel();
|
||||||
|
|
||||||
public boolean isDead() {
|
public boolean isDead() {
|
||||||
return dead;
|
return dead;
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ public class EntityBullet extends EntityParticle
|
||||||
|
|
||||||
// Spawn some blood particles
|
// Spawn some blood particles
|
||||||
if(!EntityParticle.DISABLED) {
|
if(!EntityParticle.DISABLED) {
|
||||||
chunk.spawnEntity(ParticleBlood.createBloodParticles(pos, ea.bloodParticles()));
|
chunk.spawnEntity(new ParticleBlood(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play the hit noise
|
// Play the hit noise
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import gl_engine.vec.Vec2i;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.particle.ParticleBlood;
|
import projectzombie.entity.particle.ParticleBlood;
|
||||||
import projectzombie.entity.particle.ParticleBreak;
|
|
||||||
import projectzombie.entity.particle.ParticleSmoke;
|
import projectzombie.entity.particle.ParticleSmoke;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.init.Sounds;
|
import projectzombie.init.Sounds;
|
||||||
|
|
|
||||||
|
|
@ -1,84 +1,16 @@
|
||||||
package projectzombie.entity.particle;
|
package projectzombie.entity.particle;
|
||||||
|
|
||||||
import gl_engine.MathHelpers;
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec3d;
|
|
||||||
import projectzombie.entity.Entity;
|
|
||||||
import projectzombie.entity.EntityContainer;
|
|
||||||
import projectzombie.entity.EntityHeight;
|
|
||||||
import projectzombie.entity.EntityParticle;
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
|
||||||
import projectzombie.util.math.random.RandomHelpers;
|
|
||||||
import projectzombie.world.chunk.Chunk;
|
|
||||||
import projectzombie.world.layer.Layer;
|
|
||||||
|
|
||||||
public class ParticleBlood extends EntityParticle implements EntityHeight
|
public class ParticleBlood extends ParticleBreak
|
||||||
{
|
{
|
||||||
private boolean done = false;
|
public ParticleBlood(Vec2d pos, int size) {
|
||||||
private double time = 1000;
|
super(pos, Models.PARTICLE_BLOOD, size, 0.1);
|
||||||
private double height = 0;
|
|
||||||
private Vec3d velocity;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeight(double height) {
|
|
||||||
this.height = height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleBlood(Vec2d pos) {
|
public ParticleBlood(Vec2d pos) {
|
||||||
super(pos);
|
this(pos, 200);
|
||||||
|
|
||||||
time = RandomHelpers.randrange(rand, 800, 1200);
|
|
||||||
velocity = new Vec3d(MathHelpers.moveTowards2(0.01, rand.nextDouble() * 360), rand.nextDouble() * 0.12);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityContainer createBloodParticles(Vec2d pos, int size)
|
|
||||||
{
|
|
||||||
Entity[] entities = new Entity[size];
|
|
||||||
|
|
||||||
for(int i=0;i<entities.length;i++) {
|
|
||||||
entities[i] = new ParticleBlood(pos.copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EntityContainer(pos.copy(), entities);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick(Chunk chunk, Layer layer)
|
|
||||||
{
|
|
||||||
// Call super
|
|
||||||
super.tick(chunk, layer);
|
|
||||||
|
|
||||||
if(DISABLED || time < 0) {
|
|
||||||
kill();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove some time
|
|
||||||
time -= 1;
|
|
||||||
|
|
||||||
if(done) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move in the velocity and remove some of it
|
|
||||||
pos.x += velocity.x;
|
|
||||||
pos.y += velocity.y;
|
|
||||||
height += velocity.z;
|
|
||||||
velocity.z -= MathHelpers.FallSpeed;
|
|
||||||
if(height < 0) {
|
|
||||||
velocity = new Vec3d(0, 0, 0);
|
|
||||||
height = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getModel() {
|
|
||||||
return Models.PARTICLE_BLOOD;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,169 +1,300 @@
|
||||||
package projectzombie.entity.particle;
|
package projectzombie.entity.particle;
|
||||||
|
|
||||||
|
import static org.lwjgl.opengl.GL15.glBindBuffer;
|
||||||
|
import static org.lwjgl.opengl.GL15.glBufferData;
|
||||||
|
import static org.lwjgl.opengl.GL15.glGenBuffers;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL33;
|
||||||
|
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
|
import gl_engine.matrix.Matrix4;
|
||||||
|
import gl_engine.texture.TextureRef3D;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.Entity;
|
|
||||||
import projectzombie.entity.EntityHeight;
|
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.model.IModel;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.model.ModelVertical;
|
||||||
import projectzombie.util.math.random.RandomHelpers;
|
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class ParticleBreak extends EntityParticle implements EntityHeight
|
public class ParticleBreak extends EntityParticle implements IModel
|
||||||
{
|
{
|
||||||
private double height = 0;
|
private static final Random rand = new Random();
|
||||||
private Vec3d velocity;
|
|
||||||
private int time = 0;
|
|
||||||
private boolean landed = false;
|
|
||||||
|
|
||||||
@Override
|
private class Break {
|
||||||
public double getHeight() {
|
TextureRef3D ref;
|
||||||
return height;
|
Vec3d velocity;
|
||||||
|
Vec3d pos;
|
||||||
|
boolean moving;
|
||||||
|
int flags;
|
||||||
|
int life;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private Break[] particles;
|
||||||
public void setHeight(double height) {
|
private int ibo, vbo, vao;
|
||||||
this.height = height;
|
private boolean generated;
|
||||||
|
private int dead;
|
||||||
|
|
||||||
|
public ParticleBreak(Vec2d pos, IModel model) {
|
||||||
|
this(pos, model, 200, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void spawnParticles(Chunk chunk, Vec2d pos, Entity e)
|
public ParticleBreak(Vec2d pos, IModel model, int count) {
|
||||||
{
|
this(pos, model, count, 0.05);
|
||||||
if(DISABLED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
double height = e.getModel().getHeight();
|
|
||||||
|
|
||||||
for(int i=0;i<50 * height;i++) {
|
|
||||||
chunk.spawnEntity(new ParticleBreak(pos.copy(), e, height));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void spawnParticles(Chunk chunk, Vec2d pos, TileState s)
|
protected ParticleBreak(Vec2d pos, IModel model, int count, double velocity_up_multiplier) {
|
||||||
{
|
|
||||||
if(DISABLED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
double height = s.tile.getModel(s.meta).getHeight();
|
|
||||||
|
|
||||||
for(int i=0;i<50 * height;i++) {
|
|
||||||
chunk.spawnEntity(new ParticleBreak(pos.copy(), s, height));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*private static TextureReference getTexture(TileState ts)
|
|
||||||
{
|
|
||||||
if(ts.tile instanceof IHasTexture)
|
|
||||||
{
|
|
||||||
TextureReference tex = ((IHasTexture)ts.tile).getTexture();
|
|
||||||
|
|
||||||
int px = RandomHelpers.randrange(rand, tex.start_x, tex.end_x - 2);
|
|
||||||
int py = RandomHelpers.randrange(rand, tex.start_y, tex.end_y - 2);
|
|
||||||
return tex.getTextureReference(px, px + 2, py, py + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
return TextureReference.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static TextureReference getTexture(Entity entity)
|
|
||||||
{
|
|
||||||
if(entity instanceof IHasTexture)
|
|
||||||
{
|
|
||||||
TextureReference tex = ((IHasTexture)entity).getTexture();
|
|
||||||
|
|
||||||
int px = RandomHelpers.randrange(rand, tex.start_x, tex.end_x - 2);
|
|
||||||
int py = RandomHelpers.randrange(rand, tex.start_y, tex.end_y - 2);
|
|
||||||
return tex.getTextureReference(px, px + 2, py, py + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
return TextureReference.EMPTY;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public ParticleBreak(Vec2d pos, TileState ts, double height) {
|
|
||||||
super(pos);
|
super(pos);
|
||||||
|
|
||||||
double angle = RandomHelpers.randrange(rand, 360);
|
double model_height = model.getHeight();
|
||||||
|
TextureRef3D[] textures = model.getTextures();
|
||||||
|
float[] verticies = model.getVerticies();
|
||||||
|
|
||||||
Vec2d side_v = MathHelpers.moveTowards2(0.01, Math.toRadians(angle));
|
count *= model_height;
|
||||||
velocity = new Vec3d(
|
particles = new Break[count];
|
||||||
side_v.x, side_v.y,
|
|
||||||
RandomHelpers.randrange(rand, 10000) / 200000.0);
|
|
||||||
|
|
||||||
this.height = RandomHelpers.randrange(rand, 0, (int)(height * 1000)) / 1000.0;
|
for(int i=0;i<particles.length;i++)
|
||||||
time = RandomHelpers.randrange(rand, 800, 1200);
|
{
|
||||||
}
|
Break particle = new Break();
|
||||||
|
|
||||||
public ParticleBreak(Vec2d pos, Entity entity, double height) {
|
int tex_id = (int)(rand.nextDouble() * textures.length);
|
||||||
super(pos);
|
TextureRef3D texture = textures[tex_id];
|
||||||
double angle = RandomHelpers.randrange(rand, 360);
|
TextureRef3D ref = new TextureRef3D();
|
||||||
|
|
||||||
Vec2d side_v = MathHelpers.moveTowards2(0.01, Math.toRadians(angle));
|
float dx = texture.ex - texture.sx;
|
||||||
velocity = new Vec3d(
|
float dy = texture.ey - texture.sy;
|
||||||
side_v.x, side_v.y,
|
float w = (float)model.getWidth();
|
||||||
RandomHelpers.randrange(rand, 10000) / 200000.0);
|
float h = (float)model.getHeight();
|
||||||
|
|
||||||
this.height = RandomHelpers.randrange(rand, 0, (int)(height * 1000)) / 1000.0;
|
ref.sx = (float)MathHelpers.map((int)(rand.nextDouble()*16*w), 0, 16*w, texture.sx, texture.ex - dx/(16*w));
|
||||||
time = RandomHelpers.randrange(rand, 500, 1500);
|
ref.sy = (float)MathHelpers.map((int)(rand.nextDouble()*16*h), 0, 16*h, texture.sy, texture.ey - dy/(16*h));
|
||||||
|
ref.ex = ref.sx + dx/(16*w);
|
||||||
|
ref.ey = ref.sy + dy/(16*h);
|
||||||
|
|
||||||
/*if(entity instanceof EntityVertical) {
|
ref.texmap = texture.texmap;
|
||||||
EntityVertical entity_v = (EntityVertical) entity;
|
ref.z = texture.z;
|
||||||
|
|
||||||
height = RandomHelpers.randrange(rand, 0, MathHelpers.floor(entity_v.size.y));
|
particle.life = (int)(rand.nextDouble() * 200 + 800);
|
||||||
|
particle.pos = new Vec3d(pos, rand.nextDouble() * model_height);
|
||||||
|
particle.velocity = new Vec3d(
|
||||||
|
MathHelpers.moveTowards2(0.01, rand.nextDouble() * MathHelpers.TWO_PI),
|
||||||
|
rand.nextDouble() * velocity_up_multiplier);
|
||||||
|
particle.ref = ref;
|
||||||
|
particle.moving = true;
|
||||||
|
particle.flags = (int)verticies[tex_id * Model.SIZE + Model.SIZE - 1] | 0b1000;
|
||||||
|
|
||||||
|
particles[i] = particle;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
generated = false;
|
||||||
|
dead = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
// Kill the particle if the player can't see it to reduce lag
|
dead = 0;
|
||||||
if(Main.player.pos.squareDistance(pos) > 32 || time < 0) {
|
|
||||||
this.kill();
|
for(int i=0;i<particles.length;i++)
|
||||||
|
{
|
||||||
|
Break particle = particles[i];
|
||||||
|
|
||||||
|
if(particle.life <= 0) {
|
||||||
|
dead += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
particle.life -= 1;
|
||||||
|
|
||||||
|
if(!particle.moving) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(particle.pos.z < 0) {
|
||||||
|
particle.moving = false;
|
||||||
|
particle.pos.z = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
particle.velocity.z -= MathHelpers.FallSpeed;
|
||||||
|
particle.pos = particle.pos.add(particle.velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
time -= 1;
|
if(dead == particles.length - 1) {
|
||||||
|
|
||||||
if(!landed) {
|
|
||||||
height += velocity.z;
|
|
||||||
velocity.z -= MathHelpers.FallSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(height < 0) {
|
|
||||||
height = 0;
|
|
||||||
velocity = velocity.multiply(0);
|
|
||||||
landed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(time < 0) {
|
|
||||||
kill();
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
pos.x += velocity.x;
|
|
||||||
pos.y += velocity.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(DISABLED) {
|
|
||||||
kill();
|
kill();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public IModel getModel() {
|
||||||
return Models.PARTICLE_BULLET;
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getIndicies()
|
||||||
|
{
|
||||||
|
int[] indicies = new int[getIndexSize()];
|
||||||
|
int upto = 0;
|
||||||
|
|
||||||
|
for(int i=0;i<indicies.length;i+=6)
|
||||||
|
{
|
||||||
|
indicies[i+0] = upto+0;
|
||||||
|
indicies[i+1] = upto+1;
|
||||||
|
indicies[i+2] = upto+2;
|
||||||
|
indicies[i+3] = upto+2;
|
||||||
|
indicies[i+4] = upto+3;
|
||||||
|
indicies[i+5] = upto+0;
|
||||||
|
upto += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return indicies;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float[] getVerticies()
|
||||||
|
{
|
||||||
|
float[] verticies = new float[getSize() * Model.SIZE];
|
||||||
|
|
||||||
|
int upto = 0;
|
||||||
|
|
||||||
|
for(int i=0;i<particles.length;i++)
|
||||||
|
{
|
||||||
|
Break particle = particles[i];
|
||||||
|
|
||||||
|
if(particle.life <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextureRef3D ref = particle.ref;
|
||||||
|
|
||||||
|
float f = particle.flags;
|
||||||
|
float k = Model.OFFSET;
|
||||||
|
float x = 0.05f;
|
||||||
|
float y = 0.1f;
|
||||||
|
|
||||||
|
float px = (float)(pos.x - particle.pos.x);
|
||||||
|
float py = (float)(particle.pos.z);
|
||||||
|
float pz = (float)(pos.y - particle.pos.y);
|
||||||
|
|
||||||
|
float[] p = {
|
||||||
|
-x, 0, 0, ref.sx+k, ref.sy+k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
||||||
|
x, 0, 0, ref.ex-k, ref.sy+k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
||||||
|
x, y, 0, ref.ex-k, ref.ey-k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
||||||
|
-x, y, 0, ref.sx+k, ref.ey-k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
||||||
|
};
|
||||||
|
|
||||||
|
for(int j=0;j<p.length;j++) {
|
||||||
|
verticies[upto+j] = p[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
upto += 4*Model.SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return verticies;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRef3D[] getTextures()
|
||||||
|
{
|
||||||
|
TextureRef3D[] textures = new TextureRef3D[getSize()];
|
||||||
|
int upto = 0;
|
||||||
|
|
||||||
|
for(int i=0;i<particles.length;i++) {
|
||||||
|
if(particles[i].life <= 0) continue;
|
||||||
|
textures[upto+0] = particles[i].ref;
|
||||||
|
textures[upto+1] = particles[i].ref;
|
||||||
|
textures[upto+2] = particles[i].ref;
|
||||||
|
textures[upto+3] = particles[i].ref;
|
||||||
|
upto += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return textures;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getHeight() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIndexSize() {
|
||||||
|
return 6 * (particles.length - dead);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSize() {
|
||||||
|
return 4 * (particles.length - dead);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bind()
|
||||||
|
{
|
||||||
|
if(!generated)
|
||||||
|
{
|
||||||
|
int[] indicies = this.getIndicies();
|
||||||
|
|
||||||
|
vao = GL33.glGenVertexArrays();
|
||||||
|
GL33.glBindVertexArray(vao);
|
||||||
|
|
||||||
|
vbo = GL33.glGenBuffers();
|
||||||
|
GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, vbo);
|
||||||
|
GL33.glBufferData(GL33.GL_ARRAY_BUFFER, getVerticies(), GL33.GL_DYNAMIC_DRAW);
|
||||||
|
|
||||||
|
Model.setGLArrayAttributes();
|
||||||
|
|
||||||
|
ibo = glGenBuffers();
|
||||||
|
glBindBuffer(GL33.GL_ELEMENT_ARRAY_BUFFER, ibo);
|
||||||
|
glBufferData(GL33.GL_ELEMENT_ARRAY_BUFFER, indicies, GL33.GL_STATIC_DRAW);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
GL33.glBindVertexArray(vao);
|
||||||
|
}
|
||||||
|
|
||||||
|
generated = true;
|
||||||
|
Model.bound = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render()
|
||||||
|
{
|
||||||
|
if(Model.bound != this) {
|
||||||
|
bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, vbo);
|
||||||
|
GL33.glBufferSubData(GL33.GL_ARRAY_BUFFER, 0, getVerticies());
|
||||||
|
GL33.glDrawElements(GL33.GL_TRIANGLES, getIndexSize(), GL33.GL_UNSIGNED_INT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void free() {
|
||||||
|
GL33.glDeleteBuffers(ibo);
|
||||||
|
GL33.glDeleteBuffers(vbo);
|
||||||
|
GL33.glDeleteVertexArrays(vao);
|
||||||
|
generated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModel(Matrix4 model) {
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_model, true, model.getArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLoaded() {
|
||||||
|
return generated;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth() {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,66 +8,19 @@ import projectzombie.entity.EntityContainer;
|
||||||
import projectzombie.entity.EntityHeight;
|
import projectzombie.entity.EntityHeight;
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.model.IModel;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class ParticleWater extends EntityParticle implements EntityHeight
|
public class ParticleWater extends ParticleBreak
|
||||||
{
|
{
|
||||||
private Vec3d velocity;
|
public ParticleWater(Vec2d pos) {
|
||||||
private double height = 0;
|
this(pos, 50);
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public ParticleWater(Vec2d pos, int count) {
|
||||||
public void setHeight(double height) {
|
super(pos, Models.TILE_WATER, count, 0.01);
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
ParticleWater(Vec2d pos) {
|
|
||||||
super(pos);
|
|
||||||
|
|
||||||
// Set the velocity
|
|
||||||
velocity = new Vec3d(MathHelpers.moveTowards2(0.04, rand.nextDouble() * 360), rand.nextDouble() * 0.04);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityContainer createWaterParticles(Vec2d pos, int amount)
|
|
||||||
{
|
|
||||||
Entity[] entities = new Entity[amount];
|
|
||||||
|
|
||||||
for(int i=0;i<amount;i++) {
|
|
||||||
entities[i] = new ParticleWater(pos.copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EntityContainer(pos.copy(), entities);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
|
||||||
super.tick(chunk, layer);
|
|
||||||
|
|
||||||
// Add the velocity
|
|
||||||
velocity.z -= MathHelpers.FallSpeed;
|
|
||||||
pos.x += velocity.x;
|
|
||||||
pos.y += velocity.y;
|
|
||||||
height += velocity.z;
|
|
||||||
|
|
||||||
// Is the height below 0; destroy this particle
|
|
||||||
if(height < 0) {
|
|
||||||
kill();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(DISABLED) {
|
|
||||||
kill();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getModel() {
|
|
||||||
return Models.PARTICLE_WATER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,10 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
// Create the inventory
|
// Create the inventory
|
||||||
inventory = new Inventory(10);
|
inventory = new Inventory(10);
|
||||||
|
|
||||||
inventory.addItem(new ItemStack(Items.LANTERN, 99, (short)0));
|
inventory.addItem(new ItemStack(Items.AMMO, 999, (short)0));
|
||||||
|
inventory.addItem(new ItemStack(Items.SPAWN_DUMMY, 999, (short)0));
|
||||||
|
inventory.addItem(new ItemStack(Items.SPAWN_ZOMBIE, 999, (short)0));
|
||||||
|
inventory.addItem(new ItemStack(Items.LANTERN, 999, (short)0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -150,7 +153,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
// Handle player deaths
|
// Handle player deaths
|
||||||
if(health <= 0)
|
if(health <= 0)
|
||||||
{
|
{
|
||||||
ParticleBreak.spawnParticles(chunk, pos, this);
|
chunk.spawnEntity(new ParticleBreak(pos, getModel()));
|
||||||
|
|
||||||
if(Cheats.god_mode) {
|
if(Cheats.god_mode) {
|
||||||
this.resetHealth();
|
this.resetHealth();
|
||||||
|
|
@ -188,12 +191,25 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
// Call super
|
// Call super
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
System.out.println(chunk.getLightLevel(pos.toInt()) * 0.8);
|
|
||||||
|
|
||||||
double temp_diff = MathHelpers.biggest(
|
double temp_diff = MathHelpers.biggest(
|
||||||
layer.layergen.getTemperatureDynamic(layer, pos),
|
layer.layergen.getTemperatureDynamic(layer, pos),
|
||||||
chunk.getLightLevel(pos.toInt()) * 0.8) - temperature;
|
chunk.getLightLevel(pos.toInt()) * 0.6) - temperature;
|
||||||
|
|
||||||
temperature += temp_diff / 1000;
|
temperature += temp_diff / 1000;
|
||||||
|
hydration -= Math.sqrt(Math.abs(temperature - 0.5)) / 5000;
|
||||||
|
|
||||||
|
if(temperature < 0.3) {
|
||||||
|
health -= 0.3 - temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(temperature > 0.7) {
|
||||||
|
health -= temperature - 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hydration <= 0) {
|
||||||
|
hydration = 0;
|
||||||
|
health -= 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
// Rotate left
|
// Rotate left
|
||||||
if(MOVE_LEFT) {
|
if(MOVE_LEFT) {
|
||||||
|
|
@ -231,7 +247,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleBreak.spawnParticles(chunk, pos, this);
|
chunk.spawnEntity(new ParticleBreak(pos, getModel()));
|
||||||
|
|
||||||
dead = true;
|
dead = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package projectzombie.init;
|
package projectzombie.init;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.model.ModelEmpty;
|
import projectzombie.model.ModelEmpty;
|
||||||
import projectzombie.model.ModelGrass;
|
import projectzombie.model.ModelGrass;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import projectzombie.menu.gui.ButtonGroup;
|
||||||
import projectzombie.menu.gui.GUI;
|
import projectzombie.menu.gui.GUI;
|
||||||
import projectzombie.menu.gui.components.ButtonBasic;
|
import projectzombie.menu.gui.components.ButtonBasic;
|
||||||
import projectzombie.menu.gui.components.ButtonGroupPause;
|
import projectzombie.menu.gui.components.ButtonGroupPause;
|
||||||
import projectzombie.menu.gui.components.LabelPause;
|
|
||||||
import projectzombie.menu.gui.components.OverlayBackground;
|
import projectzombie.menu.gui.components.OverlayBackground;
|
||||||
|
|
||||||
public class MenuDeath extends Menu
|
public class MenuDeath extends Menu
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ public class Label implements GUIComponent
|
||||||
{
|
{
|
||||||
private Vec2d pos = new Vec2d(0, 0);
|
private Vec2d pos = new Vec2d(0, 0);
|
||||||
private Vec2d size = new Vec2d(0.5, 0.5);
|
private Vec2d size = new Vec2d(0.5, 0.5);
|
||||||
private Vec3d color = new Vec3d(0.92, 0.92, 0.92);
|
|
||||||
private String text = "";
|
private String text = "";
|
||||||
private Alignment alignment = Alignment.CENTRE;
|
private Alignment alignment = Alignment.CENTRE;
|
||||||
|
|
||||||
|
|
@ -25,10 +24,6 @@ public class Label implements GUIComponent
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Vec3d color) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlign(Alignment alignment) {
|
public void setAlign(Alignment alignment) {
|
||||||
this.alignment = alignment;
|
this.alignment = alignment;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package projectzombie.model;
|
||||||
|
|
||||||
|
import gl_engine.matrix.Matrix4;
|
||||||
|
import gl_engine.texture.TextureRef3D;
|
||||||
|
|
||||||
|
public interface IModel
|
||||||
|
{
|
||||||
|
public abstract int[] getIndicies();
|
||||||
|
public abstract float[] getVerticies();
|
||||||
|
public abstract TextureRef3D[] getTextures();
|
||||||
|
public abstract double getWidth();
|
||||||
|
public abstract double getHeight();
|
||||||
|
public abstract int getIndexSize();
|
||||||
|
public abstract int getSize();
|
||||||
|
|
||||||
|
public void bind();
|
||||||
|
public void render();
|
||||||
|
public void free();
|
||||||
|
public void setModel(Matrix4 model);
|
||||||
|
public boolean isLoaded();
|
||||||
|
}
|
||||||
|
|
@ -18,21 +18,37 @@ import gl_engine.matrix.Matrix4;
|
||||||
import gl_engine.texture.TextureRef3D;
|
import gl_engine.texture.TextureRef3D;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
|
|
||||||
public abstract class Model
|
public abstract class Model implements IModel
|
||||||
{
|
{
|
||||||
|
public static final float OFFSET = 0.001f;
|
||||||
|
public static final int SIZE = 14;
|
||||||
|
public static IModel bound = null;
|
||||||
|
|
||||||
int vao, vbo, ibo;
|
int vao, vbo, ibo;
|
||||||
boolean loaded = false;
|
boolean loaded = false;
|
||||||
public static final int SIZE = 14;
|
|
||||||
|
|
||||||
// px, py, pz, tx, ty
|
public static void setGLArrayAttributes()
|
||||||
public abstract int[] getIndicies();
|
{
|
||||||
public abstract float[] getVerticies();
|
// aPos
|
||||||
public abstract TextureRef3D[] getTextures();
|
glVertexAttribPointer(0, 3, GL_FLOAT, false, Float.BYTES * SIZE, 0);
|
||||||
public abstract double getHeight();
|
glEnableVertexAttribArray(0);
|
||||||
public abstract int getIndexSize();
|
|
||||||
public abstract int getSize();
|
|
||||||
|
|
||||||
private static Model bound = null;
|
// aTex
|
||||||
|
glVertexAttribPointer(1, 3, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 3);
|
||||||
|
glEnableVertexAttribArray(1);
|
||||||
|
|
||||||
|
// aTexY
|
||||||
|
glVertexAttribPointer(2, 2, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 6);
|
||||||
|
glEnableVertexAttribArray(2);
|
||||||
|
|
||||||
|
// aChunkOffset
|
||||||
|
glVertexAttribPointer(3, 3, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 8);
|
||||||
|
glEnableVertexAttribArray(3);
|
||||||
|
|
||||||
|
// aFlags
|
||||||
|
glVertexAttribPointer(4, 3, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 11);
|
||||||
|
glEnableVertexAttribArray(4);
|
||||||
|
}
|
||||||
|
|
||||||
protected void generate()
|
protected void generate()
|
||||||
{
|
{
|
||||||
|
|
@ -51,7 +67,7 @@ public abstract class Model
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = verticies.length/SIZE;
|
int size = verticies.length/SIZE;
|
||||||
double k = 0.001;
|
double k = OFFSET;
|
||||||
|
|
||||||
for(int i=0;i<size;i++) {
|
for(int i=0;i<size;i++) {
|
||||||
TextureRef3D ref = refs[i];
|
TextureRef3D ref = refs[i];
|
||||||
|
|
@ -67,20 +83,7 @@ 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, 3, GL_FLOAT, false, Float.BYTES * SIZE, 0);
|
setGLArrayAttributes();
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
|
|
||||||
glVertexAttribPointer(1, 3, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 3);
|
|
||||||
glEnableVertexAttribArray(1);
|
|
||||||
|
|
||||||
glVertexAttribPointer(2, 2, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 6);
|
|
||||||
glEnableVertexAttribArray(2);
|
|
||||||
|
|
||||||
glVertexAttribPointer(3, 3, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 8);
|
|
||||||
glEnableVertexAttribArray(3);
|
|
||||||
|
|
||||||
glVertexAttribPointer(4, 3, GL_FLOAT, false, Float.BYTES * SIZE, Float.BYTES * 11);
|
|
||||||
glEnableVertexAttribArray(4);
|
|
||||||
|
|
||||||
ibo = glGenBuffers();
|
ibo = glGenBuffers();
|
||||||
glBindBuffer(GL33.GL_ELEMENT_ARRAY_BUFFER, ibo);
|
glBindBuffer(GL33.GL_ELEMENT_ARRAY_BUFFER, ibo);
|
||||||
|
|
@ -111,10 +114,11 @@ public abstract class Model
|
||||||
GL33.glDrawElements(GL33.GL_TRIANGLES, getIndexSize(), GL33.GL_UNSIGNED_INT, 0);
|
GL33.glDrawElements(GL33.GL_TRIANGLES, getIndexSize(), GL33.GL_UNSIGNED_INT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void free()
|
public void free() {
|
||||||
{
|
GL33.glDeleteBuffers(ibo);
|
||||||
GL33.glDeleteVertexArrays(vao);
|
|
||||||
GL33.glDeleteBuffers(vbo);
|
GL33.glDeleteBuffers(vbo);
|
||||||
|
GL33.glDeleteVertexArrays(vao);
|
||||||
|
loaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModel(Matrix4 model) {
|
public void setModel(Matrix4 model) {
|
||||||
|
|
|
||||||
|
|
@ -45,4 +45,9 @@ public class ModelChunk extends Model
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,11 @@ public class ModelEmpty extends Model
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getHeight() {
|
public double getHeight() {
|
||||||
return 0;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth() {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,4 +48,9 @@ public class ModelGrass extends Model
|
||||||
public double getHeight() {
|
public double getHeight() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ public class ModelGui extends Model
|
||||||
height = y;
|
height = y;
|
||||||
|
|
||||||
return new float[] {
|
return new float[] {
|
||||||
0, 0, 0, 0, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
0, 0, 0, 0, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0b10,
|
||||||
x, 0, 0, 1, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
x, 0, 0, 1, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0b10,
|
||||||
x, y, 0, 1, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
x, y, 0, 1, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0b10,
|
||||||
0, y, 0, 0, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
0, y, 0, 0, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0b10,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,4 +63,9 @@ public class ModelTile extends Model
|
||||||
public double getHeight() {
|
public double getHeight() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,6 +56,11 @@ public class ModelTree extends Model
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getHeight() {
|
public double getHeight() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ public class ModelVertical extends Model
|
||||||
{
|
{
|
||||||
private int animationSize;
|
private int animationSize;
|
||||||
private int animationSpeed;
|
private int animationSpeed;
|
||||||
private double height;
|
|
||||||
private TextureRef3D ref;
|
private TextureRef3D ref;
|
||||||
private Vec2d size;
|
private Vec2d size;
|
||||||
|
|
||||||
|
|
@ -51,8 +50,6 @@ public class ModelVertical extends Model
|
||||||
int asi = animationSize;
|
int asi = animationSize;
|
||||||
int asp = animationSpeed;
|
int asp = animationSpeed;
|
||||||
|
|
||||||
height = y;
|
|
||||||
|
|
||||||
return new float[] {
|
return new float[] {
|
||||||
-x, 0, 0, 0, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 1,
|
-x, 0, 0, 0, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 1,
|
||||||
x, 0, 0, 1, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 1,
|
x, 0, 0, 1, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 1,
|
||||||
|
|
@ -79,7 +76,11 @@ public class ModelVertical extends Model
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getHeight() {
|
public double getHeight() {
|
||||||
generate();
|
return size.x;
|
||||||
return height;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth() {
|
||||||
|
return size.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package projectzombie.tiles;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
|
|
@ -49,7 +48,7 @@ public class TileBossPortal extends Tile
|
||||||
LayerGenBossArena layergen = (LayerGenBossArena) LayerGenerators.BOSS_ARENA;
|
LayerGenBossArena layergen = (LayerGenBossArena) LayerGenerators.BOSS_ARENA;
|
||||||
layergen.spawnPlayer(ep);
|
layergen.spawnPlayer(ep);
|
||||||
layer.setFrontTile(TileState.EMPTY, tpos);
|
layer.setFrontTile(TileState.EMPTY, tpos);
|
||||||
ParticleBreak.spawnParticles(layer.getChunk(tpos), new Vec2d(1, 1), state);
|
layer.spawnEntity(new ParticleBreak(tpos.toDouble(), getModel(state.meta)));
|
||||||
|
|
||||||
int id = Main.world.addLayer(new Layer(rand, layergen));
|
int id = Main.world.addLayer(new Layer(rand, layergen));
|
||||||
Main.world.setLayer(id);
|
Main.world.setLayer(id);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class TileWater extends Tile
|
||||||
super.onWalkedOn(chunk, layer, pos, entity, state);
|
super.onWalkedOn(chunk, layer, pos, entity, state);
|
||||||
|
|
||||||
// Spawn some water particles
|
// Spawn some water particles
|
||||||
layer.spawnEntity(ParticleWater.createWaterParticles(entity.pos, 4));
|
layer.spawnEntity(new ParticleWater(pos.toDouble()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package projectzombie.util.math;
|
package projectzombie.util.math;
|
||||||
|
|
||||||
import gl_engine.vec.Vec3d;
|
|
||||||
import projectzombie.init.Tiles;
|
import projectzombie.init.Tiles;
|
||||||
import projectzombie.tiles.Tile;
|
import projectzombie.tiles.Tile;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package projectzombie.world.chunk;
|
package projectzombie.world.chunk;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import bdf.classes.IBdfClassManager;
|
import bdf.classes.IBdfClassManager;
|
||||||
|
|
@ -14,7 +13,6 @@ import gl_engine.range.Range2i;
|
||||||
import gl_engine.texture.TextureRef3D;
|
import gl_engine.texture.TextureRef3D;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
import gl_engine.vec.Vec3d;
|
|
||||||
import projectzombie.display.Camera;
|
import projectzombie.display.Camera;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityAlive;
|
import projectzombie.entity.EntityAlive;
|
||||||
|
|
@ -23,6 +21,7 @@ import projectzombie.entity.EntityHoldsEntities;
|
||||||
import projectzombie.entity.EntityKillWithParticles;
|
import projectzombie.entity.EntityKillWithParticles;
|
||||||
import projectzombie.entity.particle.ParticleBreak;
|
import projectzombie.entity.particle.ParticleBreak;
|
||||||
import projectzombie.init.Tiles;
|
import projectzombie.init.Tiles;
|
||||||
|
import projectzombie.model.IModel;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.model.ModelChunk;
|
import projectzombie.model.ModelChunk;
|
||||||
import projectzombie.tiles.Tile;
|
import projectzombie.tiles.Tile;
|
||||||
|
|
@ -192,7 +191,7 @@ public class Chunk implements IBdfClassManager
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model model = e.getModel();
|
IModel model = e.getModel();
|
||||||
double h = 0;
|
double h = 0;
|
||||||
|
|
||||||
if(e instanceof EntityHoldsEntities) {
|
if(e instanceof EntityHoldsEntities) {
|
||||||
|
|
@ -436,7 +435,7 @@ public class Chunk implements IBdfClassManager
|
||||||
|
|
||||||
if(!ts.tile.unbreakable) {
|
if(!ts.tile.unbreakable) {
|
||||||
setBackTile(layer.layergen.getTileDestroyed(), pos);
|
setBackTile(layer.layergen.getTileDestroyed(), pos);
|
||||||
ParticleBreak.spawnParticles(this, new Vec2d(pos.x + 0.5, pos.y + 0.5), ts);
|
spawnEntity(new ParticleBreak(new Vec2d(pos.x + 0.5, pos.y + 0.5), ts.tile.getModel(ts.meta)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -447,7 +446,7 @@ public class Chunk implements IBdfClassManager
|
||||||
|
|
||||||
if(!ts.tile.unbreakable) {
|
if(!ts.tile.unbreakable) {
|
||||||
setFrontTile(Tiles.VOID.getDefaultState(), pos);
|
setFrontTile(Tiles.VOID.getDefaultState(), pos);
|
||||||
ParticleBreak.spawnParticles(this, new Vec2d(pos.x + 0.5, pos.y + 0.5), ts);
|
spawnEntity(new ParticleBreak(new Vec2d(pos.x + 0.5, pos.y + 0.5), ts.tile.getModel(ts.meta)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import java.util.Random;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
import gl_engine.vec.Vec3d;
|
|
||||||
import projectzombie.display.Camera;
|
import projectzombie.display.Camera;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
|
|
|
||||||
|
|
@ -26,16 +26,16 @@ public class LayerGenEarth extends LayerGen
|
||||||
{
|
{
|
||||||
// Get the noise generator
|
// Get the noise generator
|
||||||
OpenSimplexNoise terrain_noise = layer.noise_gens[0];
|
OpenSimplexNoise terrain_noise = layer.noise_gens[0];
|
||||||
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0, 0.7);
|
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0, 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getTemperatureDynamic(Layer layer, Vec2d pos)
|
public double getTemperatureDynamic(Layer layer, Vec2d pos)
|
||||||
{
|
{
|
||||||
// Get the noise generator
|
// Get the noise generator
|
||||||
double light = (getEarthLight() + 1) * 0.2;
|
double light = (MathHelpers.sin(GameTimer.getTime() / 7200.0 - MathHelpers.PI / 4) + 1) * 0.2;
|
||||||
OpenSimplexNoise terrain_noise = layer.noise_gens[0];
|
OpenSimplexNoise terrain_noise = layer.noise_gens[0];
|
||||||
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, light, 0.5 + light);
|
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0, 0.6 + light);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec2 pPos;
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
uniform float chill;
|
||||||
|
uniform float vortex;
|
||||||
|
uniform float vsnow;
|
||||||
|
uniform float red;
|
||||||
|
uniform int red_freq;
|
||||||
|
|
||||||
|
uniform int time;
|
||||||
|
|
||||||
|
float pi = 3.14159265358979323;
|
||||||
|
|
||||||
|
int xorshift(in int value) {
|
||||||
|
value ^= value << 13;
|
||||||
|
value ^= value >> 17;
|
||||||
|
value ^= value << 5;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
float nextFloat(int seed) {
|
||||||
|
seed = xorshift(seed);
|
||||||
|
return mod(abs(fract(float(seed) / 3141.592653)), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
float smoothStep(float a) {
|
||||||
|
return a * a * (3 - 2 * a);
|
||||||
|
}
|
||||||
|
|
||||||
|
float squared(float a) {
|
||||||
|
return a * a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float distance = sqrt(pPos.x * pPos.x + pPos.y * pPos.y);
|
||||||
|
|
||||||
|
//float vsnow_v = nextFloat(xorshift(floatBitsToInt(pPos.x)) + xorshift(floatBitsToInt(pPos.y)) + xorshift(time)) * vsnow;
|
||||||
|
float red_v = distance * ((abs(time / red_freq) % 100) / 100.0) * red;
|
||||||
|
float vortex_v = (1 - distance) * squared(sin(distance * 10 + (time % 3141) / 100.0)) * vortex;
|
||||||
|
float chill_v = (distance - 1 + chill) * nextFloat(xorshift(floatBitsToInt(pPos.x)) + xorshift(floatBitsToInt(pPos.y)));
|
||||||
|
|
||||||
|
chill_v = (chill_v < 0.25 ? 0 : 1) * chill;
|
||||||
|
|
||||||
|
FragColor = vec4(red_v, 0, 0, red_v) + vec4(0, 0, 0, vortex_v) + vec4(chill_v, chill_v, chill_v, chill_v);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
#version 330
|
||||||
|
|
||||||
|
layout (location = 0) in vec2 aPos;
|
||||||
|
|
||||||
|
out vec2 pPos;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = new vec4(aPos, 0, 1);
|
||||||
|
pPos = aPos;
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,8 @@ uniform vec2 lightmap_size;
|
||||||
uniform vec2 tex_cut;
|
uniform vec2 tex_cut;
|
||||||
uniform vec4 color;
|
uniform vec4 color;
|
||||||
|
|
||||||
|
uniform float contrast;
|
||||||
|
|
||||||
vec3 color_grass_hot_wet = vec3(0.05, 0.8, 0);
|
vec3 color_grass_hot_wet = vec3(0.05, 0.8, 0);
|
||||||
vec3 color_grass_hot_dry = vec3(1, 0.6, 0);
|
vec3 color_grass_hot_dry = vec3(1, 0.6, 0);
|
||||||
vec3 color_grass_cold_wet = vec3(0.075, 0.533, 0.047);
|
vec3 color_grass_cold_wet = vec3(0.075, 0.533, 0.047);
|
||||||
|
|
@ -72,5 +74,11 @@ void main()
|
||||||
FragColor = texture(atlas, pTexture) * (mod(int(pFlags / 4), 2) == 1 ? color_grass : vec4(1,1,1,1)) *
|
FragColor = texture(atlas, pTexture) * (mod(int(pFlags / 4), 2) == 1 ? color_grass : vec4(1,1,1,1)) *
|
||||||
color * vec4(biggest(light_day, light_src), 1);
|
color * vec4(biggest(light_day, light_src), 1);
|
||||||
|
|
||||||
|
float saturation = contrast * 2 + 1;
|
||||||
|
|
||||||
|
FragColor.x = min(1, FragColor.x * saturation + contrast);
|
||||||
|
FragColor.y = min(1, FragColor.y * saturation + contrast);
|
||||||
|
FragColor.z = min(1, FragColor.z * saturation + contrast);
|
||||||
|
|
||||||
discard(FragColor.a == 0 || (pPos.x > tex_cut.y && tex_cut.x > 0.5));
|
discard(FragColor.a == 0 || (pPos.x > tex_cut.y && tex_cut.x > 0.5));
|
||||||
}
|
}
|
||||||
|
|
@ -12,6 +12,7 @@ out vec3 pPos;
|
||||||
|
|
||||||
flat out int pFlags;
|
flat out int pFlags;
|
||||||
|
|
||||||
|
uniform mat4 billboard;
|
||||||
uniform mat4 projection;
|
uniform mat4 projection;
|
||||||
uniform mat4 model;
|
uniform mat4 model;
|
||||||
uniform mat4 rotated;
|
uniform mat4 rotated;
|
||||||
|
|
@ -52,10 +53,7 @@ void main()
|
||||||
{
|
{
|
||||||
int type = int(aFlags.z);
|
int type = int(aFlags.z);
|
||||||
|
|
||||||
mat4 do_rotation = rotated;
|
vec4 pos = vec4(aPos, 1) * (mod(type >> 4, 2) == 1 ? billboard : (mod(type, 2) == 1 ? rotated : mat4(1))) *
|
||||||
mat4 no_rotation = mat4(1);
|
|
||||||
|
|
||||||
vec4 pos = vec4(aPos, 1) * (mod(type, 2) == 1 ? do_rotation : no_rotation) *
|
|
||||||
translate(aChunkOffset) * model;
|
translate(aChunkOffset) * model;
|
||||||
|
|
||||||
gl_Position = pos * projection;
|
gl_Position = pos * projection;
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue