33 lines
1.1 KiB
Java
33 lines
1.1 KiB
Java
package toolbox;
|
|
|
|
import org.atriaSoft.etk.math.Matrix4f;
|
|
import org.atriaSoft.etk.math.Vector3f;
|
|
|
|
import entities.Camera;
|
|
|
|
public class Maths {
|
|
|
|
public static Matrix4f createTransformationMatrix(Vector3f translation, Vector3f rotation, float scale) {
|
|
// Need to rework all of this this is really not optimum ...
|
|
Matrix4f matrix = new Matrix4f();
|
|
matrix.setIdentity();
|
|
matrix.translate(translation);
|
|
matrix.rotate(new Vector3f(1,0,0), rotation.x);
|
|
matrix.rotate(new Vector3f(0,1,0), rotation.y);
|
|
matrix.rotate(new Vector3f(0,0,1), rotation.z);
|
|
matrix.scale(scale);
|
|
return matrix;
|
|
}
|
|
public static Matrix4f createViewMatrix(Camera camera) {
|
|
// Need to rework all of this this is really not optimum ...
|
|
Matrix4f matrix = new Matrix4f();
|
|
matrix.setIdentity();
|
|
matrix.rotate(new Vector3f(1,0,0), camera.getPitch());
|
|
matrix.rotate(new Vector3f(0,1,0), camera.getYaw());
|
|
//matrix.rotate(new Vector3f(0,0,1), camera.getRoll());
|
|
Vector3f camarePos = camera.getPosition();
|
|
matrix.translate(new Vector3f(-camarePos.x,-camarePos.y,-camarePos.z));
|
|
return matrix;
|
|
}
|
|
}
|