blob: 97529987e646c740bf471ccbcc60bd134c3adb7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package net.tylermurphy.Minecraft.Scene;
import java.io.Serializable;
import org.joml.Vector3f;
import net.tylermurphy.Minecraft.Input.Input;
import net.tylermurphy.Minecraft.Render.Data.Display;
public class Camera implements Serializable {
private static final long serialVersionUID = -2612670500762524881L;
protected Vector3f position = new Vector3f(0, 0, 0);
protected float pitch = 0;
protected float yaw = 0;
protected float roll = 0;
public void move(){
if(!World.player.isPaused) {
calculatePitch();
calculateYaw();
}
calculateCameraPosition();
yaw%=360;
}
public void invertPitch(){
this.pitch = -pitch;
}
public Vector3f getPosition() {
return position;
}
public float getPitch() {
return pitch;
}
public float getYaw() {
return yaw;
}
public float getRoll() {
return roll;
}
public void calculateCameraPosition(){
position.x = World.player.getTransform().getPosition().x;
position.z = World.player.getTransform().getPosition().z;
position.y = World.player.getTransform().getPosition().y + 10;
}
protected void calculatePitch(){
if(Display.closed()) {
float pitchChange = (float) (Input.getMouseDY() * 0.3f);
pitch -= pitchChange;
if(pitch < -90){
pitch = -90;
}else if(pitch > 90){
pitch = 90;
}
}
}
protected void calculateYaw(){
if(Display.closed()) {
float angleChange = (float) (Input.getMouseDX() * 0.4f);
yaw += angleChange;
}
}
}
|