package gameEngine.entites.gameComponents; import gameEngine.entites.EditorEntity; import gameEngine.entites.GameObject; import gameEngine.input.Input; import gameEngine.input.MouseInput; import gameEngine.scenes.EditorScene; import gameEngine.views.*; import org.joml.Vector3f; import static org.lwjgl.glfw.GLFW.*; public class TextMesh extends GameComponent{ private GameObject parent; private Text textRenderer; public TextMesh(GameObject parent, String text, int textSize) { this.parent = parent; this.textRenderer = new Text(parent.transform.position.x, parent.transform.position.y, text, textSize); } public TextMesh(TextMesh original, GameObject newParent) { this.parent = newParent; this.textRenderer = new Text( newParent.transform.position.x, newParent.transform.position.y, original.textRenderer.text, original.textRenderer.textSize ); } @Override public GameComponent copy() { return this; } @Override public void init() { textRenderer.update(); } @Override public void update() { Vector3f globalPosition = new Vector3f(parent.transform.position).add(localPosition); textRenderer.setPosition(globalPosition); Vector3f globalRotation = new Vector3f(parent.transform.rotation).add(localRotation); textRenderer.setRotation(globalRotation); Vector3f globalScale = new Vector3f(parent.transform.scale).add(localScale); textRenderer.setScale(globalScale); textRenderer.update(); } public void setText(String newText){ textRenderer.setText(newText); } public void setTextSize(int newTextSize) { textRenderer.setTextSize(newTextSize); } public void setColor(Color color){ textRenderer.setColor(color); } public int getTextSize(){ return textRenderer.textSize; } }