mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 03:02:30 +00:00
feat(world): add CWorldScene class
This commit is contained in:
parent
1326c896df
commit
b1694c2897
12 changed files with 126 additions and 23 deletions
|
|
@ -216,3 +216,7 @@ void CursorSetMode(CURSORMODE mode) {
|
||||||
FrameScript_SignalEvent(275, nullptr);
|
FrameScript_SignalEvent(275, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CursorResetCursor() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include "cursor/Types.hpp"
|
#include "cursor/Types.hpp"
|
||||||
|
|
||||||
void CursorInitialize();
|
void CursorInitialize();
|
||||||
|
|
||||||
void CursorSetMode(CURSORMODE mode);
|
void CursorSetMode(CURSORMODE mode);
|
||||||
|
void CursorResetCursor();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,12 @@
|
||||||
#include "gx/Device.hpp"
|
#include "gx/Device.hpp"
|
||||||
#include "gx/RenderState.hpp"
|
#include "gx/RenderState.hpp"
|
||||||
#include "world/CWorld.hpp"
|
#include "world/CWorld.hpp"
|
||||||
|
#include "world/CWorldScene.hpp"
|
||||||
#include "gameui/camera/CGCamera.hpp"
|
#include "gameui/camera/CGCamera.hpp"
|
||||||
#include "event/EvtKeyDown.hpp"
|
#include "event/EvtKeyDown.hpp"
|
||||||
|
|
||||||
|
#include "model/Model2.hpp"
|
||||||
|
|
||||||
#include <bc/Memory.hpp>
|
#include <bc/Memory.hpp>
|
||||||
#include <tempest/Matrix.hpp>
|
#include <tempest/Matrix.hpp>
|
||||||
|
|
||||||
|
|
@ -160,6 +163,16 @@ void CGWorldFrame::OnWorldRender() {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
GxRsPush();
|
GxRsPush();
|
||||||
|
GxRsSet(GxRs_Multisample, 1);
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
CImVector clearColor = { 0, 0, 0, 0xFF };
|
||||||
|
GxSceneClear(3, clearColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CWorld::GetEnables() & 0x20000000) {
|
||||||
|
GxMasterEnableSet(GxMasterEnable_PolygonFill, 0);
|
||||||
|
}
|
||||||
|
|
||||||
C3Vector saveMin;
|
C3Vector saveMin;
|
||||||
C3Vector saveMax;
|
C3Vector saveMax;
|
||||||
|
|
@ -174,7 +187,11 @@ void CGWorldFrame::OnWorldRender() {
|
||||||
|
|
||||||
CShaderEffect::UpdateProjMatrix();
|
CShaderEffect::UpdateProjMatrix();
|
||||||
|
|
||||||
CWorld::Render();
|
CWorld::Render(C3Vector(), 0.0f);
|
||||||
|
|
||||||
|
if (CWorldScene::s_m2Scene) {
|
||||||
|
CWorldScene::s_m2Scene->Draw(M2PASS_0);
|
||||||
|
}
|
||||||
|
|
||||||
GxRsPop();
|
GxRsPop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,10 @@ int32_t GxMasterEnable(EGxMasterEnables state) {
|
||||||
return g_theGxDevicePtr->MasterEnable(state);
|
return g_theGxDevicePtr->MasterEnable(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxMasterEnableSet(EGxMasterEnables state, int32_t enable) {
|
||||||
|
return g_theGxDevicePtr->MasterEnableSet(state, enable);
|
||||||
|
}
|
||||||
|
|
||||||
void GxDevOverride(EGxOverride override, uint32_t value) {
|
void GxDevOverride(EGxOverride override, uint32_t value) {
|
||||||
// TODO
|
// TODO
|
||||||
// g_theGxDevicePtr->DeviceOverride(override, value);
|
// g_theGxDevicePtr->DeviceOverride(override, value);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ void* GxDevWindow();
|
||||||
|
|
||||||
int32_t GxMasterEnable(EGxMasterEnables state);
|
int32_t GxMasterEnable(EGxMasterEnables state);
|
||||||
|
|
||||||
|
void GxMasterEnableSet(EGxMasterEnables state, int32_t enable);
|
||||||
|
|
||||||
void GxDevOverride(EGxOverride override, uint32_t value);
|
void GxDevOverride(EGxOverride override, uint32_t value);
|
||||||
|
|
||||||
int32_t GxAdapterDesktopMode(CGxMonitorMode& mode);
|
int32_t GxAdapterDesktopMode(CGxMonitorMode& mode);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ target_link_libraries(world
|
||||||
gx
|
gx
|
||||||
model
|
model
|
||||||
gameui
|
gameui
|
||||||
|
cursor
|
||||||
PUBLIC
|
PUBLIC
|
||||||
bc
|
bc
|
||||||
common
|
common
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#include "world/CWorld.hpp"
|
#include "world/CWorld.hpp"
|
||||||
#include "gx/Device.hpp"
|
#include "world/CWorldScene.hpp"
|
||||||
#include "gx/Shader.hpp"
|
|
||||||
#include "gx/RenderState.hpp"
|
|
||||||
#include "model/Model2.hpp"
|
|
||||||
#include "world/World.hpp"
|
|
||||||
#include "world/map/CMap.hpp"
|
#include "world/map/CMap.hpp"
|
||||||
#include "world/daynight/DayNight.hpp"
|
#include "world/daynight/DayNight.hpp"
|
||||||
#include "gameui/camera/CGCamera.hpp"
|
|
||||||
#include "gameui/CGWorldFrame.hpp"
|
#include "gx/Device.hpp"
|
||||||
|
#include "gx/Shader.hpp"
|
||||||
|
|
||||||
|
#include "model/Model2.hpp"
|
||||||
|
|
||||||
#include "util/SFile.hpp"
|
#include "util/SFile.hpp"
|
||||||
|
|
||||||
uint32_t CWorld::s_enables;
|
uint32_t CWorld::s_enables;
|
||||||
|
|
@ -16,6 +16,7 @@ float CWorld::s_farClip;
|
||||||
float CWorld::s_nearClip;
|
float CWorld::s_nearClip;
|
||||||
float CWorld::prevFarClip;
|
float CWorld::prevFarClip;
|
||||||
|
|
||||||
|
|
||||||
void CWorld::Initialize() {
|
void CWorld::Initialize() {
|
||||||
CWorld::s_enables |=
|
CWorld::s_enables |=
|
||||||
Enables::Enable_1
|
Enables::Enable_1
|
||||||
|
|
@ -50,6 +51,7 @@ void CWorld::Initialize() {
|
||||||
(CWorld::s_enables2 & Enables2::Enable_HwPcf) != 0
|
(CWorld::s_enables2 & Enables2::Enable_HwPcf) != 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CWorldScene::Initialize();
|
||||||
CMap::Initialize();
|
CMap::Initialize();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
@ -71,12 +73,11 @@ void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t zone
|
||||||
CMap::Load(mapName, zoneID);
|
CMap::Load(mapName, zoneID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorld::Render() {
|
void CWorld::Render(const C3Vector& cameraPos, float time) {
|
||||||
GxRsPush();
|
CWorldScene::Render(cameraPos, time);
|
||||||
CRect rect;
|
// TODO: BotDetectionRoutine();
|
||||||
CGWorldFrame::s_currentWorldFrame->GetRect(&rect);
|
}
|
||||||
CGWorldFrame::GetActiveCamera()->SetGxProjectionAndView(rect);
|
|
||||||
DayNight::Update();
|
uint32_t CWorld::GetEnables() {
|
||||||
DayNight::RenderSky();
|
return CWorld::s_enables;
|
||||||
GxRsPop();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,12 @@ class CWorld {
|
||||||
static float s_nearClip;
|
static float s_nearClip;
|
||||||
static float prevFarClip;
|
static float prevFarClip;
|
||||||
|
|
||||||
|
|
||||||
// Static functions
|
// Static functions
|
||||||
static void Initialize(void);
|
static void Initialize();
|
||||||
static void LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID);
|
static void LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID);
|
||||||
static void Render();
|
static void Render(const C3Vector& cameraPos, float time);
|
||||||
|
static uint32_t GetEnables();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
57
src/world/CWorldScene.cpp
Normal file
57
src/world/CWorldScene.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include "world/CWorldScene.hpp"
|
||||||
|
#include "world/CWorld.hpp"
|
||||||
|
#include "world/map/CMap.hpp"
|
||||||
|
#include "world/daynight/DayNight.hpp"
|
||||||
|
|
||||||
|
#include "gx/Device.hpp"
|
||||||
|
#include "gx/Shader.hpp"
|
||||||
|
#include "gx/RenderState.hpp"
|
||||||
|
#include "gx/Transform.hpp"
|
||||||
|
|
||||||
|
#include "model/Model2.hpp"
|
||||||
|
|
||||||
|
#include "gameui/camera/CGCamera.hpp"
|
||||||
|
#include "gameui/CGWorldFrame.hpp"
|
||||||
|
|
||||||
|
#include "cursor/Cursor.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
CM2Scene* CWorldScene::s_m2Scene;
|
||||||
|
|
||||||
|
|
||||||
|
void CWorldScene::Initialize() {
|
||||||
|
// TODO
|
||||||
|
CWorldScene::s_m2Scene = M2CreateScene();
|
||||||
|
auto model = CWorldScene::s_m2Scene->CreateModel("Spells\\ErrorCube.mdx", 0);
|
||||||
|
model->SetAnimating(1);
|
||||||
|
model->SetVisible(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWorldScene::Render(const C3Vector& cameraPos, float time) {
|
||||||
|
// TODO
|
||||||
|
GxRsPush();
|
||||||
|
GxXformPush(GxXform_World);
|
||||||
|
CRect rect;
|
||||||
|
CGWorldFrame::s_currentWorldFrame->GetRect(&rect);
|
||||||
|
CGWorldFrame::GetActiveCamera()->SetGxProjectionAndView(rect);
|
||||||
|
|
||||||
|
|
||||||
|
if (CWorldScene::s_m2Scene) {
|
||||||
|
CWorldScene::s_m2Scene->m_flags |= 1u;
|
||||||
|
CWorldScene::s_m2Scene->AdvanceTime(static_cast<uint32_t>(time * 1000.0f));
|
||||||
|
CWorldScene::s_m2Scene->Animate(cameraPos);
|
||||||
|
CWorldScene::s_m2Scene->m_flags &= ~1u;
|
||||||
|
}
|
||||||
|
|
||||||
|
DayNight::Update();
|
||||||
|
DayNight::RenderSky();
|
||||||
|
|
||||||
|
GxXformPop(GxXform_World);
|
||||||
|
GxRsPop();
|
||||||
|
|
||||||
|
CursorResetCursor();
|
||||||
|
|
||||||
|
if (CWorld::GetEnables() & 0x200000) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/world/CWorldScene.hpp
Normal file
17
src/world/CWorldScene.hpp
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef WORLD_C_WORLDSCENE_HPP
|
||||||
|
#define WORLD_C_WORLDSCENE_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <tempest/Vector.hpp>
|
||||||
|
|
||||||
|
class CM2Scene;
|
||||||
|
|
||||||
|
class CWorldScene {
|
||||||
|
public:
|
||||||
|
static CM2Scene* s_m2Scene;
|
||||||
|
|
||||||
|
static void Initialize();
|
||||||
|
static void Render(const C3Vector& cameraPos, float time);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WORLD_C_WORLDSCENE_HPP
|
||||||
|
|
@ -74,7 +74,7 @@ void UpdateLighting() {
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
// TODO
|
// TODO
|
||||||
UpdateLighting();
|
//UpdateLighting();
|
||||||
g_stars.Update();
|
g_stars.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,8 +95,6 @@ void RenderSky() {
|
||||||
|
|
||||||
GxXformSetViewport(minX, maxX, minY, maxY, 0.99902344f, 1.0f);
|
GxXformSetViewport(minX, maxX, minY, maxY, 0.99902344f, 1.0f);
|
||||||
GxRsSet(GxRs_ScissorTest, 1);
|
GxRsSet(GxRs_ScissorTest, 1);
|
||||||
CImVector clearColor = { 124, 125, 61, 0xFF };
|
|
||||||
GxSceneClear(3, clearColor);
|
|
||||||
|
|
||||||
g_stars.Render();
|
g_stars.Render();
|
||||||
g_sky.Render();
|
g_sky.Render();
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ void CMap::Initialize() {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
CMap::MapMemInitialize();
|
// CMap::MapMemInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMap::MapMemInitialize() {
|
void CMap::MapMemInitialize() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue