mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 03:47:43 +00:00
Humungous refactor
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
#include "CParticleGlobals.hpp"
|
||||
#include "CRandom16.hpp"
|
||||
#include "CElementGen.hpp"
|
||||
#include <math.h>
|
||||
#include "zeus/Math.hpp"
|
||||
|
||||
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Vector_Elements */
|
||||
|
||||
namespace pshag
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CVEKeyframeEmitter::CVEKeyframeEmitter(CInputStream& in)
|
||||
@@ -24,7 +24,7 @@ CVEKeyframeEmitter::CVEKeyframeEmitter(CInputStream& in)
|
||||
x18_keys.push_back(in.readVec3fBig());
|
||||
}
|
||||
|
||||
bool CVEKeyframeEmitter::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVEKeyframeEmitter::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
if (!x4_percent)
|
||||
{
|
||||
@@ -63,21 +63,21 @@ bool CVEKeyframeEmitter::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
CVECone::CVECone(CVectorElement* a, CRealElement* b)
|
||||
: x4_direction(a), x8_magnitude(b)
|
||||
{
|
||||
Zeus::CVector3f av;
|
||||
zeus::CVector3f av;
|
||||
x4_direction->GetValue(0, av);
|
||||
av.normalize();
|
||||
if (av[0] > 0.8)
|
||||
xc_xVec = av.cross(Zeus::CVector3f(0.f, 1.f, 0.f));
|
||||
xc_xVec = av.cross(zeus::CVector3f(0.f, 1.f, 0.f));
|
||||
else
|
||||
xc_xVec = av.cross(Zeus::CVector3f(1.f, 0.f, 0.f));
|
||||
xc_xVec = av.cross(zeus::CVector3f(1.f, 0.f, 0.f));
|
||||
x18_yVec = av.cross(xc_xVec);
|
||||
}
|
||||
|
||||
bool CVECone::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVECone::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
float b;
|
||||
x8_magnitude->GetValue(frame, b);
|
||||
Zeus::CVector3f dir;
|
||||
zeus::CVector3f dir;
|
||||
x4_direction->GetValue(frame, dir);
|
||||
float b2 = std::min(1.f, b);
|
||||
|
||||
@@ -94,7 +94,7 @@ bool CVECone::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVETimeChain::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVETimeChain::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
int v;
|
||||
xc_swFrame->GetValue(frame, v);
|
||||
@@ -104,7 +104,7 @@ bool CVETimeChain::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
return x4_a->GetValue(frame, valOut);
|
||||
}
|
||||
|
||||
bool CVEAngleCone::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVEAngleCone::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
float xc, yc, xr, yr;
|
||||
x4_angleXConstant->GetValue(frame, xc);
|
||||
@@ -113,22 +113,22 @@ bool CVEAngleCone::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
x10_angleYRange->GetValue(frame, yr);
|
||||
|
||||
float xtmp = CRandom16::GetRandomNumber()->Float() * xr;
|
||||
float xang = (0.5f * xr - xtmp + xc) * M_PI / 180.f;
|
||||
float xang = zeus::degToRad(0.5f * xr - xtmp + xc);
|
||||
|
||||
float ytmp = CRandom16::GetRandomNumber()->Float() * yr;
|
||||
float yang = (0.5f * yr - ytmp + yc) * M_PI / 180.f;
|
||||
float yang = zeus::degToRad(0.5f * yr - ytmp + yc);
|
||||
|
||||
float mag;
|
||||
x14_magnitude->GetValue(frame, mag);
|
||||
|
||||
/* This takes a +Z vector and rotates it around X and Y axis (like a rotation matrix would) */
|
||||
valOut = Zeus::CVector3f(cosf(xang) * -sinf(yang), sinf(xang), cosf(xang) * cosf(yang)) * Zeus::CVector3f(mag);
|
||||
valOut = zeus::CVector3f(std::cos(xang) * -std::sin(yang), std::sin(xang), std::cos(xang) * std::cos(yang)) * zeus::CVector3f(mag);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEAdd::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVEAdd::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
Zeus::CVector3f a, b;
|
||||
zeus::CVector3f a, b;
|
||||
x4_a->GetValue(frame, a);
|
||||
x8_b->GetValue(frame, b);
|
||||
valOut = a + b;
|
||||
@@ -140,36 +140,36 @@ CVECircleCluster::CVECircleCluster(CVectorElement* a, CVectorElement* b, CIntEle
|
||||
{
|
||||
int cv;
|
||||
c->GetValue(0, cv);
|
||||
x20_deltaAngle = 360.f / float(cv) * M_PI / 180.f;
|
||||
x20_deltaAngle = zeus::degToRad(360.f / float(cv));
|
||||
|
||||
Zeus::CVector3f bv;
|
||||
zeus::CVector3f bv;
|
||||
b->GetValue(0, bv);
|
||||
bv.normalize();
|
||||
if (bv[0] > 0.8)
|
||||
x8_xVec = bv.cross(Zeus::CVector3f(0.f, 1.f, 0.f));
|
||||
if (bv[0] > 0.8f)
|
||||
x8_xVec = bv.cross(zeus::CVector3f(0.f, 1.f, 0.f));
|
||||
else
|
||||
x8_xVec = bv.cross(Zeus::CVector3f(1.f, 0.f, 0.f));
|
||||
x8_xVec = bv.cross(zeus::CVector3f(1.f, 0.f, 0.f));
|
||||
x14_yVec = bv.cross(x8_xVec);
|
||||
|
||||
delete b;
|
||||
delete c;
|
||||
}
|
||||
|
||||
bool CVECircleCluster::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVECircleCluster::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
Zeus::CVector3f av;
|
||||
zeus::CVector3f av;
|
||||
x4_a->GetValue(frame, av);
|
||||
|
||||
float curAngle = frame * x20_deltaAngle;
|
||||
Zeus::CVector3f x = x8_xVec * cosf(curAngle);
|
||||
Zeus::CVector3f y = x14_yVec * sinf(curAngle);
|
||||
Zeus::CVector3f tv = x + y + av;
|
||||
zeus::CVector3f x = x8_xVec * std::cos(curAngle);
|
||||
zeus::CVector3f y = x14_yVec * std::sin(curAngle);
|
||||
zeus::CVector3f tv = x + y + av;
|
||||
|
||||
float dv;
|
||||
x24_magnitude->GetValue(frame, dv);
|
||||
|
||||
Zeus::CVector3f magVec(dv * tv.magnitude());
|
||||
Zeus::CVector3f rv = magVec * Zeus::CVector3f(CRandom16::GetRandomNumber()->Float(),
|
||||
zeus::CVector3f magVec(dv * tv.magnitude());
|
||||
zeus::CVector3f rv = magVec * zeus::CVector3f(CRandom16::GetRandomNumber()->Float(),
|
||||
CRandom16::GetRandomNumber()->Float(),
|
||||
CRandom16::GetRandomNumber()->Float());
|
||||
|
||||
@@ -177,17 +177,17 @@ bool CVECircleCluster::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEConstant::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVEConstant::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
float a, b, c;
|
||||
x4_a->GetValue(frame, a);
|
||||
x8_b->GetValue(frame, b);
|
||||
xc_c->GetValue(frame, c);
|
||||
valOut = Zeus::CVector3f(a, b, c);
|
||||
valOut = zeus::CVector3f(a, b, c);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEFastConstant::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVEFastConstant::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
valOut = x4_val;
|
||||
return false;
|
||||
@@ -196,54 +196,54 @@ bool CVEFastConstant::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
CVECircle::CVECircle(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, CRealElement* e)
|
||||
: x4_direction(a), x20_angleConstant(c), x24_angleLinear(d), x28_radius(e)
|
||||
{
|
||||
Zeus::CVector3f bv;
|
||||
zeus::CVector3f bv;
|
||||
b->GetValue(0, bv);
|
||||
bv.normalize();
|
||||
if (bv[0] > 0.8)
|
||||
x8_xVec = bv.cross(Zeus::CVector3f(0.f, 1.f, 0.f));
|
||||
if (bv[0] > 0.8f)
|
||||
x8_xVec = bv.cross(zeus::CVector3f(0.f, 1.f, 0.f));
|
||||
else
|
||||
x8_xVec = bv.cross(Zeus::CVector3f(1.f, 0.f, 0.f));
|
||||
x8_xVec = bv.cross(zeus::CVector3f(1.f, 0.f, 0.f));
|
||||
x14_yVec = bv.cross(x8_xVec);
|
||||
delete b;
|
||||
}
|
||||
|
||||
bool CVECircle::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVECircle::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
float c, d, e;
|
||||
x20_angleConstant->GetValue(frame, c);
|
||||
x24_angleLinear->GetValue(frame, d);
|
||||
x28_radius->GetValue(frame, e);
|
||||
|
||||
float curAngle = (d * frame + c) * M_PI / 180.f;
|
||||
float curAngle = zeus::degToRad(d * frame + c);
|
||||
|
||||
Zeus::CVector3f av;
|
||||
zeus::CVector3f av;
|
||||
x4_direction->GetValue(frame, av);
|
||||
|
||||
Zeus::CVector3f x = x8_xVec * e * cosf(curAngle);
|
||||
Zeus::CVector3f y = x14_yVec * e * sinf(curAngle);
|
||||
zeus::CVector3f x = x8_xVec * e * std::cos(curAngle);
|
||||
zeus::CVector3f y = x14_yVec * e * std::sin(curAngle);
|
||||
|
||||
valOut = x + y + av;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEMultiply::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVEMultiply::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
Zeus::CVector3f a, b;
|
||||
zeus::CVector3f a, b;
|
||||
x4_a->GetValue(frame, a);
|
||||
x8_b->GetValue(frame, b);
|
||||
valOut = a * b;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVERealToVector::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVERealToVector::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
float a;
|
||||
x4_a->GetValue(frame, a);
|
||||
valOut = Zeus::CVector3f(a);
|
||||
valOut = zeus::CVector3f(a);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEPulse::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVEPulse::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
int a, b;
|
||||
x4_aDuration->GetValue(frame, a);
|
||||
@@ -264,71 +264,71 @@ bool CVEPulse::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEParticleVelocity::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
|
||||
bool CVEParticleVelocity::GetValue(int /*frame*/, zeus::CVector3f& valOut) const
|
||||
{
|
||||
valOut = CElementGen::g_currentParticle->x1c_vel;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEPLCO::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
|
||||
bool CVEPLCO::GetValue(int /*frame*/, zeus::CVector3f& valOut) const
|
||||
{
|
||||
valOut = CElementGen::g_currentParticle->x10_prevPos;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEPLOC::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
|
||||
bool CVEPLOC::GetValue(int /*frame*/, zeus::CVector3f& valOut) const
|
||||
{
|
||||
valOut = CElementGen::g_currentParticle->x4_pos;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEPSOF::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
|
||||
bool CVEPSOF::GetValue(int /*frame*/, zeus::CVector3f& valOut) const
|
||||
{
|
||||
Zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation();
|
||||
zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation();
|
||||
valOut.x = trans.m_basis[0].y;
|
||||
valOut.y = trans.m_basis[1].z;
|
||||
valOut.z = trans.m_origin.x;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEPSOU::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
|
||||
bool CVEPSOU::GetValue(int /*frame*/, zeus::CVector3f& valOut) const
|
||||
{
|
||||
Zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation();
|
||||
zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation();
|
||||
valOut.x = trans.m_basis[0].z;
|
||||
valOut.y = trans.m_basis[1].x;
|
||||
valOut.z = trans.m_origin.y;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEPSOR::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
|
||||
bool CVEPSOR::GetValue(int /*frame*/, zeus::CVector3f& valOut) const
|
||||
{
|
||||
Zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation();
|
||||
zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation();
|
||||
valOut.x = trans.m_basis[0].x;
|
||||
valOut.y = trans.m_basis[1].y;
|
||||
valOut.z = trans.m_basis[2].z;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEPSTR::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
|
||||
bool CVEPSTR::GetValue(int /*frame*/, zeus::CVector3f& valOut) const
|
||||
{
|
||||
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetTranslation();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVESubtract::GetValue(int frame, Zeus::CVector3f& valOut) const
|
||||
bool CVESubtract::GetValue(int frame, zeus::CVector3f& valOut) const
|
||||
{
|
||||
Zeus::CVector3f a, b;
|
||||
zeus::CVector3f a, b;
|
||||
x4_a->GetValue(frame, a);
|
||||
x8_b->GetValue(frame, b);
|
||||
valOut = a - b;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVEColorToVector::GetValue(int frame, Zeus::CVector3f &valOut) const
|
||||
bool CVEColorToVector::GetValue(int frame, zeus::CVector3f &valOut) const
|
||||
{
|
||||
Zeus::CColor val = {0.0, 0.0, 0.0, 1.0};
|
||||
zeus::CColor val = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
x4_a->GetValue(frame, val);
|
||||
valOut = Zeus::CVector3f{val.r, val.g, val.b};
|
||||
valOut = zeus::CVector3f{val.r, val.g, val.b};
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user