[gameprogrammer] Re: Rotation, Rotation, Rotation...

I'm not sure I completely understand what you are getting at but...

The first rotation may work because the player is in the beginning
state.  Matches the coordinate system that you are expecting. 
Subsequent rotations may not work because the player is not in a
coodinate system that isn't matching the default (left or right
handed coordinate system.)  

You will probably have to keep track of your player's forward, up and
right/left vectors and use those for your rotation axes.  I'm
guessing, in your situation, you can't just assume X, Y and Z axes of
your player will match the world's X, Y and Z axes for rotation.

--- richard sabbarton <richard.sabbarton@xxxxxxxxx> wrote:

> Hi Guys,
> 
> I have a problem and I am absolutely sure that I have missed
> something
> obscenely obvious.  This is C++ with OpenGL/SDL.
> 
> In a 3D environment my player struct has 3 values for rotation
> around
> x,y and z.  I want the player to be able to freely rotate around
> all 3
> axis and I always want the mouse/joystick/keypad to operate the x
> and
> y axis rotation.  When I initially move the mouse the rotation is
> correct.  Left/Right and my scene rotates left and right.
> 
> If I rotate around z and then move the mouse my scene moves up and
> down instead of left and right.  Now, I thought that all I needed
> to
> do was change the order in which I rotated around each axis.  I
> thought that if I rotated around Z first and then x and y after
> then
> the movement of the mouse would always appear correct onscreen. 
> This
> is what I call:
> 
> glRotatef(Player.ZRot,0.0f,0.0f,1.0f);  // Rotation around Z axis
> glRotatef(Player.YRot,1.0f,0.0f,0.0f); // YRot is up and down
> around X axis
> glRotatef(Player.XRot,0.0f,1.0f,0.0f); // XRot is left and right
> around Y axis
> 
> 
> I thought that after performing the rotation the subsequent
> rotations
> would be relative to the previous one.  So, if I rotate 90deg
> around Z
> I thought it would then rotate relative to that effectivly
> switching
> the x and y axis.  But it doesn't does it...
> 
> So I guess that is my question...  How do I perform a rotation and
> then make all subsequent rotations relative to that initial
> rotation?
> 
> Regards
> 
> Richard
> 
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> 
> 
> 


Robbert de Groot


      Connect with friends from any web browser - no download required. Try the 
new Yahoo! Canada Messenger for the Web BETA at 
http://ca.messenger.yahoo.com/webmessengerpromo.php

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: