Notifications
Clear all

[Closed] Viewport drawing methods help

How can i drawing selectable mark on viewport, Like FFDBox controlpoints.

6 Replies

mxs would be something like…

 fn draw_markers = 
    (
        if $selection.count > 0 then
        (
    		gw.setTransform(Matrix3 1);
            currentsel = $selection[1];
            npts = numpoints currentsel;
            for p = 1 to npts do
            (
                pt = getPointPos currentsel p;
                gw.Marker pt #hollowBox color:green;
            )
        )
    )	
    UnRegisterRedrawViewsCallback draw_markers
    RegisterRedrawViewsCallback draw_markers

selection would be indicated by changing the color value for the selected (handling how to manage selection is another matter)

Thank you so much Klvnk. Can i select only marker? i want a simple pivot change plugin. i want made selectable marker and click marker change pivot position.
i thinking method is; when goes mouse on marker and click, marker changed pivot poisiton. i cant convert, marker world position to screen position. i want inverse “mapscreentocp” function result.

Also, you can find a similar tool which uses dummies instead of markers.

thank you for sharing miauu. i like your plugin. but i didn’t want plugin. i just want solition method.

i have found this method. but i dont know how can i catch mouse click.

unRegisterRedrawViewsCallback func
fn func =
(
	a = (gw.transpoint [0,0,0])
	b = mouse.pos
	print (distance [a.x,a.y] b)
	if (distance [a.x,a.y] b) < 3 then gw.marker [0,0,0] #bigbox color:yellow
	else gw.marker [0,0,0] #hollowBox color:red
	gw.updateScreen()
	redrawViews()
)
registerRedrawViewsCallback func
1 Reply
(@serejah)
Joined: 10 months ago

Posts: 0

if you want to process only the selection mouse clicks you can set up NodeEventCallback or general selection changed event callback and save last mouse coord position for the later use in viewport drawing callback

i use pickpoint function. last status of my code. thank you all.

(
	if selection.count == 0 then
	(
		obj = box width:60 length:20 height:5
		select obj
	)
	fn func1 =
	(
		wr = mapScreenToWorldRay mouse.pos
		for loop in obj_bb do
		(
			vtm = inverse (getviewtm())
			local a = (normalize (loop-vtm.row4))
			if (distance wr.dir a) < 0.005 then
			(
				gw.marker loop #bigbox color:yellow
				if pp != undefined then
				(
					print "pivot changed"
					$.pivot = loop
					unRegisterRedrawViewsCallback func1
				)
			)
			else gw.marker loop #hollowbox
		)
		if selection.count == 0 then
		(
			unRegisterRedrawViewsCallback func1
		)
		gw.updateScreen()
		redrawViews()
	)
	if selection.count != 0 then
	(
		global obj_bb = nodeLocalBoundingBox $ 
		registerRedrawViewsCallback func1
		global pp = undefined
		pp = pickpoint()
	)
	"--"
)