PDA

View Full Version : scripting for the physx plugin to allow multiple steps simulations.


Strob
11-07-2008, 09:57 PM
Hi, sorry for the long post but you just have to read the 2 following paragraphs. Only if you want to know more about what I am doing you have to read the rest. ;)

I don't have a great experience of scripting but I am trying to make a script that will allow Physx simulation in several steps. But I don't know how to do one thing:

I got several objects and each of those object have a corresponding Physx object.
I need to find a way to query the x y and z velocities of an object and then enter those 3 values in the Physx initial velocity value of his corresponding Physx object.




I already created this simple script to query the speed in X Y and Z:

maroche = $
rocheposx = maroche.pos.x
rocheposy = maroche.pos.y
rocheposz = maroche.pos.z

t = slidertime
slidertime = t+1

rocheposxnext = maroche.pos.x
rocheposynext = maroche.pos.y
rocheposznext = maroche.pos.z

a = rocheposxnext - rocheposx
b = rocheposynext - rocheposy
c = rocheposznext - rocheposz

slidertime = t

x = (a*30)
y = (b*30)
z = (c*30)

print x
print y
print z

And now I need to know how to query this for many objects and then enter the 3 values in all the corresponding Physx objects...


And to tell exactly what I'm trying to do:

When I say several steps physx simulation I mean: for example if I want to create an animation of a building collapsing and I want the top 3 floors of a 10 story building first collapse and then a few second later all the building collapse too.

What I do (once all the pieces for the building in place) is that I select the top 3 floors pieces and I make Physx dynamic RigidBodies with them and I group the other lower floor pieces and I create a Physx static RigidBody with it. And I simulate a few second baking the first step, let's say 100 frames.

Then when I want to start simulationg the other floors together with the already falling pieces of the top 3 floors, I create a copy of the baked top 3 floors pieces and I select the original copy and I remake Dynamic Rigidbodies so they will start simulating at frame zero at that falling position. I also ungroup the first 7 floors and this time I create RigidBodies with them too. This way I can bake that second step of my simulation and I can then slide the key frame 100 frame to bring them in time after the first step.

So now I have 200 frames of baked simulation with the first 100 comprising the 3 top floors starting to fall and from frame 200 to 300, everything fall together.

But here is the problem. When I start the second simulation the objects that are falling have no initial velocities and it looks like they stop suddenly and start falling again in the middle of their course.

So what I need to do is query the speed in xyz of the first simulation objects at frame 100 and put that info in the initial velocity properties of the second simulation objects at frame 101.

Thanks for the courageous one who will read all this and try to help me! I'll promise a virtual beer for the one who can do that! :beer:

cojoMan
11-11-2008, 07:08 AM
what physX plugin ?
the only one I know is the one inside thinking particles. is that it ?
if not, could you give me a link with more info on it ? I might be able to help :)

spacefrog
11-11-2008, 07:32 AM
there is an opensource project going on, integrating PhysX into Max.
ASFAIK at this time it has got rigidbody, some softbody and some fluid already

i did a few rigidbody tests with it, and thought it was quite cool

http://sourceforge.net/projects/physxplugin

Strob
11-11-2008, 01:39 PM
what physX plugin ?
the only one I know is the one inside thinking particles. is that it ?
if not, could you give me a link with more info on it ? I might be able to help :)

Hi cojoMan and Spacefrog. I agree with spacefrog the physx plugin is pretty impressive and I think they should develop it more.

And for it to work you first need to install the Physx SDK AND the Physx software. You can download those on the nvidia website here (http://developer.nvidia.com/object/physx_downloads.html). The Physx software is also included in the latest nvidia geforce driver.

About the physx hardware accelerator card, I think we just don't need that at all for special effect cause physx is already so fast that it's almost real time, what we need is more manual control to artistically drive the simulations.

There is a free plugin for max (http://sourceforge.net/project/showfiles.php?group_id=191256) and for maya (http://sourceforge.net/project/showfiles.php?group_id=205697) too (links on the same nvidia page). In softimage XSI (http://www.softimage.com/products/xsi/tour/simulation_hair.aspx) the physx plugin is already included but seems pretty unstable with actual shapes collisions at first look. The physx engine in xsi seems fast with simple shape but is slower with convex hull approximation and verrrry slow with actual shapes. I read on xsi base (http://www.xsibase.com/forum/index.php?action=search2) that we can use the new ICE particles to simulate with Physx but only with convex hull not actual shapes. In Maya physx seems a bit unstable when you try to bake a lot of pieces. So to my experience, I think the most stable so far is in 3ds max, but it lacks a bit of features that I could maybe add if I was better in maxscript and if I find a way to access the physx properties in maxscript.

Here are some limitations for the physx Max plugin: it works only in 32 bit version of max. It is also limited to 1000 frames for simulating at a time (I wonder if we could remove that limitation by playing with the physx scripts). We can not animate the parameters of the physx simulation. Would be great if we could animate the effect of gravity and the state (passive or active) of the rigid bodies. If we could do that we would be able to simulate structures collapsing in different steps.

Also we can access the physx engine through some commercial plugins: thinking particle 3 (http://www.cebas.com/products/feature.php?UD=&PID=15&FID=627) which is the most advanced way to access it because you have total control over the simulation. With TP you can transform your objects in particles and simulate physx on them. Another plugin using physx is Rayfire 1.41 (http://www.mirvadim.com/). By the way, this one is best for breaking objects into hundreds of pieces (contrary to the shatter effect in maya which crashes when you want more than 50 pieces, rayfire can create hundreds if not thousands of pieces if you proceed step by step). And maybe one day particle flow will be able to access physx because particle flow tool box 2 is supposed to be able to do that but it is still in developpement. It is now open for beta testing for those who bougth box 3 (http://www.orbaz.com/forum/viewtopic.php?t=1417).

CGTalk Moderation
11-11-2008, 01:39 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.