Curved Shape and Multiple Shapes problem

Merlimoo

31-12-2007 16:10:16

Hi,

I have a curved object, which is a semi cylinder, something like that (

I have a problem with collisions detection. When I create the body with the TriangleMeshShape, the collisions are only detected on this side ( <- And when I put a ConvexShape, they are only detected on this one -> (

So I tried to create my body with one of thoses shapes and add this other one with the addShape function. In this case, the collisions are only decteted to the side of the creation shape. The one added seems to not be used.

What can I do to have a collision detection in both sides ?

Thanks.

Merlimoo

31-12-2007 16:29:13

Ok I've just seen a NxUnderConstruction; in the _bindToNxActor() function on the ConvexShape and TriangleMeshShape class. That explains why the addShape do not work ^^

Do the ConvexShape and TriangleMeshShape work in the both side normaly ? Because I just tought that maybe my problem is because of me. I had a problem of normal with my curved object. Only one side of the object was visible, so I made a script that duplicate the triangle in the mesh and invert the direction of the normal. Even if Ogre renders it properly, maybe PhysX has a problem with that. What do you think ?

betajaen

31-12-2007 17:23:21

Sounds like the normals are facing the wrong way. The convex mesh generation code only takes the vertices from your mesh, and generates the indices and the normals itself, where as the triangle mesh takes everything as it is which explains to me the differences in collisions.

Try flipping the normals in your 3d modeler and see what happens.

Merlimoo

31-12-2007 17:40:07

I have not tried the normal thing yet, but I still think the problem comes from my little script mentioned ealier. Each triangle is described twice, each one with different normal. With this kind of ugly thing, I am not really surprise it does not work.

So, I don't think solving this problem is really worthyt. At the begining, the problem comes from my unability to display both side of a triangle with Ogre. With the proper method, I think this problem would not occur.

Anyway, I have found a solution to my problem by using CompoundShape. Maybe if have a little free time, I will investigate this problem further. In the mean time, I will try flipping the normals to see what happen. Thanks for the help.

Btw, I tried to complete the code for adding another ConvexShape to an actor by taking example with CapsuleShape and CubeShape, but it does not work. No error, collision on only one side. I can't figure it out what the problem is and I have not much time for this now. I'll post as soon as I have some correction.

Merlimoo

31-12-2007 17:51:48

The CompoundShape does not solve my problem after all. It makes a big box englobing my semi cylinder. Arf!

betajaen

31-12-2007 20:55:02

Flipping the normals would probably be the best way to do it, and you don't have to use the same mesh use you use with Ogre and PhysX. Infact I encourage people to use a specialized mesh for PhysX whenever possible.

Merlimoo

01-01-2008 10:41:30

Like I said, the CompoundShape did not really solve my problem. So I've done what you said. I took my tuned shape for Ogre and the simple one for PhysX. But the problem is the same. I can't have collision with both side of the mesh. Can it be because my object is flat ?

Anyway, I'll try to flip the normals today. But is there a way to do it with Blender ? I can't find how to do it, so I'll write another script to invert the order of the point for each triangle before passing it into OgreXMLConverter. If somebody has a simplier solution for that... :)

betajaen

01-01-2008 11:45:32

I believe your mis-understanding what a CompoundShape exactly is, more or less it's a stl::vector of shapes passed to the actor one at a time, it has nothing to do with Meshes at all.

You could use MeshMagick to flip the normals (I forget the spelling) it's on the main forums somewhere.

Merlimoo

01-01-2008 12:15:01

Thanks for the soft.

I've just tried with the normals inverted, and the problem is exacty the same. With a TriangleMeshShape, this side -> ( has no detection collision, and with a ConvexShape it is the opposite.

I though combining a TriangleMeshShape and a ConvexShape with a CompoundShape will work, because each one allow me detect colision of one side of my object and not the other. I though that by using a CompoundShape, each shape will be use to evaluate if there are collisions or not. But when I use it, it is like the shape look like that (| and my ball does not go in the curve anymore.

Like I said, my object has no depth or thickness (I don't know the appropriate word), it is like a plan. As far as know, Ogre render only one side of a plan using normals to decide which one. Is PhysX doing the same ?

I can't think of anything else.

Merlimoo

01-01-2008 12:16:57

Btw, is it possible to join your Steam Commmunity ? I love TF2 :)

Merlimoo

02-01-2008 18:05:27

Bump! Nobody can help me ? :/

NickM

03-01-2008 00:41:49

Could you either upload the model or show us some pictures, maybe it would help us to help you a bit more.

Merlimoo

03-01-2008 11:19:45

Of course, sorry :)

http://merlimoo.free.fr/Tube.blend
http://merlimoo.free.fr/Tube.mesh.xml
http://merlimoo.free.fr/Tube.mesh

NickM

03-01-2008 20:27:06

It looks to me as though the object only has faces on the outside, so, in whatever 3d modeller you use, make a copy of the object, flip all of the faces in the copy so that their normals all point the opposite way to the original, then weld the 2 objects back into one and see if that fixes your problem.

Merlimoo

07-01-2008 08:09:57

That is exactly what I've done in the first place. Initially, I've done this for Ogre, this was the only solution I've found to see both side of the mesh. But It does not seem to work with PhysX. Like I said, depending of the MeshShape (Triangle or Convex) I use, only one side of the mesh is used for colisions detections.
To flip the normal, I made a program that take the .mesh.xml file I've got after Blender, that I have to pass through OgreXMLConverter. And before converting it, I just duplicate the faces declaration and I invert the order of the enumeration of the point. It does the trick for Ogre. But when looking at this file I've just seen a normal attribute to an element in the vertices section. Maybe it has something to do with that. I haven't touch to that section. Do you what it is ? Or where to find some doc about it ?

NickM

07-01-2008 18:59:55

I'd would do the modification in the modeller just to be sure but another thing you could try off the top of my head is to do as I suggested before but this time select all the inner faces and extrude them out to give the object some thickness.

Merlimoo

08-01-2008 18:18:13

I've tried the extrude thing, but the problem is exactly the same, except that I do not have to duplicate the face and flip the normal to see both sides of the model with Ogre. But It does not make a difference for PhysX, ConvexShape and TriangleMeshShape are still detecting collision on one side only.

My god!! I'm going to lose all my hair if this continues... :?

NickM

08-01-2008 20:17:57

What does the object look like in the remote debugger?

Merlimoo

11-01-2008 15:30:24

Sorry for the delay, I was kind of busy. I don't really know what I am looking for in the remote debugger. Can you be a little more specific ?

Here is the PhysX Event Dump : http://merlimoo.free.fr/roolbool.pxd. There are 4 tubes, one created with a TriangleMeshShape (the one falling through the ground), one with a ConvexShape (the one with no ball) et the others with CompoundShape of thoses two.

NickM

11-01-2008 16:33:33

So the one thats made using a TriangleMeshShape behaves exactly as you want with regard to the ball but it falls through the floor after you've released it from it's position. TriangleMeshShapes do not collide with TriangleMeshShapes, thats why it falls through the floor. Maybe you could make the floor from a Convex instead?

betajaen

11-01-2008 16:57:38

I haven't seen the PXD, I don't even have PhysX installed at the moment. But you should never use triangle mesh shapes in dynamic actors.

The mountain doesn't collide with you, you collide with the mountain.

NickM

11-01-2008 20:13:44

He basically has a half pipe which a sphere rolls down the inside of, once the sphere has rolled down it the half pipe collapses from its stand and falls to the floor.
How can he make a half pipe, which is a concave shape without using a TriangleMeshShape?
I guess he could create the collision part of it using a number of rectangular shapes that roughly mimic a half pipe, or he could change it from using a TriangleMeshShape into a ConcaveShape just before it collapses. :?

betajaen

11-01-2008 20:38:37

You could use cubes, but how about a collection of convex shapes?