PDA

View Full Version : Making and animating a person?



Chromecuda
12-15-2002, 07:16 PM
I'm very new at this so please bear with me. If an explanation is provided, I would really appreciate a dummy one, as I am really at THAT level. http://www.opengl.org/discussion_boards/ubb/smile.gif

I'd like to make a person out in opengl. After the person is made, I'd really like to make him walk or jump or something.

Is there an easy way of doing this?
What is involved in something like this?

Halcyon
12-15-2002, 10:22 PM
Well, for one thing i hope you are not planning on setting up each and every one of your points for the mesh by hand. http://www.opengl.org/discussion_boards/ubb/biggrin.gif That would be pure hell.

Use a program like OpenFX or MilkShape (my personal fav...but OpenFX is free) to create the model and save it to a certain file format (.3ds, .md2, .md3, etc.) and you have to write code to load that model in.

As far as animation goes, you can insert key frames into the model files. So if you have 256 frames, frames 1-10 could be of the model walking. So when you have the user press the up arrow, you keep cycling through those key frames. It's a lot like how you animate a character walking using paper and pencil. You drawn like 10 pictures. Each one is slightly different than the other and then you just flip through the pages really fast. And it looks like the picture is moving. Each one of those pages is a key-frame.

While we are at it, that is how rendering works. You draw the image and just keep flipping through it at a certain FPS (frames per second) to make it look like it's moving.

Hope all this helped!!!

- Halcyon

147-2
12-16-2002, 12:10 PM
Check out http://www.gametutorials.com there are some excellently commented code chunks available for use in that site. He's got tutorials that cover everything from the C language to learning how to animate MD3 models, and more. I bot his CD (even tho you don't have to) just so that I could pay for all of the good work this guy put into these tuts. Not only does he show you how to do that stuff, he also has tutorials on Octree culling, running Quake BSPs and more.

nexusone
12-16-2002, 12:59 PM
Depends on how detailed of a person you want.

A stick figure would not take much to do, but a life like figure takes a lot.



Originally posted by Chromecuda:
I'm very new at this so please bear with me. If an explanation is provided, I would really appreciate a dummy one, as I am really at THAT level. http://www.opengl.org/discussion_boards/ubb/smile.gif

I'd like to make a person out in opengl. After the person is made, I'd really like to make him walk or jump or something.

Is there an easy way of doing this?
What is involved in something like this?

Chromecuda
12-16-2002, 07:34 PM
Well, I'm gonna start simple and say stick figure.

So say I draw his arms, legs, torso and stuff...then how do I make each piece rotate and move when I want them to?

I think that's the problem I'm running into... I think I can handle drawing him.

I really appreciate the help by the way.

Chromecuda
12-17-2002, 06:26 PM
Care to help a little more?

I drew the body in the display function.
However, I want to be able to switch between the solidsphere to wiresphere with a keystroke.

I can see that it draws the wirespheres, but only momentarily. When I let go of the key, it switches back to the solidsphere.

How do I clear the solidsphere and change to wiresphere?

I've included the top of my display function.

void display(void)
{
GLfloat light_position2[]= {0,.2,0,1}; // setting the flashlight position
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(eyex, eyey, eyez, lookx, looky, lookz, eyex, 200.0, eyez);//sets camera location and trajectory
glutPostRedisplay();
glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;//sets the room to ambient and diffuse
glLightfv(GL_LIGHT1, GL_POSITION, light_position2);//makes flashlight move with viewport

glColor3f(0,0,1);
glutSolidSphere(1, 100,100);//the torso

glPushMatrix();
glColor3f(0,1,0);
glTranslatef(0,1.4,0);
glutSolidSphere(.6,100,100);//the head

Halcyon
12-17-2002, 10:36 PM
Have it so that when you press the key down, a boolean value is set to true if it is false and false if it is true. Then do an if statement and draw the sphere as a wireframe if the value of that variable is true (or false ... but pick one). Basically make it so that when you hit the key, instead of having to hold it down for the effect, a value gets set to true so u can let go and it'll still stay a certain state. When you press it again it'll go back to false




// NOTE: u need to define wireframe as a boolean value somewhere.


//inside where u handle a key press
if (wireframe){
wireframe = false;
}
else
{
wireframe = true;
}

// in the render function

if (wireframe){

glutWireSphere(...) //sorry don't know glut too well..actually i don't know it at all http://www.opengl.org/discussion_boards/ubb/biggrin.gif

}

else

{
glutSolidSphere(.6, 100, 100)

}

Chromecuda
12-18-2002, 01:53 PM
Hmm...
Interesting. Thanks a lot. I'm gonna try that.

nexusone
12-18-2002, 05:20 PM
Here is an easy way to make a stick figure:

// Start object stick figure
glPushMatrix();
glTranslatef(x,y,z); // Location of object
glRotatef(......); // Rotate object

glPushMatrix(); // Draw head
glTranslatef(head_x, head_y, head_z); Location of head on body
glRotatef(.....); // Rotate head
Draw_head();
glPopMatrix(); // End Drawing head

glPushMatrix(); // Draw Body
glTranslatef(body_x, body_y, body_z); Location of body
glRotatef(.....); // Rotate body
Draw_body();
glPopMatrix(); // End Drawing body

// Repeat above for each part of body

glPopMatrix(); // End of Object stick figure

Just control movement by changes to variables in the stick figure object.

Hope this gives you an idea.



Originally posted by Chromecuda:
Well, I'm gonna start simple and say stick figure.

So say I draw his arms, legs, torso and stuff...then how do I make each piece rotate and move when I want them to?

I think that's the problem I'm running into... I think I can handle drawing him.

I really appreciate the help by the way.

Anil
12-19-2002, 01:01 AM
You can check this link. I think this should help you a bit. In this site you actually build a human and make him walk and run.

Cheers
Anil
http://www.dev-gallery.com/programming/opengl/book/b_index.htm