metaforce/Runtime/Camera/CCameraShakeData.hpp

85 lines
3.3 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-04-16 23:48:29 +00:00
2016-04-17 02:50:45 +00:00
#include "zeus/CVector3f.hpp"
#include "RetroTypes.hpp"
2016-04-16 23:48:29 +00:00
namespace urde
{
2016-04-17 02:50:45 +00:00
class CRandom16;
class CStateManager;
2016-04-16 23:48:29 +00:00
struct SCameraShakePoint
{
friend class CCameraShakeData;
2017-10-10 03:50:48 +00:00
bool x0_useEnvelope = false;
float x4_value = 0.f;
2017-07-30 01:06:06 +00:00
float x8_magnitude = 0.f;
2017-10-10 03:50:48 +00:00
float xc_attackTime = 0.f;
float x10_sustainTime = 0.f;
2017-07-30 01:06:06 +00:00
float x14_duration = 0.f;
SCameraShakePoint() = default;
2017-10-10 03:50:48 +00:00
SCameraShakePoint(bool useEnvelope, float attackTime, float sustainTime, float duration, float magnitude)
: x0_useEnvelope(useEnvelope), x8_magnitude(magnitude), xc_attackTime(attackTime),
x10_sustainTime(sustainTime), x14_duration(duration) {}
float GetValue() const { return x0_useEnvelope ? x8_magnitude : x4_value; }
static SCameraShakePoint LoadCameraShakePoint(CInputStream& in);
2017-10-10 03:50:48 +00:00
void Update(float curTime);
};
class CCameraShakerComponent
{
friend class CCameraShakeData;
2017-10-10 03:50:48 +00:00
bool x4_useModulation = false;
SCameraShakePoint x8_am, x20_fm;
float x38_value = 0.f;
public:
CCameraShakerComponent() = default;
2017-10-10 03:50:48 +00:00
CCameraShakerComponent(bool useModulation, const SCameraShakePoint& am, const SCameraShakePoint& fm)
: x4_useModulation(useModulation), x8_am(am), x20_fm(fm) {}
static CCameraShakerComponent LoadNewCameraShakerComponent(CInputStream& in);
2017-10-10 03:50:48 +00:00
void Update(float curTime, float duration, float distAtt);
float GetValue() const { return x38_value; }
};
2016-04-16 23:48:29 +00:00
class CCameraShakeData
{
2016-04-17 02:50:45 +00:00
friend class CCameraManager;
float x0_duration;
float x4_curTime = 0.f;
2017-10-10 03:50:48 +00:00
CCameraShakerComponent x8_shakerX;
CCameraShakerComponent x44_shakerY;
CCameraShakerComponent x80_shakerZ;
u32 xbc_shakerId = 0;
u32 xc0_flags; // 0x1: positional sfx
zeus::CVector3f xc4_sfxPos;
2017-09-10 00:36:21 +00:00
float xd0_sfxDist;
2016-04-16 23:48:29 +00:00
public:
2017-09-10 00:36:21 +00:00
static const CCameraShakeData skChargedShotCameraShakeData;
2017-10-10 03:50:48 +00:00
CCameraShakeData(float duration, float sfxDist, u32 flags, const zeus::CVector3f& sfxPos,
const CCameraShakerComponent& shaker1, const CCameraShakerComponent& shaker2,
const CCameraShakerComponent& shaker3);
2017-07-30 01:06:06 +00:00
CCameraShakeData(float duration, float magnitude);
CCameraShakeData(CInputStream&);
2017-07-30 01:06:06 +00:00
static CCameraShakeData BuildLandingCameraShakeData(float duration, float magnitude);
static CCameraShakeData BuildProjectileCameraShake(float duration, float magnitude);
2017-09-10 00:36:21 +00:00
static CCameraShakeData BuildMissileCameraShake(float duration, float magnitude, float sfxDistance,
const zeus::CVector3f& sfxPos);
2017-07-30 01:06:06 +00:00
static CCameraShakeData BuildPhazonCameraShakeData(float duration, float magnitude);
2018-11-06 06:16:12 +00:00
static CCameraShakeData BuildPatternedExplodeShakeData(float duration, float magnitude);
static CCameraShakeData BuildPatternedExplodeShakeData(const zeus::CVector3f& pos, float duration,
float magnitude, float distance);
void Update(float dt, CStateManager& mgr);
zeus::CVector3f GetPoint() const;
2017-10-10 03:50:48 +00:00
float GetMaxAMComponent() const;
float GetMaxFMComponent() const;
void SetShakerId(u32 id) { xbc_shakerId = id; }
u32 GetShakerId() const { return xbc_shakerId; }
static CCameraShakeData LoadCameraShakeData(CInputStream& in);
2017-09-10 00:36:21 +00:00
void SetSfxPositionAndDistance(const zeus::CVector3f& pos, float f2)
{ xc0_flags |= 0x1; xc4_sfxPos = pos; xd0_sfxDist = f2; }
2016-04-16 23:48:29 +00:00
};
}