Hi all,
i had problems with just trying to take a point in screen space and get a snapped point back in world space, for use in tools, until i stumbled across the autoPlace command which looked like it would solve all my problems!
So i knocked up this little test:
draggerContext
-pressCommand "sampleContextPress"
-cursor "hand"
sampleContext;
global proc sampleContextPress()
{
float $pressPosition[] = `draggerContext -query -anchorPoint sampleContext`;
print ("Press: " + $pressPosition[0] + " " + $pressPosition[1] + " " + $pressPosition[2] + "n");
string $sphere[] = `sphere`;
float $position[] = `autoPlace -um`;
move -relative $position[0] $position[1] $position[2] $sphere[0];
}
setToolTo sampleContext;
Thas makes a sphere and moves it using autoPlace, based on where you click. The problem you will find tho is that it doesnt work! the spheres end up offset.
This offset is the vector from the top left of the desktop to the top left of the main 3d window. So autoPlace basically takes mouse coordinates in desktop space.
I cant find any way of accounting for this in MEL or the api.
Does anyone have any ideas? tools like the polyCreateFace must do this properly?