private void regenerateParticle(MovingParticle p) { // Generate random particle float cutOff = (float) Math.random() * cone.getCutOff(); float angle = (float) Math.random() * 2 * (float) Math.PI; float speed = (float) Math.random() * 5f + 1.5f; // Particle direction Quaternion4f rot = cone.getOrientation() .clone() .multiply(Quaternion4f.fromAxisAngle(0, 0, 1, angle)) .multiply(Quaternion4f.fromAxisAngle(1, 0, 0, (float) Math.toRadians(cutOff))); // Calculate position/speed p.position = cone.getPosition().clone(); p.speed = rot.rotate(new Vector3f(0, 0, speed)); }