Hi there,
While reading over the code in lesson 9 I came across the following section (note,
tilt is initialized at 90.0f):
glRotatef(tilt,1.0f,0.0f,0.0f); // Tilt The View (Using The Value In 'tilt')
glRotatef(star[loop].angle,0.0f,1.0f,0.0f); // Rotate To The Current Stars Angle
glTranslatef(star[loop].dist,0.0f,0.0f); // Move Forward On The X Plane
glRotatef(-star[loop].angle,0.0f,1.0f,0.0f); // Cancel The Current Stars Angle
glRotatef(-tilt,1.0f,0.0f,0.0f); // Cancel The Screen Tilt
The output of this lesson is a bunch of 'stars' that appear in various colors circling the Z axis and appearing as if they are 'drawn in' to the center.
As I was playing around with the other code trying to just figure out why the output looked the way it does, I couldn't help but wonder why exactly we were:
(A) using a default tilt of 90 degrees to place the Y axis where the Z axis usually is (line 1), and then
(B) rotating the newly aligned Y axis as if it was the standard Z axis (line 2)
I made the following modification and initialized
tilt at 0.0f, and the result output is identical (note that
tilt is still affected by keyboard/mouse input, hence leaving it in):
glRotatef(tilt,1.0f,0.0f,0.0f); // Tilt The View (Using The Value In 'tilt')
glRotatef(star[loop].angle,0.0f,0.0f,1.0f); // Rotate To The Current Stars Angle
glTranslatef(star[loop].dist,0.0f,0.0f); // Move Forward On The X Plane
glRotatef(-star[loop].angle,0.0f,0.0f,1.0f); // Cancel The Current Stars Angle
glRotatef(-tilt,1.0f,0.0f,0.0f); // Cancel The Screen Tilt
So, my question is did I miss something, or is there a specific reason / practice for doing that kind of "axis switching"?
Thanks!