Advertisement
Guest User

Untitled

a guest
Feb 27th, 2019
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. package entities;
  2.  
  3. import org.lwjgl.input.Keyboard;
  4. import org.lwjgl.input.Mouse;
  5. import org.lwjgl.util.vector.Vector3f;
  6.  
  7. public class Camera {
  8.  
  9. private Vector3f position = new Vector3f(0,0,0);
  10. private float pitch;
  11. private float yaw;
  12. private float roll;
  13.  
  14. public Camera() {}
  15.  
  16. public void move() {
  17. float x = Mouse.getX();
  18. if(Keyboard.isKeyDown(Keyboard.KEY_W))
  19. position.z-=0.02f;
  20. if(Keyboard.isKeyDown(Keyboard.KEY_D))
  21. position.x+=0.02f;
  22. if(Keyboard.isKeyDown(Keyboard.KEY_A))
  23. position.x-=0.02f;
  24. if(Keyboard.isKeyDown(Keyboard.KEY_S))
  25. position.z+=0.02f;
  26. }
  27.  
  28. float dx = 0.0f;
  29. float dy = 0.0f;
  30. float dt = 0.0f;
  31. float lastTime = 0.0f;
  32. float time = 0.0f;
  33. float mouseSensitivity = 0.05f;
  34. float movementSpeed = 10.0f;
  35.  
  36. public void mouse() {
  37. dx = Mouse.getDX();
  38. dy = Mouse.getDY();
  39. System.out.println(dx + " " + dy);
  40. setYaw(dx * mouseSensitivity);
  41. setPitch(dy * mouseSensitivity);
  42. }
  43.  
  44. public Vector3f getPosition() {
  45. return position;
  46. }
  47.  
  48. public float getPitch() {
  49. return pitch;
  50. }
  51.  
  52. public void setPitch(float pitch) {
  53. this.pitch -= pitch;
  54. }
  55.  
  56. public void setYaw(float yaw) {
  57. this.yaw += yaw;
  58. }
  59.  
  60. public float getYaw() {
  61. return yaw;
  62. }
  63.  
  64. public float getRoll() {
  65. return roll;
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement