natural leg movement

Show 80 post(s) from this thread on one page
Page 1 of 3 123 Last
• 01-10-2004
DavidP
natural leg movement
Well, I have solved my rotation problem (for anyone who might have been wondering). It was hard to find, but easy to fix once found (as most errors are).

Anyways, I am wondering about how to do something correctly and efficiently. I am sure I could probably do this some hacked up sort of way, but I was wondering if anybody had done this before and could enlighten me on how they did it.

I am rotating my legs of my 3d model so that they walk, however, I do not want the legs to stay like stiff boards, I want them to bend at the knee so that it looks like a natural walking movement.

Rotating the bottom half of the leg from the knee down is not the problem, but making it stay with the top part of the leg as the top part of the leg does its own thing is the hard part. For example, I could easily rotate the bottom part of the leg making it look like it is doing its natural movement, and I could easily rotate the top half of the leg making it look like it is doing its natural movement, but the top and bottom halves need to stay attatched to each other the whole time.....we dont want to have an amputated leg.

So somehow I guess I need to keep track of the position of the bottom coordinates of the top half of the leg, and then translate the bottom half of the leg up to those bottom coordinates every frame to make sure it stays with the top half of the leg. I dont know...thats what I was thinking.

Give me your ideas. A picture is below.
• 01-10-2004
Silvercord
You need to implement a skeletal animation system based on joints. Each joint has a 4x4 matrix which has a rotation component and a translation component. In order to get this to work the way you want each joint has a matrix and a parent (except for the root joint). You need to multiply the current matrix by the parent's matrix before multiplying each vertex owned by the joint by the final matrix which represents all of the transformations. If you want super realism you also implement a system of 'weights' based on vertex distances from bones, so that each vertex is affected by *all* joints in the model, but mostly affected by the closest joints (this gives the effects of lucid moving skin over the skeleton).

skelanim with milkshape3d, doesn't do the weights, but the matrix mathematics stays mostly the same.

http://rsn.gamedev.net/tutorials/ms3danim.asp

and you cannot actually build the tutorials he posted on his site, so I had to hack through and make the .net and msvcpp 6 versions work:
http://www.thedevelopersalliance.com...5/SKELANIM.zip

http://www.thedevelopersalliance.com...KELANIMNET.zip
• 01-10-2004
Aalmaron
i'd sugest decompiling a half life model in milkshape, and then looking at the walk animation for it.
• 01-10-2004
Silvercord
he's talking about the programming side of it...it's up to the animator to actually make the animation sequences

and david, something i didn't mention, in your picture above you'd have a joint at the hip, a joint at the knee, and then probably a joint at the ankle.
• 01-10-2004
also do a research on "inverse kinematics" on google, it is very useful in figuring out how a movement would affect the different joints.

also, silvercord, is the reason you have to multiply each joints matrix by the parent matrix is so that you concencate(sp?) the rotations/translations? I can pretty easily figure out what such a matrix would look like, but I dont feel like having to fill several pages worth of paper to solve out a few problems.

EDIT: what i mean by the above is sort of like if you want to rotate and translate a vector in homogenous space(figured out what that 'w' coordinate was all about :D), you would make up a rotation matrix, then make a translate matrix, then multiply them together(in this case is it cummanitive(sp?) no matter the order, as I know regular matrical multiplacation is not), and that will give the proper matrix to convert those vertices points to world space.
• 01-10-2004
VirtualAce
Most games do not take this approach. Most of them use actual actors to act out the various sequences in the game, be it running or pulling someone out of a vehicle as in GTA 3. The actor has lights or sensors at each of his/her important joints. A very simple vertex model is then derived from these points. Then the model team goes to work and refines the vertexes into an actual model, skins it, etc. So each frame of animation is skinned and modeled and put into a file. All the game is really doing is replaying that sequence frame by frame. To further illustrate this try to do a second action whilst doing another. The first action usually must complete prior to the second action's animation playing resulting in a bit of lag time between key press and actual execution.

Most of you who have played FPS's know this because sometimes your character jumps or skips a frame resulting in some odd sequnces being rendered. Most games are getting a lot better at playing transitional frames - the actor acts out what it would look like to transition from jumping to diving, etc. These transition sequences are then played/rendered back.

