#### Archived

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

# Having a little Doubt

## Recommended Posts

Hi Guys !! After reading the lesson 5 i was able to rotate my models. I have this doubt in my mind like i have this pyramid as a model, first i want it to rotate around Y axis then X axis and then Z axis separately in one go !!! how would i do that ??? plz Help

##### Share on other sites
It is "easily" possible, you just create a 4x4 matrix that represents that rotation and then send it to opengl with

glMultMatrix[fd]

But to be honest, the construction of that matrix is not that hard, it is getting the proper rotations about each axis. More than likely, it will not work the way you expect it to due to gimbal lock.

At anyrate, my main thought is that you are not yet versed enough in 3d math yet to make much use of just merely being spoon fed the answer.

www.martinb.com

But if you look in the back of the opengl redbook (assuming u have it), in one of the appendixes they show you how to make such a matrix.

##### Share on other sites
I don't think it is extremely necessary to get down into the nitty gritty of matrices (just my opinion) until you really get to know OpenGL.

Unless I'm mistaken, you should do something like this:

glRotate3f(xrot,1,0,0);glRotate3f(yrot,0,1,0);glRotate3f(zrot,0,0,1);glVertex3f(rawr,woof,bark);

By the way, I only say you shouldn't learn matrix algebra at the beginning is because right now in high school my math class is dealing with matrix transformations and my teacher isn't doing such a great job of explaining them.

[edited by - Kaezin on November 17, 2003 5:52:53 PM]

##### Share on other sites
Thanks Kaezin I think u have solved my problem, by the way i am also learning tranformations myself but i am not expert enough to use them in OPenGL

##### Share on other sites
not if you still want to rotate around y, then x and z.. but im still confused what "seperately in one go" is supposed to mean? *confused*

##### Share on other sites
Trienco

Matrix operations are faster, because open gl doesnt have to convert for you

when you call those nifty little glTranslate, and glRotate functions, opengl is doing all the math work for you

when you do the glMatrix, you''re giving the HARDCORE method of movement/translation to opengl. Meaning, it doesnt have to convert it, you got the entire matrix right there, and thats all it needs

and if its a 4x4 matrix (which means it contains 16 different float values), it will do ALL translations in one go, meaning it will rotate it, move it, scale it, and (i forget the last one)

but basically, its a faster way of "animating" (by that i mean moving and scaling and rotating) than the easier way, this way is much harder but faster

##### Share on other sites
quote:
Original post by fireking
Trienco

Matrix operations are faster, because open gl doesnt have to convert for you

I''d imagine that most graphics card would have these functions accelerated. Doing the matrix math yourself is hogging up CPU time, while the GPU could do it instead (And probably quicker).

• ### Forum Statistics

• Total Topics
628294
• Total Posts
2981882

• 9
• 9
• 11
• 10
• 10