Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Graphics > OpenGL 3D API > Re: Order of Tr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 5 Topic 4822 of 5017
Post > Topic >>

Re: Order of Transformations

by fungus <openglMYSOCKS@[EMAIL PROTECTED] > Jul 6, 2008 at 02:21 PM

On Jul 5, 10:55=A0pm, ampheta...@[EMAIL PROTECTED]
 wrote:
> Greetings! I recently started learning OpenGL and I have run into
> quite a problem. I really have no idea how to implement a simple
> camera using OpenGL's transformation functions. What particularly
> bothers me is the order in which transformations must be applied.
>
> Suppose the camera is located at (x, y, z) and its rotation is -45
> degrees (from the default orientation, that is, looking towards (0, 0,
> -1)).
>
> If I translate first, by calling glTranslate(-x, -y, -z), the rotation
> will have that point as its origin. I don't need that.
>
> If I rotate first, I will have to somehow calculate the translation
> vector (because forward, for example, won't be (0, 0, -1) anymore).
>

To go forwards you have to do the new translation before the
previous rotation/translation, ie. your transform is now:

T * R * T

Then if you want to go forwards again it becomes:

T * T * R * T

Obviously you can't keep this up forever. What you can
do is store the "R * T" part using glGetMatrix(), put it
back again the next time around with glLoadMatrix(),
then compute "T * R * T".

Now you store that matrix for the next time around and
compute "T * T * R * T" using it. etc.

After a while the floating point rounding errors will catch up
with you so you need to fix them. Each row of the upper 3x3
part of a transformation matrix is a unit vector which is the
vector product* of the other two rows. This means it's quite
easy to recompute the true value of each row. Recompute
the rows every now and again and you'll be ok.

[*] Or "cross product" in vulgar parlance.


--
<\___/>
/ O O \
\_____/  FTB.     Remove my socks for email address.
 




 5 Posts in Topic:
Order of Transformations
amphetaman@[EMAIL PROTECT  2008-07-05 13:55:12 
Re: Order of Transformations
singin_dav <sone@[EMAI  2008-07-06 07:52:30 
Re: Order of Transformations
fungus <openglMYSOCKS@  2008-07-06 14:21:56 
Re: Order of Transformations
Jonathan Campbell <jg.  2008-07-07 18:05:40 
Re: Order of Transformations
Jonathan Campbell <jg.  2008-07-07 18:07:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 7:04:50 CST 2008.