@Override public void simpleUpdate(float tpf){ time += tpf; if (time > 1f){ time -= 1f; prevColor = nextColor; nextColor = ColorRGBA.randomColor(); } ColorRGBA currentColor = new ColorRGBA(); currentColor.interpolateLocal(prevColor, nextColor, time); mat.setColor("Color", currentColor); }
protected void updateParticle(Particle p, float tpf, Vector3f min, Vector3f max){ // applying gravity p.velocity.x -= gravity.x * tpf; p.velocity.y -= gravity.y * tpf; p.velocity.z -= gravity.z * tpf; temp.set(p.velocity).multLocal(tpf); p.position.addLocal(temp); // affecting color, size and angle float b = (p.startlife - p.life) / p.startlife; p.color.interpolateLocal(startColor, endColor, b); p.size = FastMath.interpolateLinear(b, startSize, endSize); p.angle += p.rotateSpeed * tpf; // Computing bounding volume temp.set(p.position).addLocal(p.size, p.size, p.size); max.maxLocal(temp); temp.set(p.position).subtractLocal(p.size, p.size, p.size); min.minLocal(temp); if (!selectRandomImage) { p.imageIndex = (int) (b * imagesX * imagesY); } }
private static ColorRGBA mix( ColorRGBA c1, ColorRGBA c2 ) { if( c1 == null && c2 == null ) { return null; } if( c1 == null ) { return c2; } if( c2 == null ) { return c1; } return c1.clone().interpolateLocal(c2, 0.5f); }
protected void updateParticle(Particle p, float tpf, Vector3f min, Vector3f max){ // applying gravity p.velocity.x -= gravity.x * tpf; p.velocity.y -= gravity.y * tpf; p.velocity.z -= gravity.z * tpf; temp.set(p.velocity).multLocal(tpf); p.position.addLocal(temp); // affecting color, size and angle float b = (p.startlife - p.life) / p.startlife; p.color.interpolateLocal(startColor, endColor, b); p.size = FastMath.interpolateLinear(b, startSize, endSize); p.angle += p.rotateSpeed * tpf; // Computing bounding volume temp.set(p.position).addLocal(p.size, p.size, p.size); max.maxLocal(temp); temp.set(p.position).subtractLocal(p.size, p.size, p.size); min.minLocal(temp); if (!selectRandomImage) { p.imageIndex = (int) (b * imagesX * imagesY); } }