Results 1 to 7 of 7

Thread: Transformations

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    17

    Transformations

    How to rotate the object itself? And when i scale the object the position of the object also moved; I want to place the object at same positio.

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

    Re: Transformations

    glRotate... is used to rotate.

    An object is scaled around the origin so if you for example center a cube around the origin and then scale it, it will not move.

    It is important to do scaling/rotation/translation in correct order.

    Mikael


    [This message has been edited by mikael_aronsson (edited 11-03-2003).]

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    17

    Re: Transformations

    Can you give the code, Please.

  4. #4
    Member Contributor
    Join Date
    Jul 2002
    Location
    Seri Kembangan, Selangor, Malaysia
    Posts
    92

    Re: Transformations

    Hi,

    Try some simple opengl examples here... http://myopendemo.hypermart.net

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    17

    Re: Transformations

    Here i have placed my code. I tried to rotate the object around itself. But it won't work. Please modify the code.

    glLoadIdentity();
    glRotatef(gfAngle, 0.0f, 0.0f, 10.0f);

    glBegin(GL_LINE_LOOP);
    glVertex3f(10.0f, 10.0f, 0.0f);
    glVertex3f(60.0f, 10.0f, 0.0f);
    glVertex3f(60.0f, 60.0f, 0.0f);
    glVertex3f(10.0f, 60.0f, 0.0f);
    glVertex3f(10.0f, 10.0f, 0.0f);
    glEnd();

    glLoadIdentity();

    glFinish();




    [This message has been edited by Balu (edited 11-03-2003).]

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Transformations

    Ok, if my calculations are right, the center of that line loop is about 35,35.

    So... do this:

    glTranslatef(35, 35, 0); // translate back to position
    glRotatef(gfAngle, 0.0f, 0.0f, 1.0f);
    glTranslatef(-35, -35, 0); // translate to origin
    Deiussum
    Software Engineer and OpenGL enthusiast

  7. #7
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    17

    Re: Transformations

    Thank you, it is very helpful for me.

Similar Threads

  1. Hardware Transformations vs Software Transformations
    By killersquirrelz in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 12-05-2004, 04:43 AM
  2. 3d transformations
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-22-2003, 04:09 PM
  3. transformations...
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-05-2002, 10:43 PM
  4. Help on transformations
    By KurtCob in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 09-12-2000, 06:46 AM
  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