• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

### #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