Jump to content

  • Log In with Google      Sign In   
  • Create Account

Comment on lsn#9


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 noamw   Members   -  Reputation: 122

Like
0Likes
Like

Posted 27 February 2009 - 11:28 AM

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!

Sponsor:

#2 lc_overlord   Members   -  Reputation: 435

Like
0Likes
Like

Posted 28 February 2009 - 01:12 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS