RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Physics APIs, Physics file formats, Maya, Max, XSI, Cinema 4D, Lightwave, Blender, thinkingParticles™ and other simulation tools, exporters and importers
Post Reply
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Post by RBD »

Hi, I'm writing some tools and utilities for Dynamica (Bullet for Maya). I was hoping to have more done by now, but I have to leave for a couple of weeks, so I'm putting up (attached below) some of them right now, as a preview, and for possible feedback…

These will be assembled with a menu when I'm done, but for now, simply extract the MEL files from the attachment, and source them in Maya to try them out (Window > General Editors > Script Editor (or icon at bottom right of Maya); File > Source Script). They all have a UI, so just running them won't perform any actions until you choose an option.

Included right now in this preview:

Set To Initial
  • Let's say you want your scene to start with a bunch of rigid bodies in a container. You could build the container, create rigid bodies (individual or arrays) above it, then run the simulation until all of the rigid bodies come to rest inside your container. At this point you can use Set To Initial and all of the rigid bodies' current positions and orientations will become their start / initial positions and orientations. This was made possible by a recent change Nicola made to expose rigid body array positions and rotations.
Bricks On Curve
  • This one's a toy. Create a curve (try a NURS circle, or draw one using the EP tool) on the Maya grid (X-Z plane), then use Bricks on Cruve. Select a brick size, and a brick wall height (try the defaults at first), and a wall of Dynamica rigid body bricks will be built on the curve. Don't go crazy with big curves, small bricks and tall walls because you'll quickly end up with thousands of rigid bodies and could crash Maya.
Toggle Collision Shape Visibility
  • A simple utility to toggle visibility of Dynamica rigid body collision shapes. Useful if you have your own geometry attached as a child and / or you don't want to see the Dynamica collision shape as well.
Bake
  • Bake Dynamica rigid bodies for rendering / editing. This bake will only work with Dynamica primitives for now (spheres, cubes, planes). I'm working on the mesh bake... it wasn't ready yet. Bake will create new keyframed stand-alone geometry based on the Dynamica simulation you run during the baking process. This geometry and its keyframe curves can then be edited and rendered. Using instances, you can then edit the geometry (like a bevel for the cube) of one item and it will show up on all of them. Maya 2008's new "Replace Objects" would have been perfect for this, but it throws away all keyframes! :evil: Remember that Maya's keyframes take up a lot of memory, don't try to bake hundreds or thousands of rigid bodies for hundreds or thousands of frame, as you could run of out memory and crash Maya. (I'm working on a bake to disk cache for thousands of rigid bodies).
That's it. I'm still working on tools, including mesh baking, bake to disk cache, a dynamica shatter tool to break polys into bits with impact point influence, and more. Hopefully I'll get back to it when I return.

Cheers.

(UPDATED! See below)
Last edited by RBD on Fri Jul 24, 2009 7:27 pm, edited 1 time in total.
elbiancho
Posts: 1
Joined: Sun Sep 28, 2008 7:30 pm

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Post by elbiancho »

Excellent word! Keep going!! I´m looking forward for the mesh bake!
-heavy-
Posts: 1
Joined: Thu Feb 12, 2009 9:55 pm
Location: Berlin, Germany

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Post by -heavy- »

Hey RBD supremeWork you dit! :D

what about the mesh bake you wrote and the ImpactShatter ?

Any progress?
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Post by RBD »

Hi, I've been away for a very long while (long story). Anyhow... in light of the Voronoi Shatter Python script posted on CGTalk by davegreenwood (see CGTalk thread or get script on HighEnd3D, or view some quick tests done with Dynamica), I'm uploading some quick RBDTools updates to allow Dynamica users to easily create and bake using Dynamica (Bullet Physics plugin for Maya).

