This commit is contained in:
Jack Andersen 2016-09-16 10:21:43 -10:00
commit 32be061783
30 changed files with 2746 additions and 95 deletions

View File

@ -14,6 +14,8 @@ struct ITweakPlayer : BigYAML
virtual float GetPlayerSomething1() const=0; // x274 virtual float GetPlayerSomething1() const=0; // x274
virtual float GetPlayerSomething2() const=0; // x278 virtual float GetPlayerSomething2() const=0; // x278
virtual float GetPlayerSomething3() const=0; // x27c virtual float GetPlayerSomething3() const=0; // x27c
virtual float GetPlayerSomething4() const=0; // x134
virtual bool GetPlayerSomething5() const=0; // x228_24
virtual float GetLeftLogicalThreshold() const=0; virtual float GetLeftLogicalThreshold() const=0;
virtual float GetRightLogicalThreshold() const=0; virtual float GetRightLogicalThreshold() const=0;
}; };

View File

@ -25,7 +25,8 @@ make_dnalist(liblist
Tweaks/CTweakGunRes Tweaks/CTweakGunRes
Tweaks/CTweakPlayerRes Tweaks/CTweakPlayerRes
Tweaks/CTweakGui Tweaks/CTweakGui
Tweaks/CTweakSlideShow) Tweaks/CTweakSlideShow
Tweaks/CTweakCameraBob)
add_library(DNAMP1 add_library(DNAMP1
DNAMP1.hpp DNAMP1.cpp DNAMP1.hpp DNAMP1.cpp
@ -42,4 +43,5 @@ add_library(DNAMP1
MREA.cpp MREA.cpp
SCLY.hpp SCLY.cpp SCLY.hpp SCLY.cpp
FRME.cpp FRME.cpp
DeafBabe.cpp) DeafBabe.cpp
Tweaks/CTweakPlayer.cpp)

View File

@ -26,6 +26,8 @@
#include "../DNACommon/Tweaks/TweakWriter.hpp" #include "../DNACommon/Tweaks/TweakWriter.hpp"
#include "Tweaks/CTweakPlayerRes.hpp" #include "Tweaks/CTweakPlayerRes.hpp"
#include "Tweaks/CTweakGunRes.hpp" #include "Tweaks/CTweakGunRes.hpp"
#include "Tweaks/CTweakPlayer.hpp"
#include "Tweaks/CTweakCameraBob.hpp"
namespace DataSpec namespace DataSpec
{ {
@ -315,6 +317,10 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK& pak, const PAK::En
return {ExtractTweak<CTweakPlayerRes>, nullptr, {_S(".yaml")}}; return {ExtractTweak<CTweakPlayerRes>, nullptr, {_S(".yaml")}};
if (!name.compare("GunRes")) if (!name.compare("GunRes"))
return {ExtractTweak<CTweakGunRes>, nullptr, {_S(".yaml")}}; return {ExtractTweak<CTweakGunRes>, nullptr, {_S(".yaml")}};
if (!name.compare("Player"))
return {ExtractTweak<CTweakPlayer>, nullptr, {_S(".yaml")}};
if (!name.compare("CameraBob"))
return {ExtractTweak<CTweakCameraBob>, nullptr, {_S(".yaml")}};
} }
break; break;
} }

View File

@ -0,0 +1,31 @@
#ifndef __URDE_CTWEAKCAMERABOB_HPP__
#define __URDE_CTWEAKCAMERABOB_HPP__
#include "../../DNACommon/DNACommon.hpp"
namespace DataSpec
{
namespace DNAMP1
{
struct CTweakCameraBob : BigYAML
{
DECL_YAML
Value<float> cameraBobExtentX;
Value<float> cameraBobExtentY;
Value<float> cameraBobPeriod;
Value<float> orbitScale;
Value<float> maxOrbitScale;
Value<float> slowSpeedPeriodScale;
Value<float> targetMagnitudeTrackingRate;
Value<float> landingBobSpringConstant;
Value<float> viewWanderRadius;
Value<float> viewWanderSpeedMin;
Value<float> viewWanderSpeedMax;
Value<float> viewWanderRollVariation;
Value<float> gunBobMagnitude;
Value<float> helmetBobMagnitude;
};
}
}
#endif // __URDE_CTWEAKCAMERABOB_HPP__

File diff suppressed because it is too large Load Diff

View File

