XNA Rotate Camera Around It's CreateLookAt “Target”

后端 未结 1 1242
名媛妹妹
名媛妹妹 2021-01-25 09:12

How to rotate camera around it\'s CreateLookAt() \"Target\" Vector3 position as pivot point, so the camera will \"rotate around\" that pivot point and always \"facing\" to that

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-25 09:40

    assuming you have your rotation axis and angle already:

    cameraPosition = Vector3.Transform(cameraPosition - cameraTarget, Matrix.CreateFromAxisAngle(axis, angle)) + cameraTarget;
    view = CreateLookAt(cameraPosition, cameraTarget, cameraUp);
    

    This rotates the camera's position around the target and resets the view matrix appropriately.

    0 讨论(0)
提交回复
热议问题