Trouble doing mesh collision

Jul 14, 2010 at 3:08 PM

Hi all,

I'm playing with OOPS and mesh collision. I have a sphere rigid body ( ie a ball ) in a close room. Walls are modeled as Collision Planes and they works perfectly:

 CollisionGroup group = new CollisionGroup();
            group.CollisionShapes.Add(new CollisionPlane() { Normal = Vector3.Backward, Distance = -90 });
            group.CollisionShapes.Add(new CollisionPlane() { Normal = Vector3.Right, Distance = -25 });
            group.CollisionShapes.Add(new CollisionPlane() { Normal = Vector3.Left, Distance = -25 });
            group.CollisionShapes.Add(new CollisionPlane() { Normal = Vector3.Forward, Distance = -10 });
            group.UpdateTransform();
            physicsService.CollisionSystem.CollisionGroups.Add(group);

I can manage see the ball bumping into the walls properly.

Then I add some meshes into the scene: scaling was done in the import level, and the mesh are added to the collision system that way:


  
            
            var cm = new CollisionMesh(new ModelCollisionMeshProxy(Model));
            cm.Position = GetPosition();

            group = new CollisionGroup();
            
            group.Tag = "Bin";
            group.CollisionShapes.Add(cm);

            group.UpdateTransform();
            
            physicsService.CollisionSystem.CollisionGroups.Add(group);

 

The ball does not "Bump" over that object at all: the only way to see the ball touching is to call the ballRigidBody.UpdateTransform() in the Update function, but in this case it works only for one time, then the ball seems to simple ignore the mesh.

PS: the mesh is properly drawn, since the mesh *works in the OOPS test application*, so I really miss something: please give me some advice,

Thanks all.

 

Coordinator
Jul 14, 2010 at 10:39 PM

hi flexpollan,

Try setting the Position on the CollisionGroup of the CollisionMesh, not the CollisionMesh itself.

Good luck!

Jul 15, 2010 at 7:00 AM

Thanks FretboardOfFury,

I did try, but nothing change: in addition, I'm drawing the AABB of the mesh, and now, after the modify suggested, does not fit anymore the "visual" shape.

As another information: I do not use AsyncUodate, but Update instead, but plane collision works perfectly.

 

Jul 16, 2010 at 1:02 PM

FretboardOfFury,

Please never mind: problem was in the trasform of the ball, not in the mesh! Thanks for your help