@ -10,22 +10,196 @@ namespace DNAMP1
struct CTweakPlayer : ITweakPlayer struct CTweakPlayer : ITweakPlayer
{ {
DECL_YAML Delete _d;
Value<float> m_playerHeight; Value<float> x4_[8];
Value<float> m_playerXYHalfExtent; Value<float> x24_[8];
Value<float> m_unk1; Value<float> x44_[8];
Value<float> m_unk2; Value<float> x64_[8];
Value<float> m_unk3; Value<float> x84_[8];
Value<float> m_leftDiv; Value<float> xa4_[8];
Value<float> m_rightDiv; Value<float> xc4_;
float GetPlayerHeight() const { return m_playerHeight; } Value<float> xc8_;
float GetPlayerXYHalfExtent() const { return m_playerXYHalfExtent; } Value<float> xcc_;
float GetPlayerSomething1() const { return m_unk1; } Value<float> xd0_;
float GetPlayerSomething2() const { return m_unk2; } Value<float> xd4_;
float GetPlayerSomething3() const { return m_unk3; } Value<float> xd8_;
float GetLeftLogicalThreshold() const {return m_leftDiv;} Value<float> xdc_;
float GetRightLogicalThreshold() const {return m_rightDiv;} Value<float> xe0_;
CTweakPlayer(athena::io::IStreamReader& reader) {this->read(reader);} Value<float> xe4_;
Value<float> xe8_;
Value<float> xec_;
Value<float> xf0_;
Value<float> xf4_;
Value<float> xf8_;
Value<float> xfc_;
Value<float> x100_;
Value<float> x104_;
Value<float> x108_;
Value<float> x10c_;
Value<float> x110_;
Value<float> x114_;
Value<float> x118_;
Value<float> x11c_;
Value<float> x120_;
Value<float> x124_;
Value<float> x128_;
Value<float> x12c_;
Value<float> x130_;
Value<float> x134_;
Value<float> x138_;
Value<float> x13c_;
Value<float> x140_;
Value<float> x144_;
Value<float> x148_;
Value<float> x14c_;
Value<float> x150_leftDiv;
Value<float> x154_rightDiv;
Value<float> x158_[3];
Value<float> x164_[3];
Value<float> x170_[3];
Value<float> x17c_;
Value<float> x180_;
Value<float> x184_;
Value<float> x188_;
Value<float> x18c_;
Value<float> x190_;
Value<float> x194_;
Value<float> x198_;
Value<float> x19c_;
Value<float> x1a0_;
Value<float> x1a4_;
Value<atUint32> x1a8_[2];
Value<atUint32> x1b0_[2];
Value<atUint32> x1b8_[2];
Value<atUint32> x1c0_[2];
Value<atUint32> x1c8_[2];
Value<atUint32> x1d0_[2];
Value<float> x1d8_;
Value<float> x1dc_;
Value<float> x1e0_;
Value<float> x1e4_;
Value<float> x1e8_;
Value<float> x1ec_;
Value<float> x1f0_;
Value<float> x1f4_;
Value<float> x1f8_;
Value<float> x1fc_;
Value<bool> x200_24_ : 1;
Value<bool> x200_25_ : 1;
Value<float> x204_;
Value<float> x208_;
Value<float> x20c_;
Value<float> x210_;
Value<float> x214_;
Value<float> x218_;
Value<bool> x21c_24_ : 1;
Value<bool> x21c_25_ : 1;
Value<bool> x21c_26_ : 1;
Value<float> x220_;
Value<float> x224_;
Value<bool> x228_24_ : 1;
Value<bool> x228_25_ : 1;
Value<bool> x228_26_ : 1;
Value<bool> x228_27_ : 1;
Value<bool> x228_28_ : 1;
Value<bool> x228_29_ : 1;
Value<bool> x228_30_ : 1;
Value<bool> x228_31_ : 1;
Value<bool> x229_24_ : 1;
Value<bool> x229_25_ : 1;
Value<bool> x229_26_ : 1;
Value<bool> x229_27_ : 1;
Value<bool> x229_28_ : 1;
Value<bool> x229_29_ : 1;
Value<bool> x229_30_ : 1;
Value<bool> x229_31_ : 1;
Value<bool> x22a_24_ : 1;
Value<bool> x22a_25_ : 1;
Value<bool> x22a_26_ : 1;
Value<bool> x22a_27_ : 1;
Value<bool> x22a_28_ : 1;
Value<float> x22c_;
Value<float> x230_;
Value<float> x234_;
Value<float> x238_;
Value<float> x23c_;
Value<float> x240_;
Value<float> x244_;
Value<float> x248_;
Value<float> x24c_;
Value<float> x250_;
Value<float> x254_;
Value<float> x258_;
Value<float> x25c_;
Value<float> x260_;
Value<float> x264_;
Value<float> x268_;
Value<float> x26c_playerHeight;
Value<float> x270_playerXYHalfExtent;
Value<float> x274_;
Value<float> x278_;
Value<float> x27c_;
Value<float> x280_;
Value<float> x284_;
Value<float> x288_;
Value<float> x28c_;
Value<float> x290_;
Value<float> x294_;
Value<float> x298_;
Value<float> x29c_;
Value<float> x2a0_;
Value<float> x2a4_;
Value<float> x2a8_;
Value<float> x2ac_;
Value<float> x2b0_;
Value<float> x2b4_;
Value<float> x2b8_;
Value<float> x2bc_;
Value<float> x2c0_;
Value<float> x2c4_;
Value<float> x2c8_;
Value<float> x2cc_;
Value<atUint32> x2d0_;
Value<bool> x2d4_;
Value<bool> x2d5_;
Value<float> x2d8_;
Value<float> x2dc_;
Value<float> x2e0_;
Value<float> x2e4_;
Value<float> x2e8_;
Value<float> x2ec_;
Value<float> x2f0_;
Value<bool> x2f4_;
Value<float> x2f8_;
Value<atUint32> x2fc_;
Value<float> x300_;
Value<float> x304_;
Value<float> x308_;
float GetPlayerHeight() const { return x26c_playerHeight; }
float GetPlayerXYHalfExtent() const { return x270_playerXYHalfExtent; }
float GetPlayerSomething1() const { return x274_; }
float GetPlayerSomething2() const { return x278_; }
float GetPlayerSomething3() const { return x27c_; }
float GetPlayerSomething4() const { return x134_; }
bool GetPlayerSomething5() const { return x228_24_; }
float GetLeftLogicalThreshold() const {return x150_leftDiv;}
float GetRightLogicalThreshold() const {return x154_rightDiv;}
CTweakPlayer() = default;
CTweakPlayer(athena::io::IStreamReader& reader)
{
read(reader);
FixupValues();
}
void read(athena::io::IStreamReader& __dna_reader);
void write(athena::io::IStreamWriter& __dna_writer) const;
void read(athena::io::YAMLDocReader& __dna_docin);
void write(athena::io::YAMLDocWriter& __dna_docout) const;
void FixupValues();
static const char* DNAType();
const char* DNATypeV() const { return DNAType(); }
size_t binarySize(size_t __isz) const;
}; };
} }

View File

@ -22,7 +22,12 @@
#include "DNACommon/Tweaks/TweakWriter.hpp" #include "DNACommon/Tweaks/TweakWriter.hpp"
#include "DNAMP1/Tweaks/CTweakPlayerRes.hpp" #include "DNAMP1/Tweaks/CTweakPlayerRes.hpp"
#include "DNAMP1/Tweaks/CTweakGunRes.hpp" #include "DNAMP1/Tweaks/CTweakGunRes.hpp"
<<<<<<< HEAD
#include "DNAMP1/Tweaks/CTweakSlideShow.hpp" #include "DNAMP1/Tweaks/CTweakSlideShow.hpp"
=======
#include "DNAMP1/Tweaks/CTweakPlayer.hpp"
#include "DNAMP1/Tweaks/CTweakCameraBob.hpp"
>>>>>>> b27821c5eb1c9eb5b69acda11ab77c7cda018ca9
#include "hecl/ClientProcess.hpp" #include "hecl/ClientProcess.hpp"
@ -355,7 +360,13 @@ struct SpecMP1 : SpecBase
return true; return true;
else if (!strcmp(classType, DNAMP1::CTweakGunRes::DNAType())) else if (!strcmp(classType, DNAMP1::CTweakGunRes::DNAType()))
return true; return true;
<<<<<<< HEAD
else if (!strcmp(classType, DNAMP1::CTweakSlideShow::DNAType())) else if (!strcmp(classType, DNAMP1::CTweakSlideShow::DNAType()))
=======
else if (!strcmp(classType, DNAMP1::CTweakPlayer::DNAType()))
return true;
else if (!strcmp(classType, DNAMP1::CTweakCameraBob::DNAType()))
>>>>>>> b27821c5eb1c9eb5b69acda11ab77c7cda018ca9
return true; return true;
else if (!strcmp(classType, DNAMP1::HINT::DNAType())) else if (!strcmp(classType, DNAMP1::HINT::DNAType()))
return true; return true;
@ -515,6 +526,17 @@ struct SpecMP1 : SpecBase
DNAMP1::CTweakSlideShow slideShow; DNAMP1::CTweakSlideShow slideShow;
slideShow.read(reader); slideShow.read(reader);
WriteTweak(slideShow, out); WriteTweak(slideShow, out);
else if (!classStr.compare(DNAMP1::CTweakPlayer::DNAType()))
{
DNAMP1::CTweakPlayer player;
player.read(reader);
WriteTweak(player, out);
}
else if (!classStr.compare(DNAMP1::CTweakCameraBob::DNAType()))
{
DNAMP1::CTweakCameraBob cBob;
cBob.read(reader);
WriteTweak(cBob, out);
} }
else if (!classStr.compare(DNAMP1::HINT::DNAType())) else if (!classStr.compare(DNAMP1::HINT::DNAType()))
{ {

View File

@ -131,7 +131,7 @@ makeProj:
m_factoryMP1.IndexMP1Resources(*m_proj); m_factoryMP1.IndexMP1Resources(*m_proj);
m_mainMP1.emplace(m_factoryMP1, m_objStore, m_vm.m_mainBooFactory, m_mainMP1.emplace(m_factoryMP1, m_objStore, m_vm.m_mainBooFactory,
m_vm.m_mainCommandQueue, m_vm.m_renderTex, *m_vm.m_amuseAllocWrapper); m_vm.m_mainCommandQueue, m_vm.m_renderTex);
m_vm.InitMP1(*m_mainMP1); m_vm.InitMP1(*m_mainMP1);
m_vm.BuildTestPART(m_objStore); m_vm.BuildTestPART(m_objStore);

View File

@ -141,7 +141,9 @@ SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path,
} }
else if (!strcmp(className, "DataSpec::DNAMP1::CTweakPlayerRes") || else if (!strcmp(className, "DataSpec::DNAMP1::CTweakPlayerRes") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakGunRes") || !strcmp(className, "DataSpec::DNAMP1::CTweakGunRes") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakSlideShow")) !strcmp(className, "DataSpec::DNAMP1::CTweakSlideShow") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakPlayer") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakCameraBob"))
{ {
resTag.type = SBIG('CTWK'); resTag.type = SBIG('CTWK');
return true; return true;

View File

@ -77,7 +77,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
void ViewManager::InitMP1(MP1::CMain& main) void ViewManager::InitMP1(MP1::CMain& main)
{ {
main.Init(m_fileStoreManager, m_voiceEngine.get()); main.Init(m_fileStoreManager, m_voiceEngine.get(), *m_amuseAllocWrapper);
} }
void ViewManager::ParticleView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) void ViewManager::ParticleView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)

