Java Code Examples for org.andengine.opengl.util.GLState#rotateModelViewGLMatrixf()

The following examples show how to use org.andengine.opengl.util.GLState#rotateModelViewGLMatrixf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Entity.java    From tilt-game-android with MIT License 6 votes vote down vote up
protected void applyRotation(final GLState pGLState) {
	final float rotation = this.mRotation;

	if (rotation != 0) {
		final float localRotationCenterX = this.mLocalRotationCenterX;
		final float localRotationCenterY = this.mLocalRotationCenterY;

		pGLState.translateModelViewGLMatrixf(localRotationCenterX, localRotationCenterY, 0);
		pGLState.rotateModelViewGLMatrixf(-rotation, 0, 0, 1);
		pGLState.translateModelViewGLMatrixf(-localRotationCenterX, -localRotationCenterY, 0);

		/* TODO There is a special, but very likely case when mRotationCenter and mScaleCenter are the same.
		 * In that case the last glTranslatef of the rotation and the first glTranslatef of the scale is superfluous.
		 * The problem is that applyRotation and applyScale would need to be "merged" in order to efficiently check for that condition.  */
	}
}
 
Example 2
Source File: Entity.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
protected void applyRotation(final GLState pGLState) {
	final float rotation = this.mRotation;

	if(rotation != 0) {
		final float rotationCenterX = this.mRotationCenterX;
		final float rotationCenterY = this.mRotationCenterY;

		pGLState.translateModelViewGLMatrixf(rotationCenterX, rotationCenterY, 0);
		pGLState.rotateModelViewGLMatrixf(rotation, 0, 0, 1);
		pGLState.translateModelViewGLMatrixf(-rotationCenterX, -rotationCenterY, 0);

		/* TODO There is a special, but very likely case when mRotationCenter and mScaleCenter are the same.
		 * In that case the last glTranslatef of the rotation and the first glTranslatef of the scale is superfluous.
		 * The problem is that applyRotation and applyScale would need to be "merged" in order to efficiently check for that condition.  */
	}
}