PDA

View Full Version : drawing perpendicular splines, follow mouse


losbellos
03-05-2009, 08:45 AM
Hello,

I am working on some tool, and I would like to implement some basic drawing of perpendicualar splines from an other spline segment, and the lenght updated by the position of the mouse.

I managed the basic code, but Idont know how sould I solve the problem, that I have to continuosly check the mouse postion and draw the new perpendicual spline, without any event change except the mouse moves.

If I use for or while cycle the spline doesnt show up only when the function finishes.

so here is the code structure.


function startpos ()

function drawline (
for (
--get the new point
-- draw
)
)

function base (
-- get selected spline segment
call drawline()
)

getlocation = pickPoint mouseMoveCallback:#(startpos ,startpoint)
call base()

losbellos
03-06-2009, 06:17 AM
Hej, I figured a redrawviews() needed for some reason, now it works!
Thanks anyway.

magicm
03-06-2009, 10:47 AM
Are you using updateShape shpObject as well? This is needed to update the shape in the viewports after adding/removing/modifying knots.

Cheers,
Martijn

losbellos
03-06-2009, 11:30 AM
Naturally, I do, I was really surprised. I dont know why this behaviour. I will try in max2008 and will see.

I run into an other problem. THe mouse.pos, and the mouse.screenpos will give only the screen x,y, do you happen to know how to get the world coordinate x,y without pickpoint?
at least If I would know the world origin in screenpos. But that would also be a factor of the resolution of the screen.

That way I wouldnt have to click always to get a new point. Just simply move the mose and the line will extend its lenght.

ZeBoxx2
03-06-2009, 01:09 PM
I run into an other problem. THe mouse.pos, and the mouse.screenpos will give only the screen x,y, do you happen to know how to get the world coordinate x,y without pickpoint?

Have a peek at the documentation for 'mapScreenToWorldRay', 'mapScreenToView' and 'mapScreenToCP'.

losbellos
03-06-2009, 05:33 PM
Thanks so much, it works perfectly.

CGTalk Moderation
03-06-2009, 05:33 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.