glVertex4f

This is a discussion on glVertex4f within the Game Programming forums, part of the General Programming Boards category; I noticed that there is a glVertex4f. The fourth parameter is w. What is w used for?...

  1. #1
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552

    glVertex4f

    I noticed that there is a glVertex4f. The fourth parameter is w. What is w used for?

  2. #2
    Registered User
    Join Date
    Nov 2003
    Posts
    1
    hmm, weight?

  3. #3
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    the coordinate 'w' is used for quaternions.

  4. #4
    Registered User grady's Avatar
    Join Date
    Oct 2003
    Posts
    27
    Originally posted by EvBladeRunnervE
    the coordinate 'w' is used for quaternions.
    the gl uses 4x4 matrices for transformation. a translation is stored in the 4th column of that matrix. A 1 is always at the 4th col, 4th row of the matrix. The GL is always using 4 vectors internally. The w coordinate is set to 1 by default. Changing w scales how translations effect that vertex. It has nothing to do with quaternions.

  5. #5
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    I don't get it. A translation is stored in the fourth column? What translation is stored there? I thought translations only effected the first three columns.

  6. #6
    Registered User grady's Avatar
    Join Date
    Oct 2003
    Posts
    27
    Originally posted by frenchfry164
    I don't get it. A translation is stored in the fourth column? What translation is stored there? I thought translations only effected the first three columns.
    Not possible.
    The manual.
    Linear algebra.
    Dirt cheap linear algebra.
    More advanced linear algebra
    Code:
    glLoadIdentity( );
    glTranslatef( a, b, c );
    glVertex3f( x, y, z );
    |1 0 0 a|   |x|   |x+a|
    |0 1 0 b|   |y|   |y+b|
    |0 0 1 c| * |z| = |z+c|
    |0 0 0 1|   |1|   |1|
    Code:
    glLoadIdentity( );
    glTranslatef( a, b, c );
    glVertex4f( x, y, z, 3 );
    |1 0 0 a|   |x|   |x+3a|
    |0 1 0 b|   |y|   |y+3b|
    |0 0 1 c| * |z| = |z+3c|
    |0 0 0 1|   |3|   |3|
    Last edited by grady; 11-29-2003 at 02:01 PM.

  7. #7
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    I c. Thx for clearing it up. I know how to do matrix math, but I didn't know how OpenGL did translations with it.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21