Jump to content
  • Advertisement

Archived

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

GaRaOne

Rotate around a vector... ARGH

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

How can i rotate around a specific vector... i have an object with its own X Axis. If I want to rotate the object around this axis, then i have to change the X Y and Z Rotations around the MainAxis before i draw it. Or is their a way, to rotate around a specific vector? (i want no rotationmatrix, which rotates vectors around a vector, my problem is the drawing of the object) for example: i have the 3 rotationdegrees... around the 3 axis ObjectRotX ObjectRotY ObjectRotZ after using this rotations the new objectaxis are ObjectAxisX ObjectAxisY ObjectAxisZ The question now is: How i must change ObjectRotX, ObjectRotY and ObjectRotZ, than the object rotates around its own ObjectAxisX????? sorry about my english... is not one of my best skills

Share this post


Link to post
Share on other sites
Advertisement
easy. OpenGL''s rotation matrices are applied on top of eachother. In this case:

-rotate camera
-translate to object
-rotate object

now you are at the objects position and rotation. If you want to rotate it around it''s own axis just add another glRotatef function like:

glRotatef(degrees, 1.0f, 0.0f, 0.0f);

then draw the object.
Object rotations only get complicated in OpenGL if you want them to rotate around aony other axis then their own (like the camera''s axis) because you have to keep track of all the rotations and undo them (eg in particle engines, the particle must always face the camera).

- An eye for an eye will make the world go blind -

Share this post


Link to post
Share on other sites
i think it isnt so easy...

i want no extra rotation...
i want to change/calculate only the 3 rotationangles...

Share this post


Link to post
Share on other sites
I think I know what you're getting at.
So you want to rotate an object, say 90 degrees on the x axis. Now the objects y axis is now actually pointing down the z axis, and you want any further rotations to take this into effect?
Hmmmm, that is quite nasty.
Wild guess, but if you could calculate the vectors of each axis, then when you call glRotatef, plug-in the appropriate vector.

//for example
glRotatef(ObjectRotX, ObjectAxisX.x,ObjectAxisX.y,ObjectAxisX.z);
// this will change the rotation vector to the one of your object

I just don't know the math used to get those vectors. So I've answered half of your question?

------------
http://aud.vze.com <-- Newbie alert, look at your own risk. Can induce severe laughing fits and other variations of hysterical outburst.

[edited by - LockePick on June 2, 2002 7:55:45 PM]

Share this post


Link to post
Share on other sites
the vectors of the objectaxis and how i calculate them i know. with your hint i can only rotate the object on the screen around this vector, but i try to rotate it with the variables.

maybe it would be enough for me to know, how others manage the rotations of a object in 3d. for movings like an aeroplane.

Share this post


Link to post
Share on other sites
http://www.sjbaker.org/steve/omniv/index.html

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
thx... thats, what i need!




"
(If you are right-handed, you''ll find this discussion much easier to follow if you are holding a paper plane. Fold one now! Left handed people usually have better spatial reasoning skills and can grok this using their brains alone :-)
" OOOOOOOOOOYYEEAAAHHH THATS RIGHT

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!