Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. bool CPlayerInfo::Look_UpDown(const float deltaTime, const bool direction, const float speedMultiplier)
  2. {
  3. if (speedMultiplier == 0.0f)
  4. return false;
  5.  
  6. Vector3 viewUV = (target - position).Normalized();
  7. Vector3 rightUV;
  8. if (direction == false)
  9. {
  10. float pitch = (float)(-m_dSpeed * speedMultiplier * (float)deltaTime);
  11. rightUV = viewUV.Cross(up);
  12. rightUV.y = 0;
  13. rightUV.Normalize();
  14. up = rightUV.Cross(viewUV).Normalized();
  15. Mtx44 rotation;
  16. rotation.SetToRotation(pitch, rightUV.x, rightUV.y, rightUV.z);
  17. viewUV = rotation * viewUV;
  18. target = position + viewUV;
  19.  
  20. return true;
  21. }
  22. else
  23. {
  24. float pitch = (float)(m_dSpeed * speedMultiplier * (float)deltaTime);
  25. rightUV = viewUV.Cross(up);
  26. rightUV.y = 0;
  27. rightUV.Normalize();
  28. up = rightUV.Cross(viewUV).Normalized();
  29. Mtx44 rotation;
  30. rotation.SetToRotation(pitch, rightUV.x, rightUV.y, rightUV.z);
  31. viewUV = rotation * viewUV;
  32. target = position + viewUV;
  33.  
  34. return true;
  35. }
  36.  
  37. }
  38. // Detect and process look left / right on the controller
  39. bool CPlayerInfo::Look_LeftRight(const float deltaTime, const bool direction, const float speedMultiplier)
  40. {
  41. if (speedMultiplier == 0.0f)
  42. return false;
  43.  
  44. Vector3 viewUV = (target - position).Normalized();
  45. Vector3 rightUV;
  46.  
  47. if (direction == false)
  48. {
  49. float yaw = (float)-m_dSpeed * speedMultiplier * (float)deltaTime;
  50. Mtx44 rotation;
  51. rotation.SetToRotation(yaw, 0, 1, 0);
  52. viewUV = rotation * viewUV;
  53. target = position + viewUV;
  54. rightUV = viewUV.Cross(up);
  55. rightUV.y = 0;
  56. rightUV.Normalize();
  57. up = rightUV.Cross(viewUV).Normalized();
  58.  
  59. return true;
  60. }
  61. else
  62. {
  63. float yaw = (float)m_dSpeed * speedMultiplier * (float)deltaTime;
  64. Mtx44 rotation;
  65. rotation.SetToRotation(yaw, 0, 1, 0);
  66. viewUV = rotation * viewUV;
  67. target = position + viewUV;
  68. rightUV = viewUV.Cross(up);
  69. rightUV.y = 0;
  70. rightUV.Normalize();
  71. up = rightUV.Cross(viewUV).Normalized();
  72.  
  73. return true;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement