【问题标题】:Does glMatrix scale transformation require an specific order under WebGL?glMatrix 比例转换是否需要 WebGL 下的特定顺序?
【发布时间】:2012-06-29 17:24:52
【问题描述】:

我正在尝试使用 glMatrix for WebGL 进行比例转换。

当我使用以下顺序时,比例转换效果很好:

mat4.identity(mvMatrix);
mat4.translate(mvMatrix, [1, 1, 1]);
mat4.rotate(mvMatrix, degToRad(zAngle), [0, 0, 1]);
mat4.scale(mvMatrix, [2, 2, 2]);

但先进行缩放变换时,对象并没有重新缩放:

mat4.identity(mvMatrix);
mat4.scale(mvMatrix, [2, 2, 2]);
mat4.translate(mvMatrix, [1, 1, 1]);
mat4.rotate(mvMatrix, degToRad(zAngle), [0, 0, 1]);

缩放必须始终作为最后一个转换命令发生吗?

谢谢, 埃弗顿

【问题讨论】:

    标签: 3d webgl


    【解决方案1】:

    请参阅this 答案以了解 OpenGL 中的“堆叠”转换。当然,矩阵乘法不是可交换的,因此您会根据顺序得到不同的结果。

    【讨论】:

      猜你喜欢
      • 2016-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多