Initial CInterpolationCamera Imps

This commit is contained in:
Phillip Stephens 2018-06-25 23:58:43 -07:00
parent f8b8211b0f
commit 8df333b29a
4 changed files with 89 additions and 3 deletions

View File

@ -253,6 +253,7 @@ public:
void ProcessInput(const CFinalInput& input, CStateManager& mgr); void ProcessInput(const CFinalInput& input, CStateManager& mgr);
void Reset(const zeus::CTransform&, CStateManager& mgr); void Reset(const zeus::CTransform&, CStateManager& mgr);
void Render(const CStateManager& mgr) const; void Render(const CStateManager& mgr) const;
EBallCameraBehaviour GetBehaviour() const { return x188_behaviour; }
EBallCameraState GetState() const { return x400_state; } EBallCameraState GetState() const { return x400_state; }
void SetState(EBallCameraState state, CStateManager& mgr); void SetState(EBallCameraState state, CStateManager& mgr);
void Think(float dt, CStateManager& mgr); void Think(float dt, CStateManager& mgr);

View File

@ -78,7 +78,6 @@ class CCameraManager
void RestoreHintlessCamera(CStateManager& mgr); void RestoreHintlessCamera(CStateManager& mgr);
void InterpolateToBallCamera(const zeus::CTransform& xf, TUniqueId camId, const zeus::CVector3f& lookPos, void InterpolateToBallCamera(const zeus::CTransform& xf, TUniqueId camId, const zeus::CVector3f& lookPos,
float f1, float f2, float f3, bool b1, CStateManager& mgr); float f1, float f2, float f3, bool b1, CStateManager& mgr);
static constexpr bool ShouldBypassInterpolation() { return false; }
void SkipBallCameraCinematic(CStateManager& mgr); void SkipBallCameraCinematic(CStateManager& mgr);
void ApplyCameraHint(const CScriptCameraHint& hint, CStateManager& mgr); void ApplyCameraHint(const CScriptCameraHint& hint, CStateManager& mgr);
@ -157,6 +156,8 @@ public:
const CScriptCameraHint* GetCameraHint(CStateManager& mgr) const; const CScriptCameraHint* GetCameraHint(CStateManager& mgr) const;
bool HasCameraHint(CStateManager& mgr) const; bool HasCameraHint(CStateManager& mgr) const;
bool IsInterpolationCameraActive() const; bool IsInterpolationCameraActive() const;
bool ShouldBypassInterpolation() { return false; }
}; };
} }

View File

