public static Texture CreateForTextureSourceSize(ITextureSource pTextureSource, TextureOptions pTextureOptions) { int loadingScreenWidth = pTextureSource.GetWidth(); int loadingScreenHeight = pTextureSource.GetHeight(); return(new Texture(MathUtils.NextPowerOfTwo(loadingScreenWidth), MathUtils.NextPowerOfTwo(loadingScreenHeight), pTextureOptions)); }
public static void FillVertices(/* final */ RectangularShape pRectangularShape, /* final */ float[] pVertices) { /* final */ float left = pRectangularShape.GetX(); /* final */ float top = pRectangularShape.GetY(); /* final */ float right = pRectangularShape.GetWidth() + left; /* final */ float bottom = pRectangularShape.GetHeight() + top; pVertices[0 + Constants.VERTEX_INDEX_X] = left; pVertices[0 + Constants.VERTEX_INDEX_Y] = top; pVertices[2 + Constants.VERTEX_INDEX_X] = right; pVertices[2 + Constants.VERTEX_INDEX_Y] = top; pVertices[4 + Constants.VERTEX_INDEX_X] = right; pVertices[4 + Constants.VERTEX_INDEX_Y] = bottom; pVertices[6 + Constants.VERTEX_INDEX_X] = left; pVertices[6 + Constants.VERTEX_INDEX_Y] = bottom; MathUtil.RotateAndScaleAroundCenter(pVertices, pRectangularShape.GetRotation(), left + pRectangularShape.GetRotationCenterX(), top + pRectangularShape.GetRotationCenterY(), pRectangularShape.GetScaleX(), pRectangularShape.GetScaleY(), left + pRectangularShape.GetScaleCenterX(), top + pRectangularShape.GetScaleCenterY()); }
public static float[] ConvertLocalToSceneCoordinates(/* final */ Shape pShape, /* final */ float pX, /* final */ float pY) { VERTICES_LOCAL_TO_SCENE_TMP[Constants.VERTEX_INDEX_X] = pX; VERTICES_LOCAL_TO_SCENE_TMP[Constants.VERTEX_INDEX_Y] = pY; MathUtils.RotateAndScaleAroundCenter(VERTICES_LOCAL_TO_SCENE_TMP, pShape.GetRotation(), pShape.GetRotationCenterX(), pShape.GetRotationCenterY(), pShape.GetScaleX(), pShape.GetScaleY(), pShape.GetScaleCenterX(), pShape.GetScaleCenterY()); return(VERTICES_LOCAL_TO_SCENE_TMP); }
/** * @param pWidth must be a power of 2 (i.e. 32, 64, 128, 256, 512, 1024). * @param pHeight must be a power of 2 (i.e. 32, 64, 128, 256, 512, 1024). * @param pTextureOptions the (quality) settings of the Texture. * @param pTextureStateListener to be informed when this {@link Texture} is loaded, unloaded or a {@link ITextureSource} failed to load. */ protected void Init(int pWidth, int pHeight, TextureOptions pTextureOptions, ITextureStateListener pTextureStateListener) /* throws IllegalArgumentException */ { if (!MathUtils.IsPowerOfTwo(pWidth) || !MathUtils.IsPowerOfTwo(pHeight)) { throw new IllegalArgumentException("Width and Height of a Texture must be a power of 2!"); } this.mWidth = pWidth; this.mHeight = pHeight; this.mTextureOptions = pTextureOptions; this.mTextureStateListener = pTextureStateListener; }
private void UpdateControlKnob(/* final */ TouchEvent pSceneTouchEvent, /* final */ float pTouchAreaLocalX, /* final */ float pTouchAreaLocalY) { /* final */ Sprite controlBase = this.mControlBase; /* final */ float relativeX = MathUtils.BringToBounds(0, controlBase.GetWidth(), pTouchAreaLocalX) / controlBase.GetWidth() - 0.5f; /* final */ float relativeY = MathUtils.BringToBounds(0, controlBase.GetHeight(), pTouchAreaLocalY) / controlBase.GetHeight() - 0.5f; this.OnUpdateControlKnob(relativeX, relativeY); }
// =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public static float[] ConvertSceneToLocalCoordinates(/* final */ Shape pShape, /* final */ float pX, /* final */ float pY) { VERTICES_SCENE_TO_LOCAL_TMP[Constants.VERTEX_INDEX_X] = pX; VERTICES_SCENE_TO_LOCAL_TMP[Constants.VERTEX_INDEX_Y] = pY; /* final */ float left = pShape.GetX(); /* final */ float top = pShape.GetY(); MathUtils.RevertRotateAndScaleAroundCenter(VERTICES_SCENE_TO_LOCAL_TMP, pShape.GetRotation(), left + pShape.GetRotationCenterX(), top + pShape.GetRotationCenterY(), pShape.GetScaleX(), pShape.GetScaleY(), left + pShape.GetScaleCenterX(), top + pShape.GetScaleCenterY()); return(VERTICES_SCENE_TO_LOCAL_TMP); }
private void ApplySceneRotation(/* final */ TouchEvent pCameraSceneTouchEvent) { /* final */ float rotation = -this.mRotation; if (rotation != 0) { VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X] = pCameraSceneTouchEvent.GetX(); VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y] = pCameraSceneTouchEvent.GetY(); //MathUtils.RotateAroundCenter(VERTICES_TOUCH_TMP, rotation, this.getCenterX(), this.getCenterY()); MathUtils.RotateAroundCenter(VERTICES_TOUCH_TMP, rotation, this.CenterX, this.CenterY); pCameraSceneTouchEvent.Set(VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X], VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y]); } }
private void UnapplyCameraSceneRotation(/* final */ TouchEvent pCameraSceneTouchEvent) { /* final */ float cameraSceneRotation = -this.mCameraSceneRotation; if (cameraSceneRotation != 0) { //VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X] = pCameraSceneTouchEvent.getX(); VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X] = pCameraSceneTouchEvent.X; //VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y] = pCameraSceneTouchEvent.getY(); VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y] = pCameraSceneTouchEvent.Y; MathUtils.RevertRotateAroundCenter(VERTICES_TOUCH_TMP, cameraSceneRotation, (this.mMaxX - this.mMinX) * 0.5f, (this.mMaxY - this.mMinY) * 0.5f); pCameraSceneTouchEvent.Set(VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X], VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y]); } }
private void UnapplySceneRotation(/* final */ TouchEvent pSceneTouchEvent) { /* final */ float rotation = this.mRotation; if (rotation != 0) { //VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX(); VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.X; //VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY(); VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.Y; //MathUtils.revertRotateAroundCenter(VERTICES_TOUCH_TMP, rotation, this.getCenterX(), this.getCenterY()); MathUtils.RevertRotateAroundCenter(VERTICES_TOUCH_TMP, rotation, this.CenterX, this.CenterY); pSceneTouchEvent.Set(VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X], VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y]); } }
/** * Not tested for now! */ //@Deprecated /// <summary> /// Decprecated and untested /// </summary> /// <param name="IShape"></param> public void accelerateRespectingRotation(/* final */ IShape pShape, /* final */ float pAccelerationX, /* final */ float pAccelerationY) { /* final */ float rotation = pShape.GetRotation(); /* final */ float rotationRad = MathUtils.DegToRad(rotation); /* final */ float sin = FloatMath.Sin(rotationRad); /* final */ float cos = FloatMath.Cos(rotationRad); /* final */ float accelerationX = sin * -pAccelerationY + cos * pAccelerationX; /* final */ float accelerationY = cos * pAccelerationY + sin * pAccelerationX; pShape.SetAcceleration(accelerationX, accelerationY); }
// =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== /** * Not tested for now! */ // @Deprecated /// <summary> /// Deprecated and untested /// </summary> /// <param name="IShape"></param> public void setVelocityRespectingRotation(/* final */ IShape pShape, /* final */ float pVelocityX, /* final */ float pVelocityY) { /* final */ float rotation = pShape.GetRotation(); /* final */ float rotationRad = MathUtils.DegToRad(rotation); /* final */ float sin = FloatMath.Sin(rotationRad); /* final */ float cos = FloatMath.Cos(rotationRad); /* final */ float velocityX = sin * -pVelocityY + cos * pVelocityX; /* final */ float velocityY = cos * pVelocityY + sin * pVelocityX; pShape.SetVelocity(velocityX, velocityY); }
public void ConvertSurfaceToSceneTouchEvent(/* final */ TouchEvent pSurfaceTouchEvent, /* final */ int pSurfaceWidth, /* final */ int pSurfaceHeight) { /* final */ float relativeX; /* final */ float relativeY; /* final */ float rotation = this.mRotation; if (rotation == 0) { //relativeX = pSurfaceTouchEvent.getX() / pSurfaceWidth; relativeX = pSurfaceTouchEvent.X / pSurfaceWidth; //relativeY = pSurfaceTouchEvent.getY() / pSurfaceHeight; relativeY = pSurfaceTouchEvent.Y / pSurfaceHeight; } else if (rotation == 180) { //relativeX = 1 - (pSurfaceTouchEvent.getX() / pSurfaceWidth); relativeX = 1 - (pSurfaceTouchEvent.X / pSurfaceWidth); //relativeY = 1 - (pSurfaceTouchEvent.getY() / pSurfaceHeight); relativeY = 1 - (pSurfaceTouchEvent.Y / pSurfaceHeight); } else { //VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X] = pSurfaceTouchEvent.getX(); VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X] = pSurfaceTouchEvent.X; //VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y] = pSurfaceTouchEvent.getY(); VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y] = pSurfaceTouchEvent.Y; MathUtils.RotateAroundCenter(VERTICES_TOUCH_TMP, rotation, pSurfaceWidth / 2, pSurfaceHeight / 2); relativeX = VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_X] / pSurfaceWidth; relativeY = VERTICES_TOUCH_TMP[Constants.VERTEX_INDEX_Y] / pSurfaceHeight; } this.convertAxisAlignedSurfaceToSceneTouchEvent(pSurfaceTouchEvent, relativeX, relativeY); }