Very few developers have the time or manpower required to create each movement from a series of multiplies and equations. Not to mention it would be very hard to do even the simplest animation. Most everything has been pre-rendered, placed into a file and keyframed, and then is played back.

My advice is to pre-render your characters in an art program like 3D Studio Max, save it to a file and keyframe the animationm and then use Direct3D to "re-play" the sequence. You don't have to use keyframing but this is just one popular method.
• 01-10-2004
MrWizard
Quote:

Originally posted by Bubba
Most games do not take this approach. Most of them use actual actors to act out the various sequences in the game, be it running or pulling someone out of a vehicle as in GTA 3. The actor has lights or sensors at each of his/her important joints. A very simple vertex model is then derived from these points. Then the model team goes to work and refines the vertexes into an actual model, skins it, etc. So each frame of animation is skinned and modeled and put into a file. All the game is really doing is replaying that sequence frame by frame. To further illustrate this try to do a second action whilst doing another. The first action usually must complete prior to the second action's animation playing resulting in a bit of lag time between key press and actual execution.

Most of you who have played FPS's know this because sometimes your character jumps or skips a frame resulting in some odd sequnces being rendered. Most games are getting a lot better at playing transitional frames - the actor acts out what it would look like to transition from jumping to diving, etc. These transition sequences are then played/rendered back.

Very few developers have the time or manpower required to create each movement from a series of multiplies and equations. Not to mention it would be very hard to do even the simplest animation. Most everything has been pre-rendered, placed into a file and keyframed, and then is played back.

My advice is to pre-render your characters in an art program like 3D Studio Max, save it to a file and keyframe the animationm and then use Direct3D to "re-play" the sequence. You don't have to use keyframing but this is just one popular method.

We used skeletal animation in our latest game and it worked fine. No problems whatsoever.
• 01-10-2004
Silvercord
Bubba, no offense buddy, but what are you talking about? For one, the talk about how professional game studios strap the light bulbs to actors and then use those is pointless because I doubt davidp has the resources to do that. And also, David is talking about doing rotations, not keyframe animations, and subsequently what I said about the skeletal animation and concatenating matrices is the most appropriate.
• 01-10-2004
VirtualAce
I didn't say it couldn't be done, but most are not doing it. Go to GTA 3's website. You can view animations of the characters as well as how they were accomplished. Plus a lot of my game magazines are talking to developers and many of them are using this technique because its quicker and easier.

Now with real-time skeletal animation you could cause your character to crumple down against a wall or physically react to his/her environment which would be cool, but most don't. Just shoot someone next to a wall and watch what happens. They normally end up lying down in the same position as their other dead companions with one head or both legs sticking through the wall.

There is a recent game that uses skeletal animation albeit it need a bit of refining since the characters tend to end up in some very...shall we say 'acrobatic'...positions.
• 01-10-2004
Silvercord
I respect you as a programmer Bubba, but on this one I completely disagree. Skeletal animation is fine, little problems with a leg sticking into a wall won't totally ruin everything...for crying out loud we're *not* professional game developers, and trying to make everything perfect is too much stress.
• 01-10-2004
VirtualAce
My point is this: pre-render the people or whatever it is. It's the easiest way to do it. Yes you can use store a matrix for every object and compound the rotations by concatenating on down the line of objects. There is a tutorial about this on gamedev. However, I don't think this is the best way to do it.

Pre-rendered these walking legs would only take a couple of frames to accomplish some very convincing animation and would take out a whole lot of multiplies in the code - since you are simply rendering another pre-made model instead of mathematically altering one.

If you really want to do some mathematical stuff then interpolate between two known models to get an intermediate model. This would also produce some very convincing animation.

And I know we are not professional's, that's why I'm saying pre-render it.
• 01-10-2004
Silvercord
Bubba...you do know that skeletal animation is pre-rendered, right?
• 01-10-2004
VirtualAce
No. I thought skeletal animation consisted of nodes and joints that affected other nodes and joints. In other words I thought it was purely mathematical movement, which would be very hard to simulate a person using this approach.
• 01-10-2004
Silvercord
Hell no! An animator goes in there and sets the keyframes of joints and when they get to that keyframe, and all you do is interpolate the angles to produce smooth rotations (esp with quaternions if you've implemented them)
• 01-10-2004
DavidP