DirectX Camera to follow based on 3D Model's world Matrix?

后端 未结 2 1180
时光说笑
时光说笑 2021-01-26 10:06

I have multiple objects moving about in a 3D space and am looking for ways to, on button press, have the camera snap and follow the object chosen.

Is there a way to make

2条回答
  •  离开以前
    2021-01-26 10:37

    I would approach this by setting the camera's position to the same as the object to be followed. If your objects are held in a vector this will make it easier to change what object to follow by simply incrementing your index in the vector to the next object. After applying the object's position to the camera's world position you should call a MatrixTranslation by the offset you want for your camera. These would be the values to play around with to get a good effect. The camera's lookat element should be equal to the object's position so that the camera is looking directly at it. And if you don't want the camera to look directly at the object you can translate that as well. Finally the up vector on the camera should point up of course.

    Hope this helps.

提交回复
热议问题