Sign in to follow this  

Dragging cube

This topic is 675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i recently managed to  move a 3D shape using the cursor location by unprojecting the object position and adding the x and y offsets to it and then project it back into the 3d world, this seemed to work really well, however i devided to move alow the view to be rotated and the object isnt always under the mouse when i try to move it in a rotated orientation. How do i go about doing this?

Share this post


Link to post
Share on other sites

I used XNA project and unproject. both take the view matrix in as a parameter, what is the purpose of passing the view matrix to the two functions?

 

Edit:

 

I finally wrote some project and unproject functions.

On projecting :

 

-multiply cooridnates by view and projection matrices, then divide the resultant coorinate by the w component

-store the z coordinate

 

i then convert the mouse movement into projection space and add the offset to the projected coordinates 

with the z cordinate being the one stored initially

 

On unprojecting:

 

-get the mouse in the projection space

-multiply by the (view * projection)^-1 , and then divide by the w component.

 

This works however any movement into along the z axis at an angle does not track the mouse, i assume it is due to the fact that i am mapping the movment of the y-screen to the z-coordinate in 3D. i dont see another way though

Edited by qwertyPrince

Share this post


Link to post
Share on other sites

This topic is 675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this