【发布时间】:2020-11-01 11:36:59
【问题描述】:
我正在尝试使用 LWJGL3 创建一个 3D 引擎,但一直遇到这个问题:
四边形应该在中间,因为我没有更改 x 坐标,但事实并非如此。 实际上,我尝试使用 LWJGL2 中的旧实用程序 jar 重做转换矩阵,并且四边形绕其轴旋转,而不是围绕中间的某种轨道。(顺便说一句,我使用的是最新版本的 JOML)
当我在谷歌上搜索问题时,我:
- 什么都听不懂。
- 我理解的东西不起作用(比如更新 JOML)
下面是生成变换矩阵的代码:
public static Matrix4f createTransformationMatrix(Entity entity) {
Matrix4f matrix = new Matrix4f()
.identity()
.translate(new Vector3f(entity.getX(), entity.getY(), entity.getZ()))
.rotateX((float)Math.toRadians(entity.getRotationX()))
.rotateY((float)Math.toRadians(entity.getRotationY()))
.rotateZ((float)Math.toRadians(entity.getRotationZ()))
.scale(entity.getScale());
return matrix;
}
这是来自顶点着色器的代码:
#version 450
in vec3 position;
out vec4 out_color;
uniform mat4 projection;
uniform mat4 transformation;
void main()
{
gl_Position = projection * transformation * vec4(position, 1.0);
out_color = vec4(position.y, position.x, -position.x, 0);
}
提前致谢!
【问题讨论】:
标签: matrix lwjgl transformation joml