i have 2 meshes rendered with DirectX 9 and a camera that is looking at 0,0,0. One mesh is located at 0,0,0 and the other one at 5,0,0. How can i rotate the camera around 0,0,0 to always look the two meshes but from the new position? I would like to press the arrow keys on the keyboard and be able to rotate the camera
Asked
Active
Viewed 1,268 times
0
-
Was it really necessary to tag the question with both Direct3D9 and DirectX9? – Puppy Jan 23 '11 at 17:20
-
Do you mean that you want it to appear that both meshes are rotating in place? – Alex Jan 23 '11 at 17:45
-
i would rotate all the 3d models over the 0,0,0 position so that i can see them from a different position. I don't know if it's more easy to rotate the camera or the meshes... – Stefano Jan 23 '11 at 17:48
1 Answers
2
Build the camera matrix from a lookat function. There are d3dx functions to build a proper matrix.
What you want to do is to setup the camera so that you can let it go in a circle around the objects. Say a circle of radius 10 centered around 2.5,0,0. Iam not sure around what axis you want to rotate but i assume z (and x):
// pseudo
cameraposition= vec3(sin(x)*10.0 + 2.5,0,cos(x)*10)
cameralookat= vec3(2.5,0,0)
For more info see http://msdn.microsoft.com/en-us/library/bb397804.aspx

stefan
- 2,886
- 21
- 27