Ya sorry, I haven’t had a chance to work on the .toe file yet.
You don’t need to work in screen space actually. Camera space will get you close enough to what you want. Camera space is defined as a space where the camera is located at (0,0,0), right is always +X, left is -X, up is +Y and down -Y. This is always true regardless of how your camera is orientated (rotate it, move it, twist it, the numbers will always be relative to how the camera sees everything).
I’m not entirely clear of the movement you want. Lets say you click on an axis thats pointing left/right in the viewer and you move your mouse up, what do you want to happen? Would you expect your object to move up?
The way I see these jacks working is that they are always locked onto their ‘paths’, (they can only move in two directions, forwards or backwards along their current paths). But maybe you are trying to do something else?
Anyway, to do the conversion here’s how.
A vector can be defined as a point subtracted from another point. In this case you’ll want to use two points, the point where the user first clicked his mouse, and where the mouse position is now.
Lets say the user clicked and you got a UV or (100,100), and now he’s dragged his mouse up and to the right to (125,115).
So the vector is (125,115) - (100, 100), which gives you (25, 15). Now since right is +X and up is +Y , you can map this (U,V) vector to (X,Y,Z) easily, it’s simply (25, 15, 0).
Next you’ll probably want to normalize this vector. To normalize a vector you do (X,Y,Z) / length(X,Y,Z). I do this using CHOPs in the .toe file already, look at the Math CHOPs named ‘calcLength’ and ‘invert’. Those give us 1.0 / length(X,Y,Z). Which I multiply by the vector to normalize it.
So now you have a normalized vector in Camera Space. Now transform it back into object space so you can compare it to the original axii (which are the untransformed original axii). Doing this is a little clunky, but here’s how. Create an Add SOP and put your (X,Y,Z) values into a point. Then use the SOP To CHOP, and use /cameraToObject as the Transform Object parameter. You can see me doing this with /level1/HANDLES/pos/add1 and ‘sopto2’ (although I’m just transforming (0,0,0) in this case).
(/cameraToObject is relative to /level1/HANDLES/pos only btw).
The values you get you can now compare to the original axii and you now know the users movement relative to the axii. If you want to just forget about any axis-based motion, and instead just drag the object around the screen, you can just add this vector to the transform for the object and it’ll move around in a visually correct way (you can use the vector length you calculated earlier to know how far to move it).
Let me know if I’m still not explaining it well enough.