Maybe this code might help a little ? It returns the distance between a point and a plane. If your meshes are convex, you could perhaps check the distance from the point to each face, and take the shortest distance:
Function DistPointPlane#(px#,py#,pz#, x0#,y0#,z0#,x1#,y1#,z1#,x2#,y2#,z2#) ;calculate normal ax# = x1 - x0 ay# = y1 - y0 az# = z1 - z0 bx# = x2 - x1 by# = y2 - y1 bz# = z2 - z1 Nx# = ( ay * bz ) - ( az * by ) Ny# = ( az * bx ) - ( ax * bz ) Nz# = ( ax * by ) - ( ay * bx ) Ns# = Sqr( Nx*Nx + Ny*Ny + Nz*Nz ) If Ns > 0 Then Nx = Nx / Ns Ny = Ny / Ns Nz = Nz / Ns End If ;calculate plane d d# = -((nx * x0) + (ny * y0) + (nz * z0)) ;calculate point plane distance dst# = nx*px + ny*py + nz*pz + d dno# = Sqr(nx*nx + ny*ny + nz*nz) If dno <> 0 Then dst = dst / dno Return dst# End Function