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

modelview

Started by Gilmario Sep 14, 2010 at 6:28 PM 6 replies 1.1k views
Original Post
Gilmario
Gilmario
Hey, I'm pretty new to OpenGL still, and I have a simple question... Could someone explains me how modelview matrix acts in order to convert object coordinates to eye coordinates?
relsoft
relsoft
It just multiplies all your vertices by a the modelview matrix (translate, rotate, etc)

A column vertex(x,y,z) is transformed(multiplied) with every row in the modelview matrix.

Hi.
karwosts
karwosts
Unfortunately I think your question is not really a "simple question", you could probably find a 500 page math book devoted to describing all the details of matrix transformations.

What information are you looking for specifically? Pure mathematical theory? Implementation details in opengl? In my experience it takes a long time to build a good understanding of this transformation, its not something you can read in 10 minutes and then fully understand.

If you have a more specific question (maybe tell us what you are trying to do?), we can probably help you more.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Palidine
Palidine
In general terms matrices are part of a branch of mathematics called Linear Algebra. Amongst other things they have the capacity to convert vectors and points in one coordinate system into another coordinate system.

I believe the normal role of the modelview matrix is to convert from model local space into world space.

If you're dipping into 3D graphics and games, learning Linear Algebra is essential. May as well start now [smile]

-me
Zakwayda
Zakwayda
Quote:
Original post by Palidine
I believe the normal role of the modelview matrix is to convert from model local space into world space.
Minor point, but it's model space to view space.
Gilmario
Gilmario
Thank you guys, I will try to better describe my question.

If I understood at line 14 (below), modelView3 = invT2*R2*T2*invT1*R1*T1*modelView. I think my reasonig was right, was not it?

What I do not understand is why the concatenation of transforms upon modelViews give the transformation from the world to camera's coordinates system. I think I need see the math behind... but just deep enough :-)


>>>>>>>>>>----- In code below:
line 3: modelview1=invT1*R1*T1*modelView
line 4: a copy of modelView1 is stacked, modelView1 is still current
line 5: modelView2=T2*modelView1
line 6: in order to render the cylinder, its points in camera's coordinates are PTSCylEye=modelView2*PtsCyl
line 7: modelView1 is removed from the stack and become the current MODELVIEW matrix
line 10: modelView3=invT2*R2*T2*modelView1
line 11: a copy of modelView3 is stacked, modelView3 is still current
line 12: modelView4=Esc*modelView3
line 13: in order to render the cube, its points in camera's coordinates are PTSCubEye=modelView4*PtsCub
line 14: modelView3 is removed from the stack and become the current MODELVIEW matrix

void display(void)
{......................
glPushMatrix();
glTranslatef (-1.0, -0.3, 0.0); /* 1 */
glRotatef ((GLfloat) torso, 0.0, 1.0, 0.0); /* 2 */
glTranslatef (1.0, 0.3, 0.0); /* 3 */


glPushMatrix(); /* 4*/
glTranslatef (-1.0, -0.3, 0.0); /* 5 */
drawCylinder_(6, 16, 1.0, 0.4); /* 6 */
glPopMatrix(); /* 7 */

glTranslatef (-1.0, 0.0, 0.0); /* 8 */
glRotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0); /* 9 */
glTranslatef (1.0, 0.0, 0.0); /* 10 */

glPushMatrix(); /* 11 */
glScalef (2.0, 0.4, 0.4); /* 12 */
glutSolidCube (1.0); /* 13 */
glPopMatrix(); /* 14 */

................

}
relsoft
relsoft
Matrix multiplication is not commutative and the order of transformations in OpenGL is done in reverse order.
Hi.
Gilmario
Gilmario
Ok, I figured out, in fact I have:

line 3: modelview1=modelView*invT1*R1*T1

line 5: modelView2=modelView1*T2

line 10: modelView3=modelView1*invT2*R2*T2

line 12: modelView4=modelView3*Esc


Thank you...

Topic Locked

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

Sign in to reply to this topic.