Improved gravity slightly.
This commit is contained in:
parent
492b9f66aa
commit
4f172ccb98
|
@ -52,6 +52,14 @@ public class Camera {
|
||||||
velocity.set(p.getVelocity());
|
velocity.set(p.getVelocity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setToPlayerScopeView(Player p) {
|
||||||
|
Vector3f pos = new Vector3f();
|
||||||
|
Matrix4f tx = p.getHeldItemTransform();
|
||||||
|
tx.transformPosition(pos);
|
||||||
|
position.set(pos);
|
||||||
|
velocity.set(p.getVelocity());
|
||||||
|
}
|
||||||
|
|
||||||
public void setOrientationToPlayer(Player p) {
|
public void setOrientationToPlayer(Player p) {
|
||||||
orientation.set(p.getOrientation());
|
orientation.set(p.getOrientation());
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class GameRenderer {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
log.debug("Initialized model renderer.");
|
log.debug("Initialized model renderer.");
|
||||||
updatePerspective();
|
updatePerspective(config.fov);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAspectRatio() {
|
public float getAspectRatio() {
|
||||||
|
@ -147,8 +147,8 @@ public class GameRenderer {
|
||||||
/**
|
/**
|
||||||
* Updates the rendering perspective used to render the game.
|
* Updates the rendering perspective used to render the game.
|
||||||
*/
|
*/
|
||||||
private void updatePerspective() {
|
public void updatePerspective(float fov) {
|
||||||
float fovRad = (float) Math.toRadians(config.fov);
|
float fovRad = (float) Math.toRadians(fov);
|
||||||
if (fovRad >= Math.PI) {
|
if (fovRad >= Math.PI) {
|
||||||
fovRad = (float) (Math.PI - 0.01f);
|
fovRad = (float) (Math.PI - 0.01f);
|
||||||
} else if (fovRad <= 0) {
|
} else if (fovRad <= 0) {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package nl.andrewl.aos_core.model;
|
package nl.andrewl.aos_core.model;
|
||||||
|
|
||||||
|
import nl.andrewl.aos_core.Directions;
|
||||||
import nl.andrewl.aos_core.MathUtils;
|
import nl.andrewl.aos_core.MathUtils;
|
||||||
|
import org.joml.*;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
import org.joml.Vector2f;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.joml.Vector3i;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -168,6 +167,18 @@ public class Player {
|
||||||
return crouching ? HEIGHT_CROUCH : HEIGHT;
|
return crouching ? HEIGHT_CROUCH : HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a transformation that transforms a position to the position of the
|
||||||
|
* player's held gun.
|
||||||
|
* @return The gun transform.
|
||||||
|
*/
|
||||||
|
public Matrix4f getHeldItemTransform() {
|
||||||
|
return new Matrix4f()
|
||||||
|
.translate(position)
|
||||||
|
.rotate(orientation.x + (float) Math.PI, Directions.UPf)
|
||||||
|
.translate(-0.35f, getEyeHeight() - 0.4f, 0.35f);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Vector3i> getBlockSpaceOccupied() {
|
public List<Vector3i> getBlockSpaceOccupied() {
|
||||||
float playerBodyMinZ = position.z - RADIUS;
|
float playerBodyMinZ = position.z - RADIUS;
|
||||||
float playerBodyMaxZ = position.z + RADIUS;
|
float playerBodyMaxZ = position.z + RADIUS;
|
||||||
|
|
Loading…
Reference in New Issue