View File

@ -1,6 +1,9 @@
#include "CPlayerState.hpp" #include "CPlayerState.hpp"
#include "IOStreams.hpp" #include "IOStreams.hpp"
#include "zeus/Math.hpp" #include "zeus/Math.hpp"
#include "CStateManager.hpp"
#include "Camera/CCameraManager.hpp"
#include "Camera/CFirstPersonCamera.hpp"
namespace urde namespace urde
{ {
@ -201,13 +204,8 @@ bool CPlayerState::CanVisorSeeFog(const CStateManager& stateMgr) const
CPlayerState::EPlayerVisor CPlayerState::GetActiveVisor(const CStateManager& stateMgr) const CPlayerState::EPlayerVisor CPlayerState::GetActiveVisor(const CStateManager& stateMgr) const
{ {
/* TODO: We need CGameCamera, and gang in order to enable this */ const CFirstPersonCamera* cam = static_cast<const CFirstPersonCamera*>(stateMgr.GetCameraManager()->GetCurrentCamera(stateMgr));
#if 0 return (cam ? x14_currentVisor : EPlayerVisor::Combat);
CFirstPersionCamera* cam = dynamic_cast<CFirstPersonCamera*>(stateMgr.GetCameraManager()->GetCurrentCamera(stateMgr));
if (!cam)
return EVisorType::Combat;
#endif
return x14_currentVisor;
} }
void CPlayerState::UpdateStaticInterference(CStateManager& stateMgr, const float& dt) void CPlayerState::UpdateStaticInterference(CStateManager& stateMgr, const float& dt)

View File

@ -1,5 +1,7 @@
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "Camera/CCameraShakeData.hpp" #include "Camera/CCameraShakeData.hpp"
#include "Camera/CGameCamera.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "CSortedLists.hpp" #include "CSortedLists.hpp"
#include "CWeaponMgr.hpp" #include "CWeaponMgr.hpp"
#include "CFluidPlaneManager.hpp" #include "CFluidPlaneManager.hpp"
@ -301,8 +303,14 @@ void CStateManager::TouchSky() const
{ {
} }
void CStateManager::DrawSpaceWarp(const zeus::CVector3f&, float) const void CStateManager::DrawSpaceWarp(const zeus::CVector3f& v, float strength) const
{ {
CPlayerState::EPlayerVisor visor = x8b8_playerState->GetActiveVisor(*this);
if (visor == CPlayerState::EPlayerVisor::Scan || visor == CPlayerState::EPlayerVisor::Combat)
{
zeus::CVector3f screenV = x870_cameraManager->GetCurrentCamera(*this)->ConvertToScreenSpace(v);
g_Renderer->DrawSpaceWarp(screenV, strength);
}
} }
void CStateManager::DrawReflection(const zeus::CVector3f&) void CStateManager::DrawReflection(const zeus::CVector3f&)

View File

@ -283,7 +283,7 @@ public:
CWorld* GetWorld() {return x850_world.get();} CWorld* GetWorld() {return x850_world.get();}
CRelayTracker* GetRelayTracker() { return x8bc_relayTracker.get(); } CRelayTracker* GetRelayTracker() { return x8bc_relayTracker.get(); }
CCameraManager* GetCameraManager() { return x870_cameraManager; } CCameraManager* GetCameraManager() const { return x870_cameraManager; }
std::shared_ptr<CMapWorldInfo> MapWorldInfo() { return x8c0_mapWorldInfo; } std::shared_ptr<CMapWorldInfo> MapWorldInfo() { return x8c0_mapWorldInfo; }

View File

@ -1,5 +1,6 @@
#include "CCameraManager.hpp" #include "CCameraManager.hpp"
#include "CCameraShakeData.hpp" #include "CCameraShakeData.hpp"
#include "CFirstPersonCamera.hpp"
#include "Audio/CSfxManager.hpp" #include "Audio/CSfxManager.hpp"
#include "CGameCamera.hpp" #include "CGameCamera.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
@ -10,11 +11,9 @@
namespace urde namespace urde
{ {
CCameraManager::CCameraManager(TUniqueId curCameraId) CCameraManager::CCameraManager(TUniqueId curCameraId) : x0_curCameraId(curCameraId)
: x0_curCameraId(curCameraId)
{ {
CSfxManager::AddListener(CSfxManager::ESfxChannels::One, CSfxManager::AddListener(CSfxManager::ESfxChannels::One, zeus::CVector3f::skZero, zeus::CVector3f::skZero,
zeus::CVector3f::skZero, zeus::CVector3f::skZero,
{1.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, 50.f, 50.f, 1000.f, 1, 0x7f); {1.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, 50.f, 50.f, 1000.f, 1, 0x7f);
} }
@ -47,10 +46,7 @@ int CCameraManager::AddCameraShaker(const CCameraShakeData& data)
return x2c_lastShakeId; return x2c_lastShakeId;
} }
void CCameraManager::AddCinemaCamera(TUniqueId id, CStateManager& stateMgr) void CCameraManager::AddCinemaCamera(TUniqueId id, CStateManager& stateMgr) { x4_cineCameras.push_back(id); }
{
x4_cineCameras.push_back(id);
}
void CCameraManager::SetInsideFluid(bool val, TUniqueId fluidId) void CCameraManager::SetInsideFluid(bool val, TUniqueId fluidId)
{ {
@ -67,8 +63,7 @@ void CCameraManager::Update(float dt, CStateManager& stateMgr)
{ {
const CGameCamera* camera = GetCurrentCamera(stateMgr); const CGameCamera* camera = GetCurrentCamera(stateMgr);
zeus::CVector3f heading = camera->GetTransform().basis * zeus::CVector3f{0.f, 1.f, 0.f}; zeus::CVector3f heading = camera->GetTransform().basis * zeus::CVector3f{0.f, 1.f, 0.f};
CSfxManager::UpdateListener(camera->GetTransform().origin, zeus::CVector3f::skZero, CSfxManager::UpdateListener(camera->GetTransform().origin, zeus::CVector3f::skZero, heading, {0.f, 0.f, 1.f}, 0x7f);
heading, {0.f, 0.f, 1.f}, 0x7f);
x30_shakeOffset = zeus::CVector3f::skZero; x30_shakeOffset = zeus::CVector3f::skZero;
for (auto it = x18_shakers.begin(); it != x18_shakers.end();) for (auto it = x18_shakers.begin(); it != x18_shakers.end();)
@ -110,8 +105,7 @@ void CCameraManager::Update(float dt, CStateManager& stateMgr)
zeus::CVector2f tmpVector; // Get from camera zeus::CVector2f tmpVector; // Get from camera
x3c_fog.SetFogExplicit(ERglFogMode::PerspExp, tmpColor, tmpVector); x3c_fog.SetFogExplicit(ERglFogMode::PerspExp, tmpColor, tmpVector);
stateMgr.GetCameraFilterPass(4).SetFilter(CCameraFilterPass::EFilterType::Multiply, stateMgr.GetCameraFilterPass(4).SetFilter(CCameraFilterPass::EFilterType::Multiply,
CCameraFilterPass::EFilterShape::Fullscreen, CCameraFilterPass::EFilterShape::Fullscreen, 0.f, tmpColor, -1);
0.f, tmpColor, -1);
} }
x86_26_inWater = true; x86_26_inWater = true;
} }
@ -137,6 +131,13 @@ const CGameCamera* CCameraManager::GetCurrentCamera(const CStateManager& stateMg
return static_cast<const CGameCamera*>(camList->GetObjectById(GetCurrentCameraId())); return static_cast<const CGameCamera*>(camList->GetObjectById(GetCurrentCameraId()));
} }
float CCameraManager::sub80009148() const
{
const zeus::CVector3f uVec = x7c_fpCamera->GetTransform().upVector();
return 1.f - std::min(std::fabs(std::min(std::fabs(uVec.y * uVec.x * uVec.z * zeus::kUpVec.y + zeus::kUpVec.x +
zeus::kUpVec.z), 1.f) / std::cos(zeus::degToRad(30.f))), 1.f);
}
void CCameraManager::ResetCameras(CStateManager& mgr) void CCameraManager::ResetCameras(CStateManager& mgr)
{ {
zeus::CTransform xf = mgr.GetPlayer().CreateTransformFromMovementDirection(); zeus::CTransform xf = mgr.GetPlayer().CreateTransformFromMovementDirection();
@ -148,5 +149,4 @@ void CCameraManager::ResetCameras(CStateManager& mgr)
camObj->Reset(xf, mgr); camObj->Reset(xf, mgr);
} }
} }
} }

