我没有看到我应该添加的内容,它会在第30行给出错误(其中' {'为createViewMatrix是)。我希望有人知道这里发生了什么。 老实说,我认为这不是我的代码的问题。
package toolbox;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;
import entities.Camera;
public class Maths
{
public static Matrix4f createTransformationMatrix(Vector3f translation, float rx, float ry, float rz, float scale)
{
Matrix4f matrix = new Matrix4f();
matrix.setIdentity();
// setting position
Matrix4f.translate(translation, matrix, matrix);
// settings rotations
Matrix4f.rotate((float) Math.toRadians(rx), new Vector3f(1, 0, 0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(ry), new Vector3f(0, 1, 0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(rz), new Vector3f(0, 0, 1), matrix, matrix);
// setting scale
Matrix4f.scale(new Vector3f(scale, scale, scale), matrix, matrix);
return matrix;
}
public static Matrix4f createViewMatrix(Camera camera)
{
Matrix4f viewMatrix = new Matrix4f();
viewMatrix.setIdentity();
// setting rotations
Matrix4f.rotate((float) Math.toRadians(camera.getPitch()), new Vector3f(1, 0, 0), viewMatrix, viewMatrix);
Matrix4f.rotate((float) Math.toRadians(camera.getYaw()), new Vector3f(0, 1, 0), viewMatrix, viewMatrix);
Matrix4f.rotate((float) Math.toRadians(camera.getRoll()), new Vector3f(0, 0, 1), viewMatrix, viewMatrix);
// setting position
Vector3f cameraPos = camera.getPosition();
Vector3f negativeCameraPos = new Vector3f(-cameraPos.x, -cameraPos.y, -cameraPos.z);
Matrix4f.translate(negativeCameraPos, viewMatrix, viewMatrix);
return viewMatrix;
}
}