2/7
2. Particles systems
Spheres falling under gravity
-
Set the code to the next part
-
> In the file exercise_current.hpp, change the line #define EXERCISE_INTRODUCTION, into #define EXERCISE_PARTICLES compiling the scene from exercises/01_particles/particles.[ch]pp.
-
> Recompile and execute the code.
-
This code model a set of spheres falling under gravity.
-
Observe how are initialized the particles. What is their initial speed ?
-
Note how the particles are removed.
-
Change the delay between the emission of a new particle.
-
Change the initial speed such that particles have a varying $y$ component in their initial speed.
-
So far, each sphere follows a pure parabola trajectory without taking into account its collision with the plane. Implement such collision model (limited to one bounce).
-
Tips: Compute the time at which a particle intersects the ground. Compute the new trajectory taking into account a small decrease of energy due to the bouncing.
-
-
Add the visualization of the trajectory of each particle using the curve_dynamic_drawable object (you can store a vector of them) as shown in the following example.
-
In the previous example, the collision is explicitly displayed by some shadow-looking effect. How could you model such effect ? Try to implement it if you have time.
User defined trajectory
-
Modify the code to model a scene similar to the following one
Tips
-
A .obj mesh of the cauldron and spoon are available in the directory data/cauldron/. You can load them using the function mesh_load_file_obj(filename)
-
You can set the space-time trajectory of the spheres using oscillating (cos/sin) functions
-
The size and colors of the spheres can be parameters of the particle system.
Sprites
-
Set the code to the next part EXERCISE_SPRITES (files exercises/01_particles/sprites.[ch]pp) displaying a set of sprites: quadrangles with semi-transparent textures.
-
Observe the way that the quadrangle are displayed (you can activate/deactivate) the use of the transparent texture using the GUI. Change the number and size of sprites to change the style.
-
Use such sprite to adapt the previous code (with the cauldron) to model a scene similar to the following one