Page 1 of 1

Collision detection not working

Posted: Thu Mar 01, 2012 2:40 pm
by CrazyXBMax
Howdy. I am currently using the DependencyFree fork of BepuPhysics with MOGRE. Creating entities works fine but my problem is that they do not collide. If I spawn dynamic boxes, they do not collide with each other and they also do not collide with the kinematic ground.

This is how I create the ground:

Code: Select all

BEPUphysics.Entities.Prefabs.Box box = new Box(Position.ConvertPhysics(), 30, 0.9f, 30);
            space.Add(box);
(ConvertPhysics converts my own vector3 class into the BepuPhysics one.)

And the dynamic boxes are created this way:

Code: Select all

BEPUphysics.Entities.Prefabs.Box box = new BEPUphysics.Entities.Prefabs.Box(position.ConvertPhysics(), 1, 1, 1, 1.0f);
            space.Add(box);
As you can see I use the mass property as said in the Getting Started documentation. This also applies gravity cause the boxes actually fall, but they do not collide with anything.

This is how I render them:

Code: Select all

ph.model.ParentNode.Position = new Mogre.Vector3(ph.box.Position.X, ph.box.Position.Y, ph.box.Position.Z);
         ph.model.ParentNode.Orientation = new Mogre.Quaternion(ph.box.Orientation.W, ph.box.Orientation.X, ph.box.Orientation.Y, ph.box.Orientation.Z);
ph is an instance of Physical box class. Model is the graphical entity and box the BepuPhysics.Entities.Prefabs.Box instance.

Re: Collision detection not working

Posted: Thu Mar 01, 2012 9:21 pm
by Norbo
Do the graphics align with the physics? Often this kind of issue is caused by an offset or scaling issues. To verify, I usually suggest using the BEPUphysicsDrawer, but that will be a slight problem since there's no non-XNA version of the BEPUphysicsDrawer. Pulling the relevant parts of the simulation into the BEPUphysicsDemos to investigate could be helpful, though.

Were any custom collision rules defined? These can be set up to stop collisions from happening between certain objects.

Are the objects in the same space?

Re: Collision detection not working

Posted: Sat Mar 03, 2012 8:16 am
by CrazyXBMax
There where no custom collision rules and all objects are in the same space. That graphics issue is a nice point, my graphical representation may be different from the physical entity. Is there a way to see the Bounding boxes of the physical objects?

Re: Collision detection not working

Posted: Sat Mar 03, 2012 9:02 am
by Norbo
Is there a way to see the Bounding boxes of the physical objects?
There's a BoundingBoxDrawer in the BEPUphysicsDemos, though it does rely on XNA.