Beispiel #1
0
 /**
  * Create a Transformation Matrix 3D
  *
  * @param translation Position
  * @param rx Rotation X
  * @param ry Rotation Y
  * @param rz Rotation Z
  * @param scale Scale
  * @return Transformation Matrix 3D
  */
 public static Matrix4f createTransformationMatrix(
     Vector3f translation, float rx, float ry, float rz, float scale) {
   Matrix4f matrix = new Matrix4f();
   matrix.setIdentity();
   Matrix4f.translate(translation, matrix, matrix);
   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);
   Matrix4f.scale(new Vector3f(scale, scale, scale), matrix, matrix);
   return matrix;
 }
Beispiel #2
0
 /**
  * Create a View Matrix
  *
  * @param camera Camera
  * @return View Matrix
  */
 public static Matrix4f createViewMatrix(Camera camera) {
   Matrix4f viewMatrix = new Matrix4f();
   viewMatrix.setIdentity();
   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);
   Vector3f cameraPost = camera.getPosition();
   Vector3f negativeCameraPos = new Vector3f(-cameraPost.x, -cameraPost.y, -cameraPost.z);
   Matrix4f.translate(negativeCameraPos, viewMatrix, viewMatrix);
   return viewMatrix;
 }