mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-01 13:33:32 +00:00
Finish CInterpolationCamera
This commit is contained in:
parent
8df333b29a
commit
680cb7b353
@ -31,7 +31,7 @@ struct CameraHint : IScriptObject
|
|||||||
Value<bool> hintDistanceSelection; // 0x80
|
Value<bool> hintDistanceSelection; // 0x80
|
||||||
Value<bool> hintDistanceSelfPos; // 0x100
|
Value<bool> hintDistanceSelfPos; // 0x100
|
||||||
Value<bool> controlInterpolation; // 0x200
|
Value<bool> controlInterpolation; // 0x200
|
||||||
Value<bool> unknown11; // 0x400
|
Value<bool> sinusoidalInterpolation; // 0x400
|
||||||
Value<bool> unknown12; // 0x800
|
Value<bool> unknown12; // 0x800
|
||||||
Value<bool> clampVelocity; // 0x1000
|
Value<bool> clampVelocity; // 0x1000
|
||||||
Value<bool> skipCinematic; // 0x2000
|
Value<bool> skipCinematic; // 0x2000
|
||||||
@ -60,9 +60,9 @@ struct CameraHint : IScriptObject
|
|||||||
Value<atVec3f> ballToCam;
|
Value<atVec3f> ballToCam;
|
||||||
BoolFloat fov, attitudeRange, azimuthRange, anglePerSecond; // 0x8000000, 0x10000000, 0x20000000, 0x40000000
|
BoolFloat fov, attitudeRange, azimuthRange, anglePerSecond; // 0x8000000, 0x10000000, 0x20000000, 0x40000000
|
||||||
Value<float> clampVelRange;
|
Value<float> clampVelRange;
|
||||||
Value<float> unknown6;
|
Value<float> clampRotRange;
|
||||||
BoolFloat elevation; // 0x80000000
|
BoolFloat elevation; // 0x80000000
|
||||||
Value<float> unknown7;
|
Value<float> interpolateTime;
|
||||||
Value<float> clampVelTime;
|
Value<float> clampVelTime;
|
||||||
Value<float> controlInterpDur;
|
Value<float> controlInterpDur;
|
||||||
};
|
};
|
||||||
|
@ -87,10 +87,16 @@ void ViewManager::TestGameView::think()
|
|||||||
{
|
{
|
||||||
const CPlayer& pl = g_StateManager->GetPlayer();
|
const CPlayer& pl = g_StateManager->GetPlayer();
|
||||||
zeus::CQuaternion plQ = zeus::CQuaternion(pl.GetTransform().getRotation().buildMatrix3f());
|
zeus::CQuaternion plQ = zeus::CQuaternion(pl.GetTransform().getRotation().buildMatrix3f());
|
||||||
|
zeus::CTransform camXf = g_StateManager->GetCameraManager()->GetCurrentCameraTransform(*g_StateManager);
|
||||||
|
zeus::CQuaternion camQ = zeus::CQuaternion(camXf.getRotation().buildMatrix3f());
|
||||||
overlayText += hecl::Format("Player Position: x %f, y %f, z %f\n"
|
overlayText += hecl::Format("Player Position: x %f, y %f, z %f\n"
|
||||||
|
" Quaternion: w %f, x %f, y %f, z %f\n"
|
||||||
|
"Camera Position: x %f, y %f, z %f\n"
|
||||||
" Quaternion: w %f, x %f, y %f, z %f\n",
|
" Quaternion: w %f, x %f, y %f, z %f\n",
|
||||||
pl.GetTranslation().x, pl.GetTranslation().y, pl.GetTranslation().z, plQ.w, plQ.x, plQ.y,
|
pl.GetTranslation().x, pl.GetTranslation().y, pl.GetTranslation().z,
|
||||||
plQ.z);
|
plQ.w, plQ.x, plQ.y, plQ.z,
|
||||||
|
camXf.origin.x, camXf.origin.y, camXf.origin.z,
|
||||||
|
camQ.w, camQ.x, camQ.y, camQ.z);
|
||||||
}
|
}
|
||||||
if (worldInfo && worldInfo->toBoolean())
|
if (worldInfo && worldInfo->toBoolean())
|
||||||
{
|
{
|
||||||
|
@ -215,12 +215,12 @@ void CCameraManager::SetSpindleCamera(TUniqueId id, CStateManager& mgr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::InterpolateToBallCamera(const zeus::CTransform& xf, TUniqueId camId,
|
void CCameraManager::InterpolateToBallCamera(const zeus::CTransform& xf, TUniqueId camId,
|
||||||
const zeus::CVector3f& lookPos, float f1, float f2, float f3,
|
const zeus::CVector3f& lookPos, float maxTime, float positionSpeed,
|
||||||
bool b1, CStateManager& mgr)
|
float rotationSpeed, bool sinusoidal, CStateManager& mgr)
|
||||||
{
|
{
|
||||||
if (!IsInFirstPersonCamera())
|
if (!IsInFirstPersonCamera())
|
||||||
{
|
{
|
||||||
x88_interpCamera->SetInterpolation(xf, lookPos, f1, f2, f3, camId, b1, mgr);
|
x88_interpCamera->SetInterpolation(xf, lookPos, maxTime, positionSpeed, rotationSpeed, camId, sinusoidal, mgr);
|
||||||
if (!ShouldBypassInterpolation())
|
if (!ShouldBypassInterpolation())
|
||||||
SetCurrentCameraId(x88_interpCamera->GetUniqueId(), mgr);
|
SetCurrentCameraId(x88_interpCamera->GetUniqueId(), mgr);
|
||||||
}
|
}
|
||||||
@ -231,6 +231,7 @@ void CCameraManager::RestoreHintlessCamera(CStateManager& mgr)
|
|||||||
TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(xa6_camHintId);
|
TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(xa6_camHintId);
|
||||||
zeus::CTransform ballCamXf = x80_ballCamera->GetTransform();
|
zeus::CTransform ballCamXf = x80_ballCamera->GetTransform();
|
||||||
xa6_camHintId = kInvalidUniqueId;
|
xa6_camHintId = kInvalidUniqueId;
|
||||||
|
printf("Setting NULL\n");
|
||||||
xa8_hintPriority = 1000;
|
xa8_hintPriority = 1000;
|
||||||
if (hint)
|
if (hint)
|
||||||
{
|
{
|
||||||
@ -256,7 +257,7 @@ void CCameraManager::RestoreHintlessCamera(CStateManager& mgr)
|
|||||||
x80_ballCamera->TeleportCamera(x80_ballCamera->UpdateLookDirection(camToPlayerFlat, mgr), mgr);
|
x80_ballCamera->TeleportCamera(x80_ballCamera->UpdateLookDirection(camToPlayerFlat, mgr), mgr);
|
||||||
InterpolateToBallCamera(ballCamXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetLookPos(),
|
InterpolateToBallCamera(ballCamXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetLookPos(),
|
||||||
hint->GetHint().GetClampVelTime(), hint->GetHint().GetClampVelRange(),
|
hint->GetHint().GetClampVelTime(), hint->GetHint().GetClampVelRange(),
|
||||||
hint->GetHint().GetX50(),
|
hint->GetHint().GetClampRotRange(),
|
||||||
(hint->GetHint().GetOverrideFlags() & 0x800) != 0, mgr);
|
(hint->GetHint().GetOverrideFlags() & 0x800) != 0, mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,6 +285,7 @@ void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManage
|
|||||||
|
|
||||||
TCastToPtr<CScriptCameraHint> oldHint = mgr.ObjectById(xa6_camHintId);
|
TCastToPtr<CScriptCameraHint> oldHint = mgr.ObjectById(xa6_camHintId);
|
||||||
xa6_camHintId = hint.GetUniqueId();
|
xa6_camHintId = hint.GetUniqueId();
|
||||||
|
printf("Setting %08X %s\n", hint.GetEditorId().id, hint.GetName().data());
|
||||||
xa8_hintPriority = hint.GetPriority();
|
xa8_hintPriority = hint.GetPriority();
|
||||||
|
|
||||||
zeus::CTransform camXf = GetCurrentCameraTransform(mgr);
|
zeus::CTransform camXf = GetCurrentCameraTransform(mgr);
|
||||||
@ -317,7 +319,8 @@ void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManage
|
|||||||
(oldHint && oldHint->GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Default)))
|
(oldHint && oldHint->GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Default)))
|
||||||
{
|
{
|
||||||
InterpolateToBallCamera(camXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetLookPos(),
|
InterpolateToBallCamera(camXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetLookPos(),
|
||||||
hint.GetHint().GetX58(), hint.GetHint().GetClampVelRange(), hint.GetHint().GetX50(),
|
hint.GetHint().GetInterpolateTime(), hint.GetHint().GetClampVelRange(),
|
||||||
|
hint.GetHint().GetClampRotRange(),
|
||||||
(hint.GetHint().GetOverrideFlags() & 0x400) != 0, mgr);
|
(hint.GetHint().GetOverrideFlags() & 0x400) != 0, mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,6 +350,7 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr)
|
|||||||
{
|
{
|
||||||
if (it->second == id)
|
if (it->second == id)
|
||||||
{
|
{
|
||||||
|
printf("ERASE %08X %s\n", hint->GetEditorId().id, hint->GetName().data());
|
||||||
xac_cameraHints.erase(it);
|
xac_cameraHints.erase(it);
|
||||||
if (xa6_camHintId == id)
|
if (xa6_camHintId == id)
|
||||||
{
|
{
|
||||||
@ -740,6 +744,20 @@ float CCameraManager::GetCameraBobMagnitude() const
|
|||||||
|
|
||||||
bool CCameraManager::HasBallCameraInitialPositionHint(CStateManager& mgr) const
|
bool CCameraManager::HasBallCameraInitialPositionHint(CStateManager& mgr) const
|
||||||
{
|
{
|
||||||
|
if (HasCameraHint(mgr))
|
||||||
|
{
|
||||||
|
switch (mgr.GetCameraManager()->GetCameraHint(mgr)->GetHint().GetBehaviourType())
|
||||||
|
{
|
||||||
|
case CBallCamera::EBallCameraBehaviour::HintBallToCam:
|
||||||
|
case CBallCamera::EBallCameraBehaviour::HintFixedPosition:
|
||||||
|
case CBallCamera::EBallCameraBehaviour::HintFixedTransform:
|
||||||
|
case CBallCamera::EBallCameraBehaviour::PathCamera:
|
||||||
|
case CBallCamera::EBallCameraBehaviour::SpindleCamera:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,7 +779,10 @@ void CCameraManager::DeleteCameraHint(TUniqueId id, CStateManager& mgr)
|
|||||||
hint->ClearIdList();
|
hint->ClearIdList();
|
||||||
hint->SetInactive(true);
|
hint->SetInactive(true);
|
||||||
if (x2b0_inactiveCameraHints.size() != 64)
|
if (x2b0_inactiveCameraHints.size() != 64)
|
||||||
|
{
|
||||||
x2b0_inactiveCameraHints.push_back(id);
|
x2b0_inactiveCameraHints.push_back(id);
|
||||||
|
printf("Delete %08X %s\n", hint->GetEditorId().id, hint->GetName().data());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -774,7 +795,10 @@ void CCameraManager::AddInactiveCameraHint(TUniqueId id, CStateManager& mgr)
|
|||||||
[id](TUniqueId tid) { return tid == id; });
|
[id](TUniqueId tid) { return tid == id; });
|
||||||
if (search == x2b0_inactiveCameraHints.end() &&
|
if (search == x2b0_inactiveCameraHints.end() &&
|
||||||
x2b0_inactiveCameraHints.size() != 64)
|
x2b0_inactiveCameraHints.size() != 64)
|
||||||
|
{
|
||||||
x2b0_inactiveCameraHints.push_back(id);
|
x2b0_inactiveCameraHints.push_back(id);
|
||||||
|
printf("Inactive %08X %s\n", hint->GetEditorId().id, hint->GetName().data());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,7 +810,10 @@ void CCameraManager::AddActiveCameraHint(TUniqueId id, CStateManager& mgr)
|
|||||||
[id](TUniqueId tid) { return tid == id; });
|
[id](TUniqueId tid) { return tid == id; });
|
||||||
if (search == x334_activeCameraHints.end() && xac_cameraHints.size() != 64 &&
|
if (search == x334_activeCameraHints.end() && xac_cameraHints.size() != 64 &&
|
||||||
x334_activeCameraHints.size() != 64)
|
x334_activeCameraHints.size() != 64)
|
||||||
|
{
|
||||||
x334_activeCameraHints.push_back(id);
|
x334_activeCameraHints.push_back(id);
|
||||||
|
printf("Active %08X %s\n", hint->GetEditorId().id, hint->GetName().data());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +76,9 @@ class CCameraManager
|
|||||||
void SetPathCamera(TUniqueId id, CStateManager& mgr);
|
void SetPathCamera(TUniqueId id, CStateManager& mgr);
|
||||||
void SetSpindleCamera(TUniqueId id, CStateManager& mgr);
|
void SetSpindleCamera(TUniqueId id, CStateManager& mgr);
|
||||||
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,
|
||||||
float f1, float f2, float f3, bool b1, CStateManager& mgr);
|
const zeus::CVector3f& lookPos, float maxTime, float positionSpeed,
|
||||||
|
float rotationSpeed, bool sinusoidal, CStateManager& mgr);
|
||||||
void SkipBallCameraCinematic(CStateManager& mgr);
|
void SkipBallCameraCinematic(CStateManager& mgr);
|
||||||
void ApplyCameraHint(const CScriptCameraHint& hint, CStateManager& mgr);
|
void ApplyCameraHint(const CScriptCameraHint& hint, CStateManager& mgr);
|
||||||
|
|
||||||
|
@ -335,8 +335,7 @@ float CCameraSpline::FindClosestLengthOnSpline(float time, const zeus::CVector3f
|
|||||||
extrap = x4_positions.back();
|
extrap = x4_positions.back();
|
||||||
nextDelta = delta + thisPos - extrap;
|
nextDelta = delta + thisPos - extrap;
|
||||||
}
|
}
|
||||||
|
nextDelta.normalize();
|
||||||
delta.normalize();
|
|
||||||
|
|
||||||
if (i < x4_positions.size() - 2)
|
if (i < x4_positions.size() - 2)
|
||||||
{
|
{
|
||||||
@ -358,12 +357,14 @@ float CCameraSpline::FindClosestLengthOnSpline(float time, const zeus::CVector3f
|
|||||||
}
|
}
|
||||||
nextRevDelta = revDelta + *nextPos - extrap;
|
nextRevDelta = revDelta + *nextPos - extrap;
|
||||||
}
|
}
|
||||||
|
nextRevDelta.normalize();
|
||||||
|
|
||||||
revDelta.normalize();
|
|
||||||
nextDelta.normalize();
|
nextDelta.normalize();
|
||||||
nextRevDelta.normalize();
|
nextRevDelta.normalize();
|
||||||
float proj = (p - thisPos).dot(delta) / delta.dot(nextDelta);
|
zeus::CVector3f ptToPlayer = p - thisPos;
|
||||||
float nextProj = (p - *nextPos).dot(revDelta) / revDelta.dot(nextRevDelta);
|
float proj = ptToPlayer.dot(nextDelta) / nextDelta.dot(delta.normalized());
|
||||||
|
zeus::CVector3f nextPtToPlayer = p - *nextPos;
|
||||||
|
float nextProj = nextPtToPlayer.dot(nextRevDelta) / nextRevDelta.dot(revDelta.normalized());
|
||||||
float t = proj / (proj + nextProj);
|
float t = proj / (proj + nextProj);
|
||||||
|
|
||||||
if (!x48_closedLoop)
|
if (!x48_closedLoop)
|
||||||
|
@ -72,10 +72,11 @@ void CInterpolationCamera::Think(float dt, CStateManager& mgr)
|
|||||||
}
|
}
|
||||||
bool deactivate = false;
|
bool deactivate = false;
|
||||||
|
|
||||||
if (x1d8_24_)
|
if (x1d8_24_sinusoidal)
|
||||||
deactivate = sub802654d8(xf, targetOrigin, ballLookPos, x190_maxTime, x18c_time);
|
deactivate = InterpolateSinusoidal(xf, targetOrigin, ballLookPos, x190_maxTime, x18c_time);
|
||||||
else
|
else
|
||||||
deactivate = sub802658c0(xf, targetOrigin, ballLookPos, x1d0_, x1d4_, x190_maxTime, x18c_time);
|
deactivate = InterpolateWithDistance(xf, targetOrigin, ballLookPos,
|
||||||
|
x1d0_positionSpeed, x1d4_rotationSpeed, dt, x190_maxTime, x18c_time);
|
||||||
|
|
||||||
SetTransform(xf);
|
SetTransform(xf);
|
||||||
if (deactivate)
|
if (deactivate)
|
||||||
@ -86,16 +87,19 @@ void CInterpolationCamera::Think(float dt, CStateManager& 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 maxTime, float positionSpeed, float rotationSpeed,
|
||||||
|
TUniqueId camId, bool sinusoidal, CStateManager& mgr)
|
||||||
{
|
{
|
||||||
SetActive(true);
|
SetActive(true);
|
||||||
SetTransform(xf);
|
SetTransform(xf);
|
||||||
x1c4_lookPos = lookPos;
|
x1c4_lookPos = lookPos;
|
||||||
x188_targetId = camId;
|
x188_targetId = camId;
|
||||||
x1d8_24_ = b1;
|
x1d8_24_sinusoidal = sinusoidal;
|
||||||
x190_maxTime = f1;
|
x190_maxTime = maxTime;
|
||||||
x1d0_ = f2;
|
x1d0_positionSpeed = positionSpeed;
|
||||||
x1d4_ = f3;
|
x1d4_rotationSpeed = rotationSpeed;
|
||||||
|
x1dc_closeInAngle = 2.f * M_PIF;
|
||||||
|
x18c_time = 0.f;
|
||||||
|
|
||||||
if (TCastToConstPtr<CGameCamera> cam = (mgr.GetObjectById(camId)))
|
if (TCastToConstPtr<CGameCamera> cam = (mgr.GetObjectById(camId)))
|
||||||
{
|
{
|
||||||
@ -111,14 +115,126 @@ void CInterpolationCamera::DeactivateInterpCamera(CStateManager& mgr)
|
|||||||
mgr.GetCameraManager()->SetCurrentCameraId(x188_targetId, mgr);
|
mgr.GetCameraManager()->SetCurrentCameraId(x188_targetId, mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInterpolationCamera::sub802654d8(zeus::CTransform& xf, const zeus::CVector3f& targetOrigin, const zeus::CVector3f& lookPos, float maxTime, float curTime)
|
bool CInterpolationCamera::InterpolateSinusoidal(zeus::CTransform& xf, const zeus::CVector3f& targetOrigin,
|
||||||
|
const zeus::CVector3f& lookPos, float maxTime, float curTime)
|
||||||
{
|
{
|
||||||
return false;
|
if (curTime > maxTime)
|
||||||
|
curTime = maxTime;
|
||||||
|
|
||||||
|
float t = zeus::clamp(-1.f, curTime / maxTime, 1.f);
|
||||||
|
float sinT = std::sin(t * (M_PIF / 2.f));
|
||||||
|
t *= 2.f;
|
||||||
|
zeus::CVector3f interpOrigin = (1.f - (t - sinT)) * (GetTranslation() - targetOrigin) + targetOrigin;
|
||||||
|
zeus::CVector3f lookDir = lookPos - interpOrigin;
|
||||||
|
if (lookDir.canBeNormalized())
|
||||||
|
lookDir.normalize();
|
||||||
|
else
|
||||||
|
lookDir = x34_transform.basis[1];
|
||||||
|
zeus::CVector3f lookDirFlat = lookDir;
|
||||||
|
lookDirFlat.z = 0.f;
|
||||||
|
if (lookDirFlat.canBeNormalized())
|
||||||
|
{
|
||||||
|
t = zeus::clamp(-1.f, t, 1.f);
|
||||||
|
float lookProj = zeus::clamp(-1.f, x34_transform.basis[1].dot(lookDir), 1.f);
|
||||||
|
float ang = (1.f - t) * std::acos(lookProj);
|
||||||
|
if (ang > x1dc_closeInAngle)
|
||||||
|
ang = x1dc_closeInAngle;
|
||||||
|
else
|
||||||
|
x1dc_closeInAngle = ang;
|
||||||
|
zeus::CTransform lookXf = zeus::lookAt(interpOrigin, interpOrigin + lookDir);
|
||||||
|
if (std::fabs(lookProj) < 0.999999f)
|
||||||
|
{
|
||||||
|
zeus::CVector3f xfLookDir =
|
||||||
|
zeus::CQuaternion::lookAt(lookDir, x34_transform.basis[1], ang).transform(lookDir);
|
||||||
|
lookXf = zeus::lookAt(interpOrigin, interpOrigin + xfLookDir);
|
||||||
|
}
|
||||||
|
xf = lookXf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xf = x34_transform;
|
||||||
|
xf.origin = interpOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
|
return curTime >= maxTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInterpolationCamera::sub802658c0(zeus::CTransform &, const zeus::CVector3f &, const zeus::CVector3f &, float, float, float, float)
|
bool CInterpolationCamera::InterpolateWithDistance(zeus::CTransform& xf, const zeus::CVector3f& targetOrigin,
|
||||||
|
const zeus::CVector3f& lookPos, float positionSpeed,
|
||||||
|
float rotationSpeed, float dt, float maxTime, float curTime)
|
||||||
{
|
{
|
||||||
return false;
|
zeus::CVector3f interpOrigin = xf.origin;
|
||||||
|
zeus::CVector3f originDir = targetOrigin - interpOrigin;
|
||||||
|
float sdt = positionSpeed * dt;
|
||||||
|
bool ret = false;
|
||||||
|
bool positionFail = false;
|
||||||
|
if (originDir.canBeNormalized() && originDir.magnitude() > sdt)
|
||||||
|
{
|
||||||
|
float lookDist = originDir.magnitude();
|
||||||
|
originDir.normalize();
|
||||||
|
float scale = zeus::clamp(-1.f, lookDist / 0.5f, 1.f) * sdt;
|
||||||
|
interpOrigin += originDir * scale;
|
||||||
|
if (lookDist < scale)
|
||||||
|
{
|
||||||
|
interpOrigin = targetOrigin;
|
||||||
|
positionFail = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
interpOrigin = targetOrigin;
|
||||||
|
positionFail = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::CVector3f lookPosDelta = lookPos - x1c4_lookPos;
|
||||||
|
if (lookPosDelta.magnitude() > sdt)
|
||||||
|
{
|
||||||
|
float deltaMag = lookPosDelta.magnitude();
|
||||||
|
lookPosDelta.normalize();
|
||||||
|
float scale = zeus::clamp(-1.f, deltaMag / 0.5f, 1.f) * sdt;
|
||||||
|
x1c4_lookPos += lookPosDelta * scale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x1c4_lookPos = lookPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::CVector3f lookDir = x1c4_lookPos - interpOrigin;
|
||||||
|
if (lookDir.canBeNormalized())
|
||||||
|
lookDir.normalize();
|
||||||
|
else
|
||||||
|
lookDir = x34_transform.basis[1];
|
||||||
|
|
||||||
|
float lookProj = zeus::clamp(-1.f, xf.basis[1].dot(lookDir), 1.f);
|
||||||
|
float ang = zeus::clamp(-1.f, std::acos(lookProj) / (M_PIF / 6.f), 1.f) * rotationSpeed * dt;
|
||||||
|
|
||||||
|
zeus::CVector3f lookDirFlat = lookDir;
|
||||||
|
lookDirFlat.z = 0.f;
|
||||||
|
bool rotationFail = false;
|
||||||
|
if (lookDirFlat.canBeNormalized())
|
||||||
|
{
|
||||||
|
zeus::CTransform lookXf = zeus::lookAt(interpOrigin, interpOrigin + lookDir);
|
||||||
|
if (lookProj < 0.999999f)
|
||||||
|
lookXf = zeus::CQuaternion::lookAt(xf.basis[1], lookDir, ang).toTransform() * xf.getRotation();
|
||||||
|
else
|
||||||
|
rotationFail = true;
|
||||||
|
lookXf.origin = interpOrigin;
|
||||||
|
xf = lookXf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xf = x34_transform;
|
||||||
|
xf.origin = interpOrigin;
|
||||||
|
rotationFail = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (positionFail && rotationFail)
|
||||||
|
ret = true;
|
||||||
|
|
||||||
|
if (curTime >= maxTime && lookProj >= 0.9999f)
|
||||||
|
ret = true;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,17 @@ class CInterpolationCamera : public CGameCamera
|
|||||||
float x190_maxTime = 0.f;
|
float x190_maxTime = 0.f;
|
||||||
zeus::CTransform x194_;
|
zeus::CTransform x194_;
|
||||||
zeus::CVector3f x1c4_lookPos;
|
zeus::CVector3f x1c4_lookPos;
|
||||||
float x1d0_ = 0.f;
|
float x1d0_positionSpeed = 0.f;
|
||||||
float x1d4_ = 0.f;
|
float x1d4_rotationSpeed = 0.f;
|
||||||
float x1d8_ = 0.f;
|
float x1d8_ = 0.f;
|
||||||
bool x1d8_24_ : 1;
|
bool x1d8_24_sinusoidal : 1;
|
||||||
float x1dc_ = M_PIF * 2.f;
|
float x1dc_closeInAngle = M_PIF * 2.f;
|
||||||
|
|
||||||
|
bool InterpolateSinusoidal(zeus::CTransform& xf, const zeus::CVector3f& targetOrigin,
|
||||||
|
const zeus::CVector3f& lookPos, float maxTime, float curTime);
|
||||||
|
bool InterpolateWithDistance(zeus::CTransform& xf, const zeus::CVector3f& targetOrigin,
|
||||||
|
const zeus::CVector3f& lookPos, float positionSpeed,
|
||||||
|
float rotationSpeed, float dt, float maxTime, float curTime);
|
||||||
public:
|
public:
|
||||||
CInterpolationCamera(TUniqueId uid, const zeus::CTransform& xf);
|
CInterpolationCamera(TUniqueId uid, const zeus::CTransform& xf);
|
||||||
void Accept(IVisitor& visitor);
|
void Accept(IVisitor& visitor);
|
||||||
@ -27,10 +33,9 @@ public:
|
|||||||
void Reset(const zeus::CTransform&, CStateManager& mgr);
|
void Reset(const zeus::CTransform&, CStateManager& mgr);
|
||||||
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 maxTime, float positionSpeed, float rotationSpeed,
|
||||||
|
TUniqueId camId, bool sinusoidal, CStateManager& mgr);
|
||||||
void DeactivateInterpCamera(CStateManager&);
|
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);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -168,10 +168,11 @@ zeus::CTransform CPathCamera::MoveAlongSpline(float t, CStateManager& mgr)
|
|||||||
zeus::CVector3f splineToPlayer = mgr.GetPlayer().GetTranslation() -
|
zeus::CVector3f splineToPlayer = mgr.GetPlayer().GetTranslation() -
|
||||||
x188_spline.GetInterpolatedSplinePointByLength(x1d8_time).origin;
|
x188_spline.GetInterpolatedSplinePointByLength(x1d8_time).origin;
|
||||||
float distToPlayer = 0.f;
|
float distToPlayer = 0.f;
|
||||||
|
splineToPlayer.z = 0.f;
|
||||||
if (splineToPlayer.canBeNormalized())
|
if (splineToPlayer.canBeNormalized())
|
||||||
distToPlayer = splineToPlayer.magnitude();
|
distToPlayer = splineToPlayer.magnitude();
|
||||||
f30 *= 1.f - std::sin(zeus::degToRad(zeus::clamp(0.f, (distToPlayer - x1f0_minEaseDist) /
|
float easedDistT = (distToPlayer - x1f0_minEaseDist) / (x1f4_maxEaseDist - x1f0_minEaseDist);
|
||||||
(x1f4_maxEaseDist - x1f0_minEaseDist), 1.f) * 90.f));
|
f30 *= 1.f - std::sin(zeus::degToRad(zeus::clamp(0.f, easedDistT, 1.f) * 90.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
float newPos;
|
float newPos;
|
||||||
|
@ -12,13 +12,13 @@ CScriptCameraHint::CScriptCameraHint(TUniqueId uid, std::string_view name, const
|
|||||||
float maxDist, float backwardsDist, const zeus::CVector3f& lookAtOffset,
|
float maxDist, float backwardsDist, const zeus::CVector3f& lookAtOffset,
|
||||||
const zeus::CVector3f& chaseLookAtOffset, const zeus::CVector3f& ballToCam,
|
const zeus::CVector3f& chaseLookAtOffset, const zeus::CVector3f& ballToCam,
|
||||||
float fov, float attitudeRange, float azimuthRange, float anglePerSecond,
|
float fov, float attitudeRange, float azimuthRange, float anglePerSecond,
|
||||||
float clampVelRange, float f9, float elevation, float f11,
|
float clampVelRange, float clampRotRange, float elevation, float interpolateTime,
|
||||||
float clampVelTime, float controlInterpDur)
|
float clampVelTime, float controlInterpDur)
|
||||||
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic),
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic),
|
||||||
CActorParameters::None(), kInvalidUniqueId), xe8_priority(priority),
|
CActorParameters::None(), kInvalidUniqueId), xe8_priority(priority),
|
||||||
xec_hint(overrideFlags, behaviour, minDist, maxDist, backwardsDist, lookAtOffset, chaseLookAtOffset, ballToCam,
|
xec_hint(overrideFlags, behaviour, minDist, maxDist, backwardsDist, lookAtOffset, chaseLookAtOffset, ballToCam,
|
||||||
fov, attitudeRange, azimuthRange, anglePerSecond, clampVelRange, f9, elevation, f11, clampVelTime,
|
fov, attitudeRange, azimuthRange, anglePerSecond, clampVelRange, clampRotRange, elevation, interpolateTime,
|
||||||
controlInterpDur),
|
clampVelTime, controlInterpDur),
|
||||||
x168_origXf(xf)
|
x168_origXf(xf)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -76,6 +76,8 @@ void CScriptCameraHint::RemoveHelper(TUniqueId id)
|
|||||||
[id](TUniqueId tid) { return tid == id; });
|
[id](TUniqueId tid) { return tid == id; });
|
||||||
if (search != x150_helpers.end())
|
if (search != x150_helpers.end())
|
||||||
x150_helpers.erase(search);
|
x150_helpers.erase(search);
|
||||||
|
else
|
||||||
|
x150_helpers.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptCameraHint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
|
void CScriptCameraHint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
|
||||||
|
@ -22,9 +22,9 @@ class CCameraHint
|
|||||||
float x44_azimuthRange;
|
float x44_azimuthRange;
|
||||||
float x48_anglePerSecond;
|
float x48_anglePerSecond;
|
||||||
float x4c_clampVelRange;
|
float x4c_clampVelRange;
|
||||||
float x50_f9;
|
float x50_clampRotRange;
|
||||||
float x54_elevation;
|
float x54_elevation;
|
||||||
float x58_f11;
|
float x58_interpolateTime;
|
||||||
float x5c_clampVelTime;
|
float x5c_clampVelTime;
|
||||||
float x60_controlInterpDur;
|
float x60_controlInterpDur;
|
||||||
|
|
||||||
@ -32,13 +32,14 @@ public:
|
|||||||
CCameraHint(u32 overrideFlags, CBallCamera::EBallCameraBehaviour behaviour, float minDist, float maxDist,
|
CCameraHint(u32 overrideFlags, CBallCamera::EBallCameraBehaviour behaviour, float minDist, float maxDist,
|
||||||
float backwardsDist, const zeus::CVector3f& lookAtOffset, const zeus::CVector3f& chaseLookAtOffset,
|
float backwardsDist, const zeus::CVector3f& lookAtOffset, const zeus::CVector3f& chaseLookAtOffset,
|
||||||
const zeus::CVector3f& ballToCam, float fov, float attitudeRange, float azimuthRange,
|
const zeus::CVector3f& ballToCam, float fov, float attitudeRange, float azimuthRange,
|
||||||
float anglePerSecond, float clampVelRange, float f9, float elevation, float f11,
|
float anglePerSecond, float clampVelRange, float clampRotRange, float elevation, float interpolateTime,
|
||||||
float clampVelTime, float controlInterpDur)
|
float clampVelTime, float controlInterpDur)
|
||||||
: x4_overrideFlags(overrideFlags), x8_behaviour(behaviour), xc_minDist(minDist), x10_maxDist(maxDist),
|
: x4_overrideFlags(overrideFlags), x8_behaviour(behaviour), xc_minDist(minDist), x10_maxDist(maxDist),
|
||||||
x14_backwardsDist(backwardsDist), x18_lookAtOffset(lookAtOffset), x24_chaseLookAtOffset(chaseLookAtOffset),
|
x14_backwardsDist(backwardsDist), x18_lookAtOffset(lookAtOffset), x24_chaseLookAtOffset(chaseLookAtOffset),
|
||||||
x30_ballToCam(ballToCam), x3c_fov(fov), x40_attitudeRange(attitudeRange), x44_azimuthRange(azimuthRange),
|
x30_ballToCam(ballToCam), x3c_fov(fov), x40_attitudeRange(attitudeRange), x44_azimuthRange(azimuthRange),
|
||||||
x48_anglePerSecond(anglePerSecond), x4c_clampVelRange(clampVelRange), x50_f9(f9), x54_elevation(elevation),
|
x48_anglePerSecond(anglePerSecond), x4c_clampVelRange(clampVelRange), x50_clampRotRange(clampRotRange),
|
||||||
x58_f11(f11), x5c_clampVelTime(clampVelTime), x60_controlInterpDur(controlInterpDur) {}
|
x54_elevation(elevation), x58_interpolateTime(interpolateTime), x5c_clampVelTime(clampVelTime),
|
||||||
|
x60_controlInterpDur(controlInterpDur) {}
|
||||||
|
|
||||||
u32 GetOverrideFlags() const { return x4_overrideFlags; }
|
u32 GetOverrideFlags() const { return x4_overrideFlags; }
|
||||||
CBallCamera::EBallCameraBehaviour GetBehaviourType() const { return x8_behaviour; }
|
CBallCamera::EBallCameraBehaviour GetBehaviourType() const { return x8_behaviour; }
|
||||||
@ -53,9 +54,9 @@ public:
|
|||||||
float GetAzimuthRange() const { return x44_azimuthRange; }
|
float GetAzimuthRange() const { return x44_azimuthRange; }
|
||||||
float GetAnglePerSecond() const { return x48_anglePerSecond; }
|
float GetAnglePerSecond() const { return x48_anglePerSecond; }
|
||||||
float GetClampVelRange() const { return x4c_clampVelRange; }
|
float GetClampVelRange() const { return x4c_clampVelRange; }
|
||||||
float GetX50() const { return x50_f9; }
|
float GetClampRotRange() const { return x50_clampRotRange; }
|
||||||
float GetElevation() const { return x54_elevation; }
|
float GetElevation() const { return x54_elevation; }
|
||||||
float GetX58() const { return x58_f11; }
|
float GetInterpolateTime() const { return x58_interpolateTime; }
|
||||||
float GetClampVelTime() const { return x5c_clampVelTime; }
|
float GetClampVelTime() const { return x5c_clampVelTime; }
|
||||||
float GetControlInterpDur() const { return x60_controlInterpDur; }
|
float GetControlInterpDur() const { return x60_controlInterpDur; }
|
||||||
};
|
};
|
||||||
@ -76,8 +77,9 @@ public:
|
|||||||
bool active, s32 priority, CBallCamera::EBallCameraBehaviour behaviour, u32 overrideFlags,
|
bool active, s32 priority, CBallCamera::EBallCameraBehaviour behaviour, u32 overrideFlags,
|
||||||
float minDist, float maxDist, float backwardsDist, const zeus::CVector3f& lookAtOffset,
|
float minDist, float maxDist, float backwardsDist, const zeus::CVector3f& lookAtOffset,
|
||||||
const zeus::CVector3f& chaseLookAtOffset, const zeus::CVector3f& ballToCam, float fov,
|
const zeus::CVector3f& chaseLookAtOffset, const zeus::CVector3f& ballToCam, float fov,
|
||||||
float attitudeRange, float azimuthRange, float anglePerSecond, float clampVelRange, float f9,
|
float attitudeRange, float azimuthRange, float anglePerSecond, float clampVelRange,
|
||||||
float elevation, float f11, float clampVelTime, float controlInterpDur);
|
float clampRotRange, float elevation, float interpolateTime, float clampVelTime,
|
||||||
|
float controlInterpDur);
|
||||||
|
|
||||||
void Accept(IVisitor& visitor);
|
void Accept(IVisitor& visitor);
|
||||||
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr);
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr);
|
||||||
|
@ -885,23 +885,24 @@ CEntity* ScriptLoader::LoadCameraHint(CStateManager& mgr, CInputStream& in, int
|
|||||||
overrideFlags |= in.readBool() << 27;
|
overrideFlags |= in.readBool() << 27;
|
||||||
float fov = in.readFloatBig();
|
float fov = in.readFloatBig();
|
||||||
overrideFlags |= in.readBool() << 28;
|
overrideFlags |= in.readBool() << 28;
|
||||||
float attitudeRange = in.readFloatBig();
|
float attitudeRange = zeus::degToRad(in.readFloatBig());
|
||||||
overrideFlags |= in.readBool() << 29;
|
overrideFlags |= in.readBool() << 29;
|
||||||
float azimuthRange = in.readFloatBig();
|
float azimuthRange = zeus::degToRad(in.readFloatBig());
|
||||||
overrideFlags |= in.readBool() << 30;
|
overrideFlags |= in.readBool() << 30;
|
||||||
float anglePerSecond = in.readFloatBig();
|
float anglePerSecond = zeus::degToRad(in.readFloatBig());
|
||||||
float clampVelRange = in.readFloatBig();
|
float clampVelRange = in.readFloatBig();
|
||||||
float f9 = in.readFloatBig();
|
float clampRotRange = zeus::degToRad(in.readFloatBig());
|
||||||
overrideFlags |= in.readBool() << 31;
|
overrideFlags |= in.readBool() << 31;
|
||||||
float elevation = in.readFloatBig();
|
float elevation = in.readFloatBig();
|
||||||
float f11 = in.readFloatBig();
|
float interpolateTime = in.readFloatBig();
|
||||||
float clampVelTime = in.readFloatBig();
|
float clampVelTime = in.readFloatBig();
|
||||||
float controlInterpDur = in.readFloatBig();
|
float controlInterpDur = in.readFloatBig();
|
||||||
|
|
||||||
return new CScriptCameraHint(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, active, prio,
|
return new CScriptCameraHint(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, active, prio,
|
||||||
behaviour, overrideFlags, minDist, maxDist, backwardsDist, lookAtOffset,
|
behaviour, overrideFlags, minDist, maxDist, backwardsDist, lookAtOffset,
|
||||||
chaseLookAtOffset, ballToCam, fov, attitudeRange, azimuthRange, anglePerSecond,
|
chaseLookAtOffset, ballToCam, fov, attitudeRange, azimuthRange, anglePerSecond,
|
||||||
clampVelRange, f9, elevation, f11, clampVelTime, controlInterpDur);
|
clampVelRange, clampRotRange, elevation, interpolateTime, clampVelTime,
|
||||||
|
controlInterpDur);
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
|
CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
|
||||||
|
@ -387,6 +387,12 @@ public:
|
|||||||
return base::_const_cast_iterator(pos);
|
return base::_const_cast_iterator(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pop_front()
|
||||||
|
{
|
||||||
|
if (x0_size != 0)
|
||||||
|
erase(begin());
|
||||||
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
if (std::is_destructible<T>::value && !std::is_trivially_destructible<T>::value)
|
if (std::is_destructible<T>::value && !std::is_trivially_destructible<T>::value)
|
||||||
|
2
hecl
2
hecl
@ -1 +1 @@
|
|||||||
Subproject commit a2d6ffa1dcea67585381a6993cdc1e083024877a
|
Subproject commit 7909df3d0ce5ff3cd49c694e4f2ee5323d1cc1a9
|
Loading…
x
Reference in New Issue
Block a user