我遇到的困難是將相機移動到3D世界中的物體後面。我會創建兩個視圖模式。如何以相同角度將相機移動到模型後面?
1:for fps(第一人稱)。 第二名:角色背後的外部視角(第二人稱)。
我在網上搜索了一些例子,但它在我的項目中不起作用。
這裏用到我的代碼更改視圖如果F2被按下
//Camera
double X1 = this.camera.PositionX;
double X2 = this.player.Position.X;
double Z1 = this.camera.PositionZ;
double Z2 = this.player.Position.Z;
//Verify that the user must not let the press F2
if (!this.camera.IsF2TurnedInBoucle)
{
// If the view mode is the second person
if (this.camera.ViewCamera_type == CameraSimples.ChangeView.SecondPerson)
{
this.camera.ViewCamera_type = CameraSimples.ChangeView.firstPerson;
//Calcul position - ?? Here my problem
double direction = Math.Atan2(X2 - X1, Z2 - Z1) * 180.0/3.14159265;
//Calcul angle - ?? Here my problem
this.camera.position = ..
this.camera.rotation = ..
this.camera.MouseRadian_LeftrightRot = (float)direction;
}
//IF mode view is first person
else
{
//....
謝謝你一個過濾器 –