问题描述
我想沿 Y 轴旋转我的精灵(将旋转应用于变换矩阵)以翻转精灵的方向。
但不知何故它似乎也影响了我的输入系统...
按向右变成向左......似乎精灵不再在实体真实位置渲染......“真实位置”由输入系统控制,然后是相机,但精灵相反,如如果输入被反转。 (输入改变与按下的键相对应的速度,并且每次更新时变换组件由该向量平移)
这是我用来获取矩阵的代码:
public Matrix4f getTransformationMatrix() {
Matrix4f matrix = new Matrix4f();
matrix.scale(scale);
matrix.rotateX((float) Math.toRadians(rotation.getX()));
matrix.rotateY((float) Math.toRadians(rotation.getY()));
matrix.rotateZ((float) Math.toRadians(rotation.getZ()));
matrix.translate(position);
return matrix;
}
public Matrix4f getViewMatrix() {
Matrix4f matrix = new Matrix4f();
matrix.rotateZ((float) Math.toRadians(rotation.getZ()));
matrix.translate(Vector3f.scale(position,-1));
return matrix;
}
我已经检查并重新检查了我的旋转矩阵,但对这里的信心感到害怕:
X = new Matrix4f(new float[][] { {1,0},{0,cos,-sin,sin,1} })
Y = new Matrix4f(new float[][] { {cos,1,{-sin,1} })
Z = new Matrix4f(new float[][] { {cos,1} })
我在着色器中按照 projection_matrix * view_matrix * transformation_matrix * vec4(attribute_position,1.0)
的顺序使用 mvp 矩阵。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)