我有一个对象,它被转换了(沿着 Y 轴旋转 45 度)。
目标是在 x 和 y 轴上移动(平移)该对象,并保持其旋转效果不变。
很难解释,所以我画了一张图:
我知道 OpenGL 中相机的概念,我知道我实际上不能移动相机,但事实上一切都是围绕相机移动的。有人知道如何实现吗?
我的代码:
我知道 OpenGL 中相机的概念,我知道我实际上不能移动相机,但事实上一切都是围绕相机移动的。有人知道如何实现吗?
我的代码:
//set mvp
matrixProj = new PerspectiveProjectionMatrix(fovy, aspect, near, far);
matrixView = new ModelMatrix();
matrixView.LookAtTarget(new Vertex3f(0, 0, 2), new Vertex3f(0, 0, 0), new Vertex3f(0, 1, 0));
matrixModel = new ModelMatrix();
matrixModel.SetIdentity();
matrixModel.RotateY(45);
matrixModel.Translate(-2, -2, 0);
Matrix4x4 mvp = matrixProj * matrixView * matrixModel;
Gl.UniformMatrix4(Gl.GetUniformLocation(shaderProgram, "MVP"), 1, false, mvp.ToArray());
//draw quad
Gl.Begin(PrimitiveType.Quads);
Gl.Vertex3(-2, 2, 0);
Gl.Vertex3(2, 2, 0);
Gl.Vertex3(2, -2, 0);
Gl.Vertex3(-2, -2, 0);
Gl.End();