Computer graphics -- 2007-2008 -- info.uvt.ro/Laboratory 7
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, evaluation, tools, repository.
World box
editThe world box is nothing else than a simple cube that contains all the scene's objects and the camera. Thus the following constraints must be met:
- the world box must be inside the view volume; (or at least the sides that are visible;)
- the objects outside the world box should not be draws, as they will not be visible;
- the camera should not be allowed to exit the bounding box;
- it is advisable that the camera does not approaches the world box;
Usually for this box each of the sides has a particular texture -- like some stars when simulating a solar system.
Observation: when drawing the world box we should note that it must be drawn, so that the face polygon is on the inside. (Thus be careful to the vertex ordering.)
Particle engine
editThe best example of a particle engine is the emission of a comet.
For each particle we have the following properties:
- physical variables:
- position vector -- (positionX, positionY, positionZ);
- speed vector -- (speedX, speedY, speedY);
- acceleration vector -- (accelerationX, accelerationY, accelerationZ);
- display variables:
- color, material, texture, etc.;
- fading and fading factor -- how visible is the particle;
- life -- that should be decremented, and when it reaches 0 the particle should be destroyed or reused;
The physical laws are quite easy:
- at each step we update the speed by using the acceleration;
- at each step we update the position by using the speed;
- the time is considered constant -- usually 1;
- usually the particles go in the opposite direction of their source; thus we could initialize their speed with the speed of the source, but negative;
- usually the particles are emitted to form a cone, and are computed randomly;
Observation:
- usually the number of particles is constant;
- when a particle dies, a new one is created; usually we do this by reusing and reinitializing a particle;
- the bigger the time variable is, the smaller the number of frames is needed, but the movement is more fragmented;
Assignment
editThis is the seventh assignment, so please commit it to the folder assignment-07.
Implement the following simulation:
- we imagine a sphere that occupies half of the view volume; (this sphere should not be drawn;)
- on the surface of this sphere a comet is moving randomly; (be careful to implement a 'smooth (not fragmented) movement;)
- from this comet particles are emitted in the reverse direction of the comet; (thus the comet and the particles are moving in opposing directions;)
- the particles are emitted in the form of a cone;
- the entire world is inside the world box;
Bonus points:
- the comet and the particles are implemented as billboards;
- it should be possible to move the camera -- like in the previous laboratories -- but the camera should not be allowed to exit the world box;
Observations:
- as a starting point you could place the comet in the center of the system, and let it be static;