6.20.2 Boiling Water
Another good example of procedural creation is boiling water. When the
temperature reaches a certain level, bubbles begin to appear randomly
inside the water and start to go up until they reach the surface of the
water and disappear.
Right, let's do this.
1. Create a CREATION method.
2. Create a bubble under the method and add the following tags to it:
SCRE l=1
SDEL l=y>0.0
Because the value of the "I" variable in the SCRE tag is always 1, a
new bubble is created in each frame. The SDEL tag defines that the
bubble will be deleted as soon as its y coordinate reaches the value 0.
3. Use the function Modify/Properties/Velocity to define a velocity for
the bubble. The idea is that as soon as the bubble is created, it will
start to go upwards.
4. Create a PATH method to the same level with the bubble. Set the
Frequency of the method to 5, and draw a strongly oscillating curve
under the PATH method. The way we define the original position for the
bubbles is quite "deterministic", but if the path is very curved and
complicated, it will look as if the bubbles were created randomly all
over the water (We will demonstrate you later how to use a real random
function to define the position for the bubbles using RPL).
5. Create the PROCESSOR method to the same level with the CREATION method.
As mentioned earlier, an attribute itself (such as mass, velocity etc.)
does not move the object anywhere. The PROCESSOR method is needed for
converting the attributes to real motions. Because we did not create a
PROCESSOR method at the same level with the sample bubble, the sample
won't go up (the velocity is there, but it is not converted to a
motion).
6. Create a pot and a circle inside it representing the surface of the
water in the pot. Note that we used the conditional expression "y>0"
to define when bubbles should disappear, so the circle representing the
level of the water should be placed to that height.
7. Make the CREATION method object invisible, to make the bubbles appear
out of nothing.
|