Commits

Roi Atalla  committed 03dca49

Fixed biggest glitch: a typo in Quaternion.mult(Quaternion). The only glitch left is that all controls are opposite those by rosickteam.

  • Participants
  • Parent commits f147fa7

Comments (0)

Files changed (3)

File src/main/java/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example2/Example8_2.java

 	private void offsetOrientation(Vector3 axis, float angle) {
 		angle = angle * (float)Math.PI / 180;
 		
-		axis.normalize();
-		System.out.println(axis.x() + " " + axis.y() + " " + axis.z());
-		axis.mul((float)Math.sin(angle/2));
+		axis.normalize().mul((float)Math.sin(angle/2));
 		
 		Quaternion offset = new Quaternion(axis.x(), axis.y(), axis.z(), (float)Math.cos(angle/2));
 		
 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 		
 		MatrixStack stack = new MatrixStack();
-		stack.getTop().translate(0, 0, -200).mult(orientation.getMatrix());
+		stack.getTop().translate(0, 0, -200).mult(orientation.getMatrix()).scale(3, 3, 3).rotateDeg(-90, 1, 0, 0);
 		
 		program.begin();
-		stack.getTop().scale(3, 3, 3).rotateDeg(-90, 1, 0, 0);
-		
 		glUniform4f(baseColorUniform, 1, 1, 1, 1);
 		glUniformMatrix4(modelToClipMatrixUniform, false, stack.getTop().getBuffer());
-		
 		ship.render("tint");
-		
 		program.end();
 	}
 }

File src/main/java/com/ra4king/opengl/test/Test.java

 		super.resized();
 		
 		program.begin();
-		glUniformMatrix4(perspectiveMatrixUniform, false, perspectiveMatrix.clearToPerspective(90*(float)Math.PI/180, getWidth(), getHeight(), 1, 1000).getBuffer());
+		glUniformMatrix4(perspectiveMatrixUniform, false, perspectiveMatrix.clearToPerspectiveDeg(90, getWidth(), getHeight(), 1, 1000).getBuffer());
 		program.end();
 	}
 	

File src/main/java/com/ra4king/opengl/util/math/Quaternion.java

 		float xx = w*q.x + x*q.w + y*q.z - z*q.y;
 		float yy = w*q.y + y*q.w + z*q.x - x*q.z;
 		float zz = w*q.z + z*q.w + x*q.y - y*q.x;
-		float ww = w*q.w - x*q.x + y*q.y - z*q.z;
+		float ww = w*q.w - x*q.x - y*q.y - z*q.z;
 		
 		x = xx;
 		y = yy;