Results 1 to 2 of 2

Thread: animation help

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    2

    animation help

    void Keyboard (unsigned char key, int x, int y)
    {

    switch (key)
    {
    glPushMatrix();
    case 'r':
    glRotatef(1, 0, 1, 0); //rotate
    drawVileplume();
    break;
    glPopMatrix();

    //glPushMatrix();
    /*
    case 'j':
    if (up <= 50 || down >= 50)
    {
    glTranslatef( 0, 1, 0);
    up ++;
    }
    case 'J':
    if ( up >= 50 || down <= 0 )
    {
    glTranslatef(0, -1, 0);
    down++;
    }

    break;
    */
    //glPopMatrix();

    case 'd':
    glPushMatrix();
    if (scale3 <= 50)
    {
    glTranslatef(1, 0, 0);
    scale3++;
    }
    check = true;


    break;
    glPopMatrix();

    glPushMatrix();
    case 'a':

    if (scale >= 50)
    {
    glTranslatef(-1, 0, 0);
    scale--;
    }



    glPopMatrix();



    glPushMatrix();
    case 'f'://glRotatef(-1, 1, 0, 0);
    glTranslatef(0, 0, 1); //move front
    scale2++;
    drawVileplume();
    if (scale2 >= 50)
    {
    glTranslatef(0, 0, -1);
    }

    break;
    glPopMatrix();
    }

    }



    void doMainLoop()
    {

    //glPushMatrix();
    if (movingUp) // If we are moving up
    {
    yLocation += 1.0;
    }
    else
    {
    yLocation -= 1.0;
    }

    if (yLocation < -80.0) // If we have gone up too far
    {
    movingUp = false; // Reverse our direction so we are moving down
    glTranslatef(0.0, 0.0, 1.0); // Translate our object along
    yLocation --;

    }
    else if (yLocation > 80.0) // Else if we have gone down too far
    {
    movingUp = true; // Reverse our direction so we are moving up
    glTranslatef(0.0, 0.0, 1.0); // Translate our object along
    yLocation ++;

    }
    /*
    if (movingUp) // If we are moving up
    yLocation -= 1.0; // Move up along our yLocation
    else // Otherwise
    yLocation += 1.0; // Move down along our yLocation

    if (yLocation < -80.0) // If we have gone up too far
    {
    movingUp = false; // Reverse our direction so we are moving down
    glTranslatef(0.0, 0.0, 10.0); // Translate our object alon
    yLocation ++;
    }
    else if (yLocation > 80.0) // Else if we have gone down too far
    {
    movingUp = true; // Reverse our direction so we are moving up
    glTranslatef(0.0, 0.0, 10.0); // Translate our object alon
    yLocation --;
    }
    */
    //glPopMatrix();
    }
    I am bascially making the object move to the front and back to the negative z -axis again if the object reached its max in the front. How should I do it. My animation just appear from the middle then to the end and back again without translate slowly to the front before placing it in back again. Ignore all my Keyboard code . Just on my domainLoop function which I had problem. All my global variables declared. Just the animation needs help. I did not include my whole cpp file as i think it quite huge. And my up is actually movingup is actually front. I forget to change it.

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    2

    Re: animation help

    if (movingUp) // If we are moving up
    yLocation -= 1.0; // Move up along our yLocation
    else // Otherwise
    yLocation += 1.0; // Move down along our yLocation

    if (yLocation < -80.0) // If we have gone up too far
    {
    movingUp = false; // Reverse our direction so we are moving down
    glTranslatef(0.0, 0.0, 10.0); // Translate our object alon
    yLocation ++;
    }
    else if (yLocation > 80.0) // Else if we have gone down too far
    {
    movingUp = true; // Reverse our direction so we are moving up
    glTranslatef(0.0, 0.0, 10.0); // Translate our object alon
    yLocation --;
    }This is the part where I had problem.

Similar Threads

  1. Help with an animation
    By Eztlicoatl in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-03-2015, 06:03 PM
  2. Animation name
    By Vespa in forum COLLADA
    Replies: 1
    Last Post: 10-14-2009, 04:51 AM
  3. Sprite Animation / Texture Animation
    By Rodrix in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 03-11-2007, 10:36 PM
  4. How to do Animation
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-13-2003, 04:41 AM
  5. 3D animation
    By Alhek in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-20-2003, 11:09 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