CHAPTER 7: Well-Rendered Miscellany (^233)
m_SpinX+=.4f;
m_SpinY+=.6f;
m_SpinZ+=.9f;
return;
}
So, what’s going on here? Well, sit a spell, and I’ll tell you:
Lines 1f are used to turn the light on and off so as to take before and
after comparisons.
Line 2 just generates the bounce factor. Since we need it twice, I
pulled it out of the call to glTranslate() where it used to be.
The light’s position is updated at line 3 and is detailed later.
In line 4, the lighting is turned off briefly because it can affect the way
the shadows are rendered.
Line 5 translates the scene to mWorldY and mWorldZ coordinates.
The platform, or stage, is drawn in line 6.
Lines 7ff toggle the light on and off every few seconds to show the
scene with and without the shadow.
In line 8, the drawLight() routine (Listing 7-13) is called to place a little
floating ball in orbit around our scene.
We need to disable the depth test when actually drawing the shadow,
in line 9, otherwise, there will be all sorts of z contention that generates
cool but useless flickering.
Line 10 calls the routine to generate the shadow’s matrix (detailed
later), followed by line 11, which actually draws the shadow.
Finally, we can start managing the occluder in line 12, the thing that
actually causes the shadow to be thrown.
Line 13 is used to aim our eye point down to center the scene since
we are floating up above it.
N o w w e g e t t o t h e b o u n c y p a r t -----nothing really new in line 14.
Lines 15ff add the extra spins. Note that the shadow generator also
has the identical rotational code.
Line 16 safely turns on the depth testing again, after which we can
draw the two triangle fans as well.
Lines 17ff handles some of the animation parameters, and then the
buffer is updated to the screen.
singke
(singke)
#1