ASP scripted physics simulation - bouncing ball with gravity

Want to share your Moho work? Post it here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

ImageImageImage
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

New version of the script for pool table type simulations:

http://www.lowrestv.com/moho_stuff/scripts/physics1.mov


-vern
MaxHammond
Posts: 14
Joined: Mon Mar 26, 2007 7:57 pm

Post by MaxHammond »

OMG this is looking owsome keep this up and ASP will have a physics engine to rival the likes of Havok in 3DS Max LOL

http://en.wikipedia.org/wiki/Havok_%28software%29

All you need now is Cloth, Rope ,Fluid and Breakable constraints :)

Good Luck.
New to Anime Studio just want to better my self and make some funny toons :D
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Funny you should mention ragdoll physics. I am in the process of converting some IK Flash code for that... I am just not sure how to implement it in ASP.

How would it be used? I suppose a character could have it "turned off" then it could be keyed on in a later frame?

You could animate a "ragdoll" character by dragging the "joints"... but it would move like a marionette which may or may not be a good thing.

I only stumbled on this indirectly when setting up my IK script for better body rigs.

-vern
MaxHammond
Posts: 14
Joined: Mon Mar 26, 2007 7:57 pm

Post by MaxHammond »

in terms of implementing a rag doll physics dynamic into a workflow, the way 3DS max worked was you basically animated what you wanted to happen ie a car hits some guy crossing the road.

so you would animate the guy walking all the way across the road and the the car traveling down the road and trying to brake but not in time

you would then hit Havok and calc the simulation replacing the characters rig with the rag doll so that in the frames where the car interacts with the Character the Havok engine calcs the collisions.

to simplify if you wanted a ball to knock down some pins you would only animated the ball being thrown the havok engine would then take the velocity of the last key frame and calculate from there on ie towards the pins and then the collisions.

well thats how it works in max anyways

hope that helps, but i dont know anything about scripting in AS so maybe im talking rubbish LOL
New to Anime Studio just want to better my self and make some funny toons :D
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Sounds exactly how I planned to implement it.

Basically the physics script works so quietly behind the scenes all I have to do is "tell it" when to "activate". It will just start doing its thing from what ever position the bones are at.

I should be adding that feature pretty soon.

Funny I've used physics plugins before with other applications... I think this one is going to be easier to use. ;)

Do you think there is a need for "baking" the physics animation as an option? As far as I see at the moment this would require keying every single frame of the simulated movement... or possibly every 5 frames depending on the extremes of motion.

-vern
User avatar
Mikdog
Posts: 1901
Joined: Tue Jul 05, 2005 3:51 pm
Location: South Africa
Contact:

Post by Mikdog »

Nice nice nice!

That's some mighty fine physics.
MaxHammond
Posts: 14
Joined: Mon Mar 26, 2007 7:57 pm

Post by MaxHammond »

Baking a simulation is always usfull if only to use the controls to phisicaly move it on the time line/scale but in AS i dont know if one could do that but mabe im wrong

it would also help if you needed the outcome of a simulation to do a certain thing ie a bag of rubber balls is empted into a fish tank, and you need the one red one to jump out.

in max you had to bake to the timeline in order for it to work as it defualted to the game engine/preview so thats just what im used to

also if the simulation where baked could you not then add it to an action! to save time calcing the same sim over and over.
New to Anime Studio just want to better my self and make some funny toons :D
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

... to save time calcing the same sim over and over.
I haven't tried it yet with a ton of bones... generally I think the scripted motion is more "efficient" than key framed motion. This is true in Flash as well, which is why it is so popular to use Actionscript to move things around instead of key framing.

Key frames take up a ton of space in the file. For instance these files that I have been posting are teeny tiny files with a ton of motion. If these were key framed the AS files would be gigantic and probably not play any faster.

Play back using a script is smooth even when the computer isn't powerful. It ALWAYS plays every frame. Scripted motion in ASP is BETTER than in Flash. Flash can't "preview" scripted motion unless you export to SWF.

Now I will say that it is a pain to try and animate around the scripted motion because you can't scrub back and forth. Baking the animation also would allow you to scale the key frames... but only because I haven't figured out how to do that in the script... yet.

Baking the motion should be very simple to do. Just add it in as a menu script or something... you would have to remove the layer script immediately though or all heck would break loose. ;)

I have to say... I always thought that layer scripts were the BEST feature of Moho... and ASP. I always felt it had the potential to do so much more than anyone had discovered. This is only the beginning. If Mike or efontier adds a few more cool things like scriptable text note layers or objects I could build on screen text input boxes, or "fields" for controlling scripts instaed of using bone scaling.

I often thought of trying to build a floating popup window that stays on the screen... now I have an incentive. Use a floating window to input and change values to control the script...

My goodness this is fun!!

-vern
User avatar
Mikdog
Posts: 1901
Joined: Tue Jul 05, 2005 3:51 pm
Location: South Africa
Contact:

Post by Mikdog »

I'm watching this thread with great interest,
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Here's another test.

http://www.lowrestv.com/moho_stuff/scri ... ounce1.mov

I didn't post a script for it because it isn't working correctly. I had to shift the vectors on the ramps to line up. The balls are offset when bouncing... weird bug I can't track down.

Not to get too technical but this was VERY difficult. Trying to calculate angular bouncing and collisions. Pain in the freaking arse!

-vern
Post Reply