Jump to content
  • Advertisement

Archived

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

lucinpub

3d transformations

This topic is 5402 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

I am trying to write code to do matrix transformations myself, and then pass them to the opengl rasterizer. It has not been working, so I used grabbed the model_view matrix from my code and the one generated by ogl and printed them out after applying the following calls and their equaivalent in my code glLoadIdentity( ); glScalef( 2, 2, 2 ); glTranslatef( 3, 5, 2 ); glRotatef(45, 1, 0, 0 ); the only difference in the output is the final column. opengl has it scaled by 2. my matrices follow:
GLdouble scale[16];
	scale[0] = sx;	scale[4] = 0;	scale[8]  = 0;	scale[12] = 0;
	scale[1] = 0;	scale[5] = sy;	scale[9]  = 0;	scale[13] = 0;
	scale[2] = 0;	scale[6] = 0;	scale[10] = sz;	scale[14] = 0;
	scale[3] = 0;	scale[7] = 0;	scale[11] = 0;	scale[15] = 1;
I_my_glMultMat( m );

and this for my translate
GLdouble m[16];
	m[0] = 1;	m[4] = 0;	m[8]  = 0;	m[12] = tx;
	m[1] = 0;	m[5] = 1;	m[9]  = 0;	m[13] = ty;
	m[2] = 0;	m[6] = 0;	m[10] = 1;	m[14] = tz;
	m[3] = 0;	m[7] = 0;	m[11] = 0;	m[15] = 1;
	
	I_my_glMultMat( m );
are these right or wrong?... from everything i've read everywhere, they should be correct. So is there some other step I should be doing before (or after) the multiplication? I am pretty certain of my matrix multiplication routine, as it is merely an unrolled loop (ie I multiplied two general matrices by hand on paper and just coded the resulting expressions).Plus I checked it and rechecked itany help would be appreciated. edit source box [edited by - lucinpub on February 28, 2004 11:40:11 PM]

Share this post


Link to post
Share on other sites
Advertisement
Perhaps you are multiplying the matrices in the wrong order. A*B != B*A

Also, the result of

glLoadIdentity( );
glScalef( 2, 2, 2 );
glTranslatef( 3, 5, 2 );
glRotatef(45, 1, 0, 0 );


is S * T * R

Share this post


Link to post
Share on other sites
nah, I dont think so. As each command is issued, I multiply the generated matrix, call it A, with the current matrix B as in A * B. I believe this is the same as OGL, but I could be wrong.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!