Results 1 to 3 of 3

Thread: rotating a quad (Newbie)

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Australia
    Posts
    5

    rotating a quad (Newbie)

    just a quick question on how to rotate my quad exactly the way i want.

    some code.....

    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
    glLoadIdentity (); // Reset The Modelview Matrix
    glTranslatef (xpos, ypos, -18.0f); // Translate 6 Units Into The Screen
    glRotatef (angle, 0.0, 0.0f, -1.0f); // Rotate On The Y-Axis By angle
    glBegin (GL_QUADS); // Begin Drawing Triangles
    glColor3f (1.f, 0.f, 0.f); glVertex3f( 0.0f, 1.0f, 1.0f);
    glColor3f (0.f, 1.f, 0.f); glVertex3f( 1.0f, 1.0f, 1.0f);
    glColor3f (0.f, 0.f, 1.f); glVertex3f( 1.0f, 0.0f, 1.0f);
    glColor3f (1.f, 0.f, 1.f); glVertex3f( 0.0f, 0.0f, 1.0f);
    glEnd (); // Done Drawing Triangles

    Now what i want to be able to do is to rotate my quad from the centre of it. At the moment it is rotating from the 2nd vertex that i draw.

    Could someone point me in the right direction please???
    Werdy666 [img]/forum/images/%%GRAEMLIN_URL%%/laugh.gif[/img]

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Stuttgart, Germany
    Posts
    27

    Re: rotating a quad (Newbie)

    glTranslatef (xpos, ypos, -18.0f); // Translate 6 Units Into The Screen
    glRotatef (angle, 0.0, 0.0f, -1.0f); // Rotate On The Y-Axis By angle
    glBegin (GL_QUADS); // Begin Drawing Triangles
    glColor3f (1.f, 0.f, 0.f); glVertex3f( 0.0f, 1.0f, 1.0f);
    glColor3f (0.f, 1.f, 0.f); glVertex3f( 1.0f, 1.0f, 1.0f);
    glColor3f (0.f, 0.f, 1.f); glVertex3f( 1.0f, 0.0f, 1.0f);
    glColor3f (1.f, 0.f, 1.f); glVertex3f( 0.0f, 0.0f, 1.0f);
    glEnd (); // Done Drawing Triangles

    ----------------
    you have to translate to the middle of your quad and THEN rotate. the middel of the quad seems to be sth like 0.5/0.5/1.0

    translate to this position, and then rotate


    seb

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Australia
    Posts
    5

    Re: rotating a quad (Newbie)

    thanks! after a little bit of experimentation i changed the vertex coordinates to 0.5 and -0.5 and it works perfect now! Thanks for your help!

    Werdy666 [img]/forum/images/%%GRAEMLIN_URL%%/laugh.gif[/img]

Similar Threads

  1. Rotating Objects - Light Rotating not expected
    By SparkyNZ in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 08-12-2015, 07:52 PM
  2. Replies: 1
    Last Post: 07-04-2013, 01:42 AM
  3. Rotating a Texture on a Quad
    By ramona in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-19-2008, 05:03 AM
  4. rotating and object without rotating its axis
    By scam in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 12-17-2003, 08:30 AM
  5. Problem rotating parent then rotating children
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-04-2002, 11:15 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