View File

@ -73,6 +73,8 @@ public:
CFirstPersonCamera* GetFirstPersonCamera() { return x7c_fpCamera; } CFirstPersonCamera* GetFirstPersonCamera() { return x7c_fpCamera; }
CBallCamera* GetBallCamera() { return x80_ballCamera; } CBallCamera* GetBallCamera() { return x80_ballCamera; }
float sub80009148() const;
}; };
} }

View File

@ -1,11 +1,15 @@
#include "CFirstPersonCamera.hpp" #include "CFirstPersonCamera.hpp"
#include "GameGlobalObjects.hpp"
#include "Character/CCharLayoutInfo.hpp" #include "Character/CCharLayoutInfo.hpp"
#include "CStateManager.hpp"
#include "World/CPlayer.hpp"
#include <math.h>
namespace urde namespace urde
{ {
CFirstPersonCamera::CFirstPersonCamera(TUniqueId uid, const zeus::CTransform& xf, TUniqueId watchedObj, CFirstPersonCamera::CFirstPersonCamera(TUniqueId uid, const zeus::CTransform& xf, TUniqueId watchedObj,
float, float fov, float nearz, float farz, float aspect) float f1, float fov, float nearz, float farz, float aspect)
: CGameCamera(uid, true, "First Person Camera", : CGameCamera(uid, true, "First Person Camera",
CEntityInfo(kInvalidAreaId, CEntity::NullConnectionList), CEntityInfo(kInvalidAreaId, CEntity::NullConnectionList),
xf, fov, nearz, farz, aspect, watchedObj, false, 0) xf, fov, nearz, farz, aspect, watchedObj, false, 0)
@ -20,4 +24,51 @@ void CFirstPersonCamera::Reset(const zeus::CTransform&, CStateManager& mgr)
{ {
} }
void CFirstPersonCamera::sub800E318()
{
x1c8_ = zeus::CVector3f::skZero;
x1d4_ = 0.f;
}
zeus::CTransform CFirstPersonCamera::GetGunFollowTransform()
{
return x190_gunFollowXf;
}
void CFirstPersonCamera::UpdateTransform(CStateManager& mgr)
{
CPlayer* player = static_cast<CPlayer*>(mgr.ObjectById(GetWatchedObject()));
if (!player)
{
x34_transform = zeus::CTransform::Identity();
xe4_27_ = true;
xe4_28_ = true;
xe4_29_ = true;
return;
}
zeus::CTransform playerXf = player->GetTransform();
float rZ = std::sin(x1c0_);
if (std::fabs(rZ) > 1.0f)
rZ = (rZ > -0.f ? -1.0f : 1.0f);
float rY = std::cos(x1c0_);
if (std::fabs(rY) > 1.0f)
rY = (rY > -0.f ? -1.0f : 1.0f);
zeus::CVector3f rVec = playerXf.rotate({0.f, rY, rZ});
#if 1
if (player->x3dc_)
{
float f32 = g_tweakPlayer->GetPlayerSomething4();
}
#endif
}
void CFirstPersonCamera::UpdateElevation(CStateManager&)
{
}
} }

View File

@ -8,11 +8,34 @@ namespace urde
class CFirstPersonCamera : public CGameCamera class CFirstPersonCamera : public CGameCamera
{ {
float x188_;
u8 x18c_;
zeus::CTransform x190_gunFollowXf;
float x1c0_;
TUniqueId x1c4_;
union
{
struct
{
bool x1c6_24_ : 1;
};
u16 _dummy = 0;
};
zeus::CVector3f x1c8_;
float x1d4_ = 0.f;
public: public:
CFirstPersonCamera(TUniqueId, const zeus::CTransform& xf, TUniqueId, float, float, float, float, float); CFirstPersonCamera(TUniqueId, const zeus::CTransform& xf, TUniqueId, float, float, float, float, float);
void PreThink(float, CStateManager &);
void Think(float, CStateManager &);
void ProcessInput(const CFinalInput&, CStateManager& mgr); void ProcessInput(const CFinalInput&, CStateManager& mgr);
void Reset(const zeus::CTransform&, CStateManager& mgr); void Reset(const zeus::CTransform&, CStateManager& mgr);
void sub800E318();
zeus::CTransform GetGunFollowTransform();
void UpdateTransform(CStateManager&);
void UpdateElevation(CStateManager&);
}; };
} }

View File

