mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 13:41:06 +03:00
Compare commits
6 Commits
794374a59a
...
86ed9aa561
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86ed9aa561 | ||
|
|
2145348935 | ||
|
|
50685c7cc0 | ||
|
|
b3c07f0607 | ||
|
|
6bcaec1fe7 | ||
|
|
4628b7d831 |
@ -1 +1 @@
|
||||
Subproject commit dc8f10e407daa8bdf7e90d9438b55d5883780825
|
||||
Subproject commit 4ba7e0a6c3836254daf97bab159807fae6cab039
|
||||
@ -1,4 +1,5 @@
|
||||
#include "ui/simple/CSimpleCamera.hpp"
|
||||
#include "gx/Transform.hpp"
|
||||
#include "model/Model2.hpp"
|
||||
#include <tempest/Math.hpp>
|
||||
|
||||
@ -63,7 +64,7 @@ CSimpleCamera::CSimpleCamera(float nearZ, float farZ, float fov) {
|
||||
this->SetFacing(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
float CSimpleCamera::FOV() {
|
||||
float CSimpleCamera::FOV() const {
|
||||
return this->m_fov;
|
||||
}
|
||||
|
||||
@ -107,6 +108,25 @@ void CSimpleCamera::SetNearZ(float 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->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 {
|
||||
return { this->m_facing.c0, this->m_facing.c1, this->m_facing.c2 };
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define UI_SIMPLE_C_SIMPLE_CAMERA_HPP
|
||||
|
||||
#include <tempest/Matrix.hpp>
|
||||
#include <tempest/Rect.hpp>
|
||||
#include <tempest/Vector.hpp>
|
||||
|
||||
class CM2Scene;
|
||||
@ -9,7 +10,7 @@ class CM2Scene;
|
||||
class CSimpleCamera {
|
||||
public:
|
||||
// Virtual public member functions
|
||||
virtual float FOV();
|
||||
virtual float FOV() const;
|
||||
virtual C3Vector Forward() const;
|
||||
virtual C3Vector Right() const;
|
||||
virtual C3Vector Up() const;
|
||||
@ -22,6 +23,7 @@ class CSimpleCamera {
|
||||
void SetFacing(float yaw, float pitch, float roll);
|
||||
void SetFarZ(float farZ);
|
||||
void SetFieldOfView(float fov);
|
||||
void SetGxProjectionAndView(const CRect& projRect);
|
||||
void SetNearZ(float nearZ);
|
||||
|
||||
protected:
|
||||
|
||||
@ -10,9 +10,11 @@ uint32_t CWorld::s_curTimeMs;
|
||||
float CWorld::s_curTimeSec;
|
||||
uint32_t CWorld::s_enables;
|
||||
uint32_t CWorld::s_enables2;
|
||||
float CWorld::s_farClip;
|
||||
uint32_t CWorld::s_gameTimeFixed;
|
||||
float CWorld::s_gameTimeSec;
|
||||
CM2Scene* CWorld::s_m2Scene;
|
||||
float CWorld::s_nearClip = 0.1f;
|
||||
uint32_t CWorld::s_tickTimeFixed;
|
||||
uint32_t CWorld::s_tickTimeMs;
|
||||
float CWorld::s_tickTimeSec;
|
||||
@ -55,6 +57,10 @@ float CWorld::GetCurTimeSec() {
|
||||
return CWorld::s_curTimeSec;
|
||||
}
|
||||
|
||||
float CWorld::GetFarClip() {
|
||||
return CWorld::s_farClip;
|
||||
}
|
||||
|
||||
uint32_t CWorld::GetFixedPrecisionTime(float timeSec) {
|
||||
return static_cast<uint32_t>(timeSec * 1024.0f);
|
||||
}
|
||||
@ -71,6 +77,10 @@ CM2Scene* CWorld::GetM2Scene() {
|
||||
return CWorld::s_m2Scene;
|
||||
}
|
||||
|
||||
float CWorld::GetNearClip() {
|
||||
return CWorld::s_nearClip;
|
||||
}
|
||||
|
||||
uint32_t CWorld::GetTickTimeFixed() {
|
||||
return CWorld::s_tickTimeFixed;
|
||||
}
|
||||
|
||||
@ -57,9 +57,11 @@ class CWorld {
|
||||
static HWORLDOBJECT AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags);
|
||||
static uint32_t GetCurTimeMs();
|
||||
static float GetCurTimeSec();
|
||||
static float GetFarClip();
|
||||
static uint32_t GetGameTimeFixed();
|
||||
static float GetGameTimeSec();
|
||||
static CM2Scene* GetM2Scene();
|
||||
static float GetNearClip();
|
||||
static uint32_t GetTickTimeFixed();
|
||||
static uint32_t GetTickTimeMs();
|
||||
static float GetTickTimeSec();
|
||||
@ -72,9 +74,11 @@ class CWorld {
|
||||
// Private static variables
|
||||
static uint32_t s_curTimeMs;
|
||||
static float s_curTimeSec;
|
||||
static float s_farClip;
|
||||
static uint32_t s_gameTimeFixed;
|
||||
static float s_gameTimeSec;
|
||||
static CM2Scene* s_m2Scene;
|
||||
static float s_nearClip;
|
||||
static uint32_t s_tickTimeFixed;
|
||||
static uint32_t s_tickTimeMs;
|
||||
static float s_tickTimeSec;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user