Newer
Older
AlgebraicDataflowArchitectureModel / GameEngine / src / main / java / gameEngine / entites / gameComponents / TextMesh.java
  1. package gameEngine.entites.gameComponents;
  2.  
  3. import gameEngine.entites.EditorEntity;
  4. import gameEngine.entites.GameObject;
  5. import gameEngine.input.Input;
  6. import gameEngine.input.MouseInput;
  7. import gameEngine.scenes.EditorScene;
  8. import gameEngine.views.*;
  9. import org.joml.Vector3f;
  10.  
  11. import static org.lwjgl.glfw.GLFW.*;
  12.  
  13. public class TextMesh extends GameComponent{
  14.  
  15. private GameObject parent;
  16. private Text textRenderer;
  17.  
  18. public TextMesh(GameObject parent, String text, int textSize) {
  19. this.parent = parent;
  20. this.textRenderer = new Text(parent.transform.position.x, parent.transform.position.y, text, textSize);
  21. }
  22.  
  23. public TextMesh(TextMesh original, GameObject newParent) {
  24. this.parent = newParent;
  25. this.textRenderer = new Text(
  26. newParent.transform.position.x,
  27. newParent.transform.position.y,
  28. original.textRenderer.text,
  29. original.textRenderer.textSize
  30. );
  31. }
  32.  
  33. @Override
  34. public GameComponent copy() {
  35. return this;
  36. }
  37.  
  38. @Override
  39. public void init() {
  40. textRenderer.update();
  41. }
  42.  
  43. @Override
  44. public void update() {
  45. Vector3f globalPosition = new Vector3f(parent.transform.position).add(localPosition);
  46. textRenderer.setPosition(globalPosition);
  47. Vector3f globalRotation = new Vector3f(parent.transform.rotation).add(localRotation);
  48. textRenderer.setRotation(globalRotation);
  49. Vector3f globalScale = new Vector3f(parent.transform.scale).add(localScale);
  50. textRenderer.setScale(globalScale);
  51. textRenderer.update();
  52. }
  53.  
  54. public void setText(String newText){
  55. textRenderer.setText(newText);
  56. }
  57.  
  58. public void setTextSize(int newTextSize) {
  59. textRenderer.setTextSize(newTextSize);
  60. }
  61.  
  62. public void setColor(Color color){
  63. textRenderer.setColor(color);
  64. }
  65.  
  66. public int getTextSize(){
  67. return textRenderer.textSize;
  68. }
  69. }