This project is read-only.

simple collision detection problem

Apr 7, 2008 at 4:17 PM
Edited Apr 7, 2008 at 4:23 PM
I start a simple collision detection with a box and a plane and I don't understand what I'm missing. I looked at jiggle game some snippet code on codeplex and I still don't understand what's wrong.

in my contructor

physicsystem = new PhysicsSystem();
physicsystem.CollisionSystem = new CollisionSystemGrid(32, 32, 32, 13, 13, 13);

in my loadContent

floorB = new Body();
floorS = new CollisionSkin(null);
floorB.CollisionSkin = floorS;

floorS.AddPrimitive(new JigLibX.Geometry.Plane(Vector3.Up,10), (int)MaterialTable.MaterialID.UserDefined,
new MaterialProperties(0.5f, 0.5f, 0.5f));
floorB.Position = new Vector3(0, 0, 0);

floorB.MoveTo(new Vector3(0, 0, 0), Matrix.Identity);

boxB = new Body();
boxS = new CollisionSkin(boxB);
boxB.CollisionSkin = boxS;

boxS.AddPrimitive(new Box(new Vector3(0, 20, 0), Matrix.Identity, new Vector3(10,10,10)), (int)MaterialTable.MaterialID.UserDefined,
new MaterialProperties(0.5f, 0.5f, 0.5f));

boxS.ApplyLocalTransform(new Transform(new Vector3 (-1,-1,-1), Matrix.Identity));



the box passes through the plane and I still not understand why.

I'm using the latest version of jiglibX
Apr 7, 2008 at 10:00 PM
I'm not positive, but try changing the line:




On another note, I don't understand why you are using floorB. Its never added to the physics/collision system so as far as I know its doing nothing. In order to move the floorS CollisionSkin around, I believe you can use floorS.NewPosition and floorS.NewOrient.
The line physicsystem.CollisionSystem.AddCollisionSkin(boxS); is not needed either, when you call boxB.EnableBody() it automatically adds the CollisionSkin that you have associated with that body to the system.

Hope that helps,
Apr 8, 2008 at 7:18 AM
Hello I found the problem was related to the plane. I switch it to a box and the two box were colliding. So I don't know if there i a bug or something or if it's just me but I was pretty happy to find out thi one. But now I still don't know how to use a plane properly.

anyway thanks for your help