Skip to content

Commit c41c11f

Browse files
committed
Add FX Alignment options
1 parent 0bccfd4 commit c41c11f

File tree

1 file changed

+55
-3
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameClient

1 file changed

+55
-3
lines changed

GeneralsMD/Code/GameEngine/Source/GameClient/FXList.cpp

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,46 @@ static void adjustVector(Coord3D *vec, const Matrix3D* mtx)
7272
vec->z = vectmp.Z;
7373
}
7474
}
75+
//-------------------------------------------------------------------------------------------------
76+
static void adjustVectorXY(Coord3D* vec, const Matrix3D* mtx)
77+
{
78+
if (mtx)
79+
{
80+
//This can be optimized probably.
81+
82+
Coord3D u, x, y, z, pos;
83+
Matrix3D mat;
84+
Real angle = mtx->Get_Z_Rotation();
85+
86+
pos.x = mtx->Get_X_Translation();
87+
pos.y = mtx->Get_Y_Translation();
88+
pos.z = mtx->Get_Z_Translation();
89+
90+
z.x = 0.0f;
91+
z.y = 0.0f;
92+
z.z = 1.0f;
93+
94+
u.x = Cos(angle);
95+
u.y = Sin(angle);
96+
u.z = 0.0f;
97+
98+
y.crossProduct(&z, &u, &y);
99+
x.crossProduct(&y, &z, &x);
100+
101+
mat.Set(x.x, y.x, z.x, pos.x,
102+
x.y, y.y, z.y, pos.y,
103+
x.z, y.z, z.z, pos.z);
104+
105+
Vector3 vectmp;
106+
vectmp.X = vec->x;
107+
vectmp.Y = vec->y;
108+
vectmp.Z = vec->z;
109+
vectmp = mat.Rotate_Vector(vectmp);
110+
vec->x = vectmp.X;
111+
vec->y = vectmp.Y;
112+
vec->z = vectmp.Z;
113+
}
114+
}
75115

76116
///////////////////////////////////////////////////////////////////////////////////////////////////
77117
// PRIVATE CLASSES ///////////////////////////////////////////////////////////////////////////////////
@@ -572,6 +612,8 @@ class ParticleSystemFXNugget : public FXNugget
572612
{ "RotateY", INI::parseAngleReal, NULL, offsetof( ParticleSystemFXNugget, m_rotateY ) },
573613
{ "RotateZ", INI::parseAngleReal, NULL, offsetof( ParticleSystemFXNugget, m_rotateZ ) },
574614
{ "OrientToObject", INI::parseBool, NULL, offsetof( ParticleSystemFXNugget, m_orientToObject ) },
615+
{ "OrientOffset", INI::parseBool, NULL, offsetof( ParticleSystemFXNugget, m_orientOffset ) },
616+
{ "OrientXY", INI::parseBool, NULL, offsetof( ParticleSystemFXNugget, m_orientXY ) },
575617
{ "Ricochet", INI::parseBool, NULL, offsetof( ParticleSystemFXNugget, m_ricochet ) },
576618
{ "AttachToObject", INI::parseBool, NULL, offsetof( ParticleSystemFXNugget, m_attachToObject ) },
577619
{ "CreateAtGroundHeight", INI::parseBool, NULL, offsetof( ParticleSystemFXNugget, m_createAtGroundHeight ) },
@@ -589,9 +631,14 @@ class ParticleSystemFXNugget : public FXNugget
589631
void reallyDoFX(const Coord3D *primary, const Matrix3D* mtx, const Object* thingToAttachTo, Real overrideRadius ) const
590632
{
591633
Coord3D offset = m_offset;
592-
if (mtx)
593-
{
594-
adjustVector(&offset, mtx);
634+
if (mtx) {
635+
if (m_orientToObject || m_orientOffset)
636+
{
637+
adjustVector(&offset, mtx);
638+
}
639+
if (m_orientXY) {
640+
adjustVectorXY(&offset, mtx);
641+
}
595642
}
596643

597644
const ParticleSystemTemplate *tmp = TheParticleSystemManager->findTemplate(m_name);
@@ -626,6 +673,9 @@ class ParticleSystemFXNugget : public FXNugget
626673
{
627674
sys->setLocalTransform(mtx);
628675
}
676+
else if (m_orientXY) {
677+
sys->rotateLocalTransformZ(mtx->Get_Z_Rotation());
678+
}
629679
if (m_rotateX != 0.0f)
630680
sys->rotateLocalTransformX(m_rotateX);
631681
if (m_rotateY != 0.0f)
@@ -669,6 +719,8 @@ class ParticleSystemFXNugget : public FXNugget
669719
GameClientRandomVariable m_delay;
670720
Real m_rotateX, m_rotateY, m_rotateZ;
671721
Bool m_orientToObject;
722+
Bool m_orientOffset;
723+
Bool m_orientXY;
672724
Bool m_attachToObject;
673725
Bool m_createAtGroundHeight;
674726
Bool m_useCallersRadius;

0 commit comments

Comments
 (0)