• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualMedo3337

Posted 18 May 2013 - 03:53 PM

Can you provide a little bit of code so I can understand you better?

Here is how I generate a new particle:

void generateNewParticle()
{
// ...
D3DXVECTOR3 randVec = GetRandomVector();
particle.velocity += randVec * velocity_var;
particle.position = particle.velocity;
// Code to add the particle to the list here...
}

D3DXVECTOR3 GetRandomVector()
{
D3DXVECTOR3 vVector;

// Pick a random Z between -1.0f and 1.0f.
vVector.z = GetRandMinMax( -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;
}

Here is how I draw the sparks every frame:

RenderSingleLine( particle.position, particle.position - particle.velocity * lineLength );

I'm not really good in mathematics.

Now, I'm trying to change the code to make the spark lines look at the moving direction instantly after they get generated.

### #3Medo3337

Posted 18 May 2013 - 03:52 PM

Can you provide a little bit of code so I can understand you better?

Here is how I generate a new particle:

void generateNewParticle()
{
// ...
D3DXVECTOR3 randVec = GetRandomVector();
particle.velocity += randVec * velocity_var;
particle.position = particle.velocity;
// Code to add the particle to the list here...
}

D3DXVECTOR3 GetRandomVector()
{
D3DXVECTOR3 vVector;

// Pick a random Z between -1.0f and 1.0f.
vVector.z = GetRandMinMax( -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;
}

Here is how I draw the sparks every frame:

RenderSingleLine( particle.position, particle.position - particle.velocity * lineLength );

I'm not really good in mathematics.

Now, I'm trying to change the code to make the spark lines look at the moving direction instantly after they get generated.

### #2Medo3337

Posted 18 May 2013 - 03:50 PM

Can you provide a little bit of code so I can understand you better?

Here is how I generate a new particle:

void generateNewParticle()
{
// ...
D3DXVECTOR3 randVec = GetRandomVector();
particle.velocity += randVec * velocity_var;
particle.position = particle.velocity;
// Code to add the particle to the list here...
}

D3DXVECTOR3 GetRandomVector()
{
D3DXVECTOR3 vVector;

// Pick a random Z between -1.0f and 1.0f.
vVector.z = GetRandMinMax( -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;
}

Here is how I draw the sparks every frame:

RenderSingleLine( particle.position, particle.position - particle.velocity * lineLength );

I'm not really good in mathematics.

### #1Medo3337

Posted 18 May 2013 - 03:49 PM

Can you provide a little bit of code so I can understand you better?

Here is how I generate a new particle:

void generateNewParticle()
{
// ...
D3DXVECTOR3 randVec = GetRandomVector();
particle.velocity += randVec * velocity_var;
particle.position = particle.velocity;
// Code to add the particle to the list here...
}

D3DXVECTOR3 GetRandomVector()
{
D3DXVECTOR3 vVector;

// Pick a random Z between -1.0f and 1.0f.
vVector.z = GetRandMinMax( -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;
}

Here is how I draw the sparks every frame:

RenderSingleLine( particle.position, particle.position - particle.velocity * lineLength );

I'm not really good in mathematics.

PARTNERS