mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 13:44:56 +00:00
Initial CPathCamera imps
This commit is contained in:
@@ -50,6 +50,12 @@ void CCameraSpline::CalculateKnots(TUniqueId cameraId, const std::vector<SConnec
|
||||
}
|
||||
}
|
||||
|
||||
void CCameraSpline::Initialize(TUniqueId camId, const std::vector<SConnection>& connections, CStateManager& mgr)
|
||||
{
|
||||
CalculateKnots(camId, connections, mgr);
|
||||
x44_length = CalculateSplineLength();
|
||||
}
|
||||
|
||||
void CCameraSpline::Reset(int size)
|
||||
{
|
||||
x4_positions.clear();
|
||||
@@ -286,4 +292,9 @@ zeus::CVector3f CCameraSpline::GetInterpolatedSplinePointByTime(float time, floa
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
float CCameraSpline::FindClosestLengthAlongSpline(float time, const zeus::CVector3f& p)
|
||||
{
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ public:
|
||||
void UpdateSplineLength() { x44_length = CalculateSplineLength(); }
|
||||
zeus::CTransform GetInterpolatedSplinePointByLength(float pos) const;
|
||||
zeus::CVector3f GetInterpolatedSplinePointByTime(float time, float range) const;
|
||||
float FindClosestLengthAlongSpline(float time, const zeus::CVector3f& p);
|
||||
s32 GetSize() const { return x4_positions.size(); }
|
||||
float GetLength() const { return x44_length; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#include "CPathCamera.hpp"
|
||||
#include "CCameraManager.hpp"
|
||||
#include "CStateManager.hpp"
|
||||
#include "CBallCamera.hpp"
|
||||
#include "World/CScriptCameraHint.hpp"
|
||||
#include "World/CPlayer.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "TCastTo.hpp"
|
||||
|
||||
namespace urde
|
||||
@@ -23,11 +28,80 @@ void CPathCamera::Accept(IVisitor& visitor)
|
||||
visitor.Visit(this);
|
||||
}
|
||||
|
||||
void CPathCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
||||
{
|
||||
CGameCamera::AcceptScriptMsg(msg, uid, mgr);
|
||||
|
||||
if (GetActive() && msg == EScriptObjectMessage::InitializedInArea)
|
||||
x188_spline.Initialize(GetUniqueId(), GetConnectionList(), mgr);
|
||||
}
|
||||
|
||||
void CPathCamera::Think(float dt, CStateManager& mgr)
|
||||
{
|
||||
if (!GetActive())
|
||||
return;
|
||||
|
||||
if (mgr.GetCameraManager()->GetPathCameraId() != GetUniqueId())
|
||||
return;
|
||||
|
||||
if (x188_spline.GetSize() <= 0)
|
||||
return;
|
||||
|
||||
zeus::CTransform xf = GetTransform();
|
||||
zeus::CVector3f ballLook = mgr.GetCameraManager()->GetBallCamera()->GetLookPos();
|
||||
if ((x1ec_flags & 0x10))
|
||||
{
|
||||
if (const CScriptCameraHint* hint = mgr.GetCameraManager()->GetCameraHint(mgr))
|
||||
ballLook.z = hint->GetTranslation().z;
|
||||
}
|
||||
|
||||
if (!mgr.GetPlayer().GetVelocity().canBeNormalized() && (ballLook - GetTranslation()).canBeNormalized())
|
||||
{
|
||||
if (x1ec_flags & 4)
|
||||
SetTransform(x188_spline.GetInterpolatedSplinePointByLength(x1d4_pos));
|
||||
else
|
||||
SetTransform(zeus::lookAt(GetTranslation(), ballLook));
|
||||
return;
|
||||
}
|
||||
|
||||
xf = MoveAlongSpline(dt, mgr);
|
||||
SetTranslation(xf.origin);
|
||||
|
||||
if (x1ec_flags & 0x20)
|
||||
sub8012DD3C(mgr);
|
||||
|
||||
zeus::CVector3f tmp = ballLook - GetTranslation();
|
||||
tmp.z = 0.f;
|
||||
if (tmp.canBeNormalized())
|
||||
SetTransform(zeus::lookAt(GetTranslation(), ballLook));
|
||||
|
||||
if (x1ec_flags & 4)
|
||||
SetTransform(xf);
|
||||
}
|
||||
|
||||
void CPathCamera::ProcessInput(const CFinalInput&, CStateManager& mgr)
|
||||
{
|
||||
}
|
||||
|
||||
void CPathCamera::Reset(const zeus::CTransform&, CStateManager& mgr)
|
||||
{
|
||||
CPlayer& player = mgr.GetPlayer();
|
||||
float f23 = x188_spline.FindClosestLengthAlongSpline(0.f, player.GetTranslation() + g_tweakPlayer->GetPlayerBallHalfExtent());
|
||||
|
||||
float f25 = std::max(0.f, f23 - x1dc_);
|
||||
|
||||
zeus::CTransform xf = x188_spline.GetInterpolatedSplinePointByLength(f25);
|
||||
|
||||
float f1 = x188_spline.GetLength();
|
||||
|
||||
}
|
||||
|
||||
zeus::CTransform CPathCamera::MoveAlongSpline(float, CStateManager& mgr)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void CPathCamera::sub8012DD3C(CStateManager& )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ public:
|
||||
private:
|
||||
|
||||
CCameraSpline x188_spline;
|
||||
float x1d4_ = 0.f;
|
||||
float x1d8_ = 0.f;
|
||||
float x1d4_pos = 0.f;
|
||||
float x1d8_time = 0.f;
|
||||
float x1dc_;
|
||||
float x1e0_;
|
||||
float x1e4_;
|
||||
@@ -32,8 +32,13 @@ public:
|
||||
float, float, u32, EInitialSplinePosition);
|
||||
|
||||
void Accept(IVisitor&);
|
||||
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
|
||||
void Think(float, CStateManager&);
|
||||
void Render(const CStateManager&) const {}
|
||||
void ProcessInput(const CFinalInput&, CStateManager& mgr);
|
||||
void Reset(const zeus::CTransform&, CStateManager& mgr);
|
||||
zeus::CTransform MoveAlongSpline(float, CStateManager&);
|
||||
void sub8012DD3C(CStateManager&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user