三维场景的渲染与交互技术详解
1. 变换矩阵操作
在进行三维场景绘制时,变换矩阵的操作至关重要。以下是两种不同的实现方式:
1.1 手动构建矩阵
gl<<Push Matrix;
xt = identity(4); // translate this one left by .75
xt[1,4]=-.75;
xr = Identity(4); // rotate this one, cos needs radians, not degrees
xr[2,2]=cos(3.14159*a/180);
xr[2,3]=-sin(3.14159*a/180);
xr[3,2]=sin(3.14159*a/180);
xr[3,3]=cos(3.14159*a/180);
yr = Identity(4);
yr[1,1]=cos(3.14159*a/180);
yr[1,3]=sin(3.14159*a/180);
yr[3,1]=-sin(3.14159*a/180);
yr[3,3]=cos(3.14159*a/180);
zr = identity(4);
zr[1,1]=cos(3.14159*a/180);
zr[1,2]=-sin(3.14159*a/180);
zr[2,1]=sin(3.14159*a/180);
zr[2,2]=cos(3.14159*a/180);
gl<<Mult Matrix(xt*xr*yr*zr); // order of multiplication matters with matrices
gl<<arcball(dl,1);
gl<&
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



