diff --git a/src/gameui/CGWorldFrame.cpp b/src/gameui/CGWorldFrame.cpp index 2c1c449..8e3f176 100644 --- a/src/gameui/CGWorldFrame.cpp +++ b/src/gameui/CGWorldFrame.cpp @@ -1,6 +1,8 @@ #include "gameui/CGWorldFrame.hpp" #include "gx/Transform.hpp" +#include "gx/Draw.hpp" +#include "gx/Shader.hpp" #include #include @@ -36,15 +38,27 @@ void CGWorldFrame::RenderWorld(void* param) { GxXformView(saved_view); CGWorldFrame::OnWorldUpdate(); + + // TODO: PlayerNameUpdateWorldText(); + CGWorldFrame::OnWorldRender(); - //PlayerNameRenderWorldText(); + // TODO: PlayerNameRenderWorldText(); GxXformSetProjection(saved_proj); GxXformSetView(saved_view); + + CShaderEffect::UpdateProjMatrix(); } void CGWorldFrame::OnWorldUpdate() { + GxXformSetViewport(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f); + CImVector clearColor = { 0x00, 0x00, 0x00, 0xFF }; + GxSceneClear(3, clearColor); + C44Matrix matrix; + GxuXformCreateOrtho(0.0, 1.0, -0.5, 0.5, 0.0, 500.0, matrix); + GxXformSetView(C44Matrix()); + GxXformSetProjection(matrix); } void CGWorldFrame::OnWorldRender() { diff --git a/src/gameui/CMakeLists.txt b/src/gameui/CMakeLists.txt index 60fa0c3..7dc546d 100644 --- a/src/gameui/CMakeLists.txt +++ b/src/gameui/CMakeLists.txt @@ -1,4 +1,7 @@ -file(GLOB PRIVATE_SOURCES "*.cpp") +file(GLOB PRIVATE_SOURCES + "*.cpp" + "camera/*.cpp" +) add_library(gameui STATIC ${PRIVATE_SOURCES} diff --git a/src/gameui/camera/CSimpleCamera.cpp b/src/gameui/camera/CSimpleCamera.cpp new file mode 100644 index 0000000..6b48a67 --- /dev/null +++ b/src/gameui/camera/CSimpleCamera.cpp @@ -0,0 +1,65 @@ +#include "CSimpleCamera.hpp" + +#include + +CSimpleCamera::CSimpleCamera() + : m_position() + , m_facing() + , m_nearZ(0.11111111f) + , m_farZ(277.77777f) + , m_fov(1.5707964f) + , m_aspect(1.0f) { + this->SetFacing(0.0f, 0.0f, 0.0f); +} + +CSimpleCamera::CSimpleCamera(float nearZ, float farZ, float fov) + : m_position() + , m_facing() + , m_nearZ(nearZ) + , m_farZ(farZ) + , m_fov(fov) + , m_aspect(1.0f) { + this->SetFacing(0.0f, 0.0f, 0.0f); +} +CSimpleCamera::~CSimpleCamera() { +} + +C3Vector CSimpleCamera::Forward() { + return { + this->m_facing.a0, + this->m_facing.a1, + this->m_facing.a2 + }; +} + +C3Vector CSimpleCamera::Right() { + return { + this->m_facing.b0, + this->m_facing.b1, + this->m_facing.b2 + }; +} + +C3Vector CSimpleCamera::Up() { + return { + this->m_facing.c0, + this->m_facing.c1, + this->m_facing.c2 + }; +} + +void CSimpleCamera::SetFacing(float yaw, float pitch, float roll) { + // TODO +} + +void CSimpleCamera::SetFacing(const C3Vector& forward, const C3Vector& up) { + // TODO +} + +void CSimpleCamera::SetFacing(const C3Vector& forward) { + // TODO +} + +void CSimpleCamera::SetGxProjectionAndView(const CRect& projectionRect) { + // TODO +} diff --git a/src/gameui/camera/CSimpleCamera.hpp b/src/gameui/camera/CSimpleCamera.hpp new file mode 100644 index 0000000..5618f85 --- /dev/null +++ b/src/gameui/camera/CSimpleCamera.hpp @@ -0,0 +1,48 @@ +#ifndef GAME_UI_CAMERA_CSIMPLECAMERA_HPP +#define GAME_UI_CAMERA_CSIMPLECAMERA_HPP + +#include +#include + +class CRect; + +class CSimpleCamera { + public: + CSimpleCamera(); + CSimpleCamera(float nearZ, float farZ, float fov); + virtual ~CSimpleCamera(); + + C3Vector& Position() { this->m_position; }; + C33Matrix& Facing() { this->m_facing; }; + float NearZ() { this->m_nearZ; }; + float FarZ() { this->m_farZ; }; + float FOV() { this->m_fov; }; + float Aspect() { this->m_aspect; }; + + C3Vector Forward(); + C3Vector Right(); + C3Vector Up(); + + void SetPosition(const C3Vector& position) { this->m_position = position; }; + void SetPosition(float x, float y, float z) { this->m_position = C3Vector(x, y, z); }; + + void SetFacing(float yaw, float pitch, float roll); + void SetFacing(const C3Vector& forward, const C3Vector& up); + void SetFacing(const C3Vector& forward); + + void SetFieldOfView(float value) { this->m_fov = value; }; + void SetNearZ(float value) { this->m_nearZ = value; }; + void SetFarZ(float value) { this->m_farZ = value; }; + + void SetGxProjectionAndView(const CRect& projectionRect); + + // Member variables + C3Vector m_position; + C33Matrix m_facing; + float m_nearZ; + float m_farZ; + float m_fov; + float m_aspect; +}; + +#endif // GAME_UI_CAMERA_CSIMPLECAMERA_HPP