Jump to content
  • Advertisement
Sign in to follow this  
qwertyPrince

Dragging cube

This topic is 982 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
Advertisement

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!