FIX: fast spinning sun flares
by Jeff Faust · in Torque Game Engine Advanced · 10/19/2007 (1:12 pm) · 1 replies
I've been seeing this problem for months... the sun flares are spinning way too fast.
Just recently I finally stumbled across this area of code, noticed the problem, and made the easy fix. The problem is that the flares used glrotatef() to do the work in TGE and glrotatef() takes the rotational angle in degrees. The replacement code in TGEA requires the angle in radians but did not convert the value. Degrees are being interpreted as radians and the flares rotate incorrectly.
Here's the fixed code found in engine/game/fx/fxSunlight.cpp in the renderObject() method around line 1878:
I have not yet compared closely with TGE sun flares to see if the TGEA sun flares are spinning in the same direction and orient the flare image the same, but the speed does seem to be about right now.
Just recently I finally stumbled across this area of code, noticed the problem, and made the easy fix. The problem is that the flares used glrotatef() to do the work in TGE and glrotatef() takes the rotational angle in degrees. The replacement code in TGEA requires the angle in radians but did not convert the value. Degrees are being interpreted as radians and the flares rotate incorrectly.
Here's the fixed code found in engine/game/fx/fxSunlight.cpp in the renderObject() method around line 1878:
// Initialize points with basic info
Point3F points[4];
points[0] = Point3F(-BBRadius, 0.0, -BBRadius);
points[1] = Point3F( BBRadius, 0.0, -BBRadius);
points[2] = Point3F( BBRadius, 0.0, BBRadius);
points[3] = Point3F(-BBRadius, 0.0, BBRadius);
// Get info we need to adjust points
MatrixF camView = GFX->getWorldMatrix();
camView.transpose();
F32 sy, cy;
mSinCos([b]mDegToRad([/b]mAnimationRotation[b])[/b], sy, cy); [b]// FIX HERE[/b]
// Finalize points
for(int i = 0; i < 4; i++)
{
// rotate
points[i].set(cy * points[i].x - sy * points[i].z, 0.0, sy * points[i].x + cy * points[i].z);
// align with camera
camView.mulP(points[i]);
// offset
points[i] += mSunlightPosition;
}All you have to do is wrap mAnimationRotation inside a call to mDegToRad().I have not yet compared closely with TGE sun flares to see if the TGEA sun flares are spinning in the same direction and orient the flare image the same, but the speed does seem to be about right now.
About the author
Jeff Faust creates special effects indie middleware and games for Faust Logic. --- Blog: Effectronica.com --- Twitter: @FaustLogic
Torque Owner asmaloney (Andy)
Default Studio Name