Skip to main content
GameDev.net gamedev.net
🔒 Locked

Newbie Matrix question

Started by riekhof Apr 4, 2005 at 1:52 AM 0 replies 950+ views
Original Post
riekhof
riekhof
I have built a rotation matrix. When I multiply each vertex by hand and then do my gl.glVertex3f() calls, then it works for a simple test case. Do I have to do all this work by hand or is there some way to give OpenGL my rotation matrix and tell it to multiply each vertex vector by the rotation matrix? I've tried playing around with the gl.glLoadMatrixf( myRotMatrix ) calls but I can't seem to get it to work. Code below illustrates what im doing. // rotate triangle float[] rm = mm.joints[0].rotMatrix; float v11 = (rm[0] * v1[0]) + (rm[4] * v1[1]) + (rm[8] * v1[2] ) + rm[12]; float v12 = (rm[1] * v1[0]) + (rm[5] * v1[1]) + (rm[9] * v1[2] ) + rm[13]; float v13 = (rm[2] * v1[0]) + (rm[6] * v1[1]) + (rm[10] * v1[2] ) + rm[14]; float v21 = (rm[0] * v2[0]) + (rm[4] * v2[1]) + (rm[8] * v2[2] ) + rm[12]; float v22 = (rm[1] * v2[0]) + (rm[5] * v2[1]) + (rm[9] * v2[2] ) + rm[13]; float v23 = (rm[2] * v2[0]) + (rm[6] * v2[1]) + (rm[10] * v2[2] ) + rm[14]; float v31 = (rm[0] * v3[0]) + (rm[4] * v3[1]) + (rm[8] * v3[2] ) + rm[12]; float v32 = (rm[1] * v3[0]) + (rm[5] * v3[1]) + (rm[9] * v3[2] ) + rm[13]; float v33 = (rm[2] * v3[0]) + (rm[6] * v3[1]) + (rm[10] * v3[2] ) + rm[14]; // now do my gl.glVertex3f() calls.
riekhof
riekhof
I found the answer to my last question: gl.glMultMatrixf( rm ). Also had my rotation matrix crisscrossed.

Now I'm trying to do linear interpolation. Since I need both points for the vertex to do the interpolation, I guess I have to compute the start and end points for each vertex myself anyway...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.