Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / [Dark Dynamix] Rag Doll Setup Process

Author
Message
Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 11th Jul 2012 18:03 Edited at: 11th Jul 2012 18:08
Hi Matty. I wonder if you could help clarify the whole process of setting up a rag doll. I've been through the code and it's all fairly straight forward, but the little 'hack' of waiting 1 sync and then repositioning objects isn't 100% clear.

So far the process appears to be:
1. Make a dynamic actor for each limb of the model, with some tweaks like setting local rotation and tweaking damping
2. Disable each of these by turning off collision and putting them to sleep

Game is looping, and you want to switch on the rag doll
1. Enable all dynamic actors, enabling collision, waking them up and then syncing them to their respective bone
2. Join these actors together with new joints
3. Wait for a simulate and sync (what state is the simulation in now?)
4. On the next loop, reposition the object to 0,0,0, rotation 0,0,0. Why?

I'm guessing what's actually happening is, the object needs to be at 0,0,0 so that limbs/dynamics objects are synced up properly? And DarkDynamix will be moving the limbs all over the place. So culling needs to be switched off for the model to be visible. If the origin isn't visible on screen.

If this is true, I wonder if it would be possible to have a dynamic actor attached to limb 0? The central hip limb or something could be connected to this limb 0 by a fixed joint, and since limb 0 affects base object properties, it should move the actual object around. The limb object is given 0 mass and has collision turns off, so it effectively isn't simulated or have any effect on the other actors in the rag doll.

Just throwing ideas out there, as not having the model culled isn't desirable. Although, I suppose it wouldn't take much to query the screen positions of the limbs and manually handle culling based on that.

Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 12th Jul 2012 11:51
A few more questions to bolt onto this thread ...

The character model I'm using is quite complicated. The artist has added quite a few extra joints for attachment locations and various other things I don't really understand. The result is this ...

dbPerformChecklistForLimbs() returns a quantity of 67.
dynUtilGetMeshCount() return 1 mesh, as expected
dynUtilGetBoneCount(mesh 0) returns 24

So there is a discrepency of 40 odd bones/limbs, although I suspect there is a difference.

To attempt to setup my character bones, I went through the model manually, identifying which joints bones I thought would be the ones I wanted. So I cycled through all 'limbs' and rotated them with DBP commands, noting down the numbers when the correct joint moved, so I could build up a map of joint numbers.

I then went to setup my rag doll primitives, but keep getting "no associated actor messages." It's obvious why. DBP requires me to rotate limb 45 to make the hip joint move, but Dark Dyanmix only recognises 24 bones. I don't know how all this translates.

Is there a way to determine with DarkDynamix bone links to which DB limb? At the moment, I don't know how to proceed with rigging the character. I'm toying with making my own stripped down version of the character, with a simple bone structure that may correlate intuitively to how dyn reads the limbs. I'd swap this in for the normal character model when I want a rag doll, but this would probably cause issues when trying to mimic the models pose on a different bone structure.

But yes, my main question is DBP limbs = 67, dyn bone count 24, I only really want physics primitives on maybe 17 bones, so want to identify them manually and set them up. Can I work out how they correlate, or will I need to do something messy, like attach an actor to one limb at a time and see which one flops around?

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 12th Jul 2012 15:42
If you open your model in a modelling program you should be able to get the bone ID numbers. I don't think the built in limb commands help much. If you look at the model I use in the example in a modelling program you should see how the bone ID numbers correlate to how I put it together in the example. That model also has more limbs than bones so that's probably normal.

Let me know if that helps.

For DarkGDK users there is a way to query the bones by going under the hood. You can get the names like this:



Dynamix provides commands to retrieve the bone count so you don't go past the end of the array.

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 13th Jul 2012 16:43
Quote: "If this is true, I wonder if it would be possible to have a dynamic actor attached to limb 0? The central hip limb or something could be connected to this limb 0 by a fixed joint, and since limb 0 affects base object properties, it should move the actual object around. The limb object is given 0 mass and has collision turns off, so it effectively isn't simulated or have any effect on the other actors in the rag doll."


You are correct, PhysX gives you the global position/orientation of any given actor, whether you represent it as a limb/bone or object is then up to you. All three of these options are handled very different.

I think I understand your suggestion but I'm not sure it would work without extra calculations. Dark Basic will add any extra rotation/position to every limb if the model moves away from 0,0,0.

What I will explore again is the various dark basic internal variables for disabling object matrices etc. I never found a solution last time but will have another go, it's all trial and error when figuring out the dark basic internals as there is no documentation to go off.

As for the hack of waiting one frame, you should leave this out when doing your own set-up. You will then see why it is needed and may have a different/better way to handle it. It's to do with the physics always being 1 step ahead/behind(can't remember which) of what's being drawn to screen.

Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 16th Jul 2012 15:39
Thanks for your pointers Matty. I finally got rag dolls working today, after lots of days and experimentation. One lesson I've learnt is it appears that scaled characters cannot be used at all, since all limb offsets (movements) are also scaled. That threw me for ages!

One big issue I'm having is the lack of control over the capsules. Using the dynMakeCapsule command and assigning it directly to the bone, it's never the right size, even when changing the global scale. I suppose I can probably make the capsules separately and then use the dynSetToNewObject command. I'll give that a try.

Login to post a reply

Server time is: 2024-11-24 12:55:47
Your offset time is: 2024-11-24 12:55:47