本文整理汇总了Java中org.andengine.util.math.MathUtils.max方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.max方法的具体用法?Java MathUtils.max怎么用?Java MathUtils.max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.util.math.MathUtils
的用法示例。
在下文中一共展示了MathUtils.max方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clipForCamera
import org.andengine.util.math.MathUtils; //导入方法依赖的package包/类
/**
* Perform clipping using normal Scene coordinate transformations
* @param pGLState
* @param pCamera
*/
private void clipForCamera(GLState pGLState, Camera pCamera) {
final int surfaceHeight = pCamera.getSurfaceHeight();
/* In order to apply clipping, we need to determine the the axis aligned bounds in OpenGL coordinates. */
/* Determine clipping coordinates of each corner in surface coordinates. */
final float[] lowerLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, 0, new float[2]));
final int lowerLeftX = (int)Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerLeftY = surfaceHeight - (int)Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, this.mHeight, new float[2]));
final int upperLeftX = (int)Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperLeftY = surfaceHeight - (int)Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, this.mHeight, new float[2]));
final int upperRightX = (int)Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperRightY = surfaceHeight - (int)Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] lowerRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, 0, new float[2]));
final int lowerRightX = (int)Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerRightY = surfaceHeight - (int)Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
/* Determine minimum and maximum x clipping coordinates. */
final int minClippingX = MathUtils.min(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
final int maxClippingX = MathUtils.max(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
/* Determine minimum and maximum y clipping coordinates. */
final int minClippingY = MathUtils.min(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
final int maxClippingY = MathUtils.max(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
/* Determine clipping width and height. */
final int clippingWidth = maxClippingX - minClippingX;
final int clippingHeight = maxClippingY - minClippingY;
//Debug.d("ClippingY: min="+minClippingY+", max="+maxClippingY);
//Debug.d("clipForCamera: GLES20.glScissor("+minClippingX+", "+minClippingY+", "+clippingWidth+", "+clippingHeight+")");
GLES20.glScissor(minClippingX, minClippingY, clippingWidth, clippingHeight);
}
示例2: onManagedDraw
import org.andengine.util.math.MathUtils; //导入方法依赖的package包/类
@Override
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {
if (this.mClippingEnabled) {
/* Enable scissor test, while remembering previous state. */
final boolean wasScissorTestEnabled = pGLState.enableScissorTest();
final int surfaceHeight = pCamera.getSurfaceHeight();
/* In order to apply clipping, we need to determine the the axis aligned bounds in OpenGL coordinates. */
/* Determine clipping coordinates of each corner in surface coordinates. */
final float[] lowerLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, 0));
final int lowerLeftX = (int) Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerLeftY = surfaceHeight - (int) Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, this.mHeight));
final int upperLeftX = (int) Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperLeftY = surfaceHeight - (int) Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, this.mHeight));
final int upperRightX = (int) Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperRightY = surfaceHeight - (int) Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] lowerRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, 0));
final int lowerRightX = (int) Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerRightY = surfaceHeight - (int) Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
/* Determine minimum and maximum x clipping coordinates. */
final int minClippingX = MathUtils.min(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
final int maxClippingX = MathUtils.max(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
/* Determine minimum and maximum y clipping coordinates. */
final int minClippingY = MathUtils.min(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
final int maxClippingY = MathUtils.max(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
/* Determine clipping width and height. */
final int clippingWidth = maxClippingX - minClippingX;
final int clippingHeight = maxClippingY - minClippingY;
/* Finally apply the clipping. */
pGLState.glPushScissor(minClippingX, minClippingY, clippingWidth, clippingHeight);
/* Draw children, etc... */
super.onManagedDraw(pGLState, pCamera);
/* Revert scissor test to previous state. */
pGLState.glPopScissor();
pGLState.setScissorTestEnabled(wasScissorTestEnabled);
} else {
super.onManagedDraw(pGLState, pCamera);
}
}