getting a vertex handle

Blitz3D Forums/Blitz3D Programming/getting a vertex handle

Hi
how would I get the nearest vertex to an entitypick or collision?

You can use PickedTriangle to get the triangle, and then calculate the distance to each of the vertices used by the triangle.

Something like this:
ent  = PickedEntity()
surf = PickedSurface()
tri  = PickedTriangle()

v0 = TriangleVertex(surf,tri,0)
Tformpoint vertexx(surf,v0),vertexy(surf,v0),vertexz(surf,v0),ent,0
x# = tformedx()-pickedx()
y# = tformedy()-pickedy()
z# = tformedz()-pickedz()
mind# = Sqr(x*x + y*y + z*z)
vert = v0

v1 = TriangleVertex(surf,tri,1)
Tformpoint vertexx(surf,v1),vertexy(surf,v1),vertexz(surf,v1),ent,0
x# = tformedx()-pickedx()
y# = tformedy()-pickedy()
z# = tformedz()-pickedz()
d# = Sqr(x*x + y*y + z*z)
if d<mind
mind = d
vert = v1
end if

v2 = TriangleVertex(surf,tri,2)
Tformpoint vertexx(surf,v2),vertexy(surf,v2),vertexz(surf,v2),ent,0
x# = tformedx()-pickedx()
y# = tformedy()-pickedy()
z# = tformedz()-pickedz()
d# = Sqr(x*x + y*y + z*z)
if d<mind
mind = d
vert = v2
end if

print "nearest vertex: "+vert
print "distance: "+mind


thanks