Results 1 to 5 of 5

Thread: How to move a object in Parabolic shape in OpenGL

  1. #1
    Newbie Newbie
    Join Date
    Feb 2014
    Posts
    3

    Question How to move a object in Parabolic shape in OpenGL

    Hi Everyone,

    I have started learning OpenGL since 2 months. I am making one Basketball game where my aim is once user drag the ball and leave then it need to reach in basket or miss, depending upon parabolic equestion. So I am trying to move the object in Parabolic shape,I could draw the parabola but could not move the object so can anybody suggest how to move the object in parabolic shape.


    Thanks
    Girish

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    have a look at glTranslate - this is the basic function you need to move an object

  3. #3
    Newbie Newbie
    Join Date
    Feb 2014
    Posts
    3
    Thanks For the reply..I am already glTranslate to move an object in x and y direction. But once I put the for loop to move an object in paraolic shape then sometimes window goes blank or geting unpridictable behaviour. Here is my function which draws sphares in parabolic Sphere but it does not move in prabolic shape. Can you please help me in this....

    void DrawParabola()
    // The Drawing Routine
    {
    double x,y;
    glColor3f(1.0, 1.0, 1.0);
    for (tranx = -2; tranx <= 8; tranx += .002)
    {
    glPushMatrix();
    trany = 18* tranx -9* tranx * tranx;
    glLoadIdentity();
    tranx +=0.1*Speedfact;
    trany +=0.1*Speedfact;
    glTranslatef(tranx*3,trany,tranz);
    glutWireSphere(0.6, 20, 16);
    glPopMatrix();
    Sleep(50);
    glutPostRedisplay();
    }

    }

  4. #4
    Newbie Newbie
    Join Date
    Feb 2014
    Posts
    3
    Thanks For the reply..I am already using glTranslate to move an object in x and y direction. But once I put the for loop to move an object in parabolic shape then sometimes window goes blank or geting unpridictable behaviour. Here is my function which draws sphares in parabolic shape but it does not move in prabolic shape. Can you please help me in this....

    void DrawParabola()
    // The Drawing Routine
    {
    double x,y;
    glColor3f(1.0, 1.0, 1.0);
    for (tranx = -2; tranx <= 8; tranx += .002)
    {
    glPushMatrix();
    trany = 18* tranx -9* tranx * tranx;
    glLoadIdentity();
    tranx +=0.1*Speedfact;
    trany +=0.1*Speedfact;
    glTranslatef(tranx*3,trany,tranz);
    glutWireSphere(0.6, 20, 16);
    glPopMatrix();
    Sleep(50);
    glutPostRedisplay();
    }

    }

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    The code you have included looks ok but why do you change your loop control with

    tranx +=0.1*Speedfact;

    You may simply be calculating an x,y that is outside the view frustrum

Similar Threads

  1. Move a basic shape
    By sapkota in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-22-2016, 06:35 AM
  2. Applying 2 image textures to simple shape object?
    By mobileopengl in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 09-23-2015, 11:44 AM
  3. Replies: 1
    Last Post: 07-24-2014, 04:59 PM
  4. Move an object
    By JulienB in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-26-2007, 02:17 AM
  5. To Create & Rotate a Star-Shape Object
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-02-2004, 05:50 PM

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