I write programm with bepu physics.
But it work very bad, becouse some boxes fall throw other boxes.
Boxes don't collide
Boxes don't collide
- Attachments
-
- 1.png (10.49 KiB) Viewed 5590 times
Re: Boxes don't collide
It looks like the graphics do not match the actual shapes. They may be offset from the actual shape, scaled differently, or both.
The BEPUphysicsDrawer in the main source download is useful for debug visualization. You could also just put the physics side of things into a BEPUphysicsDemos demo to see if the simulation itself is behaving well (since the demos use the BEPUphysicsDrawer).
The BEPUphysicsDrawer in the main source download is useful for debug visualization. You could also just put the physics side of things into a BEPUphysicsDemos demo to see if the simulation itself is behaving well (since the demos use the BEPUphysicsDrawer).
Re: Boxes don't collide
Thank you!
I have two boxes with tags: "Box1" and "Box2".
How do I know that they are in contact or not?
Sorry, if there are grammatic errors, becouse I'm from RUSSIA.
I have two boxes with tags: "Box1" and "Box2".
How do I know that they are in contact or not?
Sorry, if there are grammatic errors, becouse I'm from RUSSIA.
Re: Boxes don't collide
One option would be to check the entity.CollisionInformation.Pairs list on one of the boxes. If it one of the pairs involves the other box, and that pair has contacts in its Contacts list with nonnegative penetration depth, then they are touching.
Each CollidablePairHandler in the pairs list will have a BroadPhaseOverlap in it. There's an EntryA and an EntryB in that. They are BroadPhaseEntry objects; BroadPhaseEntry objects have Tags which you can set. The entity.CollisionInformation property returns an EntityCollidable object which inherits from BroadPhaseEntry, so it has a Tag itself which is separate from the Entity.Tag. If you put your data in that Tag, you can look at the tags in the BroadPhaseEntry objects in the BroadPhaseOverlap to determine if the objects are the ones you want to check.
The BroadPhaseEntry can be cast down to an EntityCollidable if it is in fact an EntityCollidable, too, which would allow you to check the EntityCollidable.Entity property.
Each CollidablePairHandler in the pairs list will have a BroadPhaseOverlap in it. There's an EntryA and an EntryB in that. They are BroadPhaseEntry objects; BroadPhaseEntry objects have Tags which you can set. The entity.CollisionInformation property returns an EntityCollidable object which inherits from BroadPhaseEntry, so it has a Tag itself which is separate from the Entity.Tag. If you put your data in that Tag, you can look at the tags in the BroadPhaseEntry objects in the BroadPhaseOverlap to determine if the objects are the ones you want to check.
The BroadPhaseEntry can be cast down to an EntityCollidable if it is in fact an EntityCollidable, too, which would allow you to check the EntityCollidable.Entity property.
Re: Boxes don't collide
I went ahead and made a little modification to the development version which lets you access a pair's Collidables and Entities directly if you'd like to use it: http://bepuphysics.codeplex.com/SourceC ... evelopment
Re: Boxes don't collide
Code: Select all
Box body;
public override void Initialize ()
{
// ЗАДАЧА: добавьте здесь код инициализации
body = new Box(new Vector3(0, 10, 0), 1, 1, 1, 40);
body.Tag = "Box1";
space.Add(body);
Box box;
box = new Box(new Vector3(0, 0, 0), 1, 1, 1);
box.Tag = "Box2";
space.Add(box);
body.CollisionInformation.Events.CreatingContact += new BEPUphysics.Collidables.Events.CreatingContactEventHandler<BEPUphysics.Collidables.MobileCollidables.EntityCollidable>(Events_CreatingContact);
body.CollisionInformation.Events.PairTouched += new BEPUphysics.Collidables.Events.PairTouchedEventHandler<EntityCollidable>(Events_PairTouched);
base.Initialize();
}
void Events_PairTouched (EntityCollidable sender, Collidable other, CollidablePairHandler pair)
{
if (pair.BroadPhaseOverlap.EntryA.Tag == "Box1" || pair.BroadPhaseOverlap.EntryB.Tag == "Box2")
{
MessageBox.Show("OK!!!");
}
}
I see that the Box body falls on the Box box, but the program does not show MessegeBox.
Help me please!



Re: Boxes don't collide
The BroadPhaseEntry.Tag is separate from the Entity.Tag. If you want to use the BroadPhaseEntry.Tag, the entity.CollisionInformation.Tag must be set.