Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Question about rotation

This topic is 5738 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

I''m currently working on a program that will allow editing of 3d-models with the mouse. So I was wondering if someone could give advice as to how one knows how much to rotate for a line to point to whare the mouse is (hope this makes sense). The purpose of this is that one could "grab" the vertex of a line and rotate it around the line''s other vertex. I''m not too sure about rotation-matrices and things, so I really don''t know how to do this. Also, the program needs to do it with glRotatef. So no just moving the point. I need to know in what way and how much to glRotatef. Any help is welcome and duly thanked in advance.

Share this post

Link to post
Share on other sites
when you do it with glrotatef you won t modify the vertex coords

use a 4*4 matrix with homogene coordinates
[1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1]
^^îdentity matrix
have a look at a matrix tutorial and read up matrix multiplication
just multiply the matrix above with [ x y z w]

if you know 3*3 matrices you can replace the 1,1->3,3 fields with the 3*3 matrices
the 4,? could be px py pz 1
if you set the 4,? fields to something else than zero you transform your vertex you multiply with the 4*4 matrix around the point

Share this post

Link to post
Share on other sites
Thanks for the advice, friend. I have done as you said (and as I know I should have done ages ago) and read up on matrices. However, I''m still kind of at a loss...
Also, I forgot to mention one thing in the first post: the rotation must only be done so that the point remains on a plane, never outside. This plane is, err... I''ll try to show:

------------ The plane on which rotation occur

(viewed from "above")

------------ The "plane" of the screen

The view will be rotatable though, so I never know what axis(es) to rotate.

I just don''t know how to do what I''m after (even though I now know a bit about how matrices work).

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!