mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-08 10:25:59 +03:00
Compare commits
2 Commits
35e44e0976
...
45ceb6354b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45ceb6354b | ||
|
|
5be5ba35b9 |
@ -5,6 +5,7 @@
|
||||
|
||||
#include "client/Client.hpp"
|
||||
#include "gameui/CGWorldFrame.hpp"
|
||||
#include "gameui/GameScriptFunctions.hpp"
|
||||
#include "gx/Coordinate.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
@ -72,7 +73,7 @@ void CGGameUI::Initialize() {
|
||||
//CGInputControl::UpdateMouseMode((int)Active, 1);
|
||||
|
||||
FrameScript_Flush();
|
||||
//LoadScriptFunctions();
|
||||
LoadScriptFunctions();
|
||||
FrameScript_CreateEvents(g_scriptEvents, 722);
|
||||
//CGGameUI::RegisterGameCVars();
|
||||
//CGUIBindings::Initialize();
|
||||
|
||||
@ -3,7 +3,11 @@
|
||||
#include "gx/Transform.hpp"
|
||||
#include "gx/Draw.hpp"
|
||||
#include "gx/Shader.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include "gx/RenderState.hpp"
|
||||
#include "world/CWorld.hpp"
|
||||
#include "gameui/camera/CGCamera.hpp"
|
||||
#include "event/EvtKeyDown.hpp"
|
||||
|
||||
#include <bc/Memory.hpp>
|
||||
#include <tempest/Matrix.hpp>
|
||||
@ -14,7 +18,14 @@ CGWorldFrame* CGWorldFrame::s_currentWorldFrame = nullptr;
|
||||
|
||||
CGWorldFrame::CGWorldFrame(CSimpleFrame* parent) : CSimpleFrame(parent) {
|
||||
// TODO
|
||||
|
||||
this->m_camera = NEW(CGCamera);
|
||||
|
||||
s_currentWorldFrame = this;
|
||||
|
||||
this->EnableEvent(SIMPLE_EVENT_KEY, -1);
|
||||
this->EnableEvent(SIMPLE_EVENT_MOUSE, -1);
|
||||
this->EnableEvent(SIMPLE_EVENT_MOUSEWHEEL, -1);
|
||||
}
|
||||
|
||||
void CGWorldFrame::OnFrameRender(CRenderBatch* batch, uint32_t layer) {
|
||||
@ -24,6 +35,42 @@ void CGWorldFrame::OnFrameRender(CRenderBatch* batch, uint32_t layer) {
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CGWorldFrame::OnLayerKeyDown(const CKeyEvent& evt) {
|
||||
if (CSimpleFrame::OnLayerKeyDown(evt)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WORKAROUND: Camera testing
|
||||
C3Vector& position = this->m_camera->m_position;
|
||||
|
||||
float step = 0.1f;
|
||||
|
||||
switch (evt.key) {
|
||||
case KEY_W:
|
||||
position.z -= step;
|
||||
break;
|
||||
case KEY_A:
|
||||
position.y -= step;
|
||||
break;
|
||||
case KEY_S:
|
||||
position.z += step;
|
||||
break;
|
||||
case KEY_D:
|
||||
position.y += step;
|
||||
break;
|
||||
case KEY_PLUS:
|
||||
position.x += step;
|
||||
break;
|
||||
case KEY_MINUS:
|
||||
position.x -= step;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CSimpleFrame* CGWorldFrame::Create(CSimpleFrame* parent) {
|
||||
// TODO: Data = CDataAllocator__GetData(0, ".?AVCGWorldFrame@@", -2);
|
||||
|
||||
@ -53,15 +100,40 @@ void CGWorldFrame::RenderWorld(void* param) {
|
||||
}
|
||||
|
||||
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() {
|
||||
CRect windowSize;
|
||||
GxCapsWindowSize(windowSize);
|
||||
if (windowSize.maxY - windowSize.minY == 0.0f || windowSize.maxX - windowSize.minX == 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
GxRsPush();
|
||||
|
||||
C3Vector saveMin;
|
||||
C3Vector saveMax;
|
||||
|
||||
GxXformViewport(saveMin.x, saveMax.x, saveMin.y, saveMax.y, saveMin.z, saveMax.z);
|
||||
|
||||
// TODO
|
||||
|
||||
// WORKAROUND:
|
||||
float maxZ = saveMax.z - (saveMax.z - saveMin.z) * 0.050000001;
|
||||
GxXformSetViewport(saveMin.x, saveMax.x, saveMin.y, saveMax.y, saveMin.z, maxZ);
|
||||
|
||||
CShaderEffect::UpdateProjMatrix();
|
||||
|
||||
CWorld::Render();
|
||||
|
||||
GxRsPop();
|
||||
}
|
||||
|
||||
CGCamera* CGWorldFrame::GetActiveCamera() {
|
||||
STORM_ASSERT(CGWorldFrame::s_currentWorldFrame);
|
||||
STORM_ASSERT(CGWorldFrame::s_currentWorldFrame->m_camera);
|
||||
return CGWorldFrame::s_currentWorldFrame->m_camera;
|
||||
}
|
||||
|
||||
@ -4,16 +4,22 @@
|
||||
#include "ui/CSimpleFrame.hpp"
|
||||
#include "ui/CSimpleTop.hpp"
|
||||
|
||||
class CGCamera;
|
||||
|
||||
class CGWorldFrame : public CSimpleFrame {
|
||||
public:
|
||||
CGWorldFrame(CSimpleFrame* parent);
|
||||
|
||||
virtual void OnFrameRender(CRenderBatch* batch, uint32_t layer);
|
||||
virtual int32_t OnLayerKeyDown(const CKeyEvent& evt);
|
||||
|
||||
static CSimpleFrame* Create(CSimpleFrame* parent);
|
||||
static void RenderWorld(void* param);
|
||||
static void OnWorldUpdate();
|
||||
static void OnWorldRender();
|
||||
static CGCamera* GetActiveCamera();
|
||||
|
||||
CGCamera* m_camera = nullptr;
|
||||
|
||||
public:
|
||||
static CGWorldFrame* s_currentWorldFrame;
|
||||
|
||||
17
src/gameui/GameScriptFunctions.cpp
Normal file
17
src/gameui/GameScriptFunctions.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "gameui/GameScriptFunctions.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "ui/ScriptFunctions.hpp"
|
||||
|
||||
void LoadScriptFunctions() {
|
||||
RegisterSimpleFrameScriptMethods();
|
||||
// TODO
|
||||
CameraRegisterScriptFunctions();
|
||||
}
|
||||
|
||||
void CameraRegisterScriptFunctions() {
|
||||
for (int32_t i = 0; i < NUM_SCRIPT_FUNCTIONS_CAMERA; ++i) {
|
||||
FrameScript_RegisterFunction(
|
||||
GameScript::s_ScriptFunctions_Camera[i].name,
|
||||
GameScript::s_ScriptFunctions_Camera[i].method);
|
||||
}
|
||||
}
|
||||
20
src/gameui/GameScriptFunctions.hpp
Normal file
20
src/gameui/GameScriptFunctions.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef GAMEUI_GAME_SCRIPT_FUNCTIONS_HPP
|
||||
#define GAMEUI_GAME_SCRIPT_FUNCTIONS_HPP
|
||||
|
||||
#include "ui/Types.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
struct lua_State;
|
||||
|
||||
#define NUM_SCRIPT_FUNCTIONS_CAMERA 22
|
||||
|
||||
namespace GameScript {
|
||||
extern FrameScript_Method s_ScriptFunctions_Camera[NUM_SCRIPT_FUNCTIONS_CAMERA];
|
||||
}
|
||||
|
||||
// Utility
|
||||
|
||||
void LoadScriptFunctions();
|
||||
void CameraRegisterScriptFunctions();
|
||||
|
||||
#endif
|
||||
119
src/gameui/GameScriptFunctionsCamera.cpp
Normal file
119
src/gameui/GameScriptFunctionsCamera.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
#include "gameui/GameScriptFunctions.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
#include "util/Unimplemented.hpp"
|
||||
|
||||
|
||||
int32_t Script_CameraZoomIn(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_CameraZoomOut(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewInStart(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewInStop(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewOutStart(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewOutStop(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewLeftStart(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewLeftStop(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewRightStart(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewRightStop(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewUpStart(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewUpStop(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewDownStart(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_MoveViewDownStop(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetView(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SaveView(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_ResetView(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_NextView(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_PrevView(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_FlipCameraYaw(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_VehicleCameraZoomIn(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_VehicleCameraZoomOut(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
|
||||
FrameScript_Method GameScript::s_ScriptFunctions_Camera[NUM_SCRIPT_FUNCTIONS_CAMERA] = {
|
||||
{ "CameraZoomIn", &Script_CameraZoomIn },
|
||||
{ "CameraZoomOut", &Script_CameraZoomOut },
|
||||
{ "MoveViewInStart", &Script_MoveViewInStart },
|
||||
{ "MoveViewInStop", &Script_MoveViewInStop },
|
||||
{ "MoveViewOutStart", &Script_MoveViewOutStart },
|
||||
{ "MoveViewOutStop", &Script_MoveViewOutStop },
|
||||
{ "MoveViewLeftStart", &Script_MoveViewLeftStart },
|
||||
{ "MoveViewLeftStop", &Script_MoveViewLeftStop },
|
||||
{ "MoveViewRightStart", &Script_MoveViewRightStart },
|
||||
{ "MoveViewRightStop", &Script_MoveViewRightStop },
|
||||
{ "MoveViewUpStart", &Script_MoveViewUpStart },
|
||||
{ "MoveViewUpStop", &Script_MoveViewUpStop },
|
||||
{ "MoveViewDownStart", &Script_MoveViewDownStart },
|
||||
{ "MoveViewDownStop", &Script_MoveViewDownStop },
|
||||
{ "SetView", &Script_SetView },
|
||||
{ "SaveView", &Script_SaveView },
|
||||
{ "ResetView", &Script_ResetView },
|
||||
{ "NextView", &Script_NextView },
|
||||
{ "PrevView", &Script_PrevView },
|
||||
{ "FlipCameraYaw", &Script_FlipCameraYaw },
|
||||
{ "VehicleCameraZoomIn", &Script_VehicleCameraZoomIn },
|
||||
{ "VehicleCameraZoomOut", &Script_VehicleCameraZoomOut },
|
||||
};
|
||||
1
src/gameui/camera/CGCamera.cpp
Normal file
1
src/gameui/camera/CGCamera.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "gameui/camera/CGCamera.hpp"
|
||||
10
src/gameui/camera/CGCamera.hpp
Normal file
10
src/gameui/camera/CGCamera.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef GAME_UI_CAMERA_CGCAMERA_HPP
|
||||
#define GAME_UI_CAMERA_CGCAMERA_HPP
|
||||
|
||||
#include "gameui/camera/CSimpleCamera.hpp"
|
||||
|
||||
class CGCamera : public CSimpleCamera {
|
||||
|
||||
};
|
||||
|
||||
#endif // GAME_UI_CAMERA_CGCAMERA_HPP
|
||||
@ -5,6 +5,7 @@
|
||||
#include <tempest/matrix/C44Matrix.hpp>
|
||||
|
||||
#include "gx/Transform.hpp"
|
||||
#include "gx/Shader.hpp"
|
||||
|
||||
|
||||
static void FaceDirection(const C3Vector& direction, C3Vector* xprime, C3Vector* yprime, C3Vector* zprime) {
|
||||
@ -145,10 +146,12 @@ void CSimpleCamera::SetGxProjectionAndView(const CRect& projectionRect) {
|
||||
this->m_aspect = (projectionRect.maxX - projectionRect.minX) / (projectionRect.maxY - projectionRect.minY);
|
||||
|
||||
C44Matrix mProj;
|
||||
GxXformProjection(mProj);
|
||||
|
||||
GxuXformCreateProjection_SG(this->m_fov, this->m_aspect, this->m_nearZ, this->m_farZ, mProj);
|
||||
GxXformSetProjection(mProj);
|
||||
|
||||
C44Matrix mView;
|
||||
GxuXformCreateLookAtSgCompat(C3Vector(), Forward(), Up(), mView);
|
||||
GxuXformCreateLookAtSgCompat(this->m_position, this->m_position + Forward(), Up(), mView);
|
||||
GxXformSetView(mView);
|
||||
}
|
||||
|
||||
@ -12,27 +12,27 @@ class 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& 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; }
|
||||
|
||||
virtual C3Vector Forward();
|
||||
virtual C3Vector Right();
|
||||
virtual 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 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 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);
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ target_link_libraries(world
|
||||
PRIVATE
|
||||
gx
|
||||
model
|
||||
gameui
|
||||
PUBLIC
|
||||
bc
|
||||
common
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
#include "world/CWorld.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include "gx/Shader.hpp"
|
||||
#include "gx/RenderState.hpp"
|
||||
#include "model/Model2.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include "world/map/CMap.hpp"
|
||||
#include "world/daynight/DayNight.hpp"
|
||||
#include "gameui/camera/CGCamera.hpp"
|
||||
#include "gameui/CGWorldFrame.hpp"
|
||||
|
||||
uint32_t CWorld::s_enables;
|
||||
uint32_t CWorld::s_enables2;
|
||||
@ -50,5 +54,10 @@ void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t zone
|
||||
}
|
||||
|
||||
void CWorld::Render() {
|
||||
GxRsPush();
|
||||
CRect rect;
|
||||
CGWorldFrame::s_currentWorldFrame->GetRect(&rect);
|
||||
CGWorldFrame::GetActiveCamera()->SetGxProjectionAndView(rect);
|
||||
DayNight::RenderSky();
|
||||
GxRsPop();
|
||||
}
|
||||
|
||||
@ -32,8 +32,9 @@ void DNStars::Render() {
|
||||
}
|
||||
|
||||
this->m_model->SetAnimating(1);
|
||||
this->m_model->SetVisible(1);
|
||||
|
||||
// TODO
|
||||
// TODO: this->m_model->SetSomething(1);
|
||||
|
||||
uint32_t elapsed = OsGetAsyncTimeMs() - this->m_time;
|
||||
this->m_time += elapsed;
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
#include "world/daynight/DayNight.hpp"
|
||||
#include "world/daynight/DNStars.hpp"
|
||||
#include "gx/Transform.hpp"
|
||||
#include "gx/RenderState.hpp"
|
||||
#include "gx/Draw.hpp"
|
||||
|
||||
|
||||
namespace DayNight {
|
||||
@ -14,6 +17,22 @@ void LoadMap(int32_t zoneID) {
|
||||
|
||||
void RenderSky() {
|
||||
// TODO
|
||||
|
||||
float minX;
|
||||
float maxX;
|
||||
float minY;
|
||||
float maxY;
|
||||
float minZ;
|
||||
float maxZ;
|
||||
GxXformViewport(minX, maxX, minY, maxY, minZ, maxZ);
|
||||
|
||||
// TODO
|
||||
|
||||
GxXformSetViewport(minX, maxX, minY, maxY, 0.99902344f, 1.0f);
|
||||
GxRsSet(GxRs_ScissorTest, 1);
|
||||
CImVector color { 0xFF000000 };
|
||||
GxSceneClear(3, color);
|
||||
|
||||
g_stars.Render();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user