Results 1 to 7 of 7

Thread: more lame questions...

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    england
    Posts
    4

    more lame questions...

    Some one should be able to answer this one easy! (I hope) I know there are you basic matrix modes to be operated on in OpenGL, the model_view , projection, texture. Now when do i have to change matrix mode, and why? Also I know that matrices in openGL are 4 x 4 matrices, what does each element in the matrix represent? I know these are questions that could be answered with the openGL red or blue book,which ive ordered but still waiting for so no flaming! thanx again Mike

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    442

    Re: more lame questions...

    Generally, you will only change to GL_PERSPECTIVE once - or when your window changes size (or you a rendering a scene with a different frustum for any other number of reasons). Basically, GL_PERSPECTIVE sets the perspective transformation to be appiled to your 3d points **after** they have been transformed by the modelview matrix.

    Modelview matrix can be set once just before you need to use it (assuming you didn't push\pop matrix state) and is used to transform a single object - in either position, rotation or scale etc.

    Texture matrix is for advanced use - and for a beginner you don't need to touch it, but you would change to texture matrix if you want to modify your texture coords in some way before render (advanced lighting, projection techniques etc.).

    in the 4v4 matrix, you have the following values:

    r r r sx
    r r r sy
    r r r sz
    tx ty tz 1

    Where r is rotation, s is scale and t is translation. This is of course a `noddy' version - there are plenty of tuts out there and samples\explainations of how these values actually get set.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    352

    Re: more lame questions...

    Originally posted by Robbo:

    r r r sx
    r r r sy
    r r r sz
    tx ty tz 1

    No, it's :
    rs rs rs tx
    rs rs rs ty
    rs rs rs tz
    0 0 0 1

    Where the t's are for translation, and
    rs rs rs
    rs rs rs
    rs rs rs
    is for both rotation and scaling. If there is only scaling, it's
    sx 0 0
    0 sy 0
    0 0 sz.
    If there is a rotation, that's a bit more complicated. For example, for a rotation of angle a around the y axis, it's
    cos (a) 0 -sin (a)
    0 0 0
    sin (a) 0 cos (a)

    lateniteoverdose,

    To understand where all this comes from, you have to know how a matrix is interpreted as a transformation. This is explained in the SuperBible (among others). A link to this book has been posted very recently on this forum.

    Morglum

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    442

    Re: more lame questions...

    Doh! Of course thats right. Sorry.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    352

    Re: more lame questions...

    No problem

  6. #6
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: more lame questions...

    Some nitpicking.
    A rotation of angle a around the y axis (in OpenGL), is actually this
    Code :
     cos(a) 0 sin(a)
      0     1  0
    -sin(a) 0 cos(a)
    Matrices in OpenGL are left multiplied, model system is right handed, and there needs to be 1 in the y column.

  7. #7
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    352

    Re: more lame questions...

    Now it's my turn to say 'Doh' !

    Yes you're absolutely right about the 1. With a 0 it would squish the y-coord to 0.
    Thanx
    Morglum

Similar Threads

  1. few questions
    By jlukas in forum OpenGL: GLSL
    Replies: 2
    Last Post: 08-30-2004, 06:36 AM
  2. VBO questions
    By JanHH in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-10-2003, 07:59 AM
  3. lame question... where to find glaux.h?
    By hollowcoder in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 08-19-2002, 12:42 AM
  4. 2 Questions?
    By imported_no-one in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-16-2001, 11:15 PM
  5. GLS and other questions
    By jesusgumbau in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 02-17-2001, 09:27 AM

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