Results 1 to 4 of 4

Thread: Difference between view and Model Transformation

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    1

    Difference between view and Model Transformation

    Hello,
    I am learning Opengl.I am confused with the view transformation and model transformation.
    Code :
    glLoadIdentity();                            
    glTranslatef(0.0f,0.0f,-8.0f);               
    glBegin(GL_POLYGON);
    glVertex3f(1.0f,0.0f,-8.0f);
    glVertex3f(3.0f,0.0f,-8.0f);
    glVertex3f(2.0f,2.0f,-8.0f);
    glEnd();
    I understood the above code as view transformation,setting the camera position at (0,0,- and viewing the triangle.

    Code :
    glBegin(GL_POLYGON);
    glVertex3f(1.0f,0.0f,-8.0f);
    glVertex3f(3.0f,0.0f,-8.0f);
    glVertex3f(2.0f,2.0f,-8.0f);
    glEnd();
    glLoadIdentity();    
    glTranslatef(0.0f,0.0f,-8.0f);

    I understand this as Model transformation,translating the object by (0,0,-.

    Both gives the same output. Have i understood correctly?
    -swetha

  2. #2
    Senior Member Regular Contributor DmitryM's Avatar
    Join Date
    Mar 2009
    Location
    Toronto
    Posts
    435

    Re: Difference between view and Model Transformation

    Read the manual about glMatrixMode carefully.

  3. #3
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: Difference between view and Model Transformation

    No, totally wrong.

    All matrix operations affect currently selected matrix (look at glMatrixMode).

    So:
    Code :
    glMatrixMode(GL_PROJECTION);
    glLoadItentity();
    glFrustum(...);
    This changes current projection matrix.

    Code :
    glMatrixMode(GL_MODELVIEW);
    glLoadItentity();
    glTranslatef(...);
    This changes current modelview matrix.

    In OpenGL you have model and view matrices combined into one modelview matrix. You should know such things before you start programming.

    As for vertex operations - all vertices are processed using current state of matrices. Changing your matrix after you passed vertices makes no sense.
    This is another thing you should know before writting OpenGL programs.

    Read how OpenGL works before you learn programming it. There is no other way.

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    8

    Re: Difference between view and Model Transformation

    Conceptually view matrix affects all objects in your scene (your camera), and model matrix affects individual objects. In OpenGL they are combined into one modelview matrix, so here is what you could do:

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    // specify view matrix
    gluLookAt(...);
    glRotate(...);
    // save view matrix
    glPushMatrix();
    // specify model matrix #1
    glRotate(...);
    // define object #1. The view matrix and the model matrix #1 affect this object
    glBegin(...);
    ...
    glEnd();
    // restore view matrix
    glPopMatrix();
    // specify model matrix #2
    glRotate(...);
    // define object #2. The view matrix and the model matrix #2 affect this object
    glBegin(...);
    ...
    glEnd();
    // restore view matrix
    glPopMatrix();
    // more objects
    ...


Similar Threads

  1. Model transformation from transformation between two frames.
    By VitaliyO in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-21-2017, 02:07 AM
  2. model view matrix and view direction
    By sajis997 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-27-2014, 03:24 AM
  3. OpenGL 3.0 model-view transformation
    By RigoN in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-07-2011, 07:39 AM
  4. Replies: 1
    Last Post: 06-02-2006, 11:52 AM
  5. model view transformation
    By Luin in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-25-2000, 08:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean