Collision detection not working

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
CrazyXBMax
Posts: 4
Joined: Mon Feb 13, 2012 5:45 pm

Collision detection not working

Post 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.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Collision detection not working

Post 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?
CrazyXBMax
Posts: 4
Joined: Mon Feb 13, 2012 5:45 pm

Re: Collision detection not working

Post 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?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Collision detection not working

Post 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.
Post Reply