本文整理汇总了C++中Matrix4f::MakeCameraRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4f::MakeCameraRotation方法的具体用法?C++ Matrix4f::MakeCameraRotation怎么用?C++ Matrix4f::MakeCameraRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4f
的用法示例。
在下文中一共展示了Matrix4f::MakeCameraRotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateMatrix
Matrix4f Camera::GenerateMatrix(bool &outSucceed){
if(m_onBorder == true){
if(m_lastMouseX < m_borderDistance){
m_horizonAngle -= 5 * m_rotateScale;
}
else if(m_lastMouseX > WINDOW_WIDTH - m_borderDistance){
m_horizonAngle += 5 * m_rotateScale;
}
if(m_lastMouseY < m_borderDistance){
m_verticalAngle -= 5 * m_rotateScale;
}
else if(m_lastMouseY > WINDOW_HEIGHT - m_borderDistance){
m_verticalAngle += 5 * m_rotateScale;
}
m_dirty = true;
}
Matrix4f matrix;
if(!m_dirty){
outSucceed = false;
return matrix;
}
Vector3f m_initRight = m_initUp.Cross(m_initTarget);
Quaternion vAxis;
vAxis.MakeRotationQuaternion(m_initUp, m_horizonAngle);
(vAxis * Quaternion(m_initTarget) * vAxis.Inverse()).GetVector3(m_target);
m_target.Normalize();
m_initRight = m_initUp.Cross(m_target);
Quaternion hAxis;
hAxis.MakeRotationQuaternion(m_initRight, m_verticalAngle);
(hAxis * Quaternion(m_target) * hAxis.Inverse()).GetVector3(m_target);
m_target.Normalize();
m_up = m_target.Cross(m_initRight);
m_right = m_up.Cross(m_target);
Matrix4f matrixCameraRotate;
matrixCameraRotate.MakeCameraRotation(m_right, m_up, m_target);
Matrix4f matrixCameraTranslation;
matrixCameraTranslation.MakeTransformationMatrix4f(m_position * -1);
matrix = matrixCameraRotate * matrixCameraTranslation;
m_dirty = false;
outSucceed = true;
return matrix;
}