Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool CPlayerInfo::Look_UpDown(const float deltaTime, const bool direction, const float speedMultiplier)
- {
- if (speedMultiplier == 0.0f)
- return false;
- Vector3 viewUV = (target - position).Normalized();
- Vector3 rightUV;
- if (direction == false)
- {
- float pitch = (float)(-m_dSpeed * speedMultiplier * (float)deltaTime);
- rightUV = viewUV.Cross(up);
- rightUV.y = 0;
- rightUV.Normalize();
- up = rightUV.Cross(viewUV).Normalized();
- Mtx44 rotation;
- rotation.SetToRotation(pitch, rightUV.x, rightUV.y, rightUV.z);
- viewUV = rotation * viewUV;
- target = position + viewUV;
- return true;
- }
- else
- {
- float pitch = (float)(m_dSpeed * speedMultiplier * (float)deltaTime);
- rightUV = viewUV.Cross(up);
- rightUV.y = 0;
- rightUV.Normalize();
- up = rightUV.Cross(viewUV).Normalized();
- Mtx44 rotation;
- rotation.SetToRotation(pitch, rightUV.x, rightUV.y, rightUV.z);
- viewUV = rotation * viewUV;
- target = position + viewUV;
- return true;
- }
- }
- // Detect and process look left / right on the controller
- bool CPlayerInfo::Look_LeftRight(const float deltaTime, const bool direction, const float speedMultiplier)
- {
- if (speedMultiplier == 0.0f)
- return false;
- Vector3 viewUV = (target - position).Normalized();
- Vector3 rightUV;
- if (direction == false)
- {
- float yaw = (float)-m_dSpeed * speedMultiplier * (float)deltaTime;
- Mtx44 rotation;
- rotation.SetToRotation(yaw, 0, 1, 0);
- viewUV = rotation * viewUV;
- target = position + viewUV;
- rightUV = viewUV.Cross(up);
- rightUV.y = 0;
- rightUV.Normalize();
- up = rightUV.Cross(viewUV).Normalized();
- return true;
- }
- else
- {
- float yaw = (float)m_dSpeed * speedMultiplier * (float)deltaTime;
- Mtx44 rotation;
- rotation.SetToRotation(yaw, 0, 1, 0);
- viewUV = rotation * viewUV;
- target = position + viewUV;
- rightUV = viewUV.Cross(up);
- rightUV.y = 0;
- rightUV.Normalize();
- up = rightUV.Cross(viewUV).Normalized();
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement