Triangular collision

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
ShooterX
Posts: 4
Joined: Wed Mar 16, 2011 10:29 pm

Triangular collision

Post by ShooterX »

I just got started with BEPU physics and have a number of questions.

In the GettingStarted example, StaticMesh is used to add the terrain, which will never move.

Question 1:
How do I add triangular data that is not static. That is, what am I adding to have the engine check for collisions on the triangular level.

Question 2:
Is there any way to split this further into Meshes. That is, to fragment one model into multiple entities (its meshes) and add them to Space. (I'm aware that this degrades performance in general, but I have specific cases in my engine where I use this)

Bonus Question:
Is there any way to "group" entities such that collision checking is done only between groups. Example: 10 bullets are shot in different directions; there are 10 boxes; only the 10 bullets should hit the 10 boxes; the boxes and the bullets don't need to be checked for collisions between themselves.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Triangular collision

Post by Norbo »

Question 1:
How do I add triangular data that is not static. That is, what am I adding to have the engine check for collisions on the triangular level.
If it's a single triangle, there is a Triangle entity or you could create TriangleShape and make an entity with it.

If you want a dynamic mesh, you can create a bunch of triangle shapes and add them to a compound body. This thread has some example code based on a model: http://www.bepu-games.com/forums/viewto ... f=4&t=1109

A proper dynamic version of the StaticMesh with specialized data structures and collision systems is coming in v0.16.0 (with optional volume solidity too).
Question 2:
Is there any way to split this further into Meshes. That is, to fragment one model into multiple entities (its meshes) and add them to Space. (I'm aware that this degrades performance in general, but I have specific cases in my engine where I use this)
The physics engine doesn't know or care about where the vertices or indices come from; if you extract the data from a submesh rather than a whole mesh, it will be fine. By default, the GetVerticesAndIndicesFromModel just grabs everything in a Model, but it's just a convenience method and you can do it however you want.

If you mean dynamically splitting a single mesh entity into multiple entities later, it's still possible, but there's nothing magic about the process. It would involve setting up the split submeshes and creating entities for them, and getting rid of the original whole mesh entity.
Bonus Question:
Is there any way to "group" entities such that collision checking is done only between groups. Example: 10 bullets are shot in different directions; there are 10 boxes; only the 10 bullets should hit the 10 boxes; the boxes and the bullets don't need to be checked for collisions between themselves.
Yup, using the collision rules system: http://bepuphysics.codeplex.com/wikipag ... umentation

Specifically, check out CollisionGroups.
ShooterX
Posts: 4
Joined: Wed Mar 16, 2011 10:29 pm

Re: Triangular collision

Post by ShooterX »

Thanks for the response! Lots-a coding on the way :)
ShooterX
Posts: 4
Joined: Wed Mar 16, 2011 10:29 pm

Re: Triangular collision

Post by ShooterX »

Norbo wrote: A proper dynamic version of the StaticMesh with specialized data structures and collision systems is coming in v0.16.0 (with optional volume solidity too).
You'll probably hate this question, but I was wondering if you could comment on the approximate ETA of version 0.16.

The sample code from the thread you referenced doesn't seem to work properly for all models that I have.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Triangular collision

Post by Norbo »

You'll probably hate this question, but I was wondering if you could comment on the approximate ETA of version 0.16.
Current goal is 1-2 months. You can see the roadmap here: http://www.bepu-games.com/forums/viewto ... ?f=5&t=849
The sample code from the thread you referenced doesn't seem to work properly for all models that I have.
In what way is it failing? If it's the model vertex extractor (TriangleMesh.GetVerticesAndIndicesFromModel) failing, you can try a different approach to extracting the data. A build-time content processor or other model vertex extractor may do the job. The TriangleMesh.GetVerticesAndIndicesFromModel is known to have issues (particularly on WP7), but it's not a very high priority since it's just for convenience.
ShooterX
Posts: 4
Joined: Wed Mar 16, 2011 10:29 pm

Re: Triangular collision

Post by ShooterX »

Norbo wrote: In what way is it failing? If it's the model vertex extractor (TriangleMesh.GetVerticesAndIndicesFromModel) failing, you can try a different approach to extracting the data. A build-time content processor or other model vertex extractor may do the job. The TriangleMesh.GetVerticesAndIndicesFromModel is known to have issues (particularly on WP7), but it's not a very high priority since it's just for convenience.
I don't know what the problem is with GetVerticesAndIndicesFromModel in my usage, but I am going to guess that something, somewhere just isn't transformed correctly (that is, it's not the Entity itself, but what I draw/do after). In fact, it could even be somewhere in my code.

Either way, I have my own processor that extract indices and vertices. But the main reason as to why I am reluctant to continue anything beyond what you suggested in your reply is because of the premise of the DynamicMesh. I'll wait for it in any case.
Post Reply