关与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. 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值