Roi Atalla avatar 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.

Comments (0)

Files changed (3)

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();
 	}
 }

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();
 	}
 	

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;
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.