mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 11:07:44 +00:00
CCameraManager imps
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#include "CCameraShakeData.hpp"
|
||||
#include "CRandom16.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CCameraShakeData::CCameraShakeData(float xA, float xB, float yA, float yB,
|
||||
float zA, float zB, float duration, bool shakeY)
|
||||
: x0_pointA(xA, yA, zA), xc_pointB(xB, yB, zB), x18_duration(duration), x40_shakeY(shakeY) {}
|
||||
|
||||
zeus::CVector3f CCameraShakeData::GeneratePoint(float dt, CRandom16& r)
|
||||
{
|
||||
x3c_cycleTimeLeft -= dt;
|
||||
if (x3c_cycleTimeLeft <= 0.f)
|
||||
{
|
||||
x3c_cycleTimeLeft = r.Range(1.f / 60.f, 0.1f);
|
||||
float zVal = r.Range(-1.f, 1.f);
|
||||
float yVal = 0.f;
|
||||
if (x40_shakeY)
|
||||
yVal = r.Range(-1.f, 1.f);
|
||||
float xVal = r.Range(-1.f, 1.f);
|
||||
zeus::CVector3f shakeVec(xVal, yVal, zVal);
|
||||
if (!shakeVec.canBeNormalized())
|
||||
shakeVec = {0.f, 0.f, 1.f};
|
||||
else
|
||||
shakeVec.normalize();
|
||||
x30_velocity = (shakeVec - x24_position) / x3c_cycleTimeLeft;
|
||||
}
|
||||
|
||||
x24_position += x30_velocity * dt;
|
||||
float interp = zeus::clamp(0.f, 1.f - (x18_duration - x1c_curTime) / x18_duration, 1.f);
|
||||
|
||||
x1c_curTime += dt;
|
||||
return x24_position * zeus::CVector3f::lerp(x0_pointA, xc_pointB, interp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user