internal override Vector2X[] adjustUVs(Vector2X[] uv, Vector2X[] result = null) { SubTextureX texture = this; _transform2X.identity(); while (texture != null) { _transform2X = Transform2X.multiply(_transform2X, texture.transform); texture = texture.parent as SubTextureX; } Vector2X item; if (result == null) { result = new Vector2X[4]; } for (int i = 0; i < 4; i++) { item = uv[i]; result[i] = _transform2X.transformVector(item); } return(result); }
public override void render(RenderSupport support, float parentAlpha) { float alpha = parentAlpha * this.alpha; int numChildren = mChildren.Count; for (int i = 0; i < numChildren; ++i) { DisplayObjectX child = mChildren[i]; if (child.hasVisibleArea) { child.sceneTransform = Transform2X.multiply(mSceneTransform, child.transform); support.blendMode = child.blendMode; // if (filter) // { // filter.render(child, support, alpha); // } // else // { child.render(support, alpha); // } support.blendMode = blendMode; } } }
public Transform2X getTransformationMatrix(DisplayObjectX targetSpace, Transform2X resultMatrix = null) { DisplayObjectX commonParent; DisplayObjectX currentObject; if (resultMatrix != null) { resultMatrix.identity(); } else { resultMatrix = new Transform2X(); } if (targetSpace == this) { return(resultMatrix); } else if (targetSpace == mParent || (targetSpace == null && mParent == null)) { resultMatrix.copyFrom(transform); return(resultMatrix); } else if (targetSpace == null || targetSpace == stage) { // targetCoordinateSpace 'null' represents the target space of the base object. // -> move up from this to base currentObject = this; while (currentObject != targetSpace) { resultMatrix = Transform2X.multiply(resultMatrix, currentObject.transform); currentObject = currentObject.mParent; } return(resultMatrix); } else if (targetSpace.mParent == this) // optimization { targetSpace.getTransformationMatrix(this, resultMatrix); resultMatrix.invert(); return(resultMatrix); } // 1. find a common parent of this and the target space commonParent = findCommonParent(this, targetSpace); // 2. move up from this to common parent currentObject = this; while (currentObject != commonParent) { resultMatrix = Transform2X.multiply(resultMatrix, currentObject.transform); currentObject = currentObject.mParent; } if (commonParent == targetSpace) { return(resultMatrix); } // 3. now move up from target until we reach the common parent sHelperTransform.identity(); currentObject = targetSpace; while (currentObject != commonParent) { sHelperTransform = Transform2X.multiply(sHelperTransform, currentObject.transform); currentObject = currentObject.mParent; } // 4. now combine the two matrices sHelperTransform.invert(); resultMatrix = Transform2X.multiply(resultMatrix, sHelperTransform); return(resultMatrix); }