• Advertisement
Sign in to follow this  

Comment on lsn#9

This topic is 3246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
technically speaking there's no reason for that, i have no idea why jeff chose this path, you would really only need a translate and a rotate to do this if you use pop/push matrix.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement