PDA

View Full Version : Calculate only when neccessary?


Skittixch
11-06-2009, 04:25 PM
Hey guys. Lightwave veteran/Maya nub here. I'm curious about a couple aspects of dynamics here...

Basically, I'm wondering if there's a similar technique for only simulating and calculating what you need when you need it... What I mean by this is, in Lightwave, you have the option to "start by collision". Basically, you can make your dynamic objects remain completely static until a collision object touches it, then it'll be affected by gravity and whatever other objects you've got going on in your scene. There's no need to keyframe any dynamics on or off.

Also, there are "event" fields that can activate dynamics based on collision, but they don't necessarily "collide" it's just a switch that turns it on and off..

I guess what I'm asking here is, what are your guys favorite techniques for optimizing collisions? If it requires scripting, a full explanation would be wonderful as my experience with mel is very limited (though I have done some python in realflow, so I'm not a TOTAL nub...)

thanks in advance all! you guys rock!
E

Wick3dParticle
11-06-2009, 06:55 PM
Hey Eric,

Welcome to Maya...lol.

Im sure there is more than one way to achieve what you are after, and here is one idea.

You can activate rigid bodies based off of bounding box penetration.

So something like this pseudo code:



string $rbds[] = `ls -type rigidBody`;
float $activationBbox[] = `exactWorldBoundingBox "your activation object"`;


for ($each in $rbds){
float $rigidBbox[] = `exactWorldBoundingBox $each`;
vector $rigidCenter = << (minX + maxX)/2, (minY + maxY)/2,(minZ + maxZ)/2>>;

if( rigid center is within bounding box of activation object){
(setAttr $each.ignore off );

}
if (frame==0){
(setAttr $each.ignore on );


}
}




Of course just evaluating this every frame might take some time.
I'm curious if there are more efficient solutions as well.


~Ilan



EDIT: I noticed a few typos in my pseudo code and fixed them

stooch
11-06-2009, 06:58 PM
i hook all the active bodies to a condition node (with a python script), its true if the input from time1.outTime node is more than a a custom attribute on a control shape. that way stuff can be dynamically switched on/off - in batches at certain frames; because it is a dag network it evaluates fast.

you can also set a solver start frame up to a certain time, keyframe attributes etc

as far as collision events, im actually working that into my toolset at the moment, its taking some coding, although im using dynamica bullet as my solver so its a bit different from stock maya. (and about 30X faster)

HowardM
11-06-2009, 10:04 PM
god i miss start by event! ;)
http://www.3dink.com/media/ripshreds.mov

stooch
11-06-2009, 10:19 PM
god i miss start by event! ;)
http://www.3dink.com/media/ripshreds.mov

the ideal solution is a maya node that would return True if the currently attached object is intersecting with any other shape with the same node type attached..it would be handy for more than just dynamics.

Skittixch
11-06-2009, 10:58 PM
Howard knows what's up. It's pretty ridiculous something so basic and efficient would take scripting to execute...

Stooch, that sounds wonderful, but any suggestions as to how I might go about setting something like that up? Is this a tried and tested method, or would I be R&Ding it from scratch?

thanks all!

stooch
11-06-2009, 11:34 PM
Howard knows what's up. It's pretty ridiculous something so basic and efficient would take scripting to execute...

Stooch, that sounds wonderful, but any suggestions as to how I might go about setting something like that up? Is this a tried and tested method, or would I be R&Ding it from scratch?

thanks all!

no r&d its all pretty basic stuff.

basically do exactly what i said in the post, it will take you like 10 minutes of reading mel docs and you will be very proud of yourself when you get it working ;)

just fire up maya, create a condition node, select the time node, plug them in, and attach em to a custom attribute. you can do this once and look at the mel output and just copy and paste together a small script... I would write the code down for you but you know as they say, teach a man how to fish instead of giving the fish to him...

as far as getting item selections, look at the "ls" command.

Wick3dParticle
11-06-2009, 11:54 PM
Your switchnode idea is cool, but it basically activates all dynamics together if I understand correctly.
I think he was referring to your "ideal solution". It seems closer to what he described in the first post - Activation based off of a collision or intersection event.

~Ilan

DynamicBoy
11-07-2009, 12:03 AM
Maya has definetively lots of troubles with rigid body dynamics, It seems in this forum members use to point out all of them, the pulldownit plugin improves over maya dynamics hugely, it is much faster than Maya computing but regarding the issue of "freezing" the objects until first hit, in pdi this is done with a couple of mouse clicks just by setting a fracture body and attaching it to the ground. You can try it with the free version,this feature is included.

CGTalk Moderation
11-07-2009, 12:03 AM
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.