Archived

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

FahadAizaz

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 this post


Link to post
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.

Get started at this page:
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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).

Share this post


Link to post
Share on other sites