public virtual AsMatrix getTransformationMatrix()
 {
     if (mOrientationChanged)
     {
         mOrientationChanged = false;
         mTransformationMatrix.identity();
         if (mSkewX != 0.0f || mSkewY != 0.0f)
         {
             AsMatrixUtil.skew(mTransformationMatrix, mSkewX, mSkewY);
         }
         if (mScaleX != 1.0f || mScaleY != 1.0f)
         {
             mTransformationMatrix.scale(mScaleX, mScaleY);
         }
         if (mRotation != 0.0f)
         {
             mTransformationMatrix.rotate(mRotation);
         }
         if (mX != 0.0f || mY != 0.0f)
         {
             mTransformationMatrix.translate(mX, mY);
         }
         if (mPivotX != 0.0f || mPivotY != 0.0f)
         {
             mTransformationMatrix.tx = mX - mTransformationMatrix.a * mPivotX - mTransformationMatrix.c * mPivotY;
             mTransformationMatrix.ty = mY - mTransformationMatrix.b * mPivotX - mTransformationMatrix.d * mPivotY;
         }
     }
     return(mTransformationMatrix);
 }
Пример #2
0
 public static void uploadBitmapData(bc.flash.display3D.textures.AsTexture nativeTexture, AsBitmapData data, bool generateMipmaps)
 {
     nativeTexture.uploadFromBitmapData(data);
     if (generateMipmaps && data.getWidth() > 1 && data.getHeight() > 1)
     {
         int          currentWidth  = data.getWidth() >> 1;
         int          currentHeight = data.getHeight() >> 1;
         int          level         = 1;
         AsBitmapData canvas        = new AsBitmapData(currentWidth, currentHeight, true, 0);
         AsMatrix     transform     = new AsMatrix(.5f, 0, 0, .5f);
         AsRectangle  bounds        = new AsRectangle();
         while (currentWidth >= 1 || currentHeight >= 1)
         {
             bounds.width  = currentWidth;
             bounds.height = currentHeight;
             canvas.fillRect(bounds, (uint)(0));
             canvas.draw(data, transform, null, null, null, true);
             nativeTexture.uploadFromBitmapData(canvas, (uint)(level++));
             transform.scale(0.5f, 0.5f);
             currentWidth  = currentWidth >> 1;
             currentHeight = currentHeight >> 1;
         }
         canvas.dispose();
     }
 }