added rest of basics in TSE_Core

This commit is contained in:
2026-01-17 21:06:02 +01:00
parent d09953f476
commit 117c1e6adb
27 changed files with 2908 additions and 9 deletions

View File

@@ -0,0 +1,79 @@
#pragma once
#define CAMERA typeid(Camera).name()
#include "interfaces/IShader.hpp"
#include "Matrix4x4.hpp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#include "interfaces/IRenderTarget.hpp"
#include "elements/BehaviourScript.hpp"
namespace TSE
{
enum ProjectionType
{
Orthographic = 1,
Perspective = 2,
};
class Camera : public IResizeNotifiable, public BehaviourScript
{
private:
float RenderScale = 32;
IRenderTarget* rt = nullptr;
ProjectionType projection = ProjectionType::Orthographic;
Matrix4x4* projectionMatrix = nullptr;
Matrix4x4 viewMatrix;
float nearClippingPlane = 0;
float farClippingPlane = 100;
//perspective
float fov = 60;
Vector2 lastRtSize = {0, 0};
public:
static Camera* mainCamera;
// Getter
float GetRenderScale() const;
ProjectionType GetProjection() const;
float GetNearClippingPlane() const;
float GetFarClippingPlane() const;
float GetFov() const;
// Setter
Vector3 SceenPositionToGamePosition(Vector2 screenPos);
void SetRenderScale(float v);
void SetProjection(ProjectionType v);
void SetNearClippingPlane(float v);
void SetFarClippingPlane(float v);
void SetFov(float v);
Camera();
~Camera();
void OnResize(float width, float height, IResizable* wnd) override;
void SetRenderTarget(IRenderTarget* target);
IRenderTarget* GetRenderTarget();
void RecalculateProjMatrix();
void OnUpdate() override;
void Start() override;
void PreDraw(IShader* shader);
void PostDraw();
void Bind();
void Unbind();
void UpdateRenderTarget();
inline const char* GetName() override
{
return "Camera";
}
};
} // namespace TSE