Results 1 to 5 of 5

Thread: Independent transformations

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Bangalore, Karnataka,India
    Posts
    17

    Independent transformations

    Hi All,

    I am a beginner to OpenGL programming. I am stuck with a problem. I will
    explain it with a simple example.
    I wanted to draw a tilted V using two lines and some rotations. I wanted
    to do in the following way.

    0) Initial position.
    1) Draw line along Y-axis.
    2) Rotate it anticlickwise 45.0
    3) Come to initial position. Such that transformation done in the step (2) does not
    apply next.
    4) Now draw one more line along Y-axis.
    5) Rotate it clockwise 45.0. Now we should have a shape 'V'
    6) Now rotate thsi whole model(, I mean the V shape), 90.0

    That is I wanted to apply independent transformations to each object and one more transformation for the entire scene.

    I tried to use pusmatrix and popmatrix. But it didn't help. May be I am not
    using it in proper way. Can you please let me know how to acheive this.
    A pseudo code will be really help ful.

    Expecting your help.

    Thanks in advance
    Deek**** M

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: Independent transformations

    Maybe you could post the code that you have problems with ?

    You could do it soemmthing like this:

    glPushMatrix();
    glRotatef( -45, 0, 0, 1);
    draw line
    glPopMatrix();
    glPushMatrix();
    glRotatef( 45, 0, 0, 1);
    draw line again
    glPopMatrix();

    You save the current matrix, do the rotation and then draw the shape you want, then pop the matrix to restore it as it was before.

    You have to do any rotation before you draw the object not after.

    Mikael


    [This message has been edited by mikael_aronsson (edited 02-25-2004).]

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Bangalore, Karnataka,India
    Posts
    17

    Re: Independent transformations

    Hi Mikael,
    The code is bit complex. and conatisn 4 files, If it can be posted I can send that. Here is what I did.

    Rotate();
    PushMatrix();
    /* loadIdenity() */
    rotate_1();
    DrawLine1();
    /* loadIdenity() */
    rotate_2();
    DrawLine2();
    pop();

    But I found that drawLine2 is affected by both rorate_1() and rotate_2(). Do I need co uncomment the loadIdentity()..... ?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Princeton, NJ
    Posts
    380

    Re: Independent transformations

    you need to do some thing like this
    Rotate();
    PushMatrix();
    rotate_1();
    DrawLine1();
    PopMatrix();
    PushMatrix();
    rotate_2();
    DrawLine2();
    PopMatrix();

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Bangalore, Karnataka,India
    Posts
    17

    Re: Independent transformations

    Yes. It worked now. Thanks

Similar Threads

  1. order independent transformations for 2D framework
    By m3xican in forum OpenGL: General
    Replies: 3
    Last Post: 05-30-2011, 04:29 AM
  2. Transformations: scene/object independent rotation
    By OglNewb in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-18-2010, 04:07 AM
  3. Hardware Transformations vs Software Transformations
    By killersquirrelz in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 12-05-2004, 04:43 AM
  4. independent GUI
    By zotto in forum OpenGL: General
    Replies: 3
    Last Post: 04-13-2003, 07:26 PM
  5. Replies: 1
    Last Post: 08-30-2000, 10:54 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