@ -110,5 +110,59 @@ TUniqueId CGameCamera::GetWatchedObject() const { return xe8_watchedObject; }
float CGameCamera::GetFov() const { return x15c_fov; } float CGameCamera::GetFov() const { return x15c_fov; }
void CGameCamera::SetFov(float fov) { x15c_fov = fov; } void CGameCamera::sub8005AE3C(float f1)
{
if (x174_ > 0.f)
{
x174_ -= f1;
return;
}
if (x178_ <= 0.f)
return;
x178_ -= f1;
if (x178_ > 0.f)
{
x15c_fov = x184_;
x170_24_perspDirty = true;
}
else
{
x15c_fov = zeus::clamp(0.f, (f1 / x17c_), 1.f) + ((x180_ - x184_) * x184_);
x170_24_perspDirty = true;
}
}
void CGameCamera::sub8005AF18(float f1, float f2, float f3, float f4)
{
if (f3 < 0.f)
{
x15c_fov = f2;
x170_24_perspDirty = true;
x184_ = f2;
x184_ = x174_ = 0.f;
}
else
{
x174_ = std::max(0.f, f4);
x17c_ = f3;
x178_ = f3;
x180_ = f1;
x184_ = f2;
x15c_fov = f1;
x170_24_perspDirty = true;
}
}
void CGameCamera::sub8005AF88()
{
if (x178_ > 0)
{
x15c_fov = x184_;
x170_24_perspDirty = true;
}
x178_ = x174_ = 0.f;
}
} }

View File

@ -49,10 +49,11 @@ public:
float GetAspectRatio() const; float GetAspectRatio() const;
TUniqueId GetWatchedObject() const; TUniqueId GetWatchedObject() const;
float GetFov() const; float GetFov() const;
void SetFov(float);
void GetControllerNumber() const; void GetControllerNumber() const;
bool DisablesInput() const; bool DisablesInput() const;
void sub8005AE3C(float);
void sub8005AF18(float, float, float, float);
void sub8005AF88();
}; };
} }

View File

@ -5,6 +5,7 @@ namespace urde
namespace MP1 namespace MP1
{ {
class CMain* g_Main = nullptr; class CMain* g_Main = nullptr;
class CGameArchitectureSupport* g_archSupport = nullptr;
} }
class CMemoryCardSys* g_MemoryCardSys = nullptr; class CMemoryCardSys* g_MemoryCardSys = nullptr;

View File

@ -16,6 +16,7 @@ namespace urde
namespace MP1 namespace MP1
{ {
extern class CMain* g_Main; extern class CMain* g_Main;
extern class CGameArchitectureSupport* g_archSupport;
} }
extern class CMemoryCardSys* g_MemoryCardSys; extern class CMemoryCardSys* g_MemoryCardSys;

View File

@ -23,7 +23,7 @@ CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, bo
CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type,
TLockedToken<CTexture> tex) TLockedToken<CTexture> tex)
: CTexturedQuadFilter(type, tex->GetBooTexture()) : CTexturedQuadFilter(type, (tex ? tex->GetBooTexture() : nullptr))
{ {
m_tex = tex; m_tex = tex;
} }
@ -93,7 +93,7 @@ CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterTyp
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type,
TLockedToken<CTexture> tex) TLockedToken<CTexture> tex)
: CTexturedQuadFilterAlpha(type, tex->GetBooTexture()) : CTexturedQuadFilterAlpha(type, (tex ? tex->GetBooTexture() : nullptr))
{ {
m_tex = tex; m_tex = tex;
} }

View File

@ -10,8 +10,24 @@ namespace urde
namespace MP1 namespace MP1
{ {
CMFGameLoader::CMFGameLoader() CMFGame::CMFGame(const std::weak_ptr<CStateManager>& stateMgr, const std::weak_ptr<CInGameGuiManager>& guiMgr,
: CMFGameLoaderBase("CMFGameLoader") const CArchitectureQueue&)
: CMFGameBase("CMFGame"), x14_stateManager(stateMgr.lock()), x18_guiManager(guiMgr.lock()), x2a_25_(true)
{
//g_Main->x160_25_ = true;
}
CIOWin::EMessageReturn CMFGame::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue)
{
return EMessageReturn::Normal;
}
void CMFGame::Draw() const
{
}
CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader")
{ {
switch (g_Main->GetFlowState()) switch (g_Main->GetFlowState())
{ {
@ -38,15 +54,12 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg,
{ {
const CArchMsgParmReal32& tick = MakeMsg::GetParmTimerTick(msg); const CArchMsgParmReal32& tick = MakeMsg::GetParmTimerTick(msg);
} }
default: break; default:
break;
} }
return EMessageReturn::Exit; return EMessageReturn::Exit;
} }
void CMFGameLoader::Draw() const void CMFGameLoader::Draw() const { g_GameState->GetWorldTransitionManager()->Draw(); }
{
g_GameState->GetWorldTransitionManager()->Draw();
}
} }
} }

View File

@ -14,8 +14,23 @@ namespace MP1
class CMFGame : public CMFGameBase class CMFGame : public CMFGameBase
{ {
std::shared_ptr<CStateManager> x14_stateManager;
std::shared_ptr<CInGameGuiManager> x18_guiManager;
u32 x1c_ = 0;
u32 x24_ = 0;
TUniqueId x28_ = kInvalidUniqueId;
union
{
struct
{
bool x2a_24_ : 1;
bool x2a_25_ : 1;
};
u8 _dummy = 0;
};
public: public:
CMFGame() : CMFGameBase("CMFGame") {} CMFGame(const std::weak_ptr<CStateManager>& stateMgr, const std::weak_ptr<CInGameGuiManager>& guiMgr,
const CArchitectureQueue&);
CIOWin::EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue); CIOWin::EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue);
void Draw() const; void Draw() const;
}; };

View File

@ -10,7 +10,11 @@
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp"
<<<<<<< HEAD
#include "DataSpec/DNAMP1/Tweaks/CTweakSlideShow.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakSlideShow.hpp"
=======
#include "World/CPlayerCameraBob.hpp"
>>>>>>> b27821c5eb1c9eb5b69acda11ab77c7cda018ca9
namespace urde namespace urde
{ {
@ -36,6 +40,14 @@ void CTweaks::RegisterTweaks()
SObjectTag tag = factory.ProjectResourceFactoryBase::TagFromPath(_S("MP1/Tweaks/SlideShow.yaml")); SObjectTag tag = factory.ProjectResourceFactoryBase::TagFromPath(_S("MP1/Tweaks/SlideShow.yaml"));
strm.emplace(factory.LoadResourceSync(tag).release(), factory.ResourceSize(tag)); strm.emplace(factory.LoadResourceSync(tag).release(), factory.ResourceSize(tag));
g_tweakSlideShow = new DataSpec::DNAMP1::CTweakSlideShow(*strm); g_tweakSlideShow = new DataSpec::DNAMP1::CTweakSlideShow(*strm);
tag = factory.ProjectResourceFactoryBase::TagFromPath(_S("MP1/Tweaks/Player.yaml"));
strm.emplace(factory.LoadResourceSync(tag).release(), factory.ResourceSize(tag));
g_tweakPlayer = new DataSpec::DNAMP1::CTweakPlayer(*strm);
tag = factory.ProjectResourceFactoryBase::TagFromPath(_S("MP1/Tweaks/CameraBob.yaml"));
strm.emplace(factory.LoadResourceSync(tag).release(), factory.ResourceSize(tag));
CPlayerCameraBob::ReadTweaks(*strm);
} }
void CTweaks::RegisterResourceTweaks() void CTweaks::RegisterResourceTweaks()

View File

@ -25,8 +25,8 @@ namespace MP1
CGameArchitectureSupport::CGameArchitectureSupport(amuse::IBackendVoiceAllocator& backend) CGameArchitectureSupport::CGameArchitectureSupport(amuse::IBackendVoiceAllocator& backend)
: m_audioSys(backend, 0,0,0,0,0), : m_audioSys(backend, 0,0,0,0,0),
m_inputGenerator(0.0f /*g_tweakPlayer->GetLeftLogicalThreshold()*/, m_inputGenerator(g_tweakPlayer->GetLeftLogicalThreshold(),
0.0f /*g_tweakPlayer->GetRightLogicalThreshold()*/), g_tweakPlayer->GetRightLogicalThreshold()),
m_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero) m_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero)
{ {
g_GuiSys = &m_guiSys; g_GuiSys = &m_guiSys;
@ -90,11 +90,9 @@ void CGameArchitectureSupport::Draw()
CMain::CMain(IFactory& resFactory, CSimplePool& resStore, CMain::CMain(IFactory& resFactory, CSimplePool& resStore,
boo::IGraphicsDataFactory* gfxFactory, boo::IGraphicsDataFactory* gfxFactory,
boo::IGraphicsCommandQueue* cmdQ, boo::IGraphicsCommandQueue* cmdQ,
boo::ITextureR* spareTex, boo::ITextureR* spareTex)
amuse::IBackendVoiceAllocator& backend)
: m_booSetter(gfxFactory, cmdQ, spareTex), : m_booSetter(gfxFactory, cmdQ, spareTex),
x128_globalObjects(resFactory, resStore), x128_globalObjects(resFactory, resStore)
m_archSupport(backend)
{ {
xe4_gameplayResult = EGameplayResult::Playing; xe4_gameplayResult = EGameplayResult::Playing;
g_Main = this; g_Main = this;
@ -141,25 +139,28 @@ void CMain::LoadAudio()
} }
void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
boo::IAudioVoiceEngine* voiceEngine) boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend)
{ {
InitializeSubsystems(storeMgr, voiceEngine); InitializeSubsystems(storeMgr, voiceEngine);
x128_globalObjects.PostInitialize(); x128_globalObjects.PostInitialize();
x70_tweaks.RegisterTweaks(); x70_tweaks.RegisterTweaks();
x70_tweaks.RegisterResourceTweaks(); x70_tweaks.RegisterResourceTweaks();
m_archSupport.reset(new CGameArchitectureSupport(backend));
g_archSupport = m_archSupport.get();
//g_TweakManager->ReadFromMemoryCard("AudioTweaks"); //g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs(); FillInAssetIDs();
} }
bool CMain::Proc() bool CMain::Proc()
{ {
xe8_b24_finished = m_archSupport.Update(); xe8_b24_finished = m_archSupport->Update();
return xe8_b24_finished; return xe8_b24_finished;
} }
void CMain::Draw() void CMain::Draw()
{ {
m_archSupport.Draw(); m_archSupport->Draw();
} }
void CMain::Shutdown() void CMain::Shutdown()

View File

@ -146,6 +146,7 @@ class CGameArchitectureSupport
public: public:
CGameArchitectureSupport(amuse::IBackendVoiceAllocator& backend); CGameArchitectureSupport(amuse::IBackendVoiceAllocator& backend);
void PreloadAudio();
bool Update(); bool Update();
void Draw(); void Draw();
@ -203,7 +204,7 @@ private:
/* urde addition: these are simply initialized along with everything else */ /* urde addition: these are simply initialized along with everything else */
CGameGlobalObjects x128_globalObjects; CGameGlobalObjects x128_globalObjects;
CGameArchitectureSupport m_archSupport; std::unique_ptr<CGameArchitectureSupport> m_archSupport;
FlowState x12c_ = FlowState::Five; FlowState x12c_ = FlowState::Five;
@ -235,8 +236,7 @@ public:
CMain(IFactory& resFactory, CSimplePool& resStore, CMain(IFactory& resFactory, CSimplePool& resStore,
boo::IGraphicsDataFactory* gfxFactory, boo::IGraphicsDataFactory* gfxFactory,
boo::IGraphicsCommandQueue* cmdQ, boo::IGraphicsCommandQueue* cmdQ,
boo::ITextureR* spareTex, boo::ITextureR* spareTex);
amuse::IBackendVoiceAllocator& backend);
void RegisterResourceTweaks(); void RegisterResourceTweaks();
void ResetGameState(); void ResetGameState();
void StreamNewGameState(CInputStream&); void StreamNewGameState(CInputStream&);
@ -244,7 +244,8 @@ public:
//int RsMain(int argc, const boo::SystemChar* argv[]); //int RsMain(int argc, const boo::SystemChar* argv[]);
void Init(const hecl::Runtime::FileStoreManager& storeMgr, void Init(const hecl::Runtime::FileStoreManager& storeMgr,
boo::IAudioVoiceEngine* voiceEngine); boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend);
bool Proc(); bool Proc();
void Draw(); void Draw();
void Shutdown(); void Shutdown();

View File

