mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 21:51:06 +03:00
Compare commits
9 Commits
8bd4e08c80
...
0c0c936874
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c0c936874 | ||
|
|
f8f00b599e | ||
|
|
703dc26df7 | ||
|
|
09c016c935 | ||
|
|
2145348935 | ||
|
|
50685c7cc0 | ||
|
|
b3c07f0607 | ||
|
|
6bcaec1fe7 | ||
|
|
4628b7d831 |
@ -1 +1 @@
|
|||||||
Subproject commit dc8f10e407daa8bdf7e90d9438b55d5883780825
|
Subproject commit 4ba7e0a6c3836254daf97bab159807fae6cab039
|
||||||
@ -1,4 +1,5 @@
|
|||||||
#include "ui/simple/CSimpleCamera.hpp"
|
#include "ui/simple/CSimpleCamera.hpp"
|
||||||
|
#include "gx/Transform.hpp"
|
||||||
#include "model/Model2.hpp"
|
#include "model/Model2.hpp"
|
||||||
#include <tempest/Math.hpp>
|
#include <tempest/Math.hpp>
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ CSimpleCamera::CSimpleCamera(float nearZ, float farZ, float fov) {
|
|||||||
this->SetFacing(0.0f, 0.0f, 0.0f);
|
this->SetFacing(0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CSimpleCamera::FOV() {
|
float CSimpleCamera::FOV() const {
|
||||||
return this->m_fov;
|
return this->m_fov;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +108,25 @@ void CSimpleCamera::SetNearZ(float nearZ) {
|
|||||||
this->m_nearZ = nearZ;
|
this->m_nearZ = nearZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimpleCamera::SetGxProjectionAndView(const CRect& projRect) {
|
||||||
|
// Projection
|
||||||
|
|
||||||
|
this->m_aspect = (projRect.maxX - projRect.minX) / (projRect.maxY - projRect.minY);
|
||||||
|
|
||||||
|
C44Matrix projMat;
|
||||||
|
GxuXformCreateProjection_Exact(this->FOV() * 0.6f, this->m_aspect, this->m_nearZ, this->m_farZ, projMat);
|
||||||
|
|
||||||
|
GxXformSetProjection(projMat);
|
||||||
|
|
||||||
|
// View
|
||||||
|
|
||||||
|
C3Vector eye;
|
||||||
|
C44Matrix viewMat;
|
||||||
|
GxuXformCreateLookAtSgCompat(eye, this->Forward(), this->Up(), viewMat);
|
||||||
|
|
||||||
|
GxXformSetView(viewMat);
|
||||||
|
}
|
||||||
|
|
||||||
C3Vector CSimpleCamera::Up() const {
|
C3Vector CSimpleCamera::Up() const {
|
||||||
return { this->m_facing.c0, this->m_facing.c1, this->m_facing.c2 };
|
return { this->m_facing.c0, this->m_facing.c1, this->m_facing.c2 };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define UI_SIMPLE_C_SIMPLE_CAMERA_HPP
|
#define UI_SIMPLE_C_SIMPLE_CAMERA_HPP
|
||||||
|
|
||||||
#include <tempest/Matrix.hpp>
|
#include <tempest/Matrix.hpp>
|
||||||
|
#include <tempest/Rect.hpp>
|
||||||
#include <tempest/Vector.hpp>
|
#include <tempest/Vector.hpp>
|
||||||
|
|
||||||
class CM2Scene;
|
class CM2Scene;
|
||||||
@ -9,7 +10,7 @@ class CM2Scene;
|
|||||||
class CSimpleCamera {
|
class CSimpleCamera {
|
||||||
public:
|
public:
|
||||||
// Virtual public member functions
|
// Virtual public member functions
|
||||||
virtual float FOV();
|
virtual float FOV() const;
|
||||||
virtual C3Vector Forward() const;
|
virtual C3Vector Forward() const;
|
||||||
virtual C3Vector Right() const;
|
virtual C3Vector Right() const;
|
||||||
virtual C3Vector Up() const;
|
virtual C3Vector Up() const;
|
||||||
@ -22,6 +23,7 @@ class CSimpleCamera {
|
|||||||
void SetFacing(float yaw, float pitch, float roll);
|
void SetFacing(float yaw, float pitch, float roll);
|
||||||
void SetFarZ(float farZ);
|
void SetFarZ(float farZ);
|
||||||
void SetFieldOfView(float fov);
|
void SetFieldOfView(float fov);
|
||||||
|
void SetGxProjectionAndView(const CRect& projRect);
|
||||||
void SetNearZ(float nearZ);
|
void SetNearZ(float nearZ);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "gx/Gx.hpp"
|
#include "gx/Gx.hpp"
|
||||||
#include "gx/Shader.hpp"
|
#include "gx/Shader.hpp"
|
||||||
#include "model/Model2.hpp"
|
#include "model/Model2.hpp"
|
||||||
|
#include "world/CWorldParam.hpp"
|
||||||
#include "world/Map.hpp"
|
#include "world/Map.hpp"
|
||||||
#include "world/Weather.hpp"
|
#include "world/Weather.hpp"
|
||||||
#include <storm/Memory.hpp>
|
#include <storm/Memory.hpp>
|
||||||
@ -10,14 +11,36 @@ uint32_t CWorld::s_curTimeMs;
|
|||||||
float CWorld::s_curTimeSec;
|
float CWorld::s_curTimeSec;
|
||||||
uint32_t CWorld::s_enables;
|
uint32_t CWorld::s_enables;
|
||||||
uint32_t CWorld::s_enables2;
|
uint32_t CWorld::s_enables2;
|
||||||
|
float CWorld::s_farClip;
|
||||||
uint32_t CWorld::s_gameTimeFixed;
|
uint32_t CWorld::s_gameTimeFixed;
|
||||||
float CWorld::s_gameTimeSec;
|
float CWorld::s_gameTimeSec;
|
||||||
CM2Scene* CWorld::s_m2Scene;
|
CM2Scene* CWorld::s_m2Scene;
|
||||||
|
float CWorld::s_nearClip = 0.1f;
|
||||||
|
float CWorld::s_prevFarClip;
|
||||||
uint32_t CWorld::s_tickTimeFixed;
|
uint32_t CWorld::s_tickTimeFixed;
|
||||||
uint32_t CWorld::s_tickTimeMs;
|
uint32_t CWorld::s_tickTimeMs;
|
||||||
float CWorld::s_tickTimeSec;
|
float CWorld::s_tickTimeSec;
|
||||||
Weather* CWorld::s_weather;
|
Weather* CWorld::s_weather;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
float AdjustFarClip(float farClip, int32_t mapID) {
|
||||||
|
float minFarClip = 183.33333f;
|
||||||
|
float maxFarClip = 1583.3334f;
|
||||||
|
|
||||||
|
if (mapID < 530 || mapID == 575 || mapID == 543) {
|
||||||
|
if (!CWorldParam::cvar_farClipOverride || CWorldParam::cvar_farClipOverride->GetInt() < 1) {
|
||||||
|
maxFarClip = 791.66669f;
|
||||||
|
}
|
||||||
|
} else if (false /* TODO OsGetPhysicalMemory() <= 1073741824 */) {
|
||||||
|
maxFarClip = 791.66669f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::min(std::max(farClip, minFarClip), maxFarClip);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
HWORLDOBJECT CWorld::AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags) {
|
HWORLDOBJECT CWorld::AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags) {
|
||||||
auto entity = CMap::AllocEntity(objFlags & 0x8 ? true : false);
|
auto entity = CMap::AllocEntity(objFlags & 0x8 ? true : false);
|
||||||
|
|
||||||
@ -55,6 +78,10 @@ float CWorld::GetCurTimeSec() {
|
|||||||
return CWorld::s_curTimeSec;
|
return CWorld::s_curTimeSec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CWorld::GetFarClip() {
|
||||||
|
return CWorld::s_farClip;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t CWorld::GetFixedPrecisionTime(float timeSec) {
|
uint32_t CWorld::GetFixedPrecisionTime(float timeSec) {
|
||||||
return static_cast<uint32_t>(timeSec * 1024.0f);
|
return static_cast<uint32_t>(timeSec * 1024.0f);
|
||||||
}
|
}
|
||||||
@ -71,6 +98,10 @@ CM2Scene* CWorld::GetM2Scene() {
|
|||||||
return CWorld::s_m2Scene;
|
return CWorld::s_m2Scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CWorld::GetNearClip() {
|
||||||
|
return CWorld::s_nearClip;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t CWorld::GetTickTimeFixed() {
|
uint32_t CWorld::GetTickTimeFixed() {
|
||||||
return CWorld::s_tickTimeFixed;
|
return CWorld::s_tickTimeFixed;
|
||||||
}
|
}
|
||||||
@ -133,10 +164,14 @@ void CWorld::Initialize() {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID) {
|
void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t mapID) {
|
||||||
|
CWorld::s_farClip = AdjustFarClip(CWorldParam::cvar_farClip->GetFloat(), mapID);
|
||||||
|
CWorld::s_nearClip = 0.2f;
|
||||||
|
CWorld::s_prevFarClip = CWorld::s_farClip;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
CMap::Load(mapName, zoneID);
|
CMap::Load(mapName, mapID);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@ -147,6 +182,24 @@ int32_t CWorld::OnTick(const EVENT_DATA_TICK* data, void* param) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWorld::SetFarClip(float farClip) {
|
||||||
|
farClip = AdjustFarClip(farClip, CMap::s_mapID);
|
||||||
|
|
||||||
|
if (CWorld::s_farClip == farClip) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CWorld::s_prevFarClip = CWorld::s_farClip;
|
||||||
|
CWorld::s_farClip = farClip;
|
||||||
|
|
||||||
|
// TODO CMapRenderChunk::DirtyPools();
|
||||||
|
|
||||||
|
CWorld::s_nearClip = 0.2f;
|
||||||
|
|
||||||
|
// TODO dword_D1C410 = 1;
|
||||||
|
// TODO dword_ADEEE0 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void CWorld::SetUpdateTime(float tickTimeSec, uint32_t curTimeMs) {
|
void CWorld::SetUpdateTime(float tickTimeSec, uint32_t curTimeMs) {
|
||||||
auto tickTimeFixed = CWorld::GetFixedPrecisionTime(tickTimeSec);
|
auto tickTimeFixed = CWorld::GetFixedPrecisionTime(tickTimeSec);
|
||||||
|
|
||||||
|
|||||||
@ -57,24 +57,30 @@ class CWorld {
|
|||||||
static HWORLDOBJECT AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags);
|
static HWORLDOBJECT AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags);
|
||||||
static uint32_t GetCurTimeMs();
|
static uint32_t GetCurTimeMs();
|
||||||
static float GetCurTimeSec();
|
static float GetCurTimeSec();
|
||||||
|
static float GetFarClip();
|
||||||
static uint32_t GetGameTimeFixed();
|
static uint32_t GetGameTimeFixed();
|
||||||
static float GetGameTimeSec();
|
static float GetGameTimeSec();
|
||||||
static CM2Scene* GetM2Scene();
|
static CM2Scene* GetM2Scene();
|
||||||
|
static float GetNearClip();
|
||||||
static uint32_t GetTickTimeFixed();
|
static uint32_t GetTickTimeFixed();
|
||||||
static uint32_t GetTickTimeMs();
|
static uint32_t GetTickTimeMs();
|
||||||
static float GetTickTimeSec();
|
static float GetTickTimeSec();
|
||||||
static void Initialize();
|
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 mapID);
|
||||||
static int32_t OnTick(const EVENT_DATA_TICK* data, void* param);
|
static int32_t OnTick(const EVENT_DATA_TICK* data, void* param);
|
||||||
|
static void SetFarClip(float farClip);
|
||||||
static void SetUpdateTime(float tickTimeSec, uint32_t curTimeMs);
|
static void SetUpdateTime(float tickTimeSec, uint32_t curTimeMs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Private static variables
|
// Private static variables
|
||||||
static uint32_t s_curTimeMs;
|
static uint32_t s_curTimeMs;
|
||||||
static float s_curTimeSec;
|
static float s_curTimeSec;
|
||||||
|
static float s_farClip;
|
||||||
static uint32_t s_gameTimeFixed;
|
static uint32_t s_gameTimeFixed;
|
||||||
static float s_gameTimeSec;
|
static float s_gameTimeSec;
|
||||||
static CM2Scene* s_m2Scene;
|
static CM2Scene* s_m2Scene;
|
||||||
|
static float s_nearClip;
|
||||||
|
static float s_prevFarClip;
|
||||||
static uint32_t s_tickTimeFixed;
|
static uint32_t s_tickTimeFixed;
|
||||||
static uint32_t s_tickTimeMs;
|
static uint32_t s_tickTimeMs;
|
||||||
static float s_tickTimeSec;
|
static float s_tickTimeSec;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "world/CWorldParam.hpp"
|
#include "world/CWorldParam.hpp"
|
||||||
|
#include "world/CWorld.hpp"
|
||||||
#include "console/CVar.hpp"
|
#include "console/CVar.hpp"
|
||||||
|
|
||||||
CVar* CWorldParam::cvar_baseMip;
|
CVar* CWorldParam::cvar_baseMip;
|
||||||
@ -53,7 +54,8 @@ bool CWorldParam::ExtShadowQualityCallback(CVar* var, const char* oldValue, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CWorldParam::FarClipCallback(CVar* var, const char* oldValue, const char* value, void* arg) {
|
bool CWorldParam::FarClipCallback(CVar* var, const char* oldValue, const char* value, void* arg) {
|
||||||
// TODO
|
CWorld::SetFarClip(SStrToFloat(value));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#ifndef WORLD_C_WORLD_PARAM_HPP
|
#ifndef WORLD_C_WORLD_PARAM_HPP
|
||||||
#define WORLD_C_WORLD_PARAM_HPP
|
#define WORLD_C_WORLD_PARAM_HPP
|
||||||
|
|
||||||
class CVar;
|
#include "console/CVar.hpp"
|
||||||
|
|
||||||
class CWorldParam {
|
class CWorldParam {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -28,6 +28,7 @@ uint32_t* CMap::s_mapObjDefGroupHeap;
|
|||||||
uint32_t* CMap::s_mapObjDefHeap;
|
uint32_t* CMap::s_mapObjDefHeap;
|
||||||
uint32_t* CMap::s_mapObjGroupHeap;
|
uint32_t* CMap::s_mapObjGroupHeap;
|
||||||
uint32_t* CMap::s_mapObjHeap;
|
uint32_t* CMap::s_mapObjHeap;
|
||||||
|
int32_t CMap::s_mapID = -1;
|
||||||
char CMap::s_mapName[256];
|
char CMap::s_mapName[256];
|
||||||
char CMap::s_mapPath[256];
|
char CMap::s_mapPath[256];
|
||||||
char CMap::s_wdtFilename[256];
|
char CMap::s_wdtFilename[256];
|
||||||
@ -61,7 +62,7 @@ void CMap::Initialize() {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMap::Load(const char* mapName, int32_t zoneID) {
|
void CMap::Load(const char* mapName, int32_t mapID) {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
auto nameOfs = SStrCopy(CMap::s_mapPath, "World\\Maps\\");
|
auto nameOfs = SStrCopy(CMap::s_mapPath, "World\\Maps\\");
|
||||||
@ -72,6 +73,10 @@ void CMap::Load(const char* mapName, int32_t zoneID) {
|
|||||||
SStrPrintf(CMap::s_wdtFilename, sizeof(CMap::s_wdtFilename), "%s\\%s.wdt", CMap::s_mapPath, CMap::s_mapName);
|
SStrPrintf(CMap::s_wdtFilename, sizeof(CMap::s_wdtFilename), "%s\\%s.wdt", CMap::s_mapPath, CMap::s_mapName);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
CMap::s_mapID = mapID;
|
||||||
|
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMap::MapMemInitialize() {
|
void CMap::MapMemInitialize() {
|
||||||
|
|||||||
@ -23,6 +23,7 @@ class CMap {
|
|||||||
static uint32_t* s_mapObjDefHeap;
|
static uint32_t* s_mapObjDefHeap;
|
||||||
static uint32_t* s_mapObjGroupHeap;
|
static uint32_t* s_mapObjGroupHeap;
|
||||||
static uint32_t* s_mapObjHeap;
|
static uint32_t* s_mapObjHeap;
|
||||||
|
static int32_t s_mapID;
|
||||||
static char s_mapName[];
|
static char s_mapName[];
|
||||||
static char s_mapPath[];
|
static char s_mapPath[];
|
||||||
static char s_wdtFilename[];
|
static char s_wdtFilename[];
|
||||||
@ -30,7 +31,7 @@ class CMap {
|
|||||||
// Static functions
|
// Static functions
|
||||||
static CMapEntity* AllocEntity(int32_t a1);
|
static CMapEntity* AllocEntity(int32_t a1);
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Load(const char* mapName, int32_t zoneID);
|
static void Load(const char* mapName, int32_t mapID);
|
||||||
static void MapMemInitialize();
|
static void MapMemInitialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user