2 Replies - 18011 Views - Last Post: 15 July 2009 - 04:37 AM Rate Topic: -----

#1 Kanvus   User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 452
  • Joined: 19-February 09

3D Skeletal Animation Tutorial

Posted 13 July 2009 - 10:23 AM

This is about drawing full-body models that work and dance like you want. However, only skeletons are covered, no mesh and skin. The wiki link has that stuff.

What u need:
Knowing structures and pointers(not really, just structs).

This is code for:
Only 1 glut example. Rest is platform independent. But can't be used in C(do in C++).

Enjoy kind peoples.

Each bone has 2 points: x1 and y1 ex. (0,0) and the second is x2 and y2 or (0,1). Now the picture we have if we drew this is a stick coming straight up from the ground, at the center of the screen. Then in the same place we give it a hole to stick another bone into it, just like toys that click together. The entire code for one bone is:
struct bone{
	float x1, x2, y1, y2; //two points on graph
	bone* child; //the hole/slot to append bones

Then we give it the points said earlier, (0,0) going to (0,1):
bone boney; // create 1 bone
bone.x1 = 0; bone.y1 = 0; // (0,0) first point
bone.x2 = 0; bone.y2 = 1; // (0,1) second point

Posted Image becomes Posted Image

Now we need another bone because one is retarded. All we do is make another:
bone propane; // yes boomhauer, propane  
:dangole: dangole wut
Then hook it up with boney:
boney.child = &propane; // & because child is a pointer

However, there was no big reason to do that for today. It's useful later on when you want to manage entire skeletons that have string names and labels. It's for organization mostly.

Our first bone was a stick pointing straight up. The second bone's beginning is at the end of the tip of the first bone, which is (0,1) so we give propane's x1 and y1 boney's x2 and y2: (we may refer to the new bone as boney* child or itself, propane.etc)
propane.x1 = boney.x2; // or boney.child->x1 = boney.x2;
propane.y1 = boney.y2; // or boney.child->y1 = boney.y2;

//Now assign the tip of the second bone
propane.x2 = 2; propane.y2 = 1; // (2,1)

Posted Image

Tah~dahh. The picture is an upside down L or T with its left arm mauled off.

If you have OpenGL:(the draw code)


//To animate the thing
propane.y2 -= 0.1; // Bends the right arm 
				   // inward like a real arm(roughly)

Posted Image

If you know more, please post lots of suggestions/links to better tuts and guides. My binging skills cannot find them all(or any :[)


Anyone know where some lessons or info on skeletal or character animation in code is? In DarkGDK last year I remember loading up an .X file that played through about 300 frames in loops and it seemed simple enough. Now looking through search engines it looks like no one really knows much about it other than animating in modeling studios and saving to an animation file.

Animadead is something that pops up a lot. Do you guys use this library or know a book with better detail?

Edit: Went through this forum and found two things for starters. Book: Focus on 3D Models and an Irrlicht tutorial that moves single nodes at a time http://irrlicht.sour...example004.html.
A nice tutorial for OpenGL and using bones http://gpwiki.org/in...ic_Bones_System <-Best resource so far.

This post has been edited by Kanvus: 15 July 2009 - 05:59 AM

Is This A Good Question/Topic? 0
  • +

Replies To: 3D Skeletal Animation Tutorial

#2 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: 3D Skeletal Animation Tutorial

Posted 13 July 2009 - 11:13 AM

This has some really useful information.

You are right, the resources for info like this on the web are not great. You have to piece it all together yourself.

To be honest its not too hard once you know what your doing and you can write something to load and animate nicely.

A good start point may be to use .md2 models and write a loader for them.
Was This Post Helpful? 0
  • +
  • -

#3 Kanvus   User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 452
  • Joined: 19-February 09

Re: 3D Skeletal Animation Tutorial

Posted 15 July 2009 - 04:37 AM

Yeah I think I get it now, so might as well contribute so someone can search this dead thread later. The idea of character skeletons are like legos. Modified above into tut. Thanks for help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1