开发者

XNA How To Make Camera Orbit Around And Always Look At A Vector3.Zero?

Halo everyone,

Ho开发者_如何学Pythonw to make a camera orbiting a Vector3.Zero within a certain distance (like the earth orbiting sun) AND make the camera always look at that Vector3.Zero?

Please kindly answer, thank you


The camera is usually passed to effects as a View matrix.

You can create a "look at" matrix with Matrix.CreateLookAt (MSDN).

That takes three arguments: the target and up vectors should be pretty standard (presumably Vector3.Zero and Vector3.Up in your case).

Now you just need the position of the camera itself. And you want it to rotate. It will be something like this:

Vector3.Transform(new Vector3(distance, 0, 0), Matrix.CreateRotationY(angle));

For more information, take a look at the methods that the Matrix class provides for creating transformation matrices.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