Roi Atalla avatar Roi Atalla committed 6c2d6b7

Oops. Forgot to convert my radians angles to degrees. I added alternate methods that accept degrees instead of radians in Matrix4.

Comments (0)

Files changed (2)

src/main/java/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example1/Example8_1.java

 	
 	@Override
 	public void update(long deltaTime) {
-		float speed = 9 * deltaTime / (float)1e9;
+		float speed = 90 * deltaTime / (float)1e9;
 		
 		if(Keyboard.isKeyDown(Keyboard.KEY_W))
 			angles.x += speed;
 		
 		stack.getTop().translate(0, 0, -200);
 		
-		stack.getTop().rotate(angles.x, 1, 0, 0);
+		stack.getTop().rotateDeg(angles.x, 1, 0, 0);
 		drawGimbal(stack, GimbalAxis.GIMBAL_X_AXIS, 0.4f, 0.4f, 1, 1);
-		stack.getTop().rotate(angles.y, 0, 1, 0);
+		stack.getTop().rotateDeg(angles.y, 0, 1, 0);
 		drawGimbal(stack, GimbalAxis.GIMBAL_Y_AXIS, 0, 1, 0, 1);
-		stack.getTop().rotate(angles.z, 0, 0, 1);
+		stack.getTop().rotateDeg(angles.z, 0, 0, 1);
 		drawGimbal(stack, GimbalAxis.GIMBAL_Z_AXIS, 1, 0.3f, 0.3f, 1);
 		
 		program.begin();
-		stack.getTop().scale(3, 3, 3).rotate(-90*(float)Math.PI/180, 1, 0, 0);
+		stack.getTop().scale(3, 3, 3).rotateDeg(-90, 1, 0, 0);
 		glUniform4f(baseColorUniform, 1, 1, 1, 1);
 		glUniformMatrix4(modelToCameraMatrixUniform, false, stack.getTop().getBuffer());
 		ship.render("tint");
 			case GIMBAL_X_AXIS:
 				break;
 			case GIMBAL_Y_AXIS:
-				stack.getTop().rotate(90, 1, 0, 0);
-				stack.getTop().rotate(90, 0, 0, 1);
+				stack.getTop().rotateDeg(90, 0, 0, 1);
+				stack.getTop().rotateDeg(90, 1, 0, 0);
 				break;
 			case GIMBAL_Z_AXIS:
-				stack.getTop().rotate(90, 1, 0, 0);
-				stack.getTop().rotate(90, 0, 1, 0);
+				stack.getTop().rotateDeg(90, 0, 1, 0);
+				stack.getTop().rotateDeg(90, 1, 0, 0);
 				break;
 		}
 		

src/main/java/com/ra4king/opengl/util/math/Matrix4.java

 		return clear().put(0,fov/(width/height)).put(5,fov).put(10,(far+near)/(near-far)).put(14,(2*far*near)/(near-far)).put(11,-1);
 	}
 	
+	public Matrix4 clearToPerspectiveDeg(float fov, float width, float height, float near, float far) {
+		return clearToPerspective((float)Math.toRadians(fov), width, height, near, far);
+	}
+	
 	public float get(int index) {
 		return matrix.get(index);
 	}
 		return rotate(angle, vec.x(), vec.y(), vec.z());
 	}
 	
+	public Matrix4 rotateDeg(float angle, float x, float y, float z) {
+		return rotate((float)Math.toRadians(angle), x, y, z);
+	}
+	
+	public Matrix4 rotateDeg(float angle, Vector3 vec) {
+		return rotate((float)Math.toRadians(angle),vec);
+	}
+	
 	private final static FloatBuffer direct = BufferUtils.createFloatBuffer(16);
 	
 	public FloatBuffer getBuffer() {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.