PDA

View Full Version : active rigids controled with animated sceleton?


nikiatanasov
11-09-2005, 12:12 PM
Hi, I have to do a character witch is made out of stone to break-down to parts (rigid bodies), the problem is that tha character have to move while some parts of it begin to fall.
I know that rigid bodies can't be parented.. How to connect them tho have the transformation from the rig and to start falling dynamicly at given time. after a while the whole character have to breakdown at once.
I know its a hard thing to do but I'll appreciate any ideas how to do such a thing.
10x

With Regards
Nikolai Atanasov

nikiatanasov
11-10-2005, 09:20 AM
now after some research I've found that I can parent Passive Rigids to my rig, also I'm creating a particle in the center of each rigid body witch is parented to the sceleton too. I'm using the particles only for "listening" for a volume fields and to switch passive to active.
if (inputforce[0] > 0.1){
setAttr "rigidbody1.active" 1;
}

The idea is working on few objects, now I have to write mel that will automate the creation of the particles an putting expression to each particle object to control representing rigid body attribute for .active, but I'm not shure how can I add expression to the particles with mel.

If someone have a better idea please share it whith us :)
10x

nikiatanasov
11-12-2005, 08:11 AM
hmm some kind of East Europe monologue happens here :sad:

anyway, I have solved my problem and will post the solution. I think it's not the best way but its working.

I don't have strong expirence with mel and thats because the script I made have to be edited for each kind of set you have in the scene. It works with selected geometry and two previously created fields "worldGravity" and "gravityField", but it can be extended for more complex situations.
so how to use it:

1. place all objects (parts) to be in the pose similar to the curent character pose(because you have to parent them later to the coresponding bones)
2. create one gravity field and rename it to "worldGravity" (this is the gravity for the rigids)
3. create second gravity with volume shape and give it a name "gravityField1" (this is for the particles, that will listen for this gravity and when particle gets into the region of this gravity, the particle have to execute a command that will set coresponding rigid body to Active)
after seting these things the script comes here:

/////////////////////////////////////////////////////////////////////////////////////////
string $sel[] = `ls -sl`;
$mysize=size($sel);
$i = 0;
while($i< $mysize)
{
select -r $sel[$i];
float $myCenter[] = `xform -q -t`;
rigidBody -passive -n ("rigid_body"+$i);
particle -p $myCenter[0] $myCenter[1] $myCenter[2] -n ("particle_center"+$i);
string $inputforce = "particle_center"+$i+"Shape.inputForce[10]";
string $outputforce = "gravityField1.outputForce["+$i+"]";
string $particleName = "particle_center"+$i;
connectAttr -f $outputforce $inputforce;
connectDynamic -f gravityField1 $particleName;
connectDynamic -f worldGravity $sel[$i];
string $expr1 = "\"if(mag(particle_center" +$i+ "Shape.inputForce[10])>.1)\n{\nsetAttr \"rigid_body" +$i+ ".active\" 1;\n}else{\nsetAttr \"rigid_body" +$i+ ".active\" 0;\n};\"";
dynExpression -rbd -s $expr1 ("particle_center"+$i+"Shape");
$i = $i+1;

}

/////////////////////////////////////////////////////////////////////

now all selected objects are passive rigids and there is a particle object in the center of every one peace of geometry, the particle contains dynamic expression that will affect coresponding rigid body.
All you need now is to parent the particles and the rigids to coresponding joint and to change the mass of the particles to "0" (this will prevent particle from fly away when its in the volumeshape of the gravityField)
now you can animate this volume where to go and to make the rigids from passive to active.
I'm not finished with my project, so there will be update on this stuff.

I hope that this is helpfull :thumbsup:

With Regards,
Nikolai Atanasov

coccosoids
11-25-2005, 03:37 PM
very cool info
:thumbsup:

CGTalk Moderation
11-25-2005, 03:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.