static actor/triangle mesh shape problem

Rhys

28-08-2007 00:10:39

Hi everyone!

Just a little question...well..."little"...;)

Ok, here is the situation:

I'm currently writing a world editor for my project. The world should be be based on tiles (no heightmap) and I want to have physics enabled in the editor.
So, now my problem: to have accurate terrain shapes, I have to use TriangleMeshShapes as static actors, as far as I have seen. Unfortunately the PhysX SDK documentation tells me not to move static actors around - but this is understandably needed within an editor ;)
I tried to ignore that, but I received some strange effects from moving/rotating static actors, e.g. bounding box is not updated and so on.

Setting up the terrain tiles as convex shapes isn't that good, because they are not convex, thus the collision detection is not usable...

Does anyone have a solution to this, or do I have to do the editor without physics?

Thanks in advance ;)

jchmack

28-08-2007 00:50:16

i would recommend using kinetic objects instead of static for the objects you HAVE to move =).

Rhys

28-08-2007 00:52:42

Yeah, but as far is I know (correct me if I am wrong), kinetic objects can not be triangle shaped meshes, thus the collision shape would be wrong for my concave terrain tiles.

And the terrain tiles have to be movable in the editor

jchmack

28-08-2007 01:29:09

Yeah, but as far is I know (correct me if I am wrong), kinetic objects can not be triangle shaped meshes, thus the collision shape would be wrong for my concave terrain tiles.

And the terrain tiles have to be movable in the editor


hmm it has been a while since i have messed with my old engine but i know that i have a kinetic meshshape (which was changed to triangle shaped mesh in later versions). So im sure it can be done with the old mesh shape. But im not certain with the newer triangle mesh stuff. You would have to ask betajaen.

Rhys

28-08-2007 01:35:01

Referring to his statement it is not possible...but we'll wait :)
TriangleMeshs can only be in "static" actors/bodies though. (to be found here: http://www.ogre3d.org/phpBB2addons/view ... emeshshape )

betajaen

28-08-2007 09:23:47

You could try it as long as the iterator is not running (turn the framelistener off) or adjust the TimeModifier in Physics driver to zero.

You can use kinematic actors with TerrainShapes (calm down people), it's just not spoken off because your limited to what you collide with, but since your doing an editor it's not a problem. I remember Grom working on something like this for PLSM, and the terrain pages did move around.

Rhys

28-08-2007 10:40:18

Terrain pages are build from a height map, as I remember. I planned to use predesigned 3d meshes...mh...but maybe I have to reconsider that ;)

Night Elf

28-08-2007 14:50:15

Referring to his statement it is not possible...but we'll wait :)
TriangleMeshs can only be in "static" actors/bodies though. (to be found here: http://www.ogre3d.org/phpBB2addons/view ... emeshshape )


Yesterday, when I moved to revision 34, and I was having the problem of not being able to move static bodies around, I followed betajaen's advice and tried turning them to kinematic objects. Though finally I ended up creating the static body where it was supposed to be and not moving it, when I changed my objects to kinematic for a little while I was surprised to notice they were working just fine with TriangleMeshes...

The code I used to create them was:

nxBody = g_nxScene->createBody(
meshName,
new NxOgre::TriangleMeshShape(meshName),
NxOgre::Pose(position, orientation),
"mass: 100");


Those bodies reacted to collisions and gravity as they were supposed to.

As for your problem: do you need physics enabled while you're moving your terrain tiles around? If not, I guess you could just destroy the body while you're manipulating the tile and recreate it when the transformations are over.

Rhys

28-08-2007 15:19:08


Yesterday, when I moved to revision 34, and I was having the problem of not being able to move static bodies around, I followed betajaen's advice and tried turning them to kinematic objects. Though finally I ended up creating the static body where it was supposed to be and not moving it, when I changed my objects to kinematic for a little while I was surprised to notice they were working just fine with TriangleMeshes...

The code I used to create them was:

nxBody = g_nxScene->createBody(
meshName,
new NxOgre::TriangleMeshShape(meshName),
NxOgre::Pose(position, orientation),
"mass: 100");


Those bodies reacted to collisions and gravity as they were supposed to.

Ah...got it! They only react with ConvexShapes. So if I create my ground tiles as kinematic triangle meshes and the other ones as convex shapes it will work, more or less. Hm...should be acceptable :)
Thanks ;)


As for your problem: do you need physics enabled while you're moving your terrain tiles around? If not, I guess you could just destroy the body while you're manipulating the tile and recreate it when the transformations are over.

I also thought of this, but I don't if this solution may be a little bit...well, slow?

betajaen

28-08-2007 17:02:47

Static Actors
Static actors do not have any of the dynamic properties discussed in the Rigid Body Properties section. Create a static actor by setting the body member to NULL in the actor descriptor.

Once the static actor is created, do not do anything with it. Even though operations such as changing the position, adding more shapes, or even deleting the static actor are not explicitly forbidden, they are not recommended for two reasons: 1) the SDK assumes that static actors are indeed static, and does all sorts of optimizations that rely on this property. Changing the static actor may force time consuming re-computation of such data structures, and 2) the code driving dynamic actors and joints is written with the assumption that static actors will not move or be deleted for the duration of the simulation, which permits a number of optimizations for this very common scenario. For example, moving a static actor out from under a stack of sleeping boxes will not wake these up, thus they will levitate in midair. Even if they are woken up, the collision response between moving static and dynamic actors is of low quality.

To achieve the behaviors of movable static actors, use 'kinematic' actors. Read about them in the Kinematic Actors section.

Rhys

28-08-2007 17:06:29

I know this one ;)
The problem was to handle triangle meshe shapes and convex shapes.

But thanks anyway.

betajaen

28-08-2007 17:23:50

It was aimed at NightElf but you should read it too. ;)

Night Elf

28-08-2007 18:18:09

Aah... so, you can't delete them either. Good to know. Thanks for clarifying that.