关与opengl和d3d中的坐标系和变换

opengl中用的是右手坐标系,d3d中用的是左手坐标系。手的四指握向手心,大拇指指向的方向为z轴的方向。因此坐标变换时,opengl中是逆时针旋转,direct 3d中是顺时针旋转。(沿坐标轴向原点看去)
判断的方法是大拇指面向自己,四指握向手心。

d3d中变换坐标时右乘矩阵,因此复合变换时矩阵连乘的顺序是从左到右。
D3DXMatrixMultiply( &matWorld, &matRotation, &matTranslation ); //先旋转变换,后平移变换
m_pDevice->SetTransform( D3DTS_WORLD, &matWorld );


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixf(N); /* apply transformation N */
glMultMatrixf(M); /* apply transformation M */
glMultMatrixf(L); /* apply transformation L */
glBegin(GL_POINTS);
glVertex3f(v); /* draw transformed vertex v */
glEnd();

in opengl,With this code, the modelview matrix successively contains I, N, NM, and finally NML, where I
represents the identity matrix. The transformed vertex is NMLv. Thus, the vertex transformation is
N(M(Lv)) - that is, v is multiplied first by L, the resulting Lv is multiplied by M, and the resulting MLv
is multiplied by N. Notice that the transformations to vertex v effectively occur in the opposite order than
they were specified. (Actually, only a single multiplication of a vertex by the modelview matrix occurs;
in this example, the N, M, and L matrices are already multiplied into a single matrix before it's applied to v. 

你可能感兴趣的:(关与opengl和d3d中的坐标系和变换)