Cloud direction question.
by Gary Preston · in Torque Game Engine · 07/12/2005 (5:03 am) · 8 replies
I'm having a few problems with clouds/wind direction and projectiles. The wind velocity effects projectiles motion so for example if we have a wind coming from [44 0] projectiles will blown onto a heading of [-44 0].
In the above example, when I run TGE with the wind velocity set to [44 0] the clouds move on a heading of [-44 0] and projectiles are blown onto [-44 0] as expected. (it seems unless I've missunderstood this post, that wind velocity specifys where the wind comes from not where its heading, which this example agrees with).
However, when the wind velocity is set to [0 44] based on the previous example, I would expect the clouds and projectiles to have a heading of [0 -44]. This doesn't happen. Instead clouds take a heading of [0,44] whilst projectiles head [0,-44]. The clouds are now travelling the same direction as the wind velocity, unlike in the first example where they travelled opposite.
So when the wind velocity is blowing along the X axis. Both cloud and projectiles will head in the same direction. However when the wind blows along the Y axis, both clouds and projectiles head in different directions. The clouds appear to travel in the direction of the wind velocity along the Y axis, yet travel the inverse of the wind velocity on the X axis.
Does anyone have any idea what may be causing this? Even if we compleatly take projectiles out of the equation and just use the world editor to check which direction the clouds are travelling in when we set the velocity down the X or Y axis, it does not appear to be consistant.
I've spent a day or two working through everything, to see whether there is a problem or what it is I'm misunderstanding. But for the life of me I can't see it. I'm sure its something obvious, maybe I can't see the woods for the trees at this point.
I've assumed Z is 0 in all the above cases btw.
In the above example, when I run TGE with the wind velocity set to [44 0] the clouds move on a heading of [-44 0] and projectiles are blown onto [-44 0] as expected. (it seems unless I've missunderstood this post, that wind velocity specifys where the wind comes from not where its heading, which this example agrees with).
However, when the wind velocity is set to [0 44] based on the previous example, I would expect the clouds and projectiles to have a heading of [0 -44]. This doesn't happen. Instead clouds take a heading of [0,44] whilst projectiles head [0,-44]. The clouds are now travelling the same direction as the wind velocity, unlike in the first example where they travelled opposite.
So when the wind velocity is blowing along the X axis. Both cloud and projectiles will head in the same direction. However when the wind blows along the Y axis, both clouds and projectiles head in different directions. The clouds appear to travel in the direction of the wind velocity along the Y axis, yet travel the inverse of the wind velocity on the X axis.
Does anyone have any idea what may be causing this? Even if we compleatly take projectiles out of the equation and just use the world editor to check which direction the clouds are travelling in when we set the velocity down the X or Y axis, it does not appear to be consistant.
I've spent a day or two working through everything, to see whether there is a problem or what it is I'm misunderstanding. But for the life of me I can't see it. I'm sure its something obvious, maybe I can't see the woods for the trees at this point.
I've assumed Z is 0 in all the above cases btw.
#2
07/12/2005 (6:45 am)
The rain thread (if you're refering to the one I linked to in my post) is a different problem from what I can see. It was down to a misunderstanding between what the wind velocity vector represented. One person had coded it to be the direction the wind came from whilst the other the direction the wind goes to (which would be opposite directions). Although this is something I've dealt with in the case of projectiles, it still doesn't resolve the problem above.
#3
But what i understand you use the projectiles effect by wind resource.
Check this one against the precipitation code and see how it gets the windvelocity from the sky.
07/12/2005 (7:17 am)
Ok sorry didnt know that.But what i understand you use the projectiles effect by wind resource.
Check this one against the precipitation code and see how it gets the windvelocity from the sky.
#4
Now try Sky.setWindVelocity(0,44,0); Rather than going from top to bottom down the negative Y axis, they go up it.
To resolve this I've modified the cloud render code so that it cycles the Y axis of the texture opposite to what it does by default in TGE. In SKy.cc around line 1433 look for
and replace it with
Now the clouds always move in the correct direction coming from the direction specified in wind velocity. Alternativly setting
will cause the clouds to head in the direction specified in wind velocity. Although that may then require changes to precipitation and anything else that uses wind velocity depending upon their interpretation of what direction wind velocity represents. I'm going to run through precipitation and the particle engine to check that rain and smoke travel in the same direction as the clouds do, now that projectiles and clouds finally go the same way :)
07/12/2005 (8:34 am)
After a bit more testing, if you enter the game with a player and orient your player facing down the +Y axis. Then type Sky.setWindVelocity(44,0,0); the clouds move from right to left, eg down the negative X axis. Sky.setWindVelocity(-44,0,0); moves the clouds left to right down +ve X.Now try Sky.setWindVelocity(0,44,0); Rather than going from top to bottom down the negative Y axis, they go up it.
To resolve this I've modified the cloud render code so that it cycles the Y axis of the texture opposite to what it does by default in TGE. In SKy.cc around line 1433 look for
for(S32 x = 0; x < 5; x++)
for(S32 y = 0; y < 5; y++)
mTexCoords[y * 5 + x].set ( x * mTextureScale.x + mBaseOffset.x,
y * mTextureScale.y + mBaseOffset.y);and replace it with
for(S32 x = 0; x < 5; x++)
for(S32 y = 0; y < 5; y++)
mTexCoords[y * 5 + x].set ( x * mTextureScale.x + mBaseOffset.x,
y * mTextureScale.y - mBaseOffset.y);Now the clouds always move in the correct direction coming from the direction specified in wind velocity. Alternativly setting
for(S32 x = 0; x < 5; x++)
for(S32 y = 0; y < 5; y++)
mTexCoords[y * 5 + x].set ( x * mTextureScale.x - mBaseOffset.x,
y * mTextureScale.y + mBaseOffset.y);will cause the clouds to head in the direction specified in wind velocity. Although that may then require changes to precipitation and anything else that uses wind velocity depending upon their interpretation of what direction wind velocity represents. I'm going to run through precipitation and the particle engine to check that rain and smoke travel in the same direction as the clouds do, now that projectiles and clouds finally go the same way :)
#5
when you change the y axis.
So thanks for the fix !
07/12/2005 (9:16 am)
I think you are right here, even the emitters moves in reverse direction compared to the clouds.when you change the y axis.
So thanks for the fix !
#6
07/12/2005 (6:32 pm)
Interested. Noted under issue #144.
#7
07/12/2005 (6:52 pm)
Glad you got this problem sorted out, Gary. So it was the cloud/sky code after all?
#8
08/08/2005 (10:01 pm)
In trunk now. Thanks guys!
Torque 3D Owner Billy L
Try to search for that fix and i think you can fix the projectile bugg to .