View Full Version : addition of transformation matrix

05-03-2005, 07:10 AM
i have a transformed modelview matrix stored in a float array. now i want to add this matrix to the current matrix (the current matrix is also in an array).
is this possible?

thanks h.stony

05-03-2005, 04:58 PM
Yes though not directly - there isn't a glAddMatrix function.

pseudo code:

float mymat[16];
initialize mymat
float mat[16];
mat = glGetFloatv( GL_MODELVIEW_MATRIX );
for( i=0;i<16;i++ )
mat[i] += mymat[i];
glMatrixMode( GL_MODELVIEW );
glLoadMatrixf( mat );

05-04-2005, 04:34 AM
But... why would you want to add a matrix to another?

Combining the effects of the matrices is a matter of multiplying matrices (use glMultMatrix).
That's how OGL handles its rotates/translates/scales.

05-05-2005, 01:13 AM
yes. glMultMatrix was my first idea. but the result was really strange. i know that a addition beetween the matrices is senseless. i try glMultMatrix a second time.


float mymat[16];
initialize mymat
glMatrixMode( GL_MODELVIEW ); // i am already in modelview mode. but without it doesn't work
glLoadMatrixf( mat );thanks

05-05-2005, 04:20 AM
obtain the modelview matrix add the 2 together and load the resulting matrix