I've updated the Bake script (dynamicaBake.mel). It will still allow you to bake all Dynamica primitives (spheres, cubes, planes; passive or active, stand-alone or arrays) and now as well it will allow you to bake all hull and mesh rigid bodies, stand-alone or arrays, that have been created using the "EasyBake" script (see below). I've also added an option to turn off the undo buffer to save memory if needed (use this option with caution). Make sure the simulation window is in focus during the baking process. You can stop the baking at any time by pressing Esc, what has baked up to that point will be preserved.

I've added a new "Create Dynamica Hulls and Meshes for EasyBake" script (dynamicaHullMeshForEasyBake.mel); it allows you to create hull and mesh rigid bodies that can later be easily baked (using the bake script) and / or rendered. The principal for "EasyBake" is fairly simple: a copy of the original mesh is used to create the Dynamica collision object and then the original mesh is preserved and made a child of the Dynamica rigid body. You could also do this yourself, however this script does more: it will shrink the rigid body collision object's shell (all of its vertexes) to effectively eliminate the collision margin from the original mesh's surface. Therefore when objects are stacked there will not be explosions nor will there be gaps between them. Also, if you load Maya BonusTools' measure.dll plugin, EasyBake will assign a different mass to each object relative to its volume. I didn't make a UI prompt for the mass range (more can be done, in fact probably want to prompt for density of the object), if you want to change it, check the script. (Note: with bullet, try not to place small mass objects under large mass objects on a floor, that is an explosive recipe.) This script will only work on discrete polygon objects, don't run it on groups / structures or other types of geometry.

I also updated the Toggle Visibility script (dynamicaToggleVisibility.mel). It can toggle visibility of both the collision objects or the entire rigid body now. Note that currently with Dynamica, when no rigid bodies are visible at all the simulation is disabled, this is useful when reviewing baked results.

To use these scripts, simply source them from Maya's script editor, or place them on a shelf. I did them fairly quickly, so I haven’t tested every scenario (save your work). They all have some sort of UI.

The basic workflow is:
  • Using Dynamica's menu, create the primitive rigid bodies you need (a passive plane for a floor is always a good start). Do not create hull or mesh rigid bodies using Dynamica's menu.
  • Select the poly objects you would like to convert to hull or mesh rigid bodies, then run the "EasyBake" script to convert them to rigid bodies. (Always favor using a rigid body hull over mesh, convex hulls are much faster and much more stable than meshes, convex or not.)
  • Rewind the scene (resets Dynamica's state and rigid bodies).
  • Play and adjust the simulation until you are satisfied. (Be careful to select and move the rigidbody parents, not the child polys)
  • Use the Bake script to bake the simulation.
  • Use the Toggle Visibility script to hide all Dynamica rigid bodies while you verify your baked results.
  • If you like the results, you can then delete the Dynamica rigid bodies and render; if not, then you can delete the baked results and use the Toggle Visibility script to make all rigid bodies visible again.
Here's a quick "how to" use davegreenwood's Voronoi script with Dynamica:
  • Create a poly object (try a simple one at first, like a cuboid).
  • You then need to create a group of locators to tell the Voronoi shatter script the location of each shard generated by the shatter.
  • Instead you can simply let the script create a group of locators for you from particles using a Maya emitter. To do this, place a Maya emitter in the scene and shoot particles at / into the poly object you just created. Don't shoot too many particles or have them packed too densely because each one will represent one shard in the shatter. To start, keep the number of particles very low. Run the Voronoi Shatter script UI, set the mesh object (your poly object) and set the particles by selecting them then pressing the set button.
  • Select the "Constrained Particles to Locators" button. The script should create a group of locators from the particles that exist only inside the poly object.
  • Set the Crack Width to 0.0.
  • Do the Voronoi shatter.
  • Place the group where you want it in the scene before converting the shards to rigidbodies.
  • Select all of the individual shards (not the group!), then run the "EasyBake" script to create dynamica rigid bodies with all of the shards. When prompted to "Center pivots?", select yes!
  • Rewind the scene (resets Dynamica).
  • Play.
p.s.: Note that the difference between an active Dynamca rigid body and a passive one is simply: if mass = 0 it's passive.
(edit: re-uploaded fixed dynamicaHullMeshForEasyBake.mel to unparent objects)
Attachments
RBDTools.zip
RBDTools for Dynamica
(8.39 KiB) Downloaded 1700 times
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Post by RBD »

Just re-uploading the same file... seems my previous message's file attachment now responds with "Unable to deliver file"...
Attachments
RBDTools.zip
(8.39 KiB) Downloaded 1303 times
stooch
Posts: 7
Joined: Thu Oct 29, 2009 11:08 pm

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Post by stooch »

haha. yeah i tried downloading but couldnt, so i ended up making my own script. :)
curtainsNZ
Posts: 5
Joined: Tue Mar 23, 2010 7:42 am
Location: Wellington, New Zealand

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Post by curtainsNZ »

