metaforce/Runtime/Particle/CEmitterElement.cpp

79 lines
2.2 KiB
C++
Raw Normal View History

2016-02-16 05:50:41 +00:00
#include "CEmitterElement.hpp"
2016-02-16 10:03:08 +00:00
#include "CRandom16.hpp"
2016-02-16 05:50:41 +00:00
2016-02-28 06:55:05 +00:00
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Emitter_Elements */
2016-03-04 23:04:53 +00:00
namespace urde
2016-02-16 05:50:41 +00:00
{
2016-03-04 23:04:53 +00:00
bool CEESimpleEmitter::GetValue(int frame, zeus::CVector3f& pPos, zeus::CVector3f& pVel) const
2016-02-16 05:50:41 +00:00
{
2016-02-16 10:03:08 +00:00
x4_loc->GetValue(frame, pPos);
if (x8_vec)
x8_vec->GetValue(frame, pVel);
else
2016-03-04 23:04:53 +00:00
pVel = zeus::CVector3f();
2016-02-16 10:03:08 +00:00
2016-02-16 07:01:55 +00:00
return false;
2016-02-16 05:50:41 +00:00
}
2016-03-04 23:04:53 +00:00
bool CVESphere::GetValue(int frame, zeus::CVector3f& pPos, zeus::CVector3f& pVel) const
2016-02-16 05:50:41 +00:00
{
2016-03-04 23:04:53 +00:00
zeus::CVector3f a;
2016-02-29 03:03:11 +00:00
x4_sphereOrigin->GetValue(frame, a);
2016-02-16 10:03:08 +00:00
float b;
2016-02-29 03:03:11 +00:00
x8_sphereRadius->GetValue(frame, b);
2016-02-16 10:03:08 +00:00
CRandom16* rand = CRandom16::GetRandomNumber();
int rand1 = rand->Range(-100, 100);
int rand2 = rand->Range(-100, 100);
int rand3 = rand->Range(-100, 100);
2016-03-04 23:04:53 +00:00
zeus::CVector3f normVec1 = zeus::CVector3f(0.0099999998f * float(rand3),
2016-02-16 10:03:08 +00:00
0.0099999998f * float(rand2),
0.0099999998f * float(rand1));
if (normVec1.canBeNormalized())
normVec1.normalize();
pPos = b * normVec1 + a;
2016-03-04 23:04:53 +00:00
zeus::CVector3f normVec2 = (pPos - a);
2016-02-16 10:03:08 +00:00
if (normVec2.canBeNormalized())
normVec2.normalize();
float c;
2016-02-29 03:03:11 +00:00
xc_velocityMag->GetValue(frame, c);
2016-02-16 10:03:08 +00:00
pVel = c * normVec2;
2016-02-16 07:01:55 +00:00
return false;
2016-02-16 05:50:41 +00:00
}
2016-03-04 23:04:53 +00:00
bool CVEAngleSphere::GetValue(int frame, zeus::CVector3f& pPos, zeus::CVector3f& pVel) const
2016-02-16 05:50:41 +00:00
{
2016-03-04 23:04:53 +00:00
zeus::CVector3f a;
2016-02-29 03:03:11 +00:00
x4_sphereOrigin->GetValue(frame, a);
2016-02-16 10:03:08 +00:00
float b, d, e, f, g;
2016-02-29 03:03:11 +00:00
x8_sphereRadius->GetValue(frame, b);
x10_angleXBias->GetValue(frame, d);
x14_angleYBias->GetValue(frame, e);
x18_angleXRange->GetValue(frame, f);
x1c_angleYRange->GetValue(frame, g);
2016-02-16 10:03:08 +00:00
CRandom16* rand = CRandom16::GetRandomNumber();
2016-03-04 23:04:53 +00:00
d = zeus::degToRad(d + ((0.5f * (f * rand->Float())) - f));
e = zeus::degToRad(e + ((0.5f * (g * rand->Float())) - g));
2016-02-16 10:03:08 +00:00
2016-03-04 23:04:53 +00:00
float cosD = zeus::fastCosF(d);
pPos.x = a.x + (b * (-zeus::fastSinF(e) * cosD));
pPos.y = a.y + (b * zeus::fastSinF(d));
2016-02-16 10:03:08 +00:00
pPos.z = a.z + (b * (cosD * cosD));
2016-03-04 23:04:53 +00:00
zeus::CVector3f normVec = (pPos - a).normalized();
2016-02-16 10:03:08 +00:00
float c;
2016-02-29 03:03:11 +00:00
xc_velocityMag->GetValue(frame, c);
2016-02-16 10:03:08 +00:00
pVel = c * normVec;
2016-02-16 07:01:55 +00:00
return false;
2016-02-16 05:50:41 +00:00
}
}