当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils.max方法代码示例

本文整理汇总了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);
 }
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:43,代码来源:Scrollable.java

示例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);
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:53,代码来源:ClipEntity.java


注:本文中的org.andengine.util.math.MathUtils.max方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。