Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/143.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ DirectX摄像机定位(第三人称视图)_C++_Directx 10 - Fatal编程技术网

C++ DirectX摄像机定位(第三人称视图)

C++ DirectX摄像机定位(第三人称视图),c++,directx-10,C++,Directx 10,我正在创建一个3d飞行游戏,并使用DXUTCamera进行查看 我可以让相机拍摄角色的位置,但我想在第三人称中查看我的角色 这是我第一人称观点的核心 //Put the camera on the object. D3DXVECTOR3 viewerPos; D3DXVECTOR3 lookAtThis; D3DXVECTOR3 up ( 5.0f, 1.0f, 0.0f );

我正在创建一个3d飞行游戏,并使用DXUTCamera进行查看

我可以让相机拍摄角色的位置,但我想在第三人称中查看我的角色

这是我第一人称观点的核心

//Put the camera on the object.                     

        D3DXVECTOR3 viewerPos;
        D3DXVECTOR3 lookAtThis;
        D3DXVECTOR3 up         ( 5.0f, 1.0f, 0.0f );
        D3DXVECTOR3 newUp;
        D3DXMATRIX matView;

        //Set the viewer's position to the position of the thing.

        viewerPos.x = character->x;   viewerPos.y = character->y;
        viewerPos.z = character->z;


        // Create a new vector for the direction for the viewer to look

        character->setUpWorldMatrix();
        D3DXVECTOR3 newDir, lookAtPoint;
        D3DXVec3TransformCoord(&newDir, &character->initVecDir,
                                      &character->matAllRotations);

        // set lookatpoint

        D3DXVec3Normalize(&lookAtPoint, &newDir);
        lookAtPoint.x += viewerPos.x;
        lookAtPoint.y += viewerPos.y;
        lookAtPoint.z += viewerPos.z;

        g_Camera.SetViewParams(&viewerPos, &lookAtPoint);

那么,有人知道如何将相机移动到第三人称视图吗?最好是定时的,这样在相机运动中有一个平滑的动作。(我希望我可以编辑这段代码,而不是加入另一个camera类)

好吧,我相信我可以在理论上帮助你从第一人称视角转变为第三人称视角。对不起,我不能给你实际的密码,但我是用电话打的。你必须把你的视角稍微放在球员身后,然后用注视点来注视球员。另外,确保根据第三人称的逻辑移动、x、y和z。希望有帮助。如果这样做没有任何帮助的话,我很抱歉,但是打电话对我来说有点困难,我不能很好地解释它。

这个问题应该发布在中。啊,我从来都不知道这个网站的存在-谢谢!