PDA

View Full Version : Disappearing models



gottijay
07-25-2011, 12:49 PM
Tried to do some simple animations which basically moves individual model from one position to the other...each of them enclosed in an animation function ....the problem i have is when one animation finishes the model related to that animation disappears...making way for the model in the next animation.....which is not exactly what i want...

what i want is for the first model to remain displayed while the second animation was running... and the first and the second models remain displayed while the third model is running an so on...this is how my animation function looks

i'm thinking it might be a transformation problem...no idea how to fix it.



display(){
.....
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
animation();
glPopMatrix();

glPushMatrix();
animation2();
glPopMatrix();

glPushMatrix();
animation3();
glPopMatrix();
}

void Animation()
{
if(flag1){
glPushMatrix();
// Tell the timer a new frame has been started:
g_Timer.StartNewFrame();

// Start and End time of the teapot animation:
float StartTime = 10.0f;
float EndTime = 15.0f;

// Time since last frame, and total rendering time:
float FrameTime = g_Timer.GetFrameTime();
//float FrameTime = g_Timer.GetFrameTime();
static float TotalTime = 0.0f;
TotalTime += FrameTime;

// Start and end position of the teapot, as well as it's current position:

glm::vec3 StartPoint=glm::vec3(-15,3.4,10);
glm::vec3 EndPoint=glm::vec3(7, 5, -1.9);

static glm::vec3 CurrentPos = StartPoint;

// If we're in the animation interval, animate:
if ((TotalTime > StartTime) &amp;&amp; (TotalTime < EndTime))
{
CurrentPos.x += (EndPoint.x - StartPoint.x) * (FrameTime / (EndTime - StartTime));
CurrentPos.y += (EndPoint.y - StartPoint.y) * (FrameTime / (EndTime - StartTime));
CurrentPos.z += (EndPoint.z - StartPoint.z) * (FrameTime / (EndTime - StartTime));
}

// Translate and draw:
glTranslatef(CurrentPos.x, CurrentPos.y, CurrentPos.z);
glScalef( .3, .3, .3 );
// glColor3f(1,0,0);

drawMast();



if (TotalTime>15.0f){
flag1=false;
flag2=true;
}
glPopMatrix();
}//end flag


connectMast=true;
//glutPostRedisplay();
}


the other animation functions are basically the same ....how do i ensure the models dont disappear after their respective functions have finished executing.....


thanks...hope my question is not too vague