Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a picture drawn on the x-y plane and I am looking down at it from somwhere on the z plane giving a 2-dimensional map from above feel to it. I would like to be able to use the mouse to scroll the map around - drag it similiar to an adobe pdf document. I have figured out a way to do this by setting the camera vectors in the dev.transform.view matrix. The problem is, depending on my level of zoom, the map will scroll at a rate faster or slower than the cursor so a small, precise movement of the mouse yeilds a large shift in the map.

 

How can I fix this problem?

Posted
Use Vector3.Unproject. Compute result on Vector3(mouseX, mouseY, 0) and Vector3(mouseX, mouseY, 1), the other parameters fetched from device. This gives you a ray in world space as defined by the mouse position. You can compute the intersection of this ray with your plane, giving you a 3D position of the mouse. Computing this at two times and subtracting it gives you the amount you have to move with the view matrix.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...