diff --git a/src/cursor/Cursor.cpp b/src/cursor/Cursor.cpp index 72bdfd3..0404fdd 100644 --- a/src/cursor/Cursor.cpp +++ b/src/cursor/Cursor.cpp @@ -216,3 +216,7 @@ void CursorSetMode(CURSORMODE mode) { FrameScript_SignalEvent(275, nullptr); } } + +void CursorResetCursor() { + // TODO +} diff --git a/src/cursor/Cursor.hpp b/src/cursor/Cursor.hpp index ca5187a..d6435c8 100644 --- a/src/cursor/Cursor.hpp +++ b/src/cursor/Cursor.hpp @@ -7,7 +7,7 @@ #include "cursor/Types.hpp" void CursorInitialize(); - void CursorSetMode(CURSORMODE mode); +void CursorResetCursor(); #endif diff --git a/src/gameui/CGWorldFrame.cpp b/src/gameui/CGWorldFrame.cpp index 55fa2b8..1f2d713 100644 --- a/src/gameui/CGWorldFrame.cpp +++ b/src/gameui/CGWorldFrame.cpp @@ -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 #include @@ -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(); } diff --git a/src/gx/Device.cpp b/src/gx/Device.cpp index 4d2e311..30f4c3c 100644 --- a/src/gx/Device.cpp +++ b/src/gx/Device.cpp @@ -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); diff --git a/src/gx/Device.hpp b/src/gx/Device.hpp index ddfce25..edad28d 100644 --- a/src/gx/Device.hpp +++ b/src/gx/Device.hpp @@ -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); diff --git a/src/world/CMakeLists.txt b/src/world/CMakeLists.txt index c0b69f4..1d48106 100644 --- a/src/world/CMakeLists.txt +++ b/src/world/CMakeLists.txt @@ -18,6 +18,7 @@ target_link_libraries(world gx model gameui + cursor PUBLIC bc common diff --git a/src/world/CWorld.cpp b/src/world/CWorld.cpp index e516db7..b54e731 100644 --- a/src/world/CWorld.cpp +++ b/src/world/CWorld.cpp @@ -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; } diff --git a/src/world/CWorld.hpp b/src/world/CWorld.hpp index 108833d..49535f8 100644 --- a/src/world/CWorld.hpp +++ b/src/world/CWorld.hpp @@ -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 diff --git a/src/world/CWorldScene.cpp b/src/world/CWorldScene.cpp new file mode 100644 index 0000000..6c0253a --- /dev/null +++ b/src/world/CWorldScene.cpp @@ -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(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 + } +} diff --git a/src/world/CWorldScene.hpp b/src/world/CWorldScene.hpp new file mode 100644 index 0000000..2e03580 --- /dev/null +++ b/src/world/CWorldScene.hpp @@ -0,0 +1,17 @@ +#ifndef WORLD_C_WORLDSCENE_HPP +#define WORLD_C_WORLDSCENE_HPP + +#include +#include + +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 diff --git a/src/world/daynight/DayNight.cpp b/src/world/daynight/DayNight.cpp index 213adaf..da1cf90 100644 --- a/src/world/daynight/DayNight.cpp +++ b/src/world/daynight/DayNight.cpp @@ -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(); diff --git a/src/world/map/CMap.cpp b/src/world/map/CMap.cpp index a637999..0c1f83b 100644 --- a/src/world/map/CMap.cpp +++ b/src/world/map/CMap.cpp @@ -53,7 +53,7 @@ void CMap::Initialize() { // TODO - CMap::MapMemInitialize(); + // CMap::MapMemInitialize(); } void CMap::MapMemInitialize() {