Problem where the angle given in the rotation function was not converted to a radian
This commit is contained in:
parent
2570553b93
commit
5f4b2aa56e
@ -60,7 +60,7 @@ public class Engine {
|
||||
|
||||
glfwSetFramebufferSizeCallback(window, resizeWindow);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
System.out.println("OpenGL: " + glGetString(GL_VERSION));
|
||||
|
||||
this.scene = new Scene("shaders/vert.vert", "shaders/frag.frag", Primitive.rectangle, Primitive.rectangle_indices, Primitive.rectangle_color, Primitive.rectangle_texture);
|
||||
|
@ -4,6 +4,7 @@ import engine.graphics.Shader;
|
||||
import engine.graphics.Texture;
|
||||
import engine.graphics.VertexArray;
|
||||
import engine.math.Matrix4f;
|
||||
import engine.math.Vector3f;
|
||||
|
||||
public class Scene {
|
||||
|
||||
@ -39,12 +40,14 @@ public class Scene {
|
||||
this.vertexArray = new VertexArray(this.vertices, this.indices, this.color, this.texture);
|
||||
shader.setUniform1i("texture1", 0);
|
||||
shader.setUniform1i("texture2", 1);
|
||||
this.transform = Matrix4f.rotateZ(3.14f/2.0f);
|
||||
this.transform = Matrix4f.translate(new Vector3f(-0.1f, 0.2f, 0.0f));
|
||||
this.transform = this.transform.multiply(Matrix4f.rotateZ(90.0f));
|
||||
shader.setUniformMat4f("transform", this.transform);
|
||||
}
|
||||
|
||||
public void render(){
|
||||
// this.transform = this.transform.multiply(Matrix4f.rotateZ(0.001f));
|
||||
this.transform = this.transform.multiply(Matrix4f.rotateZ(1.0f));
|
||||
this.transform = this.transform.multiply(Matrix4f.translate(new Vector3f(-0.001f, 0.0f, 0.0f)));
|
||||
shader.setUniformMat4f("transform", this.transform);
|
||||
this.shader.enable();
|
||||
this.texture_map.bind();
|
||||
|
@ -51,8 +51,8 @@ public class Matrix4f {
|
||||
public static Matrix4f rotateX(float angle){
|
||||
Matrix4f result = identity();
|
||||
float r = (float) Math.toRadians(angle);
|
||||
float cos = (float) Math.cos(angle);
|
||||
float sin = (float) Math.sin(angle);
|
||||
float cos = (float) Math.cos(r);
|
||||
float sin = (float) Math.sin(r);
|
||||
|
||||
result.elements[1 + 1 * 4] = cos;
|
||||
result.elements[2 + 1 * 4] = -sin;
|
||||
@ -66,8 +66,8 @@ public class Matrix4f {
|
||||
public static Matrix4f rotateY(float angle){
|
||||
Matrix4f result = identity();
|
||||
float r = (float) Math.toRadians(angle);
|
||||
float cos = (float) Math.cos(angle);
|
||||
float sin = (float) Math.sin(angle);
|
||||
float cos = (float) Math.cos(r);
|
||||
float sin = (float) Math.sin(r);
|
||||
|
||||
result.elements[0 + 0 * 4] = cos;
|
||||
result.elements[2 + 0 * 4] = sin;
|
||||
@ -81,8 +81,8 @@ public class Matrix4f {
|
||||
public static Matrix4f rotateZ(float angle){
|
||||
Matrix4f result = identity();
|
||||
float r = (float) Math.toRadians(angle);
|
||||
float cos = (float) Math.cos(angle);
|
||||
float sin = (float) Math.sin(angle);
|
||||
float cos = (float) Math.cos(r);
|
||||
float sin = (float) Math.sin(r);
|
||||
|
||||
result.elements[0 + 0 * 4] = cos;
|
||||
result.elements[1 + 0 * 4] = -sin;
|
||||
|
Loading…
x
Reference in New Issue
Block a user