Pro OpenGL ES for iOS

(singke) #1

CHAPTER 8: Putting It All Together (^247)
The scale of our model is set at 1 unit=1 million miles (1.7m kilometers or 8.3m furlongs).
The sun has a radius of 400,000 miles, or .4 in these units. That means earth’s radius
would be .004, but I’ve increased it by 10 times, to .04, to make it a little easier to deal
with. Because earth’s default position is along the +Z-axis, let’s put the eye position
right behind the earth, only a quarter million miles away, at ‘‘93.25.’’ And in the execute
method for the solar-system object, remove glRotatef() so that the earth will now
stay fixed. That makes things a lot simpler for the time being. Make sure to modify the
headers as needed. Go to your friend, setClipping(), and change the field of view from
50 degrees to 30; also, set zFar=2000 (to handle future objects). You should ultimately
get something that looks like Figure 8-1. Because the sun is actually behind the earth
from our viewpoint, I cranked up the specular lighting for SS_FILLLIGHT1.
Figure 8-1. Our home on a tiny screen
‘‘All well and good, code-boy!’’ you must be muttering under your breath. ‘‘But now
we’re stuck in space!’’ True enough, so that means the next step is to add a navigational
element. And that means (cue dramatic music) we’ll be adding quaternions.

Free download pdf