Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1.     void Camera::Rotate(float xR, float yR, float zR)
  2.     {
  3.         DirectX::XMVECTOR quad = XMQuaternionRotationRollPitchYaw(xR, yR, zR);
  4.  
  5.         DirectX::XMStoreFloat4(&mQuaternion, quad);
  6.  
  7.         CalculateDirections();
  8.     }
  9.  
  10.     void Camera::CalculateDirections()
  11.     {
  12.         DirectX::XMVECTOR quat = DirectX::XMLoadFloat4(&mQuaternion);
  13.  
  14.         DirectX::XMFLOAT3 inputEdit = DirectX::XMFLOAT3(1, 0, 0);
  15.         DirectX::XMVECTOR input = DirectX::XMLoadFloat3(&inputEdit);
  16.         input = DirectX::XMVector3Rotate(input, quat);
  17.         DirectX::XMStoreFloat3(&inputEdit, input);
  18.         mRight = inputEdit;
  19.  
  20.         inputEdit = DirectX::XMFLOAT3(0, 1, 0);
  21.         input = DirectX::XMLoadFloat3(&inputEdit);
  22.         input = DirectX::XMVector3Rotate(input, quat);
  23.         DirectX::XMStoreFloat3(&inputEdit, input);
  24.         mUp = inputEdit;
  25.  
  26.         inputEdit = DirectX::XMFLOAT3(0, 0, 1);
  27.         input = DirectX::XMLoadFloat3(&inputEdit);
  28.         input = DirectX::XMVector3Rotate(input, quat);
  29.         DirectX::XMStoreFloat3(&inputEdit, input);
  30.         mForward = inputEdit;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement