Sparks Animation

Started by
11 comments, last by GameDev.net 10 years, 11 months ago

Okay, I figured one step towards solving this problem:

How do I modify the following code to make it generate a random vector looking at or close the direction of gravity?

Basically, I want the particle random vector to be limited to the half circle of the direction of the gravity

I think the line following line should be modified:

float t = getRandMinMax( -D3DX_PI, D3DX_PI ); // I want to limit this circle

D3DXVECTOR3 getRandVector(D3DXVECTOR3 gravity)
{
D3DXVECTOR3 vVector;
// Pick a random Z between -1.0f and 1.0f.
vVector.z = GetRandomMinMax( -1.0f, 1.0f );
// Get radius of this circle
float radius = (float)sqrt(1 - vVector.z * vVector.z);
// Pick a random point on a circle.
float t = getRandMinMax( -D3DX_PI, D3DX_PI );
// Compute matching X and Y for our Z.
vVector.x = (float)cosf(t) * radius;
vVector.y = (float)sinf(t) * radius;
return vVector;
}
[attachment=15792:gr.png]

Advertisement

Up.

Sorry, went out of town. Will reply in the other thread shortly...

This topic is closed to new replies.

Advertisement