• Create Account

Banner advertising on our site currently available from just \$5!

### #ActualMedo3337

Posted 17 May 2013 - 04:14 PM

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.

return vVector;
}

[attachment=15792:gr.png]

### #1Medo3337

Posted 17 May 2013 - 04:13 PM

Okay, I figured one step towards solving this problem:

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

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

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.