package net.halbear.Terrain4J.EngineCore.Main.Scene;

import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;

public class Actor{
    private final String ID;
    private final String ModelID;
    private final Matrix4f ModelMatrix;
    private final Vector3f Position;
    private final Quaternionf Rotation;
    private float Scale;

    public Actor(String ID, String ModelID, Vector3f Position){
        this.ID = ID;
        this.ModelID = ModelID;
        this.Position = Position;
        Scale = 1f;
        Rotation = new Quaternionf();
        ModelMatrix = new Matrix4f();
        UpdateModelMatrix();
    }

    public void ResetRotation(){
        Rotation.x = 0;
        Rotation.y = 0;
        Rotation.z = 0;
        Rotation.w = 1.0f;
    }

    public final void SetPosition(float x, float y, float z){
        Position.x = x;
        Position.y = y;
        Position.z = z;
        UpdateModelMatrix();
    }

    public void SetScale(float Scale){
        this.Scale = Scale;
        UpdateModelMatrix();
    }

    public void UpdateModelMatrix(){
        ModelMatrix.translationRotateScale(Position, Rotation, Scale);
    }

    public String GetID(){return ID;}
    public String GetModelID(){return ModelID;}
    public Matrix4f GetModelMatrix(){return ModelMatrix;}
    public Vector3f GetPosition(){ return Position;}
    public Quaternionf GetRotation(){return Rotation;}
    public float GetScale(){return Scale;}
}
