Please Someone Help. Script Works But Need Better Option

guys, girls

i have this script working just as i want it, however i need it to do the exact same thing only using dynamics of some sort as further along i require rigid body collision with these cubes.

can someone, please suggest how I could simulate this using dynamics with the cubes as rigid bodies?

thankyou

polyCube -ch on -o on -w 4 -h 46 -d 1 -cuv 4 -n FoneWone ;
move -2 -23 0.5 .scalePivot .rotatePivot ;
move -r 2 23 0 ;

for ($i = 0; $i < 100; $i++){

$randx = `rand -4 4`;
$randy = `rand -45 45`;
$randz = `rand -56 56`;


$Name = `ls -sl`;
duplicate $Name;
move -r $randx $randy $randz;

$timeVisible = ($i * 2);
$timeExtrude = ($timeVisible + 2);

    setKeyframe -t 1 -v 0 -at visibility $Name ;
    setKeyframe -t $timeVisible -v 1 -at visibility $Name ;
setKeyframe -t $timeVisible -v 1 -at scaleZ $Name ;
setKeyframe -t $timeExtrude -v 56 -at scaleZ $Name ;

}

You're going to have to be really careful setting that up... the rigid solver will have some issues if boxes are interpenetrating each other... just something to be aware of. You'd have to turn them into active rigid bodies (affected by forces), and collide with a passive rigid (meaning its not affected by gravity or other forces), without interpenetrating. You should be able to alter their collision layers so they don't error in the dynamics, but then they won't react to each other, only the passive body.

So, basically, create a gravity field, kick up the magnitude, turn objects into active rigid bodies, create a passive as a ground plane, play with collision layers, and you should be good.

Well, despite it will sound stupid, im going to ask again, what is your final goal? I mean its much easier to help youonce we know your final goal.

Anyway ccare to describe how you need them stacked.

What i would do here is put each box on separate depth and then drop them against a a container to stack them up properly before starting the sim.

thanks for your response, i should clarify though...

with the object thats created b this script..
imagine 2 of them runing side to side and about to collide. I need the collision to be as rigid bodies.

my biggest problem is replicating exaclty what that script does with dyniamics.

how can a possibly replicate the movements of the 100 cubes so it does the same things. is particles the way?

thanks

thnaks Joo,

basically i will have three or more of these stacks growing randomly. this is done dy duplicating each cube every 2 frames and extruding them 56 in the z. this is what the script does.

there will be 3 or more of these stacks growing indpependantly in the scene with a potentail to collide because of the random function which could send it in any direction.

what i need to do is ensure that the 3 stacks never cross or intersect, now my theory is that if they are rigid bodies they will not penetrate each other but rather bounce back on collision.

the reason i want to use dynamics and rigids is that im not advanced enough to create a script, that somehow tells each stack not to cross each other, something like get position or similar. Naturally this would be the best way to do if you know how? becasue as you see half the script is already working and yes its stupid to try and have working with dynamics, but i have no ther way of stoppoing them itnersecting.

so probably the better question for you experts is,

What can put in the script to other stacks like the one descirbed in the script crossing paths if they were running in the same scene.

thankyou so much!

QUOTE(jenn7 @ 10/26/07, 05:09 PM) [snapback]275459[/snapback]
what i need to do is ensure that the 3 stacks never cross or intersect, now my theory is that if they are rigid bodies they will not penetrate each other but rather bounce back on collision.

'
No th wont happen, the computer works on comparing movement between frames and thus if they get created within eachother they get created within each other

Are you trying to draw letters?

err, not sure if i follow, but i will take you word for it. your knowledge far outweighs mine..

ok, what im doing.

imagine 3 snakes that weve around in a scene ( the snakes in my case need to by comprised of the 1000 or so cubes that are created in the script)

the snakes movement is random. so i dont know where they will go

i must not let the snakes (cubes) corss each other. (actually in need to ensure they remain 5units apart)

is this impossible?

oh, and all this is to occur inside a volume, where if the snakes (cubes) hit the edge they will bounce back and keep going (again why rigids would work ok)

this last bit os not essentail however the not crossing paths is..

thnakyou

Rigid body dynamics don't work that way on the creation of objects the way your script works. They take existing geo, and either apply forces like gravity, wind, etc. to them to make them move. And rigids hit into rigids... So you would have to script that limit into your MEL. You'd have to have it check, say the X position, and say, if its beyond 50 in X, move it back some number of units. That would limit how far the boxes can be made in a given direction.

As far as keeping them five units apart, I'd make an adjustment to the script or three scripts, where your initial box's creation is at least five units apart from where the previous one was made. Again, you can try to limit their movement just as before. Hopefully that would work.

Why dont you create three curves, tweak and randomize the cvs if you want, then adjust them.

Create 3 joint chains and use each curve as a spline IK for the respective joint chain.

Make as many joints in a chain as the ALL the cubes comprising your snake. Snap the cubes to the joints and parent/ parent constrain them to the joints before you create the IK.

The SplineIK offset attribute will define the slide of the chain on your curve (like a roller coaster)

What about the cubes you want created during the snake "growth"? Animate the cubes' visibility attributes and/or assign a shader and animate the transpatency. This way you have all your cubes created from the start and then you decide which one to show to the viewer.

The viewer won't know the difference between a cube popping up cause you animated the transparency or because you created it on the fly.

Transparency offers much more control over the final outcome as you can make smoother transitions or use animated textures to get even more interesting results.

You can even make cluster deformers for the curves CV to have more control (and be able to animate) over the paths.

Give it a shot I think it will make a cleaner scene and it is something that could be handled by expressions.

Also if you are to use expressions create a null, like a cube or a Locator and add attributes to it to make it a control object for your three snakes. This is where you will place your expressions and connect the attributes with the animated objects attributes.
For example you can create three float attributes on that controller called SnakeOffset1, SnakeOffset2 etc
and then create an expression to change the offset over time. Then you can connect that to the SplineIK offset attribute.

If you want to use somewhat physicaly accurate snake paths inside a volume use a script (can't remember the name ) that takes particle motion and translates it into curves and animation paths, so you can have your snakes/joint chains "ride" them instead of running rigid body sims.

Just create a Sphere, an emitter, set the emitter up as you like and set the particle object to collide with the sphere and the ground. I'm sure you'll find three paths in the end that dont' intersect.

Well inevitably id use paths to controll the snakes. Why is it important that its automatic i mean maya is a animation tool which is supposed to do MANUAL animations. (or then dynamically generate the paths)

Anyway if you really really want to do this properly you'll ditch mel right thi instant. And switch over to python, because quite frankly you dont want to use c++, as you will need to look into octrees to get this baby going.

But this is quite out of the scope of general scripting.