mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 13:41:06 +03:00
feat(ui): add CSimpleCamera::SetGxProjectionAndView
This commit is contained in:
parent
7d491570e4
commit
4628b7d831
@ -1,4 +1,5 @@
|
|||||||
#include "ui/simple/CSimpleCamera.hpp"
|
#include "ui/simple/CSimpleCamera.hpp"
|
||||||
|
#include "gx/Transform.hpp"
|
||||||
#include "model/Model2.hpp"
|
#include "model/Model2.hpp"
|
||||||
#include <tempest/Math.hpp>
|
#include <tempest/Math.hpp>
|
||||||
|
|
||||||
@ -107,6 +108,25 @@ void CSimpleCamera::SetNearZ(float nearZ) {
|
|||||||
this->m_nearZ = nearZ;
|
this->m_nearZ = nearZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimpleCamera::SetGxProjectionAndView(const CRect& projRect) {
|
||||||
|
// Projection
|
||||||
|
|
||||||
|
this->m_aspect = (projRect.maxX - projRect.minX) / (projRect.maxY - projRect.minY);
|
||||||
|
|
||||||
|
C44Matrix projMat;
|
||||||
|
GxuXformCreateProjection_Exact(this->m_fov * 0.6f, this->m_aspect, this->m_nearZ, this->m_farZ, projMat);
|
||||||
|
|
||||||
|
GxXformSetProjection(projMat);
|
||||||
|
|
||||||
|
// View
|
||||||
|
|
||||||
|
C3Vector eye;
|
||||||
|
C44Matrix viewMat;
|
||||||
|
GxuXformCreateLookAtSgCompat(eye, this->Forward(), this->Up(), viewMat);
|
||||||
|
|
||||||
|
GxXformSetView(viewMat);
|
||||||
|
}
|
||||||
|
|
||||||
C3Vector CSimpleCamera::Up() const {
|
C3Vector CSimpleCamera::Up() const {
|
||||||
return { this->m_facing.c0, this->m_facing.c1, this->m_facing.c2 };
|
return { this->m_facing.c0, this->m_facing.c1, this->m_facing.c2 };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define UI_SIMPLE_C_SIMPLE_CAMERA_HPP
|
#define UI_SIMPLE_C_SIMPLE_CAMERA_HPP
|
||||||
|
|
||||||
#include <tempest/Matrix.hpp>
|
#include <tempest/Matrix.hpp>
|
||||||
|
#include <tempest/Rect.hpp>
|
||||||
#include <tempest/Vector.hpp>
|
#include <tempest/Vector.hpp>
|
||||||
|
|
||||||
class CM2Scene;
|
class CM2Scene;
|
||||||
@ -22,6 +23,7 @@ class CSimpleCamera {
|
|||||||
void SetFacing(float yaw, float pitch, float roll);
|
void SetFacing(float yaw, float pitch, float roll);
|
||||||
void SetFarZ(float farZ);
|
void SetFarZ(float farZ);
|
||||||
void SetFieldOfView(float fov);
|
void SetFieldOfView(float fov);
|
||||||
|
void SetGxProjectionAndView(const CRect& projRect);
|
||||||
void SetNearZ(float nearZ);
|
void SetNearZ(float nearZ);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user