//my triangle
let vertdata =
[| new Vector3(-1.0f, -1.0f,0.0f)
new Vector3(1.0f, -1.0f,0.0f)
new Vector3(0.0f, 1.0f,0.0f) |]
//VertexShader
..
uniform mat4 mview;
...
gl_Position = mview * vec4(vPosition, 1.0);
..
使用Identity矩阵渲染它看起来像
mview = Matrix4.Identity
正如所料。
mview = Matrix4.CreateTranslation(Vector3(0.0f,1.0f,0.0f))
在y中翻译为1。但是,如果我将它旋转90°,它会以某种方式转换为x方向。
mview = Matrix4.CreateTranslation(Vector3(0.0f,1.0f,0.0f))
* Matrix4.CreateRotationZ(toRad(90.0f))
知道为什么这样做吗?如果我在脑子里做数学应该是。
Matrix4.CreateRotationZ(toRad(90.0f))
* Vector3(0.0f, 1.0f,0.0f) = Vector3(-1.0f, 0.0f,0.0f)
Matrix4.CreateTranslation(Vector3(0.0f,1.0f,0.0f))
* Vector3(-1.0f, 0.0f,0.0f) = Vector3(-1.0f, 1.0f,0.0f)
//but it seems to be Vector3(-2.0f, 0.0f,0.0f)
答案 0 :(得分:3)
您需要颠倒组合矩阵的顺序。