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: 263
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.
So, I've tried to do that :
- Compute a ray from mouse position to 3D world.
- Calculate intersection with the ground.
- Check intersection difference old position <-> new position.
- Translate camera with the difference.
I've got a problem with this method:
- The ray is computed with the current camera's position
- I move the camera
- I compute the new ray with new camera position.
- 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