예제 #1
0
파일: Maths.java 프로젝트: elsantiF/Voxel
 /**
  * Create a Transformation Matrix 2D
  *
  * @param translation Position
  * @param scale Scale
  * @return Transformation Matrix 2D
  */
 public static Matrix4f createTransformationMatrix(Vector2f translation, Vector2f scale) {
   Matrix4f matrix = new Matrix4f();
   matrix.setIdentity();
   Matrix4f.translate(translation, matrix, matrix);
   Matrix4f.scale(new Vector3f(scale.x, scale.y, 1f), matrix, matrix);
   return matrix;
 }
예제 #2
0
파일: Maths.java 프로젝트: elsantiF/Voxel
 /**
  * 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;
 }
예제 #3
0
파일: Maths.java 프로젝트: elsantiF/Voxel
 /**
  * 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;
 }