mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 21:51:06 +03:00
Compare commits
5 Commits
96503de55b
...
4d30d108b0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d30d108b0 | ||
|
|
b3c07f0607 | ||
|
|
6bcaec1fe7 | ||
|
|
4628b7d831 | ||
|
|
7d491570e4 |
@ -1,4 +1,6 @@
|
|||||||
#include "ui/simple/CSimpleCamera.hpp"
|
#include "ui/simple/CSimpleCamera.hpp"
|
||||||
|
#include "gx/Transform.hpp"
|
||||||
|
#include "model/Model2.hpp"
|
||||||
#include <tempest/Math.hpp>
|
#include <tempest/Math.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -52,7 +54,7 @@ void BuildBillboardMatrix(const C3Vector& direction, C33Matrix& rotation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSimpleCamera::CSimpleCamera(float nearZ, float farZ, float fov) {
|
CSimpleCamera::CSimpleCamera(float nearZ, float farZ, float fov) {
|
||||||
this->float10 = 0.0f;
|
this->m_scene = nullptr;
|
||||||
|
|
||||||
this->m_nearZ = nearZ;
|
this->m_nearZ = nearZ;
|
||||||
this->m_farZ = farZ;
|
this->m_farZ = farZ;
|
||||||
@ -62,7 +64,7 @@ CSimpleCamera::CSimpleCamera(float nearZ, float farZ, float fov) {
|
|||||||
this->SetFacing(0.0f, 0.0f, 0.0f);
|
this->SetFacing(0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CSimpleCamera::FOV() {
|
float CSimpleCamera::FOV() const {
|
||||||
return this->m_fov;
|
return this->m_fov;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +72,14 @@ C3Vector CSimpleCamera::Forward() const {
|
|||||||
return { this->m_facing.a0, this->m_facing.a1, this->m_facing.a2 };
|
return { this->m_facing.a0, this->m_facing.a1, this->m_facing.a2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CM2Scene* CSimpleCamera::GetScene() {
|
||||||
|
if (!this->m_scene) {
|
||||||
|
this->m_scene = M2CreateScene();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->m_scene;
|
||||||
|
}
|
||||||
|
|
||||||
C3Vector CSimpleCamera::Right() const {
|
C3Vector CSimpleCamera::Right() const {
|
||||||
return { this->m_facing.b0, this->m_facing.b1, this->m_facing.b2 };
|
return { this->m_facing.b0, this->m_facing.b1, this->m_facing.b2 };
|
||||||
}
|
}
|
||||||
@ -98,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->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,29 +2,34 @@
|
|||||||
#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 CSimpleCamera {
|
class CSimpleCamera {
|
||||||
public:
|
public:
|
||||||
// Virtual public member functions
|
// Virtual public member functions
|
||||||
virtual float FOV();
|
virtual float FOV() const;
|
||||||
virtual C3Vector Forward() const;
|
virtual C3Vector Forward() const;
|
||||||
virtual C3Vector Right() const;
|
virtual C3Vector Right() const;
|
||||||
virtual C3Vector Up() const;
|
virtual C3Vector Up() const;
|
||||||
|
|
||||||
// Public member functions
|
// Public member functions
|
||||||
CSimpleCamera(float nearZ, float farZ, float fov);
|
CSimpleCamera(float nearZ, float farZ, float fov);
|
||||||
|
CM2Scene* GetScene();
|
||||||
void SetFacing(const C3Vector& forward);
|
void SetFacing(const C3Vector& forward);
|
||||||
void SetFacing(const C3Vector& forward, const C3Vector& up);
|
void SetFacing(const C3Vector& forward, const C3Vector& up);
|
||||||
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:
|
||||||
// Protected member variables
|
// Protected member variables
|
||||||
|
CM2Scene* m_scene;
|
||||||
C3Vector m_position;
|
C3Vector m_position;
|
||||||
float float10;
|
|
||||||
C33Matrix m_facing;
|
C33Matrix m_facing;
|
||||||
float m_nearZ;
|
float m_nearZ;
|
||||||
float m_farZ;
|
float m_farZ;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user