public:t-gede-14-1:lab8
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| public:t-gede-14-1:lab8 [2014/03/10 17:15] – [Discussion] marino | public:t-gede-14-1:lab8 [2024/04/29 13:33] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== LAB8: Particle Systems ====== | ====== LAB8: Particle Systems ====== | ||
| - | In this lab we will be checking out particle systems, This lab will be based on the "The Ogre 3D Startup Sequence" | + | In this lab we will be checking out particle systems, This lab will be roughly |
| Line 8: | Line 8: | ||
| Discussion thread for this lab is here: [[https:// | Discussion thread for this lab is here: [[https:// | ||
| + | ===== Preperation ===== | ||
| + | You will have to create the folder '' | ||
| + | You can use your own project or start fresh with the base application {{: | ||
| + | ===== Lab ===== | ||
| - **Add the following code your MyApplication:: | - **Add the following code your MyApplication:: | ||
| Ogre:: | Ogre:: | ||
| Line 21: | Line 25: | ||
| // Make the emitter limit the emitter to have at maximum 500 particles active. | // Make the emitter limit the emitter to have at maximum 500 particles active. | ||
| // And set the particle type as point, which always faces the camera. | // And set the particle type as point, which always faces the camera. | ||
| - | quota 500 | + | quota 500 |
| billboard_type point | billboard_type point | ||
| // Make the emitters origin a point. | // Make the emitters origin a point. | ||
| emitter Point { | emitter Point { | ||
| // Make the emitter emit 3 particles per second. | // Make the emitter emit 3 particles per second. | ||
| - | emission_rate 3 | + | emission_rate 3 |
| // Emitt the particles in the given direction, at a velocity of 20 units per second. | // Emitt the particles in the given direction, at a velocity of 20 units per second. | ||
| direction 1 0 0 | direction 1 0 0 | ||
| Line 32: | Line 36: | ||
| } | } | ||
| }</ | }</ | ||
| - | - **Now add additional properties to the Emitter**, Now lets make the particle emitter shoot the particles in a random fashion, and destroy them after 10 seconds alive. Additionally we will color them red. <code cpp> | + | - **Now add additional properties to the Emitter**, Now lets make the particle emitter shoot the particles in a random fashion, and destroy them after 10 seconds alive. Additionally we will colour |
| - | // This will be the range of angle varialtion | + | // This will be the range of angle variation |
| angle 30 | angle 30 | ||
| // Destroy the particle after 10 seconds. | // Destroy the particle after 10 seconds. | ||
| - | time_to_live 10 | + | time_to_live 10 |
| // Colour the particles red with a fully opaque alpha value. | // Colour the particles red with a fully opaque alpha value. | ||
| Colour 1 0 0 1</ | Colour 1 0 0 1</ | ||
| - | - **Now we will add some Additional variation** Lets make the time to live random, and give them colour a certain range. We do that by chaning | + | - **Now we will add some Additional variation** Lets make the time to live random, and give them colour a certain range. We do that by changing |
| time_to_live_min 1 | time_to_live_min 1 | ||
| time_to_live_max 10 | time_to_live_max 10 | ||
| Line 45: | Line 49: | ||
| colour_range_start 1 0 0 | colour_range_start 1 0 0 | ||
| colour_range_end 0 0 1</ | colour_range_end 0 0 1</ | ||
| - | - **Additional attributes, | + | - **Additional attributes, |
| duration 1 | duration 1 | ||
| - | repeat_delay 1</ | + | repeat_delay 1</ |
| - **Adding affectors** Now we will explore particle system affectors: Remove the attributes added in the last step. leaving again, only the '' | - **Adding affectors** Now we will explore particle system affectors: Remove the attributes added in the last step. leaving again, only the '' | ||
| - **Scaling affector:** Add the following line to the particle_system block, this will scale the particles by the given value per second : <code cpp> | - **Scaling affector:** Add the following line to the particle_system block, this will scale the particles by the given value per second : <code cpp> | ||
| - | rate 10 | + | rate 10 |
| }</ | }</ | ||
| - | - **Color fading affector** | + | - **Colour |
| affector ColourFader { | affector ColourFader { | ||
| red 0.0 | red 0.0 | ||
| Line 73: | Line 77: | ||
| alpha2 | alpha2 | ||
| }</ | }</ | ||
| - | - And finally we have probably the most useful tool, called | + | - And finally we have the ColorInterpelator. |
| affector ColourInterpolator { | affector ColourInterpolator { | ||
| time0 0 | time0 0 | ||
| Line 92: | Line 96: | ||
| time5 1 | time5 1 | ||
| colour5 0 1 0 0 | colour5 0 1 0 0 | ||
| - | }</ | + | }</ |
| - | - **Direction Randomiser** We can make the particles change direction at random: <code cpp>// This will make the particles fly around like it has no tomorrow. | + | - **Direction Randomiser** We can make the particles change direction at random: <code cpp>// This will make the particles fly around like they have no tomorrow. |
| affector DirectionRandomiser { | affector DirectionRandomiser { | ||
| // This indicates the magnitude of the random choices the particle makes. | // This indicates the magnitude of the random choices the particle makes. | ||
| - | randomness 1000 | + | randomness |
| // Scope governs the chance that a given particle takes a random direction change scale from 0..1 ~ 0-100% | // Scope governs the chance that a given particle takes a random direction change scale from 0..1 ~ 0-100% | ||
| - | scope 1 | + | scope |
| // Here you can indicate if the particle should randomize its velocity or not. < | // Here you can indicate if the particle should randomize its velocity or not. < | ||
| keep_velocity true | keep_velocity true | ||
| - | }</ | + | }</ |
| - **Deflector Planes** Deflector planes can make the particles change direction when they hit the deflector plane, the plane is provided in point normal form. <code cpp>// Deflector planes bounce the particles of the given plane. | - **Deflector Planes** Deflector planes can make the particles change direction when they hit the deflector plane, the plane is provided in point normal form. <code cpp>// Deflector planes bounce the particles of the given plane. | ||
| affector DeflectorPlane { | affector DeflectorPlane { | ||
| //The point of the plane, note: the plane is infinite | //The point of the plane, note: the plane is infinite | ||
| - | plane_point 10 0 0 | + | plane_point |
| // The normal vector of the plane, the direction of the particles will be mirror around this normal. | // The normal vector of the plane, the direction of the particles will be mirror around this normal. | ||
| - | plane_normal -0.7 0.7 0 | + | plane_normal |
| // The amount of velocity the particles retain after the collision. | // The amount of velocity the particles retain after the collision. | ||
| - | bounce 1.0 | + | bounce |
| } | } | ||
| // You can provide more than one plane. | // You can provide more than one plane. | ||
| affector DeflectorPlane { | affector DeflectorPlane { | ||
| - | plane_point 10 15 0 | + | plane_point |
| - | plane_normal -0.7 -0.7 0 | + | plane_normal |
| - | bounce 1.0 | + | bounce |
| } </ | } </ | ||
| - **Different emitters** We can make the spawn point of the particles different, some of them have different parameters see: [[http:// | - **Different emitters** We can make the spawn point of the particles different, some of them have different parameters see: [[http:// | ||
| Line 125: | Line 129: | ||
| - Hollow Ellipsoid | - Hollow Ellipsoid | ||
| - Ring | - Ring | ||
| - | - **Get your hands dirty.** Now create a particle system using the things you have learned. | + | - **Get your hands dirty.** Now create a particle system using the things you have learned. |
| ===== Bonus ===== | ===== Bonus ===== | ||
| + | <box green 100% | Das Bonus von GEDE!> | ||
| + | - **Using particle effects for something swell.** Add a glowing particle effect to Sinbads sword. Particle effects are often used for all sorts of [[https:// | ||
| + | // Create the sword entity. | ||
| + | Ogre:: | ||
| + | // Attach the sword to Sinbads right hand. | ||
| + | _SinbadEnt-> | ||
| + | // Clasp Sinbads hands around the hilt of the sword. | ||
| + | _SinbadEnt-> | ||
| + | - **Celebrate Sinbads amazing sword effect.** If you followed the last point then Sinbad is surely a happy seadog, and a happy fellow deserves a show! Create some fireworks using the particle system Ogre provides. //**Hint:** Check out the [[http:// | ||
| + | particle_system Fireworks { | ||
| + | // Make the particles use the " | ||
| + | material Examples/ | ||
| + | particle_width 1 | ||
| + | particle_height 1 | ||
| + | // Make the emitter limit the emitter to have at maximum 2000 particles active. | ||
| + | // And set the particle type as point, which always faces the camera. | ||
| + | quota 2000 | ||
| + | billboard_type point | ||
| + | |||
| + | // The maximum amount of emitter emitters | ||
| + | emit_emitter_quota 10 | ||
| + | |||
| + | // Make the emitters origin a Point. | ||
| + | emitter Point { | ||
| + | // tell the particles to emitt the "bomb emitter" | ||
| + | emit_emitter bomb | ||
| + | // Fire one firework per second | ||
| + | emission_rate 1 | ||
| + | |||
| + | // Make the particles go up. | ||
| + | direction 0 1 0 | ||
| + | velocity 70 | ||
| + | time_to_live 2 | ||
| + | } | ||
| + | |||
| + | // The emitter emitted by the particles above | ||
| + | emitter Point { | ||
| + | // Name the emitter to match the name in the emit_emitter block | ||
| + | name bomb | ||
| + | |||
| + | // Configure the explosion. | ||
| + | emission_rate 200 | ||
| + | velocity 30 | ||
| + | |||
| + | // How long should the firework emit | ||
| + | duration_min | ||
| + | duration_max 0.2 | ||
| + | |||
| + | // This is used to make sure the particles in the emitter emitter dont fire while the particle is in mid flight. | ||
| + | repeat_delay_min | ||
| + | repeat_delay_max | ||
| + | time_to_live_min 0.3 | ||
| + | time_to_live_max 0.4 | ||
| + | |||
| + | } | ||
| + | |||
| + | // Add some pseudo gravity. | ||
| + | affector LinearForce { | ||
| + | force_vector 0 -50 0 | ||
| + | } | ||
| + | |||
| + | }</ | ||
| + | - **Lastly** If you come up with a use for the particle system and think that it deserves an additional bonus point or half, then I might be generous :) \\ **Hint:** You could use the cylindrical effect from Lab 3 for interesting particle system effects :) | ||
| + | </ | ||
| ===== When You Are Finished ===== | ===== When You Are Finished ===== | ||
| Upload your **commented source files** into Lab8 in MySchool (zip them up if more than one). The lab projects will not be graded, but their completion counts towards your participation grade. | Upload your **commented source files** into Lab8 in MySchool (zip them up if more than one). The lab projects will not be graded, but their completion counts towards your participation grade. | ||
/var/www/cadia.ru.is/wiki/data/attic/public/t-gede-14-1/lab8.1394471706.txt.gz · Last modified: 2024/04/29 13:32 (external edit)