--MoveVertexOnSurface - RightClick Menu --Idea by Chris Harvey
--Version 0.1
--Started: 11/30/99
--Started: 11/30/99
--by Borislav Petrov
--http.//gfxcentral.com/bobo/
--REQUIRES MOUSTRK.DLX EXTENSION TO BE INSTALLED UNDER PLUGINS!


--Copy this file to your \Scripts\Startup directory.
--Restart MAX
--Select an Editable Mesh without modifiers
--Got to Vertex Level, select a single vertex
--Right-click, select "Move Vertex On Surface" from context menu
--Click LMB or click and drag on the object's surface to specify new position
--Right-click or click outside Geometry to cancel.

--If more than one vertex are selected, only the first one found will be moved.





RcMenu MoveVertexOnSurfaceRCM
(

fn flt_SingleVertex = 
(
(selection.count == 1) and (classof selection[1] == Editable_mesh) and (classof selection[1] != TargetObject) and (SubObjectLevel == 1)
)

MenuItem mi_MoveVertexOnSurface "Move Vertex On Surface" filter:flt_SingleVertex


on mi_MoveVertexOnSurface picked do 
(
work_node = selection[1]
vert_selection = getvertselection work_node
for i = 1 to vert_selection.count do 
	(
	if vert_selection[i] == true then 
		(
		vert_index = i
		print i
		exit
		)
	)
	
fn get_normal_function  msg ir obj faceNum shift ctrl alt =
(
if msg == #mouseMove or msg == #mousePoint then
	(
	setvert work_node vert_index (ir.pos)
	update work_node
	)

if msg != #mouseAbort then 
	(
	return #continue
	)
	else 
	(
	return #end
	)
)


try
(
undo on
(
mouseTrack on:work_node trackCallBack:get_normal_function
)
)
catch
(
messagebox "This Script Requires the MouseTrack.DLX MAXScript Extension!\n(But this error message might mean something else crashed...:o)"
)
)--end on

)--end script

RegisterRightClickMenu MoveVertexOnSurfaceRCM