Пример #1
0
        // For when using a batch node
        // In this instance, drawing will not make use of node's local matrix
        public void UpdateTransformedSpriteTextureQuads()
        {
            if (batchNode == null || AtlasIndex == CCMacros.CCSpriteIndexNotInitialized)
            {
                return;
            }

            transformedQuad = quad;

            // We can't use the AffineWorldTransform because that's the 2d projection of a 3d transformation
            // i.e. The Z coords of our quad would remain unaltered which in general incorrect
            // Instead, we need use the XnaWolrdTransform which incorporates any potential z-transforms
            Matrix  worldMatrix = XnaWorldMatrix;
            Vector3 topLeft     = quad.TopLeft.Vertices.XnaVector;
            Vector3 topRight    = quad.TopRight.Vertices.XnaVector;
            Vector3 bottomLeft  = quad.BottomLeft.Vertices.XnaVector;
            Vector3 bottomRight = quad.BottomRight.Vertices.XnaVector;

            topLeft     = Vector3.Transform(topLeft, worldMatrix);
            topRight    = Vector3.Transform(topRight, worldMatrix);
            bottomLeft  = Vector3.Transform(bottomLeft, worldMatrix);
            bottomRight = Vector3.Transform(bottomRight, worldMatrix);

            transformedQuad.TopLeft.Vertices     = new CCVertex3F(topLeft.X, topLeft.Y, topLeft.Z);
            transformedQuad.TopRight.Vertices    = new CCVertex3F(topRight.X, topRight.Y, topRight.Z);
            transformedQuad.BottomLeft.Vertices  = new CCVertex3F(bottomLeft.X, bottomLeft.Y, bottomLeft.Z);
            transformedQuad.BottomRight.Vertices = new CCVertex3F(bottomRight.X, bottomRight.Y, bottomRight.Z);

            if (textureAtlas != null && textureAtlas.TotalQuads > AtlasIndex)
            {
                textureAtlas.UpdateQuad(ref transformedQuad, AtlasIndex);
            }
        }
Пример #2
0
        // For when using a batch node
        // In this instance, drawing will not make use of node's local matrix
        public void UpdateTransformedSpriteTextureQuads()
        {
            if (batchNode == null || AtlasIndex == CCMacros.CCSpriteIndexNotInitialized)
            {
                return;
            }

            transformedQuad =
                AffineWorldTransform.Transform(quad);

            if (textureAtlas != null && textureAtlas.TotalQuads > AtlasIndex)
            {
                textureAtlas.UpdateQuad(ref transformedQuad, AtlasIndex);
            }
        }