List of triangles contained by bounding box

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Garold
Posts: 60
Joined: Fri Sep 23, 2011 5:17 pm
Location: Liverpool, England

List of triangles contained by bounding box

Post by Garold »

I am trying to add texture decals to my level. Such as the visual blast damage from a grenade, or blood splattered on the ground and up a wall.

I have been looking around for ways to achieve this: one method suggested is to draw a box at the point of impact, found by casting a ray. Then determine the triangles that intersect. Use these triangles to create new geometry. The geometry could be added to for multiple blasts, bullet holes, etc.

Here's some images of what I am on about, taken from this article: http://blog.wolfire.com/2009/06/how-to-project-decals/

Image
Image

I know that the data is contained within the static mesh/group, how would I go about getting this data?

As always, thank you!
BEPUphysics rules my world
http://cloneofduty.com
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: List of triangles contained by bounding box

Post by Norbo »

You can grab all triangles with AABBs overlapping an AABB using the staticMesh.Mesh.Tree.GetOverlaps method. For performance reasons, linking the physics representation so completely to the graphics may not be a good idea if you ever want to have high resolution graphical meshes. It might be worth just creating a TriangleMesh (as opposed to a whole StaticMesh) specifically for the graphics so that you aren't restricted to using the same content for both graphics and physics.

Edit:
For dynamic decals like bullet holes which could appear on any surface and can't be baked into level geometry, it might be better to go with an approach similar to shadow maps. This also avoids the nontrivial annoyance of implementing geometry clipping.
Garold
Posts: 60
Joined: Fri Sep 23, 2011 5:17 pm
Location: Liverpool, England

Re: List of triangles contained by bounding box

Post by Garold »

Thanks Norbo,

I have implemented bullet holes using a shadow map technique, I draw the scene to a depth buffer, then when I draw the bullet hole quad, if the depth behind is > bias then I make the quad pixel transparent. This is good for bullet hole's and I store many in a buffer so only 1 draw :)

Like in this video:



Ideally I want to duplicate Volume Decals similar to this site: http://www.humus.name/index.php?page=3D but that example uses DirectX 10, which is not available on the XBOX. I will investigate this technique further though, as you suggested. I consider it essential part of a game and it's my last nut to crack.
BEPUphysics rules my world
http://cloneofduty.com
Post Reply