I've got a 3D model loaded (a planet) and I have a camera that I want to allow the user to move freely around it. I have no problem getting the camera to orbit the planet around either the x or y axis. My problem is when I try to move the camera on a different axis I have no idea how to go about doing it. I am using OpenGL on Android with the libGDX library. I want the camera to orbit the planet in the direction that the user swipes their finger on the screen.
2 Answers
You basically want the camera to walk around on a sphere. And you want the camera to look at the center of the planet while doing it.
Or rotate the camera around it's target. Or implement an arcball camera.
-
\$\begingroup\$ Thanks for all of the links. I think I should be able to make something work based off these. \$\endgroup\$ Dec 12, 2012 at 1:00
If you want to save some processing power and it won't mess with the rest of your game, you can also rotate the planet in the opposite direction and leave the camera at one point. :)
-
\$\begingroup\$ I was thinking about doing it this way but I figured just moving the camera around the planet would be easiest since I am going to have other objects orbiting the planet at the same time... \$\endgroup\$ Dec 12, 2012 at 13:49
-
\$\begingroup\$ If you have more objects in your scene, it will get harder. I have a camera class in c++ using the winapi for mouse input. I could post it, but it's not really optimised in any way nor is it the right language for you. \$\endgroup\$– KevinDec 12, 2012 at 13:55