I'm using LiquidFun to simulate water, it's a physics engine based on box2d that uses particles. My problem is when rendering the particles with a specific color.
what is the purpose of setting the particle color on it's particle definition? when you also have to set the color on which the particle is to be rendered on the ParticleDebugRenderer.
public void createWater(float x, float y){
ParticleDef def = new ParticleDef();
def.color.set(Color.Red); //set particle color
def.flags.add(ParticleDef.ParticleType.b2_tensileParticle);
def.flags.add(ParticleDef.ParticleType.b2_colorMixingParticle);
def.position.set(x, y);
int index = system.createParticle(def);
}
ParticleDebugRenderer:
pdr = new ParticleDebugRenderer(Color.BLUE, maxParticles); //set as BLUE
if I set the particle to be RED it would still be rendered in blue because the ParticleDebugRenderer is set to BLUE.
Looking at the source code we can find 2 renderers.
ParticleDebugRenderer.java and ColorParticleRenderer.java
The code difference between them is that ColorParticleRenderer gets color from ParticleSystem and ParticleDebugRenderer gets color from constuctor.
The main use difference is that we use ColorParticleRenderer everytime we are not debugging. ParticleDebugRenderer is the one to use when we want to debug a particle. We use it, because we don't want to make changes in colors at the definition of ParticleSystem, because
Your confusion comes from fact that you are using ParticleDebugRenderer when you are not debugging so you assign the same color twice.