Added coordinate tracking in ObjectGl

This commit is contained in:
Antoine 2021-06-02 20:07:34 +02:00
parent b5319de940
commit 7b349c573b
2 changed files with 22 additions and 1 deletions

View File

@ -197,7 +197,7 @@ public class Engine {
/*
Engine Init
*/
Engine engine = new Engine(800, 600, 3.0f / 4.0f);
Engine engine = new Engine(1280, 720, 3.0f / 4.0f);
int speed = 10; //vitesse d<EFBFBD>placement Object
engine.init();

View File

@ -27,6 +27,12 @@ public class ObjectGl {
public static Matrix4f projection;
public static Matrix4f view;
/*
* xPos and yPos will stop to be relevant if you use rotate function
*/
private float xPos;
private float yPos;
private float zPos;
private float width; // To be used in setTextureWrap
private float height;
@ -61,6 +67,8 @@ public class ObjectGl {
this.texture = new Texture(tex, 0);
}
this.xPos = 0.0f;
this.yPos = 0.0f;
this.zPos = z;
this.height = h;
this.width = w;
@ -92,6 +100,9 @@ public class ObjectGl {
public void resetTransform(){
this.transform = Matrix4f.identity();
this.scalingFactor = 1;
this.xPos = 0.0f;
this.yPos = 0.0f;
this.zPos = 0.0f;
}
/**
@ -101,6 +112,8 @@ public class ObjectGl {
public void translate(Vector3f vec){
vec.divXY(this.scalingFactor);
this.transform = this.transform.multiply(Matrix4f.translate(vec));
this.xPos += vec.x;
this.yPos += vec.y;
this.zPos += vec.z;
}
@ -210,6 +223,14 @@ public class ObjectGl {
this.vertexArray.swapTextureBufferObject(texture);
}
public float getXPos(){
return xPos;
}
public float getYPos(){
return yPos;
}
public float getZPos(){
return zPos;
}