@ -15,11 +15,14 @@ class CDamageInfo;
class CScriptWater; class CScriptWater;
class IVisitor; class IVisitor;
class CFinalInput; class CFinalInput;
class CPlayerCameraBob;
class CFirstPersonCamera; class CFirstPersonCamera;
class CPlayer : public CPhysicsActor class CPlayer : public CPhysicsActor
{ {
friend class CStateManager; friend class CStateManager;
friend class CFirstPersonCamera;
friend class CPlayerCameraBob;
public: public:
enum class EPlayerScanState enum class EPlayerScanState
{ {
@ -72,9 +75,11 @@ private:
: x0_(a), x4_(b), x8_(c), xc_(d), x1c_(e) {} : x0_(a), x4_(b), x8_(c), xc_(d), x1c_(e) {}
}; };
bool x38c_;
bool x3dc_;
std::unique_ptr<CPlayerGun> x490_gun; std::unique_ptr<CPlayerGun> x490_gun;
std::unique_ptr<CMorphBall> x768_morphball; std::unique_ptr<CMorphBall> x768_morphball;
std::unique_ptr<CPlayerCameraBob> x76c_cameraBob;
public: public:
CPlayer(TUniqueId, const zeus::CTransform&, const zeus::CAABox&, unsigned int, CPlayer(TUniqueId, const zeus::CTransform&, const zeus::CAABox&, unsigned int,
const zeus::CVector3f&, float, float, float, float, const CMaterialList&); const zeus::CVector3f&, float, float, float, float, const CMaterialList&);

View File

@ -1,10 +1,243 @@
#include "CPlayerCameraBob.hpp" #include "CPlayerCameraBob.hpp"
#include "World/CPlayer.hpp"
#include "CStateManager.hpp"
#include "Camera/CCameraManager.hpp"
#include "zeus/Math.hpp"
namespace urde namespace urde
{ {
float CPlayerCameraBob::kCameraBobExtentX = 0.071f;
float CPlayerCameraBob::kCameraBobExtentY = 0.142f;
float CPlayerCameraBob::kCameraBobPeriod = 0.47f;
float CPlayerCameraBob::kOrbitBobScale = 0.769f;
float CPlayerCameraBob::kMaxOrbitBobScale = 0.8f;
float CPlayerCameraBob::kSlowSpeedPeriodScale = 0.3f;
float CPlayerCameraBob::kTargetMagnitudeTrackingRate = 0.1f;
float CPlayerCameraBob::kLandingBobSpringConstant = 150.f;
float CPlayerCameraBob::kViewWanderRadius = 2.9f;
float CPlayerCameraBob::kViewWanderSpeedMin = 0.1f;
float CPlayerCameraBob::kViewWanderSpeedMax = 0.3f;
float CPlayerCameraBob::kViewWanderRollVariation = 0.3f;
float CPlayerCameraBob::kGunBobMagnitude = 0.3f;
float CPlayerCameraBob::kHelmetBobMagnitude = 2.f;
const float CPlayerCameraBob::kLandingBobDamping = 2.f * zeus::sqrtF(150.f);
CPlayerCameraBob::CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float) CPlayerCameraBob::CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float f1)
: x0_type(type), x4_vec(vec), xc_(f1)
{ {
} }
zeus::CTransform CPlayerCameraBob::GetViewWanderTransform() const { return xd0_viewWanderXf; }
zeus::CVector3f CPlayerCameraBob::GetHelmetBobTranslation() const
{
return {kHelmetBobMagnitude * x2c_cameraBobTransform.origin.x,
kHelmetBobMagnitude * x2c_cameraBobTransform.origin.y,
kHelmetBobMagnitude * (x2c_cameraBobTransform.origin.z - x78_)};
}
zeus::CTransform CPlayerCameraBob::GetGunBobTransformation() const
{
return zeus::CTransform::Translate((1.f + kGunBobMagnitude) * x2c_cameraBobTransform.origin);
}
zeus::CTransform CPlayerCameraBob::GetCameraBobTransformation() const { return x2c_cameraBobTransform; }
void CPlayerCameraBob::SetPlayerVelocity(const zeus::CVector3f& velocity)
{
x5c_playerVelocity = velocity;
x68_ = zeus::min(x68_, velocity.z);
}
void CPlayerCameraBob::SetBobMagnitude(float magnitude) { x10_bobMagnitude = zeus::clamp(0.f, magnitude, 1.f); }
void CPlayerCameraBob::SetBobTimeScale(float ts) { x18_bobTimeScale = zeus::clamp(0.f, ts, 1.f); }
void CPlayerCameraBob::ResetCameraBobTime() { x1c_bobTime = 0.f; }
void CPlayerCameraBob::SetState(CPlayerCameraBob::ECameraBobState state, CStateManager& mgr)
{
if (x24_curState == state)
return;
x20_oldState = x24_curState;
x24_curState = state;
if (x20_oldState == ECameraBobState::Two)
{
x28_applyLandingTrans = true;
x68_ = std::min(x68_, -35.f);
x29_ = (x68_ >= -30.f);
if (x29_)
x74_ += x68_;
else
{
x6c_ += x68_;
x68_ = 0.f;
}
}
if (x24_curState == ECameraBobState::Three && x100_ != 0.f)
InitViewWander(mgr);
}
void CPlayerCameraBob::InitViewWander(CStateManager& mgr)
{
x7c_wanderPoints[0] = {0.f, 1.f, 0.f};
x7c_wanderPoints[1] = x7c_wanderPoints[0];
x7c_wanderPoints[2] = x7c_wanderPoints[0];
x7c_wanderPoints[3] = CalculateRandomViewWanderPosition(mgr);
xb0_wanderPitches[0] = 0.f;
xb0_wanderPitches[1] = xb0_wanderPitches[0];
xb0_wanderPitches[2] = xb0_wanderPitches[0];
xb0_wanderPitches[3] = CalculateRandomViewWanderPitch(mgr);
xc8_viewWanderSpeed =
(kViewWanderSpeedMax - kViewWanderRadius) * kViewWanderRadius + mgr.GetActiveRandom()->Float();
xc4_wanderTime = 0.f;
xcc_wanderIndex = 0;
}
void CPlayerCameraBob::UpdateViewWander(float dt, CStateManager& mgr)
{
zeus::CVector3f pt = zeus::getCatmullRomSplinePoint(
x7c_wanderPoints[xcc_wanderIndex], x7c_wanderPoints[(xcc_wanderIndex + 1) & 3],
x7c_wanderPoints[(xcc_wanderIndex + 2) & 3], x7c_wanderPoints[(xcc_wanderIndex + 3) & 3], dt);
pt.x *= x100_;
pt.z *= x100_;
zeus::CTransform orient = zeus::CTransform::RotateY((
zeus::getCatmullRomSplinePoint(xb0_wanderPitches[xcc_wanderIndex], xb0_wanderPitches[(xcc_wanderIndex + 1) & 3],
xb0_wanderPitches[(xcc_wanderIndex + 2) & 3],
xb0_wanderPitches[(xcc_wanderIndex + 3) & 3], dt) *
x100_));
xd0_viewWanderXf = zeus::lookAt(pt, zeus::CVector3f::skZero, zeus::kUpVec) * orient;
xc4_wanderTime = (xc8_viewWanderSpeed * xc4_wanderTime) + dt;
if (xc4_wanderTime > 1.f)
{
x7c_wanderPoints[xcc_wanderIndex] = CalculateRandomViewWanderPosition(mgr);
xb0_wanderPitches[xcc_wanderIndex] = CalculateRandomViewWanderPitch(mgr);
xc8_viewWanderSpeed =
((kViewWanderSpeedMax - kViewWanderSpeedMin) * kViewWanderSpeedMin) + mgr.GetActiveRandom()->Float();
xcc_wanderIndex = (xcc_wanderIndex + 1) & 3;
xc4_wanderTime -= 1.f;
}
}
void CPlayerCameraBob::Update(float dt, CStateManager& mgr)
{
x1c_bobTime = (dt * x1c_bobTime) + x18_bobTimeScale;
float landSpring = kLandingBobSpringConstant;
float landDampen = kLandingBobDamping;
if (x28_applyLandingTrans)
{
landDampen = 4.f * zeus::sqrtF(40.f);
landSpring = 40.f;
}
x6c_ = dt * x6c_ + -(landSpring * -(landDampen * x6c_) - x28_applyLandingTrans);
x70_landingTranslation = x6c_ * x28_applyLandingTrans + dt;
x74_ = dt * x74_ + -(80.f * -((6.f * zeus::sqrtF(80.f)) * x74_) - x78_);
x78_ = x74_ * x78_ + dt;
if (std::fabs(x6c_) < 0.0049f && std::fabs(x70_landingTranslation) < 0.0049f && std::fabs(x78_) < 0.0049f)
{
x28_applyLandingTrans = false;
x28_applyLandingTrans = 0.f;
x78_ = 0.f;
}
if (x24_curState == ECameraBobState::Three)
x104_ = 1.f;
else
x104_ = 0.f;
float f1 = mgr.GetCameraManager()->sub80009148();
x70_landingTranslation *= f1;
x78_ *= f1;
x104_ *= f1;
if (mgr.GetPlayer().x38c_)
{
x70_landingTranslation *= 0.2f;
x78_ *= 0.2f;
x104_ *= 0.4f;
}
x100_ = kTargetMagnitudeTrackingRate * x100_ + (x104_ - x100_);
x100_ = std::max(x100_, 0.f);
float tmp = x14_;
x14_ = kTargetMagnitudeTrackingRate * tmp + (x10_bobMagnitude - tmp);
UpdateViewWander(dt, mgr);
x78_ = tmp;
x2c_cameraBobTransform = GetViewWanderTransform() * CalculateCameraBobTransformation() *
zeus::lookAt(zeus::CVector3f::skZero, {0.f, 2.f, x78_}, zeus::kUpVec);
}
zeus::CVector3f CPlayerCameraBob::CalculateRandomViewWanderPosition(CStateManager& mgr)
{
const float angle = (2.f * (M_PIF * mgr.GetActiveRandom()->Float()));
const float bias = kViewWanderRadius * mgr.GetActiveRandom()->Float();
return {(bias * std::sin(angle)), 1.f, (bias * std::cos(angle))};
}
float CPlayerCameraBob::CalculateRandomViewWanderPitch(CStateManager& mgr)
{
return zeus::degToRad((2.f * (mgr.GetActiveRandom()->Float() - 0.5f)) * kViewWanderRollVariation);
}
void CPlayerCameraBob::CalculateMovingTranslation(float& x, float& y) const
{
if (x0_type == ECameraBobType::Zero)
{
double c = ((M_PIF * 2.f) * std::fmod(x1c_bobTime, 2.0f * xc_) / xc_);
x = (x14_ * x4_vec.x) * std::sin(c);
y = (x14_ * x4_vec.y) * (std::fabs(std::cos(c * .5)) * std::cos(c * .5));
}
else if (x0_type == ECameraBobType::One)
{
float fX = std::fmod(x1c_bobTime, 2.f * xc_);
if (fX > xc_)
x = (2.f - (fX / xc_)) * (x14_ * x4_vec.x);
else
x = ((fX / xc_)) * (x14_ * x4_vec.x);
float sY = std::sin(std::fmod((M_PI * fX) / xc_, M_PI));
y = (((1.f - sY) * (x14_ * x4_vec.y)) * (0.5f * (-((sY * 1.f) - sY) * (x14_ * x4_vec.y)))) + 0.5f;
}
}
float CPlayerCameraBob::CalculateLandingTranslation() const { return x70_landingTranslation; }
zeus::CTransform CPlayerCameraBob::CalculateCameraBobTransformation() const
{
float x = 0.f;
float y = 0.f;
CalculateMovingTranslation(x, y);
if (x28_applyLandingTrans)
y += CalculateLandingTranslation();
return zeus::CTransform::Translate(x, 0.f, y);
}
void CPlayerCameraBob::ReadTweaks(CInputStream& in)
{
if (in.hasError())
return;
kCameraBobExtentX = in.readFloatBig();
kCameraBobExtentY = in.readFloatBig();
kCameraBobPeriod = in.readFloatBig();
kOrbitBobScale = in.readFloatBig();
kMaxOrbitBobScale = in.readFloatBig();
kSlowSpeedPeriodScale = in.readFloatBig();
kTargetMagnitudeTrackingRate = in.readFloatBig();
kLandingBobSpringConstant = in.readFloatBig();
kViewWanderRadius = in.readFloatBig();
kViewWanderSpeedMin = in.readFloatBig();
kViewWanderSpeedMax = in.readFloatBig();
kViewWanderRollVariation = in.readFloatBig();
kGunBobMagnitude = in.readFloatBig();
kHelmetBobMagnitude = in.readFloatBig();
}
} }

