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:
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:
