سؤال

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

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top