本文整理汇总了C++中Matrix4d::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4d::set方法的具体用法?C++ Matrix4d::set怎么用?C++ Matrix4d::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4d
的用法示例。
在下文中一共展示了Matrix4d::set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setView
void ViewportUtil::setView() {
// passage souris en normalisé : xn=1/wv*xs-xv, yn=1/yw*ys-yv
Matrix4d mproj;
Matrix4d mmodelview;
Matrix4d localNormalized;
double viewport[4]; // viewport : [0]=x_min,[1]=y_min, [2]=width, [3]=height
double mat[16];
glGetDoublev(GL_VIEWPORT, viewport);
glGetDoublev(GL_PROJECTION_MATRIX,mat);
mproj.set(mat);
glGetDoublev(GL_MODELVIEW_MATRIX, mat);
eyeLocal.set(mat);
mmodelview.set(mat);
normalizedLocal.mul(mproj,mmodelview);
localNormalized.invert(normalizedLocal);
normalizedWindow.setRow(0,2.0/viewport[2],0,0,-1-viewport[0]);
normalizedWindow.setRow(1,0,-2.0/viewport[3],0,1+viewport[1]);
normalizedWindow.setRow(2,0,0,1,0);
normalizedWindow.setRow(3,0,0,0,1);
// normalizedWindow.print("normalizedWindow");
windowNormalized.invert(normalizedWindow);
// windowNormalized.print("windowNormalized");
localWindow.mul(localNormalized,normalizedWindow);
// localWindow.print("localWindow=");
}
示例2: cameraLocal
Point3d ViewportUtil::cameraLocal() {
float mat[16];
glGetFloatv(GL_MODELVIEW_MATRIX,mat);
Matrix4d m;
m.set(mat);
m.invert();
Point3d p(0,0,0);
m.transform(&p);
return p;
}
示例3: computeMatrix
void Camera::computeMatrix(){
Vector3d z = e - d;
z.normalize();
Vector3d x = up.cross(z);
x.normalize();
Vector3d y = z.cross(x);
y.normalize();
Matrix4d r;
r.identity();
r.set(0, 0, x[0]);
r.set(1, 0, x[1]);
r.set(2, 0, x[2]);
r.set(0, 1, y[0]);
r.set(1, 1, y[1]);
r.set(2, 1, y[2]);
r.set(0, 2, z[0]);
r.set(1, 2, z[1]);
r.set(2, 2, z[2]);
Matrix4d t;
t.identity();
t.makeTranslate(-e[0], -e[1], -e[2]);
m = r * t;
}
示例4: setCamera
void Camera::setCamera(double eyeX, double eyeY, double eyeZ,
double centerX, double centerY, double centerZ,
double upX, double upY, double upZ){
double f[3];
f[0] = centerX - eyeX;
f[1] = centerY - eyeY;
f[2] = centerZ - eyeZ;
double m_f = sqrt(f[0] * f[0] + f[1] * f[1] + f[2] * f[2]);
f[0] /= m_f;
f[1] /= m_f;
f[2] /= m_f;
double up[3];
up[0] = upX;
up[1] = upY;
up[2] = upZ;
double m_u = sqrt(up[0] * up[0] + up[1] * up[1] + up[2] * up[2]);
up[0] /= m_u;
up[1] /= m_u;
up[2] /= m_u;
double s[3];
s[0] = f[1] * up[2] - f[2] * up[1];
s[1] = f[2] * up[0] - f[0] * up[2];
s[2] = f[0] * up[1] - f[1] * up[0];
double u[3];
u[0] = s[1] * f[2] - s[2] * f[1];
u[1] = s[2] * f[0] - s[0] * f[2];
u[2] = s[0] * f[1] - s[1] * f[0];
Matrix4d r; // inverse rotation
r.identity();
r.set(0, 0, s[0]);
r.set(1, 0, s[1]);
r.set(2, 0, s[2]);
r.set(0, 1, u[0]);
r.set(1, 1, u[1]);
r.set(2, 1, u[2]);
r.set(0, 2, -f[0]);
r.set(1, 2, -f[1]);
r.set(2, 2, -f[2]);
Matrix4d t; // inverse translation
t.identity();
t.makeTranslate(-eyeX, -eyeY, -eyeZ);
m = r * t; // inverse camera
}