Jump to content

  • Log In with Google      Sign In   
  • Create Account

Physics and Animation (3D)?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 TheComet   Crossbones+   -  Reputation: 2535


Posted 27 May 2014 - 04:23 AM

I've little experience with physics simulation, and was wondering what the best approach is to mixing skeletal animation with physics along with some procedural animation.


It occurred to me that animations aren't bound to the physical limitations a ragdoll (for instance) would enforce. That is, an animation can very easily create infinite amounts of energy, which basically ends up destroying any purely physically simulated object on contact. An example of this behaviour can be observed in Skate 3.


I'm trying to simulate something like what Nintendogs did, where you can pet an animal with the mouse cursor. I want to support things such as moving an arm into a certain position, then have the pet stay like that, all while having the pet react to other physical objects. On top of that, the pet plays various animations blended together with procedural animation.


My approach would have been to use some form of PID controller to generate force inputs for the physics engine, depending on what the skeleton should be doing, and what it actually is doing. This would mean the pet would be a full ragdoll, and the animation would only influence the way it moved.


Would this be the best approach? Is there a library that already handles this? Can someone perhaps point me to some useful articles on the subject?

Edited by TheComet, 27 May 2014 - 04:25 AM.

"Windows 10 doesn't only include spyware, it is designed as spyware" -- Gaius Publius, The Big Picture RT Interview

"[...] we will access, disclose and preserve personal data, including your content (such as the content of your emails, other private communications or files in private folders), when we have a good faith belief that doing so is necessary" -- Windows 10 Privacy Statement

#2 Bluebat   Members   -  Reputation: 487


Posted 27 May 2014 - 04:41 PM

That's a very interesting subject and I'd also like to know more.

I tried a very similar approach, but the results weren't satisfactory. For chain of joints, it was either lagging behind animation or oscillating too much, depending on how I tuned the (kindof) pid controller. I tried Bullet's joint targets, applying impulses and applying forces and it just didn't feel right.

I believe you have to fake the effect using something simpler. My idea would be: for non-ragdoll modes, have some sphere sensors in physics world and then use them to modify the pose with some inverse kinematics. For example if a wall is pushing the character from the right, detect how far it is and move the arm accordingly, while applying a pushing force to the bodies. This is NOT really a generic solution for what you want, but many effects could be faked this way.

Another thing is having ragdolls smoothly transitioned from animation. Of course it's important to sample not only anim positions, but also velocities of the bones. And to make the transition smooth, I'd keep both animation and ragdoll simulated at the same time and lerp between them. If the transition is fast, this should look good.

Looking forward to more ideas! 


#3 cardinal   Members   -  Reputation: 908


Posted 28 May 2014 - 11:31 PM

In my experience it's very hard to get nice looking procedural animations. For something like a pet simulator, I don't know that you would even want to use physics outside of solving joint constraints.


In general the way you would do it would be to generate an animation driven pose (from mocap or hand keyed data), use IK to retarget some joints (like a puppy reaching his paw to shake where you touch the screen), physics would then generate a second pose solving for collisions and constraints as best as possible. You could then blend between these poses when it makes sense.


I'm not sure that Nintendogs would have even used physics at all (It's been a while since I played it, so I'm speculating). You could probably achieve everything they did using IK. Obviously you need some logic to prevent overextending IK, but generally this is better than relying on physics to solve it for you anyways.


In cases where physics is important (solving collisions between two animated characters) physics would solve the poses as a second pass (after generating the animation pose). While colliding you probably want to blend fully into the physics pose, if the pose becomes too deviated from the animation pose you can trigger the actor to fall down, and once actors are no longer colliding, you can blend back to the animation pose. Physics generally runs after IK.


The physics solver itself and collision handling is a huge topic in an of itself though. It's not a simple task, and even now, most games (even AAA) don't do animation driven physics on articulated figures (powered ragdolls), instead having either fully animated, or fully simulated (ragdoll) states.

#4 frob   Moderators   -  Reputation: 39052


Posted 29 May 2014 - 09:09 AM

Agreed with the animation + IK approach.

I have used such systems on several games. (Used them, never written the IK systems, they seem like a massive undertaking.) Modelers build the IK constraints into their rigs, since that helps out everybody. Animators build the animations they want, and since constraints were added to the rig they can more quickly position the characters where they want. Animators then modify the joints they need.

Then when it comes to the game, you can specify an IK goal for a specific joint (such as the paw you described) and allow the IK solver to do the magic. Every engine I've worked with has allowed a weighted IK solver, so you blend the IK from 0 to 1 (moving from the animated paw position to the animation+IK position), then do your IK work, then blend back from 1 to 0 returning to the animated position.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.

#5 Tutorial Doctor   Members   -  Reputation: 2510


Posted 29 May 2014 - 09:13 AM

Wow, I just posted about the same thing. haha. 



I called it an "autonomous animation" but I guess the word I was looking for was "procedural." I know what you mean by the ragdoll effect. 


Someone suggested IK solvers to me. 

Edited by Tutorial Doctor, 29 May 2014 - 09:14 AM.

They call me the Tutorial Doctor.

#6 Tutorial Doctor   Members   -  Reputation: 2510


Posted 29 May 2014 - 09:38 AM

Oh, I forgot to mention, on my post about using Blender for games I gave links to some animation plugins I use. One of them is called BEPUIK, and the other is realtimeAnimation. 




Seems like you want a mix of these two types of things, as well as rag-doll physics (rigid bodies). You'd have to use drivers.



I think you can bake physics animations to frames. 



Edited by Tutorial Doctor, 29 May 2014 - 10:35 AM.

They call me the Tutorial Doctor.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.