PickedVertex()

Blitz3D Forums/Blitz3D Programming/PickedVertex()

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Not tested...

Function pickedVertex()
	Local xd#,yd#,zd#,sd#,td#,px#,py#,pz#,srf,tri,vert,v
 	TFormPoint PickedX(),PickedY(),PickedZ(),0,PickedEntity()
	px = TFormedX() 
	py = TFormedY()
	pz = TFormedZ()
	srf = PickedSurface()
	tri = PickedTriangle()
	For v=0 To 2
		vert = TriangleVertex(srf,tri,v)
		xd = VertexX(srf,vert)-px
		yd = VertexY(srf,vert)-py
		zd = VertexZ(srf,vert)-pz
		td = xd*xd+yd*yd+zd*zd
		If td < sd Or v = 0
			sd=td
			rVert=vert
		EndIf
    Next
;	TFormPoint VertexX(srf,rVert),VertexY(srf,rVert),VertexZ(srf,rVert),PickedEntity(),0
;	PositionEntity vertcube,TformedX(),TformedY(),TformedZ(),True
    Return rVert
End Function