Drag camera/view in a 3D world

Posted by Dono on Game Development See other posts from Game Development or by Dono
Published on 2013-07-31T16:02:41Z Indexed on 2013/11/05 4:15 UTC
Read the original article Hit count: 233

Filed under:
|
|

I'm trying to make a Draggable view in a 3D world.

Currently, I've made it using mouse position on the screen, but, when I move the distance traveled by my mouse is not equal to the distance traveled in the 3D world.

Explication with a picture

So, I've tried to do that :

  1. Compute a ray from mouse position to 3D world.
  2. Calculate intersection with the ground.
  3. Check intersection difference old position <-> new position.
  4. Translate camera with the difference.

I've got a problem with this method:

  1. The ray is computed with the current camera's position
  2. I move the camera
  3. I compute the new ray with new camera position.
  4. The difference between old ray and new ray is now invalid.

So, graphically my camera don't stop to move to previous/new position everytime.

How can I do a draggable camera with another solution ?

Thanks!

© Game Development or respective owner

Related posts about 3d

Related posts about camera