Add Game Engine Main File
This commit is contained in:
parent
929fcb19f2
commit
569f2dfb00
39 changed files with 2503 additions and 29 deletions
107
src/globalgamejam/math/Vector3f.java
Normal file
107
src/globalgamejam/math/Vector3f.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
package globalgamejam.math;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
|
||||
*/
|
||||
public class Vector3f {
|
||||
|
||||
public float x,y,z;
|
||||
|
||||
public Vector3f(){
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
public Vector3f(float x,float y,float z){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Vector3f(Vector2f vec,float z){
|
||||
this(vec.x,vec.y,z);
|
||||
}
|
||||
|
||||
public Vector3f(Vector3f vec){
|
||||
this(vec.x,vec.y,vec.z);
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(float x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(float y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public float getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(float z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float length(){
|
||||
return Mathf.sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
public Vector3f lookAt(Vector3f d){
|
||||
Vector3f rot = new Vector3f();
|
||||
float x1 = d.x - x;
|
||||
float y1 = d.y - y;
|
||||
float z1 = d.z - z;
|
||||
|
||||
return rot;
|
||||
}
|
||||
|
||||
public Vector3f normalize(){
|
||||
float length = length();
|
||||
x /= length;
|
||||
y /= length;
|
||||
z /= length;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3f mul(float m){
|
||||
x *= m;
|
||||
y *= m;
|
||||
z *= m;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
StringJoiner st = new StringJoiner(",","vec3(",")");
|
||||
st.add("" + x);
|
||||
st.add("" + y);
|
||||
st.add("" + z);
|
||||
return st.toString();
|
||||
}
|
||||
|
||||
public Vector3f toRadians() {
|
||||
x = Mathf.toRadians(x);
|
||||
y = Mathf.toRadians(y);
|
||||
z = Mathf.toRadians(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3f toDegrees() {
|
||||
x = Mathf.toDegrees(x);
|
||||
y = Mathf.toDegrees(y);
|
||||
z = Mathf.toDegrees(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue