PDA

View Full Version : Animation problem



01-11-2005, 07:16 AM
I have draw a 2D object. The object(head) consist of hair, eye, nose, etc. In my program, only eye is animating. I notice there is one problem, that is each time the animation executed, all the other parts are repainted.

My question here is, is there any way for me to keep the parts other than the eye to be static (not to be repainted each time the animation is executed), only eye is repainted each time animation is executed.

VinŪcius Reis
01-11-2005, 07:53 AM
Iím a freshman at this subject, but Iíll try to respond.
Once you want to actualize your screen you the OpenGL redraws the entire scene in the buffer, an after the buffer is changed and the scene is displayed.
So if you want your application to be faster, you should make the less calculation as possible. So you just change what is necessary and after, I think, you have to say to OpenGL redraw the hole scene.

Please, if Iím wrong correct me!

01-11-2005, 08:06 AM
Hi,
one thing you can do is use a displaylist for all parts which are not animated.

cheers
Boim

01-11-2005, 08:35 AM
Did you mean glNewList() ... glEndList()?

What if my functions are in a following sequence:

drawHair();
..
..
drawEye();
..
..
drawMouth();

Beside, there are glPushAttrib() and glPushMatrix. How do I tie together all these? I have one computer graphics reference book, but it does not mentioned how the OpenGL API is to be used in detail.

01-12-2005, 10:01 AM
Try using a hierarchy for your models in compiled lists:

1) In the global namespace, for example:

//defines
#define eye 1
#define mouth 2
#define nose 3

//various variable declarations and definitions
....declare and define starting values for above

//Prototype function declarations
void DrawFace(void);
void init_FacialParts(void);
void Face_mouth(void);
void Face_nose(void);
void Face_eyes(void);

2) In the Body of the App, for example:

void init_FacialParts(void)
{
// Call each of the functions that make
//the following facial parts
Face_mouth();
Face_nose();
Face_eyes(void);
}

void Face_mouth(void)
{
glNewList(mouth,GL_COMPILE);
make the mouth, for example...
glEndList();
return 0;
}
void Face_nose(void)
{

glNewList(nose,GL_COMPILE);
make the nose, for example...
glEndList();
return 0;
}

void Face_eyes(void)
{

glNewList(eyes,GL_COMPILE);
make the eyes, for example...
glEndList();
return 0;
}

void DrawFace(void)
{
/*-----------FAcial Parts-------------*/
glPushMatrix();
//glTranslatef(0,0,-6);
glRotatef(nose,0,1,0);
glRotatef(mouth,1,0,0);
glRotatef(eyes,1,0,0); // make more eye positions to animate eyes only (just an idea)
glPushMatrix();
glCallList(nose);
glCallList(mouth);
glCallList (eyes);

glPopMatrix();

return 0:

}

Just an idea. Hope it helps

01-12-2005, 10:07 AM
Wow, it was kind of you to help me! I will try your suggestion now.