Hi, sorry to dig up an old post!
But:

I was wondering if anyone could point me in the right direction for extracting the mass-measuring part of this script, so I can just run it on an object and give it an appropriate mass?
Basically the idea is to use it to attribute the right amount of mass after it has been keyed to zero at the start of a sim - and then easily keying it back to zero again when it's not needed.

Thanks for any help!
nito
Posts: 1
Joined: Sat May 15, 2010 11:15 pm

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake, etc.

Post by nito »

yeah Hi......

i'm new to this plugin BulletPhysics and RBD tool............from what i have seen looks awesome. tho i tried it myself with a scene of a basic cube shattered ...... i run the simulation all looks good and works , but when i try and use the easy bake to copy that dynamic information back into the original shattered cube objects ( i'm presuming this is what RBD tool does ????)) then rewind . But the objects seem to explode or shoot outward as if expelled by some force , and i dont know whats going on .............i tried following your tut on how to use it , but maybe i'm just dumb and cant figure how to do it right .......please if anyone can help, it would be much appreciated.....................

I just wanna break up my models, and run the simulation and bake that movment information into the original models , so i can render them.............and maybe if anyone knows how to cache it as well???
thanks any help will be appreciated .... :(
wonton
Posts: 1
Joined: Sun Aug 22, 2010 11:04 pm

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake,

Post by wonton »

nito wrote:But the objects seem to explode or shoot outward as if expelled by some force , and i dont know whats going on ...........(
I must be overlooking something as well. Polys were selected, and easybake script applied. Everything goes well until it goes back to frame1, when everything goes to 0,0,0 on the coordinate system, causing the above mentioned "explosion".

In short, everything works up to the step where you rewind the scene. When the rewind button is hit, the rigidbodies all go to 0,0,0.
Assistance would be very much appreciated.
dominice
Posts: 1
Joined: Fri Oct 08, 2010 8:13 am

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake,

Post by dominice »

I got the same problem, when I hit rewind all the active rigidbodies are snapped to 0,0,0 coordinates :shock:
Have you found the solution? also sometimes that happens right after I run EasyBake script. I'm using Maya 2010

I think the shooting outwards objects happens when the meshes are overlapping each other.

Couldn't figure out the 0,0,0 thing tho. any help will be greatly appreciated. Thanks!
ErikJE
Posts: 8
Joined: Fri Aug 06, 2010 4:25 pm

Re: RBD Tools for Dynamica (Bullet for Maya) = utils, bake,

Post by ErikJE »

dominice wrote:I got the same problem, when I hit rewind all the active rigidbodies are snapped to 0,0,0 coordinates :shock:
Have you found the solution? also sometimes that happens right after I run EasyBake script. I'm using Maya 2010

I think the shooting outwards objects happens when the meshes are overlapping each other.

Couldn't figure out the 0,0,0 thing tho. any help will be greatly appreciated. Thanks!
http://bulletphysics.org/Bullet/phpBB3/ ... =12&t=5576

Use these tools instead. They are based of RBDs work but further developed. I have never had the snapping to origo problem with them.
Post Reply