This commit is contained in:
2025-05-13 02:50:08 +03:00
parent 20b4502be5
commit 9af2bb814e
102 changed files with 259423 additions and 2 deletions
+31
View File
@@ -0,0 +1,31 @@
#include "Camera.h"
#include "Transform.h"
#include "Mathf.h"
#include "Archive.h"
float4x4 Camera::worldToCameraMatrix() {
auto world = transform()->GetGlobalTransform();
//TODO: why not affine ?
world = inverse(world, false);
// auto test = lookatlh(transform()->GetGlobalPosition(), float3(0, 1, 1), float3(0, 1, 0));
return world;
}
void Camera::serialize(Archive& archive) {
Component::serialize(archive);
archive << nearClipPlane << farClipPlane << fov << aspect;
}
void Camera::UpdateProjectionMatrix() {
_projection = matrix4x4Perspective(fov * Mathf::DegToRad(), aspect, nearClipPlane, farClipPlane);
}
float4x4 Camera::projectionMatrix() {
UpdateProjectionMatrix();
return _projection;
}