fIND NEAREST VERTEX

Blitz3D Forums/Blitz3D Programming/fIND NEAREST VERTEX

RifRaf(Posted 2003) [#1]
How might I find the nearest vertex to a picked location.

I have a large mesh, I pick a point on it. I want to remove the nearest vertex on that mes to the picked location on it. How?

Thanks in advance.


Codemonger(Posted 2003) [#2]
Just a quick thought ... someone else could prob. elaborate a little better.

#1) use camerapick() to get the entity at point x,y
#2) use pickedtriangle() to get the trianlge you picked from the entity
#3) use pickedX,PickedY,PickedZ to get the world cord. of the pick
#4) use trianglevertex() and grab the 3 vertices of the trianle
#5) transform the vertex cordinates to world cords.
#6) do a distance comparison of the pickedX,Y,Z cordinates to the transformed vertices
#7) the closest one wins ! thats your vertex