關與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. 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章