Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: OpenGL: matrix manipulation

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    10

    OpenGL: matrix manipulation

    Hello everyone, I'm an Italian student, so you have to excuse me if my English is not perfect.
    I have some problems using the matrix stack in an application for an exam. In particular, the application implements a model viewer and i have to modify it:
    1) positioning just 3 different geometric models in the scene using OpenGl function: glPushMatrix() and glPopMatrix().
    2) Permit translation, rotation of the single object respect of the WCS, OCS, VCS reference system. The single objects must be selected by means of '1' '2' '3' key. The trasformations of translation or rotation must me applied by means of key 'x' 'X' 'y' 'Y' 'z' 'Z'. The selection of the type of the transformation (translation/rotation) and the reference system must be done with:
    - 'o' translation respect OCS
    - 'O' rotation respect OCS
    - 'w' translation respect WCS
    - 'W' rotation respect WCS
    - 'v' translation respect VCS
    - 'V' rotation respect VCS (with the direction of the rotation axis same of the VCS and pass through the Origin of the VCS).

    I ask you some help. I can't do it and maybe you can provide me some suggestions.

    Thank you everyone

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,169

    Re: OpenGL: matrix manipulation

    Quote Originally Posted by Davide87Imola
    I can't do it ...
    If you're not even gonna try and you say this, I'm sure you're correct.

    But yes you can, if you set your mind to it. This isn't rocket science or particle physics.

    Start here and ask questions as needed.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    10

    Re: OpenGL: matrix manipulation

    i have alredy tried, but i was not able to find a solution. I'm desperate

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2010
    Location
    D.C.
    Posts
    21

    Re: OpenGL: matrix manipulation

    What do you have so far?
    Genfx Visual Simulations - hi-fidelity realtime simulator systems

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    10

    Re: OpenGL: matrix manipulation

    excuse for my English.
    i have alredy positioned 3 differend object in the scene and i have understand how it is possible to translate and rotate them respect on the WCS. I have some problems with OCS and VCS

  6. #6
    Junior Member Newbie
    Join Date
    Feb 2010
    Location
    D.C.
    Posts
    21

    Re: OpenGL: matrix manipulation

    If you're drawing three of the same objects, but positioning them independently in world coordinate space... and then changing your view ... does your code resemble something like this?

    Code :
    PushMatrix()
      // apply view
      transformTo(VCS)
     
      // position object 1
      PushMatrix()
        transformTo(WCS1)
        transformTo(OCS)
        drawObject()
      PopMatrix()
     
      // position object 2
      PushMatrix()
        transformTo(WCS2)
        transformTo(OCS)
        drawObject()
      PopMatrix()
     
      // position object 3
      PushMatrix()
        transformTo(WCS3)
        transformTo(OCS)
        drawObject()
      PopMatrix()
     
    PopMatrix()
    Genfx Visual Simulations - hi-fidelity realtime simulator systems

  7. #7
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    10

    Re: OpenGL: matrix manipulation

    yes, it is the same. But....the last part of the exercise requires that i select one of the 3 object with key 1,2,3 and it is done...but how can i manipulate one of the 3 objects when they are all alredy inserted in the sceene? i would like to rotate and traslate a single object whene it is alredy positioned in the scene. Do you understand, even if my English in not well?

  8. #8
    Junior Member Newbie
    Join Date
    Feb 2010
    Location
    D.C.
    Posts
    21

    Re: OpenGL: matrix manipulation

    In the pseudocode provided above, there are 5 distinct transformations used: VCS, OCS, WCS1, WCS2, WCS3. Adjusting the rotation and translation parameters used to produce the WCS1, WCS2, WCS3 transformations should allow you to independently move each individual object in the scene.
    Genfx Visual Simulations - hi-fidelity realtime simulator systems

  9. #9
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    10

    Re: OpenGL: matrix manipulation

    thank you...i have done...thank you very much.
    Last problem: and respect the VCS, how can i manipulate a single object?

  10. #10
    Junior Member Newbie
    Join Date
    Feb 2010
    Location
    D.C.
    Posts
    21

    Re: OpenGL: matrix manipulation

    The VCS will change the position of all objects, as it is a transformation done to the entire scene. If you are attempting to manipulate a single object, you're probably looking to change one of the WCS transformations.

    In the example above:
    - VCS affects the entire scene.
    - WCS[1,2,3] affects 1 instance of the object.
    - OCS affects all instances of the object.
    Genfx Visual Simulations - hi-fidelity realtime simulator systems

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •