finding mesh normals *not bepu related

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
RyanGadz
Posts: 32
Joined: Thu Aug 12, 2010 8:34 pm
Contact:

finding mesh normals *not bepu related

Post by RyanGadz »

just posting this on here because you guys have been so helpful in the past

what are some methods of finding the normal of a mesh at a given point. the point being the location of my ball/sphere that is rolling over a triangle mesh.

finding the closest point is the biggest issue because i dont know where to begin with this.

thanks
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: finding mesh normals *not bepu related

Post by Norbo »

To get the normals without using BEPUphysics, you'd have to write a fairly significant portion of the collision detection system. Fortunately, the CollisionPairs on the ball (assuming it is a BEPUphysics entity) have within them lists of contact points. Each contact has a normal, amongst other things.

The only trick would be to determine whether the other entity in the collision was part of a mesh. This could be done by specifying the StaticTriangleGroup's Tag to be itself so that all of its triangles will inherit that tag. If a CollisionPair contains an entity with the appropriate Tag, then you have a mesh collision.

Without using BEPUphysics, the problem gets harder due to the redundant work. You'd need an acceleration structure for your mesh to query to find the 'nearby' triangles. This could be an AABB tree like the engine uses, or anything else. Query that acceleration structure with the ball's shape to get the nearby triangles. Then, for each of those nearby triangles, compute contact data. Sphere-triangle can be boiled down to the closest point between a point and a triangle. If you only need a normal, that particular test could be optimized too.
RyanGadz
Posts: 32
Joined: Thu Aug 12, 2010 8:34 pm
Contact:

Re: finding mesh normals *not bepu related

Post by RyanGadz »

oh haha so i guess it is bepu related

so there will be several pairs and possibly several objects (depending on my scene and where the ball is) that i will have to chose from or average together to pick the one i need.

okay that makes sense ill start with that

here is my game so far
http://www.youtube.com/watch?v=bgmJS7AhyHA
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: finding mesh normals *not bepu related

Post by Norbo »

so there will be several pairs and possibly several objects (depending on my scene and where the ball is) that i will have to chose from or average together to pick the one i need.
Yep, basically.
here is my game so far
Looking good :)
Post Reply