   Distance to arbitrary mesh
  I want a way to find the distance between an arbitrary point in 3D space and the closest point on the surface of an arbitrary triangle mesh. So I guess it boils down to finding the closest point on the mesh. Can anyone point me in the right direction? I'm not too bothered about it being efficient, I only need it to illustrate a point.   
  closest point on triangle x many triangle, take the closest :)http://www.gamedev.net/community/forums/topic.asp?topic_id=516608;  This is similar to collision detection. First find the normal from the given point to the plane of a triangle. If that normal intersects the plane inside the borders of the triangle you are done for that triangle. Otherwise find the normals from the point to each of the three lines containing the edges. If a normal intersect its respectve line within the bounds of its edge you are done for that edge and you do not have to check its end points (however you still need to check the other two edges and the other point in the triangle for a closer intersection) .  If you still haven't found any intersections, just take the closest point of the three.Note, you have to apply this to all the triangles in the mesh but there are some optimizations.  For instance if you check for an edge intersection you don't have to check it again from the adjoining triangle. What you might do is check all faces first, then check all edges and check all points, setting flags for objects I don't need to check as I go along.  For instance, if you find a face intersection you can set flags on all its edges and points so you don't check them again. Or if you find an edge intersection you can just set flags on its points.You can also use bounding spheres to sort your triangles before starting any tests. That way you can eliminate most of your checks.  If you do this you will probably want to check one complete triangle at a time as opposed to doing face then edge and then point checks although you can still make use of the flags. You can also eliminate faces that face away from the target point as well as their edges and points, assuming you don't care if this works from inside your mesh.;  http://reference.kfupm.edu.sa/content/e/f/efficient_distance_computation_between_n_30151.pdf   