Jump to content
  • Advertisement

Archived

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

simbobx

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.

If you intended to correct an error in the post then please contact us.

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


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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);
glLoadIdentity();
gluPerspective(50.0f, ratio, 1.0f, 10000.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// 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[ 8] = sv.head.x;
m[ 9] = sv.head.y;
m[10] = sv.head.z;
m[11] = 0.0f;

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

// glLoadMatrixf ( m );
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 this post


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

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!