Moving an object with respect to the camera

I have an object in 3d space using perspective projection. What i want to do is select the object (which i can already do) then move it using the mouse. This works fine if the screen is parallel to the x axis, but if I rotate around the y axis I want to move the object with respect to the cameras (screens) x axis, not the world x axis.

for example if I rotate 180 degrees, moving the mouse to the left would make the object move to the right.

If anyone can offer any suggetsions i would be grateful

Thanks

Can only give you a hint on how to do.

Let’s say a=angle around the y-axis and v=distance you want to move the object.

new_x = x + vcos(a)
new_z = z + v
sin(a)

This pseudocode should do the work. Translation along the y-axis is unaffected by rotations about the y-axis.

So if you move your mouse to the right (for example), v will get a positive value, and if you move your mouse left, it will get a negative value.

It’s a litle bit more tricky if you camera can look downwards/upwards too…

Bob

btw, this is just theory…

Yup that works!

Thanks

Yup that works!

Thanks