package net.halbear.Terrain4J.EngineCore.Vulkan.Rendering.Projection;

import org.joml.Matrix4f;

public class Project3D {
    private final float FOV; // IT IS IN RADIANS!! REMEEEEMMMBER RADIANS!!!! PI/180!!!!!
    // there is a universal DegToRad conversion variable one can use in EngineConfig if they need to convert it
    private final Matrix4f ProjectionMatrix;
    private final float ZFarPlane;
    private final float ZNearPlane;

    public Project3D(float FOV, float zNear, float zFar, int Width, int Height){
        this.FOV = FOV;
        this.ZFarPlane = zFar;
        this.ZNearPlane = zNear;
        ProjectionMatrix = new Matrix4f();
        Resize(Width, Height);
    }

    public float GetFOV(){
        return FOV;
    }
    public float GetFarZ(){
        return ZFarPlane;
    }
    public float GetNearZ(){
        return ZNearPlane;
    }

    public Matrix4f GetProjectionMatrix(){return ProjectionMatrix;}

    public void Resize(int Width, int Height){
        ProjectionMatrix.identity();
        ProjectionMatrix.perspective(FOV, (float)Width/(float)Height, ZNearPlane, ZFarPlane, true);
    }
}
