mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-25 21:36:05 +03:00
feat(world): add CWorldScene class
This commit is contained in:
parent
1326c896df
commit
b1694c2897
@ -216,3 +216,7 @@ void CursorSetMode(CURSORMODE mode) {
|
||||
FrameScript_SignalEvent(275, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void CursorResetCursor() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include "cursor/Types.hpp"
|
||||
|
||||
void CursorInitialize();
|
||||
|
||||
void CursorSetMode(CURSORMODE mode);
|
||||
void CursorResetCursor();
|
||||
|
||||
#endif
|
||||
|
||||
@ -6,9 +6,12 @@
|
||||
#include "gx/Device.hpp"
|
||||
#include "gx/RenderState.hpp"
|
||||
#include "world/CWorld.hpp"
|
||||
#include "world/CWorldScene.hpp"
|
||||
#include "gameui/camera/CGCamera.hpp"
|
||||
#include "event/EvtKeyDown.hpp"
|
||||
|
||||
#include "model/Model2.hpp"
|
||||
|
||||
#include <bc/Memory.hpp>
|
||||
#include <tempest/Matrix.hpp>
|
||||
|
||||
@ -160,6 +163,16 @@ void CGWorldFrame::OnWorldRender() {
|
||||
// TODO
|
||||
|
||||
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 saveMax;
|
||||
@ -174,7 +187,11 @@ void CGWorldFrame::OnWorldRender() {
|
||||
|
||||
CShaderEffect::UpdateProjMatrix();
|
||||
|
||||
CWorld::Render();
|
||||
CWorld::Render(C3Vector(), 0.0f);
|
||||
|
||||
if (CWorldScene::s_m2Scene) {
|
||||
CWorldScene::s_m2Scene->Draw(M2PASS_0);
|
||||
}
|
||||
|
||||
GxRsPop();
|
||||
}
|
||||
|
||||
@ -98,6 +98,10 @@ int32_t GxMasterEnable(EGxMasterEnables 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) {
|
||||
// TODO
|
||||
// g_theGxDevicePtr->DeviceOverride(override, value);
|
||||
|
||||
@ -26,6 +26,8 @@ void* GxDevWindow();
|
||||
|
||||
int32_t GxMasterEnable(EGxMasterEnables state);
|
||||
|
||||
void GxMasterEnableSet(EGxMasterEnables state, int32_t enable);
|
||||
|
||||
void GxDevOverride(EGxOverride override, uint32_t value);
|
||||
|
||||
int32_t GxAdapterDesktopMode(CGxMonitorMode& mode);
|
||||
|
||||
@ -18,6 +18,7 @@ target_link_libraries(world
|
||||
gx
|
||||
model
|
||||
gameui
|
||||
cursor
|
||||
PUBLIC
|
||||
bc
|
||||
common
|
||||
|
||||
@ -1,13 +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/CWorldScene.hpp"
|
||||
#include "world/map/CMap.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"
|
||||
|
||||
uint32_t CWorld::s_enables;
|
||||
@ -16,6 +16,7 @@ float CWorld::s_farClip;
|
||||
float CWorld::s_nearClip;
|
||||
float CWorld::prevFarClip;
|
||||
|
||||
|
||||
void CWorld::Initialize() {
|
||||
CWorld::s_enables |=
|
||||
Enables::Enable_1
|
||||
@ -50,6 +51,7 @@ void CWorld::Initialize() {
|
||||
(CWorld::s_enables2 & Enables2::Enable_HwPcf) != 0
|
||||
);
|
||||
|
||||
CWorldScene::Initialize();
|
||||
CMap::Initialize();
|
||||
|
||||
// TODO
|
||||
@ -71,12 +73,11 @@ void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t zone
|
||||
CMap::Load(mapName, zoneID);
|
||||
}
|
||||
|
||||
void CWorld::Render() {
|
||||
GxRsPush();
|
||||
CRect rect;
|
||||
CGWorldFrame::s_currentWorldFrame->GetRect(&rect);
|
||||
CGWorldFrame::GetActiveCamera()->SetGxProjectionAndView(rect);
|
||||
DayNight::Update();
|
||||
DayNight::RenderSky();
|
||||
GxRsPop();
|
||||
void CWorld::Render(const C3Vector& cameraPos, float time) {
|
||||
CWorldScene::Render(cameraPos, time);
|
||||
// TODO: BotDetectionRoutine();
|
||||
}
|
||||
|
||||
uint32_t CWorld::GetEnables() {
|
||||
return CWorld::s_enables;
|
||||
}
|
||||
|
||||
@ -49,10 +49,12 @@ class CWorld {
|
||||
static float s_nearClip;
|
||||
static float prevFarClip;
|
||||
|
||||
|
||||
// Static functions
|
||||
static void Initialize(void);
|
||||
static void Initialize();
|
||||
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
|
||||
|
||||
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() {
|
||||
// TODO
|
||||
UpdateLighting();
|
||||
//UpdateLighting();
|
||||
g_stars.Update();
|
||||
}
|
||||
|
||||
@ -95,8 +95,6 @@ void RenderSky() {
|
||||
|
||||
GxXformSetViewport(minX, maxX, minY, maxY, 0.99902344f, 1.0f);
|
||||
GxRsSet(GxRs_ScissorTest, 1);
|
||||
CImVector clearColor = { 124, 125, 61, 0xFF };
|
||||
GxSceneClear(3, clearColor);
|
||||
|
||||
g_stars.Render();
|
||||
g_sky.Render();
|
||||
|
||||
@ -53,7 +53,7 @@ void CMap::Initialize() {
|
||||
|
||||
// TODO
|
||||
|
||||
CMap::MapMemInitialize();
|
||||
// CMap::MapMemInitialize();
|
||||
}
|
||||
|
||||
void CMap::MapMemInitialize() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user