Results 1 to 2 of 2

Thread: Moving an airplane flap

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Ireland
    Posts
    5

    Moving an airplane flap

    The following is code that I have written for a basic Airplane tail fin:
    void Tail()
    {
    glBegin(GL_POLYGON);
    glVertex3f(0,0,0);
    glVertex3f(4,0,0.4);
    glVertex3f(2,8,0.4);
    glVertex3f(0,8,0);
    glEnd();

    glBegin(GL_POLYGON);//Back FACE green
    glColor3f(0.0,0.0,1.0);
    glVertex3f(0,0,1);
    glVertex3f(4,0,0.6);
    glVertex3f(2,8,0.6);
    glVertex3f(0,8,1);

    glEnd();

    glBegin(GL_POLYGON);//lhs blue
    glColor3f(0.0,0.0,1.0);
    glVertex3f(4,0,0.4);
    glVertex3f(4,0,0.6);
    glVertex3f(2,8,0.6);
    glVertex3f(2,8,0.4);

    glEnd();
    glBegin(GL_POLYGON);//RHS white
    glColor3f(1.0,1.0,1.0);
    glVertex3f(0,0,0);
    glVertex3f(0,0,1);
    glVertex3f(0,8,1);
    glVertex3f(0,8,0);

    glEnd();
    glBegin(GL_POLYGON);//Top color
    glColor3f(1.0,0.0,1.0);
    glVertex3f(0,8,0);
    glVertex3f(0,8,1);
    glVertex3f(2,8,0.6);
    glVertex3f(2,8,0.4);

    glEnd();
    glBegin(GL_POLYGON);//BOTTOM
    glColor3f(0.0,1.0,1.0);
    glVertex3f(0,0,0);
    glVertex3f(4,0,0.4);
    glVertex3f(4,0,.6);
    glVertex3f(0,0,1);

    glEnd();
    glBegin(GL_POLYGON);//flaps
    glColor3f(0,0,1);
    glVertex3f(2,8,0.5);
    glVertex3f(4,0,0.5);
    glVertex3f(4.75,0,0.5);
    glVertex3f(2.75,8,0.5);
    glEnd();

    }
    The last polygon is for a flap, as it is on the slanted side of the wing I cannot seem to be able to move it up and down, Any help please
    Ger

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Moving an airplane flap

    You need to make use of glPush/pop matrix commands.


    I have edited your code below

    Originally posted by gerire:
    The following is code that I have written for a basic Airplane tail fin:
    void Tail()
    {
    glPushMatrix();
    glBegin(GL_POLYGON);
    glVertex3f(0,0,0);
    glVertex3f(4,0,0.4);
    glVertex3f(2,8,0.4);
    glVertex3f(0,8,0);
    glEnd();

    glBegin(GL_POLYGON);//Back FACE green
    glColor3f(0.0,0.0,1.0);
    glVertex3f(0,0,1);
    glVertex3f(4,0,0.6);
    glVertex3f(2,8,0.6);
    glVertex3f(0,8,1);

    glEnd();

    glBegin(GL_POLYGON);//lhs blue
    glColor3f(0.0,0.0,1.0);
    glVertex3f(4,0,0.4);
    glVertex3f(4,0,0.6);
    glVertex3f(2,8,0.6);
    glVertex3f(2,8,0.4);

    glEnd();
    glBegin(GL_POLYGON);//RHS white
    glColor3f(1.0,1.0,1.0);
    glVertex3f(0,0,0);
    glVertex3f(0,0,1);
    glVertex3f(0,8,1);
    glVertex3f(0,8,0);

    glEnd();
    glBegin(GL_POLYGON);//Top color
    glColor3f(1.0,0.0,1.0);
    glVertex3f(0,8,0);
    glVertex3f(0,8,1);
    glVertex3f(2,8,0.6);
    glVertex3f(2,8,0.4);

    glEnd();
    glBegin(GL_POLYGON);//BOTTOM
    glColor3f(0.0,1.0,1.0);
    glVertex3f(0,0,0);
    glVertex3f(4,0,0.4);
    glVertex3f(4,0,.6);
    glVertex3f(0,0,1);

    glEnd();

    glPushMatrix();
    glRotatef(angle_rotate, 0,1,0); // not sure which axis will work best, just try one at a time X,Y,Z to get correct motion.
    glBegin(GL_POLYGON);//flaps
    glColor3f(0,0,1);
    glVertex3f(2,8,0.5);
    glVertex3f(4,0,0.5);
    glVertex3f(4.75,0,0.5);
    glVertex3f(2.75,8,0.5);
    glEnd();
    glPopMatrix();

    glPopMatrix();
    }
    The last polygon is for a flap, as it is on the slanted side of the wing I cannot seem to be able to move it up and down, Any help please

Similar Threads

  1. Making a bird flap
    By Scythed in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-10-2010, 07:17 PM
  2. how to make airplane in OpenGl in c?
    By kotaiba in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-30-2009, 12:55 PM
  3. HELP:rotating airplane left and right
    By jakes in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-30-2009, 05:52 AM
  4. Rotating airplane
    By 4WheelDrive in forum OpenGL: General
    Replies: 2
    Last Post: 09-09-2004, 11:18 PM
  5. Help me rotate an airplane
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-27-2000, 01:49 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