View File

@ -9,6 +9,7 @@
namespace urde namespace urde
{ {
class CStateManager;
class CPlayerCameraBob class CPlayerCameraBob
{ {
public: public:
@ -17,37 +18,84 @@ public:
Zero, Zero,
One One
}; };
enum class ECameraBobState
{
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight
};
private: private:
static float kCameraBobExtentX;
static float kCameraBobExtentY;
static float kCameraBobPeriod;
static float kOrbitBobScale;
static float kMaxOrbitBobScale;
static float kSlowSpeedPeriodScale;
static float kTargetMagnitudeTrackingRate;
static float kLandingBobSpringConstant;
static float kViewWanderRadius;
static float kViewWanderSpeedMin;
static float kViewWanderSpeedMax;
static float kViewWanderRollVariation;
static float kGunBobMagnitude;
static float kHelmetBobMagnitude;
static const float kLandingBobDamping;
ECameraBobType x0_type; ECameraBobType x0_type;
zeus::CVector2f x4_vec; zeus::CVector2f x4_vec;
float xc_; float xc_;
float x10_ = 0.f; float x10_bobMagnitude = 0.f;
float x14_ = 0.f; float x14_ = 0.f;
float x18_ = 0.f; float x18_bobTimeScale = 0.f;
float x1c_ = 0.f; float x1c_bobTime = 0.f;
u32 x20_ = 8; ECameraBobState x20_oldState = ECameraBobState::Eight;
u32 x24_ = 8; ECameraBobState x24_curState = ECameraBobState::Eight;
bool x28_ = false; bool x28_applyLandingTrans = false;
bool x29_ = false; bool x29_ = false;
zeus::CTransform x2c_; zeus::CTransform x2c_cameraBobTransform;
float x5c_ = 0.f; zeus::CVector3f x5c_playerVelocity;
float x60_ = 0.f;
float x64_ = 0.f;
float x68_ = 0.f; float x68_ = 0.f;
float x6c_ = 0.f; float x6c_ = 0.f;
float x70_ = 0.f; float x70_landingTranslation = 0.f;
float x74_ = 0.f; float x74_ = 0.f;
float x78_ = 0.f; float x78_ = 0.f;
zeus::CVector3f x7c_[4] = {zeus::CVector3f{0.f, 1.f, 0.f}}; zeus::CVector3f x7c_wanderPoints[4] = {zeus::CVector3f{0.f, 1.f, 0.f}};
float xb0_[4] = {0.f}; float xb0_wanderPitches[4] = {0.f};
float xc4_ = 0.f; float xc4_wanderTime = 0.f;
float xc8_ = 0.1f; float xc8_viewWanderSpeed = kViewWanderSpeedMin;
u32 xcc_ = 0; u32 xcc_wanderIndex = 0;
zeus::CTransform xd0_; zeus::CTransform xd0_viewWanderXf;
float x100_ = FLT_EPSILON; float x100_ = FLT_EPSILON;
float x104_ = 0.f; float x104_ = 0.f;
public: public:
CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float); CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float);
zeus::CTransform GetViewWanderTransform() const;
zeus::CVector3f GetHelmetBobTranslation() const;
zeus::CTransform GetGunBobTransformation() const;
zeus::CTransform GetCameraBobTransformation() const;
void SetPlayerVelocity(const zeus::CVector3f& velocity);
void SetBobMagnitude(float);
void SetBobTimeScale(float);
void ResetCameraBobTime();
void SetState(ECameraBobState, CStateManager&);
void InitViewWander(CStateManager&);
void UpdateViewWander(float, CStateManager&);
void Update(float, CStateManager &);
zeus::CVector3f CalculateRandomViewWanderPosition(CStateManager&);
float CalculateRandomViewWanderPitch(CStateManager&);
void CalculateMovingTranslation(float& x, float& y) const;
float CalculateLandingTranslation() const;
zeus::CTransform CalculateCameraBobTransformation() const;
static void ReadTweaks(CInputStream& in);
}; };
} }