Game Development Community

FIX: Inconsistent Wind Directions

by Jeff Faust · in Torque Game Engine Advanced · 10/21/2007 (8:04 pm) · 2 replies

The wind direction specified by the "windVelocity" field in the Sky object effects the direction that the cloud layers move and also influences the movement of particles (if windCoefficient is non-zero). In TGEA, the clouds interpret the wind-direction differently from the particles, negating the y component and thus mirroring the movement across the world's x-axis.

windVelocity already has a non-intuitive interpretation in TGE in that it is not the direction of the wind force but points in the direction the wind force is coming from. But at least it's interpreted consistently by the clouds and particles.

If you'd like your wind to effect your cloud movement and particle movement consistently, and also be consistent with how TGE interprets it, here is a possible fix. It goes in terrain/sky.cpp in the initSkyData() method at line 163:
void Sky::initSkyData()
{
   calcPoints();
   [b]mWindDir = Point2F(mWindVelocity.x, -mWindVelocity.y);   // <--NEW[/b]
   // mWindDir = Point2F(mWindVelocity.x, mWindVelocity.y); // <-- OLD
   mWindDir.normalize();
   for(S32 i = 0; i < MAX_NUM_LAYERS; ++i)
   {
      mCloudLayer[i].setHeights(mCloudHeight[i], mCloudHeight[i]-0.05f, 0.00f);
      mCloudLayer[i].setSpeed(mWindDir * mCloudSpeed[i]);
      mCloudLayer[i].setPoints();
   }
   setVisibility();
}
Just negate the y component of mWindVelocity when it's assigned to mWindDir.

About the author

Jeff Faust creates special effects indie middleware and games for Faust Logic. --- Blog: Effectronica.com --- Twitter: @FaustLogic


#1
10/22/2007 (9:26 am)
Another GL -> DX Port error ...
Looks like all Y calculations that are not for shaders, should be checked.

thanks for pointing that out.
#2
10/22/2007 (2:13 pm)
Consistency is good - fixed in repo. Thanks.