SHARE
TWEET

Particle System Definition

a guest Mar 10th, 2015 201 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Spawn between 300 and 400 particles per second
  2. partsys.emitter.spawnRateMin = 300.0f;
  3. partsys.emitter.spawnRateMax = 400.0f;
  4.  
  5. //=====================================================================================================================
  6. // Generators determine the initial attributes of the particles
  7. //=====================================================================================================================
  8.  
  9. partsys.generators.add(new RandomEnergyGenerator(6, 7)); // Particles live between 6 and 7 seconds.
  10.  
  11. // For the position and velocity, use random values between a min and max coordinate value.
  12. partsys.generators.add(new MinMaxPositionGenerator(new Vector3f(-0.2f, -0.2f, -0.2f), new Vector3f(0.2f, 0.2f, 0.2f)));
  13. partsys.generators.add(new MinMaxVelocityGenerator(new Vector3f(-1f, 0.5f, -1f), new Vector3f(+1f, 2.0f, +1f)));
  14.  
  15. //=====================================================================================================================
  16. // Affectors determine how the attributes change over time
  17. //=====================================================================================================================
  18.  
  19. partsys.affectors.add(new ForwardEulerAffector());                         // enables simple physics
  20. partsys.affectors.add(new StaticForceAffector(new Vector3f(0, 0.25f, 0))); // adds upward force
  21. partsys.affectors.add(new DampingAffector(0.6f));                          // simulates air friction                               
  22.  
  23. // The following defines and adds a multi-key RGBA gradient, so the colors change over time
  24. // Note: this currently uses Vector4f, but will be changed to use Color instead          
  25. EnergyColorAffector energyColorAffector = new EnergyColorAffector();
  26.                     energyColorAffector.gradientMap.put(6.5f, new Vector4f(0.9f, 0.9f, 0.9f, 0.8f));
  27.                     energyColorAffector.gradientMap.put(6.4f, new Vector4f(1.0f, 1.0f, 0.3f, 1.0f));
  28.                     energyColorAffector.gradientMap.put(5.6f, new Vector4f(1.0f, 0.2f, 0.1f, 0.0f));
  29.                     energyColorAffector.gradientMap.put(5.0f, new Vector4f(1.0f, 0.2f, 0.1f, 0.7f));
  30.                     energyColorAffector.gradientMap.put(2.5f, new Vector4f(0.1f, 0.1f, 0.1f, 0.0f));
  31.                     energyColorAffector.gradientMap.put(1.0f, new Vector4f(0.1f, 0.1f, 0.1f, 1.0f));
  32.                     energyColorAffector.gradientMap.put(0.0f, new Vector4f(0.1f, 0.1f, 0.1f, 0.0f));
  33. partsys.affectors.add(energyColorAffector);
  34.  
  35. // In a similar fashion, the size (xyz) over time can be controlled. (Z makes no sense with billboards :P)
  36. EnergySizeAffector energySizeAffector = new EnergySizeAffector();
  37.                    energySizeAffector.gradientMap.put(6.5f, new Vector3f(0.01f, 0.01f, 0.01f));
  38.                    energySizeAffector.gradientMap.put(6.2f, new Vector3f(0.1f, 0.1f, 0.1f));
  39.                    energySizeAffector.gradientMap.put(5.0f, new Vector3f(0.0f, 0.0f, 0.0f));
  40.                    energySizeAffector.gradientMap.put(2.5f, new Vector3f(0.01f, 0.01f, 0.01f));
  41.                    energySizeAffector.gradientMap.put(0.0f, new Vector3f(0.7f, 0.7f, 0.7f));
  42. partsys.affectors.add(energySizeAffector);
  43.  
  44.  
  45. partsys.affectors.add(new TurbulenceAffector(2.5f)); // Adds some randomness to the motion (random forces)
  46.  
  47. // end of particle system definition
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top