Archived

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

glTrans/Rot or manual transforms?

This topic is 5826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Well, the basic question is: should I modify vertices manually myself or should I use glTranslate/Rotate etc. My initial plan was to do everything myself so I could combine world-interaction with part of the gfx process and kill two birds with one stone. I''m now wondering, however, if it might make more sense to provide a coarse set of initial world-interaction steps (fine tuning only when required - e.g. bounding box collision detection followed by per-face detection or whatever) and use glRotate/Translate etc to update the modelview (i.e. take proper advantage of accel hardware). Suggestions? What do you do? On a related note: am I going to walk into gimble-lock problems with glRotate in 3d? Cheers. Apologies for the n00b Q.

Share on other sites
Here is a common way to do this that helps with speed and with useablility

1. Don''t use glrotate for complex rotations (Such as ones that would run into Gimble lock because glrotate does run into this problem)

2. Use other meathods like Quaternions or something else and Turn it into a matrix then multiply that into opengl.

3. Don''t do the math yourself make sure opengl does it because opengl will always do the math so If you do it then you are useing both the cpu and the gfx card to do the same thing while the gfx card is being totaly useless. so you can configure the rotations and transforms manually but multiply those matrixs onto your opengl one so you don''t preform the transforms and rotaitons twice.

4. one more thing don''t transform wastefully such as saying
Don''t do this ->glRotatef(90,0,1,0);glRotatef(90,0,0,1);DrawCube();glRotatef(-90,0,0,1);glRotatef(-90,0,1,0);Do this ->glPushMatrix();glRotatef(90,0,1,0);glRotatef(90,0,0,1);DrawCube();glPopMatrix();

Xero-X2

Share on other sites
Hi,

1. and 2. are what I''m trying to accomplish. I''m fairly new to OpenGL and just can''t make this work. I have a 3x3 rotation matrix and want to convert that into an OpenGL matrix to use with either glLoadMatrix or glMultMatrix.

//-----------------------------------------------------
static float zvalue = 1.0f;
zvalue += 10.0f;
glMatrixMode(GL_PROJECTION);
gluPerspective(50.0f, ratio, 1.0f, 10000.0f);

glMatrixMode(GL_MODELVIEW);
// use my attitude matrix
GLfloat m[16];
// ''convert'' native rotation matrix to OpenGL matrix
m[ 0] = sv.nose.x;
m[ 1] = sv.nose.y;
m[ 2] = sv.nose.z;
m[ 3] 0.0f;

m[ 4] = sv.side.x;
m[ 5] = sv.side.y;
m[ 6] = sv.side.z;
m[ 7] = 0.0f;

m[11] = 0.0f;

m[12] = 0.0f;
m[13] = 0.0f;
m[14] = 0.0f;
m[15] = 1.0f;

glMultMatrixf ( m );

//-----------------------------------------------------

The complete code with accompanying texture can be found at : http://ourworld.compuserve.com/homepages/IvanScheers/eightball.zip (219 Kb)

What am I doing wrong ?

Ivan

> 1. Don''t use glrotate for complex rotations (Such as
> ones that would run into Gimble lock because glrotate
> does run into this problem)
>
> 2. Use other meathods like Quaternions or something
> else and Turn it into a matrix then multiply that
> into opengl.

Share on other sites
glRotatef does not have any gymbal lock. it takes an axis and an angle.. if you call it 3 times to pass over euler angles, thats your own stupidity.. (to the one that replied and told it has gymbal lock)

"take a look around" - limp bizkit

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 19
• 12
• 14
• 9
• Forum Statistics

• Total Topics
633362
• Total Posts
3011531
• Who's Online (See full list)

There are no registered users currently online

×