Fixed issues with rendering entities
This commit is contained in:
parent
93ff25c5aa
commit
28be74ec0d
|
|
@ -7,4 +7,5 @@ public interface ITransparentObject
|
||||||
{
|
{
|
||||||
public boolean isOpaqueTile();
|
public boolean isOpaqueTile();
|
||||||
public void render(Vec2d pos, Camera camera);
|
public void render(Vec2d pos, Camera camera);
|
||||||
|
public Vec2d getRenderOffset();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ class TransparentObject
|
||||||
Vec2d pos;
|
Vec2d pos;
|
||||||
|
|
||||||
TransparentObject(ITransparentObject object, Camera camera, Vec2d pos) {
|
TransparentObject(ITransparentObject object, Camera camera, Vec2d pos) {
|
||||||
this.distance = camera.pos.distance(new Vec3d(pos.x, pos.y, 0));
|
Vec2d offset = object.getRenderOffset();
|
||||||
|
this.distance = camera.pos.distance(new Vec3d(offset.x + pos.x, offset.y + pos.y, 0));
|
||||||
this.object = object;
|
this.object = object;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import shootergame.tiles.Tile;
|
||||||
import shootergame.util.math.MathHelpers;
|
import shootergame.util.math.MathHelpers;
|
||||||
import shootergame.util.math.vec.Vec2d;
|
import shootergame.util.math.vec.Vec2d;
|
||||||
import shootergame.util.math.vec.Vec2i;
|
import shootergame.util.math.vec.Vec2i;
|
||||||
|
import shootergame.util.math.vec.Vec3d;
|
||||||
import shootergame.world.World;
|
import shootergame.world.World;
|
||||||
import shootergame.world.chunk.Chunk;
|
import shootergame.world.chunk.Chunk;
|
||||||
import shootergame.world.layer.Layer;
|
import shootergame.world.layer.Layer;
|
||||||
|
|
@ -85,6 +86,11 @@ public class Entity implements ITransparentObject
|
||||||
chunk.killEntity(this);
|
chunk.killEntity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void activateSteppedOnBlocks()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public boolean moveIsLegal(Vec2d pos)
|
public boolean moveIsLegal(Vec2d pos)
|
||||||
{
|
{
|
||||||
// Is this entity solid
|
// Is this entity solid
|
||||||
|
|
@ -141,4 +147,9 @@ public class Entity implements ITransparentObject
|
||||||
// Send back true if everything passes
|
// Send back true if everything passes
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec2d getRenderOffset() {
|
||||||
|
return new Vec2d(0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public class EntityVertical extends Entity
|
||||||
|
|
||||||
public void render(Vec2d pos, Camera camera, TextureReference tex, double height) {
|
public void render(Vec2d pos, Camera camera, TextureReference tex, double height) {
|
||||||
super.render(pos, camera);
|
super.render(pos, camera);
|
||||||
VerticalRender.render(pos, camera, tex, height);
|
VerticalRender.render(new Vec2d(pos.x - 0.5, pos.y - 0.5), camera, tex, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import shootergame.entity.Entity;
|
||||||
import shootergame.entity.player.EntityPlayer;
|
import shootergame.entity.player.EntityPlayer;
|
||||||
import shootergame.util.math.vec.Vec2d;
|
import shootergame.util.math.vec.Vec2d;
|
||||||
import shootergame.util.math.vec.Vec2i;
|
import shootergame.util.math.vec.Vec2i;
|
||||||
|
import shootergame.util.math.vec.Vec3d;
|
||||||
import shootergame.world.chunk.Chunk;
|
import shootergame.world.chunk.Chunk;
|
||||||
import shootergame.world.layer.Layer;
|
import shootergame.world.layer.Layer;
|
||||||
|
|
||||||
|
|
@ -49,4 +50,8 @@ public class Tile implements ITransparentObject
|
||||||
public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity) {
|
public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec2d getRenderOffset() {
|
||||||
|
return new Vec2d(0.5, 0.5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,17 @@ public class VerticalRender
|
||||||
double angle_r = camera.angle.x;
|
double angle_r = camera.angle.x;
|
||||||
|
|
||||||
// Make the tile upright
|
// Make the tile upright
|
||||||
GlHelpers.translate(0.5, 0, 0);
|
GlHelpers.translate(0.5, 0.5, 0);
|
||||||
GlHelpers.translate(pos.x, pos.y, 0);
|
GlHelpers.translate(pos.x, pos.y, 0);
|
||||||
GlHelpers.rotate(-angle_r, 0, 0, 1);
|
GlHelpers.rotate(-angle_r, 0, 0, 1);
|
||||||
GlHelpers.translate(-0.5, 0, 0);
|
GlHelpers.translate(-0.5, -0.5, 0);
|
||||||
|
|
||||||
// Render the tile
|
// Render the tile
|
||||||
GlHelpers.begin();
|
GlHelpers.begin();
|
||||||
tex.texCoord(1, 1); GlHelpers.vertex3(0, 0, 0);
|
tex.texCoord(1, 1); GlHelpers.vertex3(0, 0.5, 0);
|
||||||
tex.texCoord(0, 1); GlHelpers.vertex3(1, 0, 0);
|
tex.texCoord(0, 1); GlHelpers.vertex3(1, 0.5, 0);
|
||||||
tex.texCoord(0, 0); GlHelpers.vertex3(1, 0, h);
|
tex.texCoord(0, 0); GlHelpers.vertex3(1, 0.5, h);
|
||||||
tex.texCoord(1, 0); GlHelpers.vertex3(0, 0, h);
|
tex.texCoord(1, 0); GlHelpers.vertex3(0, 0.5, h);
|
||||||
GlHelpers.end();
|
GlHelpers.end();
|
||||||
|
|
||||||
// Pop the matrix
|
// Pop the matrix
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue