本文整理汇总了C++中Mat4f::createTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4f::createTranslation方法的具体用法?C++ Mat4f::createTranslation怎么用?C++ Mat4f::createTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4f
的用法示例。
在下文中一共展示了Mat4f::createTranslation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyViewingTransform
void Camera::applyViewingTransform() {
if( mDirtyTransform )
calculateViewingTransformParameters();
ModelerDrawState *mds = ModelerDrawState::Instance();
if(mds->m_rayFile)
{
fprintf( mds->m_rayFile, "camera {\n\tposition = (%f, %f, %f);\n\tlook_at = (%f, %f, %f);\n\taspectratio = 1\n\tfov = 30; }\n\n",
mPosition[0], mPosition[1], mPosition[2],
mLookAt[0], mLookAt[1], mLookAt[2]);
}
// Place the camera at mPosition, aim the camera at
// mLookAt, and twist the camera such that mUpVector is up
/*gluLookAt( mPosition[0], mPosition[1], mPosition[2],
mLookAt[0], mLookAt[1], mLookAt[2],
mUpVector[0], mUpVector[1], mUpVector[2]);*/
// You Will Have to implement this (gluLookAt() ) yourself!
// what fun that will be!
Vec3f n = mPosition - mLookAt;
Vec3f v = mUpVector - ((mUpVector * n) / (n * n)) * n;
Vec3f u = v ^ n;
u.normalize();
v.normalize();
n.normalize();
Mat4f mat;
mat[0][0] = u[0]; mat[0][1] = v[0]; mat[0][2] = n[0];
mat[1][0] = u[1]; mat[1][1] = v[1]; mat[1][2] = n[1];
mat[2][0] = u[2]; mat[2][1] = v[2]; mat[2][2] = n[2];
mat = mat.transpose();
mat = mat * mat.createTranslation(-mPosition[0], -mPosition[1], -mPosition[2]);
// Transpose the final matrix so that n is in column-major order to match OpenGL.
mat = mat.transpose();
glMultMatrixf(mat.n);
}