Time for action — adding fireworks

It's always nice to see a firework after a special event.

  1. Create a particle system that bursts different-colored particles in all directions at a steady interval:
    particle_system Firework
    {
    material Examples/Smoke
    particle_width 10
    particle_height 10
    quota 5000
    billboard_type point
    emitter Point
    {
    emission_rate 100
    direction 0 1 0
    velocity 50
    angle 360
    duration 0.1
    repeat_delay 1
    color_range_start 0 0 0
    color_range_end 1 1 1
    }
    }
    
  2. Create five instances of this particle system:
    Ogre::ParticleSystem* partSystem1 = _sceneManager->createParticleSystem("Firework1","Firework");
    Ogre::ParticleSystem* partSystem2 = _sceneManager->createParticleSystem("Firework2","Firework");
    Ogre::ParticleSystem* partSystem3 = _sceneManager->createParticleSystem("Firework3","Firework");
    Ogre::ParticleSystem* partSystem4 = _sceneManager->createParticleSystem("Firework4","Firework");
    Ogre::ParticleSystem* partSystem5 = _sceneManager->createParticleSystem("Firework5","Firework");
    
  3. Then five nodes at different positions in the sky:
    Ogre::SceneNode* node1 = _sceneManager->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0,10,0));
    Ogre::SceneNode* node2 = _sceneManager->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(10,11,0));
    Ogre::SceneNode* node3 = _sceneManager->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(20,9,0));
    Ogre::SceneNode* node4 = _sceneManager->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(-10,11,0));
    Ogre::SceneNode* node5 = _sceneManager->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(-20,19,0));
    
  4. Finally, attach the particle systems to their nodes:
    node1->attachObject(partSystem1);
    node2->attachObject(partSystem2);
    node3->attachObject(partSystem3);
    node4->attachObject(partSystem4);
    node5->attachObject(partSystem5);
    
  5. Compile and run the application for the last time and enjoy the show
    Time for action — adding fireworks

What just happened?

We created a firework-like particle system and duplicated it so it would look like there are several fireworks in the sky.

Pop quiz — different types of emitter

Name all emitter types we have used in this chapter and a few of their differences and similarities.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.231.26