Hi,
I have my rotations calculated (i hope) in a 4x4 matrix, but now how to i use glRotatef(...) with it?
thanks,
Scott
Email
Website
"If you try and don''t succeed, destroy all evidence that you tried."
matrix to glRotate data
If you already have the matrix precalculated, you can use something like this:
glLoadIdentity();
glMultMatrix(m);
The multmatrix command will multiply the matrix currently in use by the specified matrix. Another thing to watch for, is that the matrix must be in column major order, like so:
if
m[16] = { 0, 1 , 2, 3, 4, 5, ... , 14, 15 };
then the matrix looks like:
[[0, 4, 8, 12],
[1, 5, 9, 13],
[2, 6, 10, 14],
[3, 7, 11, 15]]
That should help...
glLoadIdentity();
glMultMatrix(m);
The multmatrix command will multiply the matrix currently in use by the specified matrix. Another thing to watch for, is that the matrix must be in column major order, like so:
if
m[16] = { 0, 1 , 2, 3, 4, 5, ... , 14, 15 };
then the matrix looks like:
[[0, 4, 8, 12],
[1, 5, 9, 13],
[2, 6, 10, 14],
[3, 7, 11, 15]]
That should help...
below is what I''m using so far, and by what you said, i''m going to have to change it. Would you agree?
Thanks,
Scott
Email
Website
"If you try and don''t succeed, destroy all evidence that you tried."
|
Thanks,
Scott
Website
"If you try and don''t succeed, destroy all evidence that you tried."
September 27, 2001 11:39 AM
I suck at math, so I''d probably do it the other way.
Do the rotations with glRotate, then read back the matrix if you need it.
- Pete
Do the rotations with glRotate, then read back the matrix if you need it.
- Pete
yeah, but then i''d have the gimbal lock problem wouldn''t I? that''s the main reason i''m using matrices.
Scott
Email
Website
"If you try and don''t succeed, destroy all evidence that you tried."
Scott
Website
"If you try and don''t succeed, destroy all evidence that you tried."
September 28, 2001 05:25 AM
But in the code above, the matrix is being created using plain rotations - isn''t that still going to get gimbal lock?
- Pete
- Pete
Hi Scott!!
In my eyes it look like you are trying to archive the same that you can get using glRotatef();
Nothing more...nothing less!! (exept for a few lines more code)
Take Care!
- -- ---[XaOs]--- -- -
[ project fy ]
In my eyes it look like you are trying to archive the same that you can get using glRotatef();
Nothing more...nothing less!! (exept for a few lines more code)

Take Care!
- -- ---[XaOs]--- -- -
[ project fy ]
damn, which shows that i need help 
I''d like to use matrices for rotations and translations instead of using both quaternions and matrices because the quaternion code i do have working for rotations is a mess, and i''d rather use matrices.
help would really be appreciated,
Thank,
Scott
Email
Website
"If you try and don''t succeed, destroy all evidence that you tried."

I''d like to use matrices for rotations and translations instead of using both quaternions and matrices because the quaternion code i do have working for rotations is a mess, and i''d rather use matrices.
help would really be appreciated,
Thank,
Scott
Website
"If you try and don''t succeed, destroy all evidence that you tried."
September 28, 2001 11:21 AM
If you''ve got the matrix already, maybe you could just use glMultMatrix instead of figuring out the rotations? I don''t know how translations will affect this though :-(
- Pete
- Pete
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement