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); }
public virtual void resetMatrix() { mMatrixStackSize = 0; mCurrentMatrix.identity(); }
public virtual AsMatrix getTransformationMatrix(AsDisplayObject targetSpace, AsMatrix resultMatrix) { if (resultMatrix != null) { resultMatrix.identity(); } else { resultMatrix = new AsMatrix(); } AsDisplayObject currentObject = this; if (targetSpace == this) { return(resultMatrix); } else { if (targetSpace == mParent || (targetSpace == null && mParent == null)) { if (mPivotX != 0.0f || mPivotY != 0.0f) { resultMatrix.translate(-mPivotX, -mPivotY); } if (mScaleX != 1.0f || mScaleY != 1.0f) { resultMatrix.scale(mScaleX, mScaleY); } if (mRotation != 0.0f) { resultMatrix.rotate(AsMathHelper.toRadians(mRotation)); } if (mX != 0.0f || mY != 0.0f) { resultMatrix.translate(mX, mY); } return(resultMatrix); } else { if (targetSpace == null) { currentObject = this; while (currentObject != null) { currentObject.getTransformationMatrix(currentObject.mParent, sHelperMatrix); resultMatrix.concat(sHelperMatrix); currentObject = currentObject.getParent(); } return(resultMatrix); } else { if (targetSpace.mParent == this) { targetSpace.getTransformationMatrix(this, resultMatrix); resultMatrix.invert(); return(resultMatrix); } } } } sAncestors.setLength(0); AsDisplayObject commonParent = null; while (currentObject != null) { sAncestors.push(currentObject); currentObject = currentObject.getParent(); } currentObject = targetSpace; while (currentObject != null && sAncestors.indexOf(currentObject) == -1) { currentObject = currentObject.getParent(); } if (currentObject == null) { throw new AsArgumentError("Object not connected to target"); } else { commonParent = currentObject; } currentObject = this; while (currentObject != commonParent) { currentObject.getTransformationMatrix(currentObject.mParent, sHelperMatrix); resultMatrix.concat(sHelperMatrix); currentObject = currentObject.getParent(); } sTargetMatrix.identity(); currentObject = targetSpace; while (currentObject != commonParent) { currentObject.getTransformationMatrix(currentObject.mParent, sHelperMatrix); sTargetMatrix.concat(sHelperMatrix); currentObject = currentObject.getParent(); } sTargetMatrix.invert(); resultMatrix.concat(sTargetMatrix); return(resultMatrix); }
public virtual AsMatrix getTransformationMatrix(AsDisplayObject targetSpace, AsMatrix resultMatrix) { AsDisplayObject commonParent = null; AsDisplayObject currentObject = null; if (resultMatrix != null) { resultMatrix.identity(); } else { resultMatrix = new AsMatrix(); } if (targetSpace == this) { return(resultMatrix); } else { if (targetSpace == mParent || (targetSpace == null && mParent == null)) { resultMatrix.copyFrom(getTransformationMatrix()); return(resultMatrix); } else { if (targetSpace == null || targetSpace == get_base()) { currentObject = this; while (currentObject != targetSpace) { resultMatrix.concat(currentObject.getTransformationMatrix()); currentObject = currentObject.mParent; } return(resultMatrix); } else { if (targetSpace.mParent == this) { targetSpace.getTransformationMatrix(this, resultMatrix); resultMatrix.invert(); return(resultMatrix); } } } } commonParent = null; currentObject = this; while (currentObject != null) { sAncestors.push(currentObject); currentObject = currentObject.mParent; } currentObject = targetSpace; while (currentObject != null && sAncestors.indexOf(currentObject) == -1) { currentObject = currentObject.mParent; } sAncestors.setLength(0); if (currentObject != null) { commonParent = currentObject; } else { throw new AsArgumentError("Object not connected to target"); } currentObject = this; while (currentObject != commonParent) { resultMatrix.concat(currentObject.getTransformationMatrix()); currentObject = currentObject.mParent; } if (commonParent == targetSpace) { return(resultMatrix); } sHelperMatrix.identity(); currentObject = targetSpace; while (currentObject != commonParent) { sHelperMatrix.concat(currentObject.getTransformationMatrix()); currentObject = currentObject.mParent; } sHelperMatrix.invert(); resultMatrix.concat(sHelperMatrix); return(resultMatrix); }
public virtual void loadIdentity() { mModelViewMatrix.identity(); }