Skip to main content
gamedev.net
🔒 Locked

Game model physics???

Started by double O seven Oct 10, 2006 at 8:45 PM 2 replies 550+ views
Original Post
double O seven
double O seven
OK, not sure which forum section this belonged in, but I have a question that involves both models and programming, sort of speak. I know what I want to do, but not sure how to put it into words. Anyways, how would I go about doing this. Having a 3D model, but making parts of the model physics based. EXAMPLE: A man walking in a fully animated walk, but having something hanging off of him just dangling and responding how it would if it were being controlled by physics. Another example: You have a tree, but the branches on the tree are moved by the wind which is controlled by physics. Kinda see what I'm saying. 3rd example: You have an animated enemy, and when you hit that enemy it fall's out of its animated state and is then controlled by a rag doll effect based on physics. But if you did all that, how would you make the animation and physics flow as one? Example: Enemy gets hit > Fall's out of animation state and into the rag doll effect > But instead of changing 3D quardinates like some games do, it flows from its animated state into the rag doll effect. Hope that makes somewhat of a shred of sense. I'm not a programmer, but I am extremely curious how this stuff is achieved. Thanks for any help.
erissian
erissian
Well, for physics questions, the Math and Physics forum is a good place to start.

Anyways, in the simplest form, you have to divide your model into mass points, which are connected to each other by some constraints. In the case of a tall pole sticking out of the ground, I would divide it into a number of sections n. If the wind is blowing, then each section feels a force proportional to the speed of the wind and the cross section area of the section.

Also each section is constrained in its motion compared to the section below it, so how far can it move? It depends on the material, and whether you'll allow it to deform or break under strong forces. (For now, no.) Consider that the tension of the material will make it behave a little like a spring, so the pole will oscillate a little. Because each section can move a little, the effect accumulates as you reach the top of the pole, so the very top will move much more wildly than the bottom. It may be best to just treat each object as a special case.

Start with simple objects first. Try the pole example:

Say the pole is solid Oak, 0.5 meters across, and 30 meters tall.
We'll divide it into 'square' sections, so 60 half-meter sections.
The density of oak is 600 kg/m3, and each section is pi r2 h = 0.098 m3, and therefore 58.9 kg.

If you picture the cross section as a square, and deform the top by some angle from the base, then the lengths of the sides will be deformed to the lengths 0.5 cos T +- 0.25 sin T, where T is the angle from the horizontal plane. It should naturally be 90 degrees. So delta-L = 0.5 L sin T.

Using Young's modules for Oak = 11 GPa, we can find the restoring force of the deformation by:

F = YA delta-L/L

Where A is the area that the force is applied to. That's the cross section, or L2 (where L=0.5m). Also, we're more interested in torque, since this is an angular deformation, so using torque q = F/R = [YL2 (0.5 L sin T)/L]/L = Y/2 sin T = 5.5e9 sin T.

That's a pretty strong force, but be sure to constraint T to a reasonable figure. Oak will break when bent too far.

Also, there's the force of the wind, and we'll keep it simple by saying that F = Cd A v p/2, with Cd being the drag coefficient (we'll use .4), p being the air density (~1), and A being our cross section again (0.25). Turning that into a torque, we have q = 0.1 v, where v is the wind speed.

That gives us a general motion described by the torque q = 0.1 v - 5.5e9 sin T, where T is the angle from the normal of the node below the node we're calculating.

From here you can determine incrementally velocity and position. Also, don't forget to account for the force of gravity.

Now that we've done a pole, are you ready for a human body? :)
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Raghar
Raghar
Quote:
Original post by double O seven
But if you did all that, how would you make the animation and physics flow as one? Example: Enemy gets hit > Fall's out of animation state and into the rag doll effect > But instead of changing 3D quardinates like some games do, it flows from its animated state into the rag doll effect.

Hope that makes somewhat of a shred of sense. I'm not a programmer, but I am extremely curious how this stuff is achieved.

Animation state is the same as rag doll effect. You just disable forces on rag doll. (Either by explicit zeroing, and detachment, or by detachment that preserve original movement.) The second case is better, however you need to have some simplifications of "air drag" and a ground "drag". Or have simply dissipation of energy in detached objects in the game/world/3D engine. The dissipation of energy of detached objects is probably the best way.

And remember game mechanics isn't physics. Certainly it isn't that textbook variety.
NIm
NIm
I think you might do welel to use a physics library like ODE, or one of te wrappers or it. In one of them, (I forget which one) you can set a part to a location, and instead of changing it's location, it will apply forces to get to that location in one frame. This has the effect of converting the animation into physics terms, so thta it can interact with the wind.

One problem you might have: if the wind disrupts your anmation too much, the charachter might not ook like they are walking. in this case, you might want to make them fall and stop walking, so that it looks sane.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.