@ -1,5 +1,9 @@
#include "CInterpolationCamera.hpp" #include "CInterpolationCamera.hpp"
#include "CCameraManager.hpp" #include "CCameraManager.hpp"
#include "CStateManager.hpp"
#include "Camera/CBallCamera.hpp"
#include "World/CPlayer.hpp"
#include "World/CScriptSpindleCamera.hpp"
#include "TCastTo.hpp" #include "TCastTo.hpp"
namespace urde namespace urde
@ -11,7 +15,6 @@ CInterpolationCamera::CInterpolationCamera(TUniqueId uid, const zeus::CTransform
xf, CCameraManager::ThirdPersonFOV(), CCameraManager::NearPlane(), xf, CCameraManager::ThirdPersonFOV(), CCameraManager::NearPlane(),
CCameraManager::FarPlane(), CCameraManager::Aspect(), kInvalidUniqueId, false, 0) CCameraManager::FarPlane(), CCameraManager::Aspect(), kInvalidUniqueId, false, 0)
{ {
} }
void CInterpolationCamera::Accept(IVisitor& visitor) void CInterpolationCamera::Accept(IVisitor& visitor)
@ -39,15 +42,83 @@ void CInterpolationCamera::Reset(const zeus::CTransform&, CStateManager& mgr)
// Empty // Empty
} }
void CInterpolationCamera::Think(float, CStateManager& mgr) void CInterpolationCamera::Think(float dt, CStateManager& mgr)
{ {
if (!GetActive())
return;
x15c_currentFov = mgr.GetCameraManager()->GetBallCamera()->GetFov();
x170_24_perspDirty = true;
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphing)
DeactivateInterpCamera(mgr);
x18c_time += dt;
if (x18c_time > x190_maxTime)
x18c_time = x190_maxTime;
zeus::CTransform xf = GetTransform();
if (TCastToConstPtr<CGameCamera> cam = mgr.GetObjectById(x188_targetId))
{
zeus::CVector3f targetOrigin = cam->GetTranslation();
zeus::CVector3f ballLookPos = mgr.GetCameraManager()->GetBallCamera()->GetLookPos();
if (mgr.GetCameraManager()->GetBallCamera()->GetBehaviour() == CBallCamera::EBallCameraBehaviour::SpindleCamera)
{
if (TCastToConstPtr<CScriptSpindleCamera> spindle = mgr.GetObjectById(mgr.GetCameraManager()->GetSpindleCameraId()))
{
float mag = (mgr.GetPlayer().GetTranslation() - spindle->GetTranslation()).magnitude();
ballLookPos = spindle->GetTranslation() + (mag * spindle->GetTransform().frontVector());
}
}
bool deactivate = false;
if (x1d8_24_)
deactivate = sub802654d8(xf, targetOrigin, ballLookPos, x190_maxTime, x18c_time);
else
deactivate = sub802658c0(xf, targetOrigin, ballLookPos, x1d0_, x1d4_, x190_maxTime, x18c_time);
SetTransform(xf);
if (deactivate)
DeactivateInterpCamera(mgr);
}
else
DeactivateInterpCamera(mgr);
} }
void CInterpolationCamera::SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookPos, void CInterpolationCamera::SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookPos,
float f1, float f2, float f3, TUniqueId camId, bool b1, CStateManager& mgr) float f1, float f2, float f3, TUniqueId camId, bool b1, CStateManager& mgr)
{ {
SetActive(true);
SetTransform(xf);
x1c4_lookPos = lookPos;
x188_targetId = camId;
x1d8_24_ = b1;
x190_maxTime = f1;
x1d0_ = f2;
x1d4_ = f3;
if (TCastToConstPtr<CGameCamera> cam = (mgr.GetObjectById(camId)))
{
x15c_currentFov = cam->GetFov();
x170_24_perspDirty = true;
}
}
void CInterpolationCamera::DeactivateInterpCamera(CStateManager& mgr)
{
SetActive(false);
if (!mgr.GetCameraManager()->ShouldBypassInterpolation())
mgr.GetCameraManager()->SetCurrentCameraId(x188_targetId, mgr);
}
bool CInterpolationCamera::sub802654d8(zeus::CTransform& xf, const zeus::CVector3f& targetOrigin, const zeus::CVector3f& lookPos, float maxTime, float curTime)
{
return false;
}
bool CInterpolationCamera::sub802658c0(zeus::CTransform &, const zeus::CVector3f &, const zeus::CVector3f &, float, float, float, float)
{
return false;
} }
} }

View File

@ -8,6 +8,16 @@ namespace urde
class CInterpolationCamera : public CGameCamera class CInterpolationCamera : public CGameCamera
{ {
TUniqueId x188_targetId = kInvalidUniqueId;
float x18c_time = 0.f;
float x190_maxTime = 0.f;
zeus::CTransform x194_;
zeus::CVector3f x1c4_lookPos;
float x1d0_ = 0.f;
float x1d4_ = 0.f;
float x1d8_ = 0.f;
bool x1d8_24_ : 1;
float x1dc_ = M_PIF * 2.f;
public: public:
CInterpolationCamera(TUniqueId uid, const zeus::CTransform& xf); CInterpolationCamera(TUniqueId uid, const zeus::CTransform& xf);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
@ -18,6 +28,9 @@ public:
void Think(float, CStateManager &); void Think(float, CStateManager &);
void SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookPos, void SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookPos,
float f1, float f2, float f3, TUniqueId camId, bool b1, CStateManager& mgr); float f1, float f2, float f3, TUniqueId camId, bool b1, CStateManager& mgr);
void DeactivateInterpCamera(CStateManager&);
bool sub802654d8(zeus::CTransform&, const zeus::CVector3f&, const zeus::CVector3f&, float, float);
bool sub802658c0(zeus::CTransform&, const zeus::CVector3f&, const zeus::CVector3f&, float, float, float, float);
}; };
} }