Advertisement

Rotate around a vector... ARGH

Started by May 30, 2002 06:32 PM
5 comments, last by GaRaOne 22 years, 8 months ago
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
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 -

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

Advertisement
i think it isnt so easy...

i want no extra rotation...
i want to change/calculate only the 3 rotationangles...
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]
_______________________________________Pixelante Game Studios - Fowl Language
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.
http://www.sjbaker.org/steve/omniv/index.html

http://uk.geocities.com/sloppyturds/gotterdammerung.html
Advertisement
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

This topic is closed to new replies.

Advertisement