ParticleControler particle directions

hello @zarch,

using ParticleController i try to orient particles with an influencer like the regular particle system allows to orient particles
i try to have sparks that need to be alligned toward the velocity vector ( toward the center of geometry)

but i cant make it work

rotation and rotationVelocity have no apparent effect

[java]
@Override
public void influenceParticleCreation(ParticleController ctrl, int index, ParticleData data) {
data.velocity.multLocal(0);
data.velocity.addLocal(data.position.mult(startSpeed));
data.rotationalVelocity.addLocal(0.1f,0.1f,0.1f);
//data.rotation.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
}

@Override
public void influenceParticle(ParticleController ctrl, int index, ParticleData data, float tpf) {

// data.velocity.normalizeLocal().multLocal(FastMath.interpolateLinear(data.lifeProgress, startSpeed, endSpeed));
data.velocity.multLocal(0);
data.velocity.addLocal(data.position.mult(startSpeed));
data.rotationalVelocity.addLocal(0.1f,0.1f,0.1f);
//data.rotation.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
}
[/java]

also the fact that velocity is a final variable makes it hard to assign a new value ( only my opinion :slight_smile: )

can you help me out ?

thx

You need to use a QuadMesh and either set the billboard mode to USE_PARTICLE_ROTATION if you want to see the rotation from your influencer or the alternative is to not use the influencer at all and simply use the billboard mode VELOCITY or VELOCITY_Z_UP.

Velocity is final for three reasons:

  1. It prevents a lot of bad accidental bugs. For example if someone did ParticleData.velocity = Vector3f.ZERO - then that would seem to work but in fact the particle data now contains the Vector3f.ZERO vector and changes to the particle are now changing that core Vector3f!
  2. It prevents crashes due to people setting it to null or whatever
  3. It saves on resources by preventing people creating new vector3f just to modify the data

To zero it just do data.velocity.set(0,0,0) or data.velocity.set(Vector3f.ZERO)

Hope that helps :slight_smile:

[java]
data.velocity.multLocal(0);
data.velocity.addLocal(data.position.mult(startSpeed));
[/java]

This could much better be done as:

[java]
data.position.mult(startSpeed, data.velocity);
[/java]

<cite>@zarch said:</cite> [java] data.velocity.multLocal(0); data.velocity.addLocal(data.position.mult(startSpeed)); [/java]

This could much better be done as:

[java]
data.position.mult(startSpeed, data.velocity);
[/java]

thx :slight_smile: