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] How are bone synced actor models positioned?

Author
Message
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 11th Sep 2012 13:41 Edited at: 11th Sep 2012 15:51
A question for the all knowing Matty

How are the bones in a rag doll positioned, under the covers? I mean, when PhsyX comes back with a position/rotation for the actor, how do you pose the boned model appropriately?

I'm asking because for my dismemberment code, I need to pose separate models in exactly the same position as a DynamiX controlled rag doll. So in my code, there is a master rag doll controlled by Dark DynamiX. However, visually I may only want to display the body minus a head. To do this, I visually hide the dynamix controlled ragdoll, and I then want to synchronise legs, arms, torso etc. models with this DynamiX controlled 'whole' model. All the models have the same bone structure.

What I tried to do was take my dynamix controlled rag doll, iterate through all the limbs, then take out dbLimbAngleX and dbLimbOffsetX components and apply these to my various body parts. On initial testing though, this doesn't seem to be how you've done it as I'm not getting expected result (i.e. the body parts aren't moving).

I'll continue playing around, but any insight into how the rag doll model is positioned would be really useful! Cheers Matty.

Edit: Just as a heads up, I am currently experimenting with assigning different models/bones to the same joined rag doll, which may be a better option. Will report back with results, so may not need help with this.

Edit 2: No, my idea won't work, as one actor would have to be able to modify bone rotations in two different models. So I still need a mechanism for copying bone rotation/positioning from one model to another. Continuing to look ...

Edit 3: Ok, looking at "dbGetObject(dbObj)->ppFrameList[0]->". I'm assuming frames are in fact bones, as there seem to be meshes and frames within the model data. So I'm going to have a go at iterating through the frames in my model and copying the matrix data from one to the other to see if that works. If it does, I could simply change the pointer of the frame list in one model to point at the other model's frame list. Could be disastrous!

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 11th Sep 2012 16:08 Edited at: 11th Sep 2012 16:09
You can set/get a bones matrix like this:



You also need to inform that you want to control the bone directly.


I was wondering how you were going to do dismemberment, if you check out the non-bone ragdoll example then you will see how easy it is to remove the head(just delete the joint) etc

Not sure on the advantages of bone animations, perhaps quicker? But for dismemberment, limb based animation(separate meshes) would be much easier.

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 11th Sep 2012 16:28
Cheers Matty. That might be exactly what I need.

I need the bone animation because, where two non-dismembered (membered?!?! lol) limbs connect, I need to maintain the nice fluid weighted vertex moving you get from bone animation. If I make them all individual meshes then just delete joints, while the physics effect would be spot on, I think it would look ropey visually.

So what I've done is this:
1. Got my fully rigged model made with 1 mesh
2. Unwelded the verts where I want the limbs to come off and added hidden bloody stump geometry there.
3. Saved out a load of different models for each detachable limb component, but keeping the existing skeleton/bone structure.

Now, if I have all the individual component parts share the same matrix data the model will remain completely seamless and also all the vertex weighting/bending/moving will remain the same. One master model (a complete character) can be controlled by dynamix. I can then hide and show which ever limbs I want based on what's been chopped off and delete joints/bones which aren't needed (for the chopped off areas).

I then have another rag doll with the same setup for everything that's been cut off. So if a leg gets cut off, I have an additional rag doll for that, with the opposite body parts hidden and bones/joints deleted.

It's quite heavy weight compared to a nice 1 limb per bone solution with just deleting joints, but in the model, the knee joint for example modifies verts in the upper leg and lower leg. I may also want severance points half way down a bone. So really, there's no way of me getting away from the fact 1 bone needs to modify more than 1 mesh.

Anyway, what you gave me should do the job a treat mate. Thanks for that. I'll let you know how it goes!

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 12th Sep 2012 15:59 Edited at: 12th Sep 2012 16:04
Update on this Matty ...

I've followed the steps you described but am not seeing any results. Interestingly, DBP/GDK appears to drop bones from a model when they're not important. So in the case of a leg, even though the .X model contains the whole bone structure (as verified by other modelling programs), it appears DBP keeps the root, hip, knee, ankle etc. bones, and discards the rest. So my models don't have the same bone structure. Very interesting. However, they still share the same names, so I believe this should be possible.

With the body component I want to synchronise with the Dynamix controlled rag doll, I do the following:
1. objPart->position.bCustomBoneMatrix = true;

2. Extract the no of bones in the body part I want to synchronise
int intPartBones = objPart->ppMeshList[0]->dwBoneCount;

3. I then loop through these bones, finding the name of each one with:
char* strPartBoneName = objPart->ppMeshList[0]->pFrameRef[pb]->szName;

4. I do the same with the main dynamix controlled character, and then do a strcmp() to ensure they're the same bone.

5. I then copy the matrix data from the dynamix controlled character to the body part I want to synchronise:
D3DXMATRIX* matPart = objMaster->ppMeshList[0]->pFrameMatrices[pb];
To get a pointer to the matrix, and then a load of these manually to copy it across ...
dest->_11 = source->_11;
dest->_12 = source->_12;
dest->_13 = source->_13;
dest->_14 = source->_14;

etc.

Code here ...



I can confirm the strcmp works and the CopyMatrix function is run for each limb, every loop. So it's being copied, but my body part models still stay unrotated/positioned and at the origin.

Any ideas what I may be missing or doing wrong?

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 12th Sep 2012 17:46
It looks good to me.

Could you email me the model(s) and I will take a look in a couple of hours. If you can't email the models then I will try it on the model I provided with Dynamix and see if I can get that to work.

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 12th Sep 2012 17:59
Will knock you something up either this evening or tomorrow Matty. May also have a go at a simplified example before I waste your time. Right now I have just taken delivery of a shed and now have to build something tangible before it rains.

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 12th Sep 2012 18:20
Not to worry, I replicated the problem with another model. You were passing in the same matrix twice to your matrix copy function



Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 12th Sep 2012 22:56
BALLS!!!

D3DXMATRIX* matMaster = objMaster->ppMeshList[0]->pFrameMatrices[mb];
D3DXMATRIX* matPart = objMaster->ppMeshList[0]->pFrameMatrices[pb];

A perfect example of the danger of copy and paste. Thanks for debugging my code buddy! Do I have to pay extra for that?

I'll fix that on the dev machine tomorrow and let you know about the results. Cheers again.

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 13th Sep 2012 00:50
No problem Invoice is in the post

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 13th Sep 2012 10:19
Changed the line of code, problem solved! Cheers again chap for the bug testing eyes. Updates to come later once I've finished the rest of the splatter.

Login to post a reply

Server time is: 2024-04-16 06:19:21
Your offset time is: 2024-04-16 06:19:21