scale body post-creation

alienskull

27-11-2007 14:24:11

How would I go about scaling a NxBody after I have created it?

I'm thinking something along the lines of creating a new shape (scaled) and then deleting the original shape. And then scaling the ogre entity.

I'm not sure exactly.. some (pseudo)code would be helpful.


And what about keeping the forces that are already applied?

betajaen

27-11-2007 17:04:07

It's possible but problems aside of tunnelling, stuck bodies or an explosion.

Why do you want the shape to change size after it's been created?

alienskull

28-11-2007 00:26:56

Why do you want the shape to change size after it's been created?

Well I'm designing an engine, and I would like to allow the people using my engine to do whatever they want, including re-scaling objects after creation.

But it looks like there will be alot of issues with it, so I guess I'll put this functionality on the back burner, maybe save it for v2.0 or something.

betajaen

28-11-2007 09:29:45

It's more than possible, and the implementation is relativity simple.

But you could only lower the size of the shapes safely, if you increase the size, there is a high probability of the shape "clipping" another shape, which may cause a mini-explosion of some of the smaller shaped actors, or the new resized shape may get stuck in another.

You could probably get away with checking if there are any shapes before you resize and push them away, but that may be a little complicated and the code to do so would be easy for spheres but more complicated for cubes and you'll need a PhD in convexes.

alienskull

28-11-2007 12:04:56

unfortunately my engine deals almost exclusively in convexes and trianglemeshes.. better work on getting my PhD :lol: haha

I will eventually implement this but its not a main feature right now so I'm gonna push it back.

I'll update this thread when I get to working on a solution.

betajaen

28-11-2007 12:25:58

When you do get around to it, look at the intersection class. The convex code isn't complete yet, but that's fairly easy to get going compared to the calculations of forces to apply based on the shape of the convex.

However, I wonder if you could slowly make the shape larger; you'd be new'ing and deleting shapes on every frame and it may make PhysX nervous but it could be a cheap hack.