Entity3D.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package eu.tankernn.gameEngine.entities;
  2. import org.lwjgl.util.vector.Vector3f;
  3. import eu.tankernn.gameEngine.animation.model.AnimatedModel;
  4. import eu.tankernn.gameEngine.loader.models.AABB;
  5. import eu.tankernn.gameEngine.loader.models.TexturedModel;
  6. import eu.tankernn.gameEngine.util.IPositionable;
  7. public class Entity3D implements IPositionable {
  8. private TexturedModel model;
  9. protected Vector3f position;
  10. private Vector3f rotation;
  11. private float scale;
  12. private AABB boundingBox;
  13. protected boolean dead;
  14. public Entity3D(TexturedModel model, Vector3f position, Vector3f rotation, float scale, AABB boundingBox) {
  15. this.model = model;
  16. this.position = position;
  17. this.rotation = rotation;
  18. this.scale = scale;
  19. this.boundingBox = boundingBox;
  20. this.boundingBox.updatePosition(position);
  21. }
  22. public void increasePosition(Vector3f velocity) {
  23. this.position.x += velocity.x;
  24. this.position.y += velocity.y;
  25. this.position.z += velocity.z;
  26. }
  27. public void increaseRotation(Vector3f deltaRotation) {
  28. Vector3f.add(this.rotation, deltaRotation, this.rotation);
  29. }
  30. public void update() {
  31. this.boundingBox.updatePosition(this.position);
  32. if (model instanceof AnimatedModel)
  33. ((AnimatedModel) model).update();
  34. }
  35. public TexturedModel getModel() {
  36. return model;
  37. }
  38. public void setModel(TexturedModel model) {
  39. this.model = model;
  40. }
  41. public Vector3f getPosition() {
  42. return position;
  43. }
  44. public void setPosition(Vector3f position) {
  45. this.position = position;
  46. }
  47. public Vector3f getRotation() {
  48. return rotation;
  49. }
  50. public float getScale() {
  51. return scale;
  52. }
  53. public void setScale(float scale) {
  54. this.scale = scale;
  55. }
  56. public AABB getBoundingBox() {
  57. return boundingBox;
  58. }
  59. public boolean isDead() {
  60. return dead;
  61. }
  62. }