Esempio n. 1
0
        /// <summary>Render this image at the given position and size, ignoring any transparency mask.</summary>
        /// <param name="positionAndSize">Position and size of the rendered image.</param>
        public void RenderIgnoreMask(RectangleF positionAndSize)
        {
            float horizontalScaleFactor = positionAndSize.Width / imageLocation.Width;
            float verticalScaleFactor   = positionAndSize.Height / imageLocation.Height;

            DXQuad q = videoTexture.Graphics.Quad;

            q.Texture            = videoTexture.Texture;
            q.ModulationColor    = 0xffffffff;
            q.TextureCoordinates = textureCoordinates;

            float right  = imageLocation.Width * 0.5f * horizontalScaleFactor;
            float left   = -right;
            float bottom = imageLocation.Height * 0.5f * verticalScaleFactor;
            float top    = -bottom;

            PointF offset = new PointF(
                imageLocation.Width * 0.5f * horizontalScaleFactor + positionAndSize.X - 0.5f,
                imageLocation.Height * 0.5f * verticalScaleFactor + positionAndSize.Y - 0.5f);

            q.Coord0 = new PointF(left + offset.X, top + offset.Y);
            q.Coord1 = new PointF(left + offset.X, bottom + offset.Y);
            q.Coord2 = new PointF(right + offset.X, top + offset.Y);
            q.Coord3 = new PointF(right + offset.X, bottom + offset.Y);

            videoTexture.Graphics.RenderTexturedQuadIgnoreMask();
        }
Esempio n. 2
0
        /// <summary>Render this image at the given position and size.</summary>
        /// <param name="positionAndSize">Position and size of the rendered image.</param>
        /// <param name="rotationAngle">Rotation angle. The rotation axis goes through the center of this image.</param>
        /// <param name="modulationColor">Modulation color in A8R8G8B8 format.</param>
        public void Render(RectangleF positionAndSize, float rotationAngle, uint modulationColor)
        {
            int   mipMapLevel           = 0;
            float horizontalScaleFactor = positionAndSize.Width / imageLocation.Width;
            float verticalScaleFactor   = positionAndSize.Height / imageLocation.Height;
            float mipMapFactor          = Math.Max(horizontalScaleFactor, verticalScaleFactor);

            while (mipMapLevel < (int)tileSet.DetailLevel || (mipMapFactor <= 0.5f && mipMapLevel < tesselation.Length - 1))
            {
                ++mipMapLevel;
                mipMapFactor *= 2.0f;
            }

            Quad[] tess = tesselation[mipMapLevel];

            for (int i = 0; i < tess.Length; ++i)
            {
                DXQuad q = tileSet.Graphics.Quad;

                q.Texture            = (tess[i].Tile == null ? null : tess[i].Tile.Texture);
                q.ModulationColor    = modulationColor;
                q.TextureCoordinates = tess[i].TextureCoordinates;

                float left   = tess[i].Coordinates.Left * horizontalScaleFactor;
                float right  = tess[i].Coordinates.Right * horizontalScaleFactor;
                float top    = tess[i].Coordinates.Top * verticalScaleFactor;
                float bottom = tess[i].Coordinates.Bottom * verticalScaleFactor;

                PointF offset = new PointF(
                    imageLocation.Width * 0.5f * horizontalScaleFactor + positionAndSize.X - 0.5f,
                    imageLocation.Height * 0.5f * verticalScaleFactor + positionAndSize.Y - 0.5f);

                if (rotationAngle != 0.0f)
                {
                    // rotation:
                    // x <- x * cos - y * sin
                    // y <- x * sin + y * cos
                    float sin = (float)Math.Sin(-rotationAngle);
                    float cos = (float)Math.Cos(-rotationAngle);

                    q.Coord0 = new PointF(left * cos - top * sin + offset.X, left * sin + top * cos + offset.Y);
                    q.Coord1 = new PointF(left * cos - bottom * sin + offset.X, left * sin + bottom * cos + offset.Y);
                    q.Coord2 = new PointF(right * cos - top * sin + offset.X, right * sin + top * cos + offset.Y);
                    q.Coord3 = new PointF(right * cos - bottom * sin + offset.X, right * sin + bottom * cos + offset.Y);
                }
                else
                {
                    q.Coord0 = new PointF(left + offset.X, top + offset.Y);
                    q.Coord1 = new PointF(left + offset.X, bottom + offset.Y);
                    q.Coord2 = new PointF(right + offset.X, top + offset.Y);
                    q.Coord3 = new PointF(right + offset.X, bottom + offset.Y);
                }

                tileSet.Graphics.RenderTexturedQuad();
            }
        }
Esempio n. 3
0
        /// <summary>Render the silhouette for this image at the given position and size.</summary>
        /// <param name="positionAndSize">Position and size of the rendered image.</param>
        /// <param name="rotationAngle">Rotation angle. The rotation axis goes through the center of this image.</param>
        /// <param name="color">Color of the silhouette in A8R8G8B8 format.</param>
        public void RenderSilhouette(RectangleF positionAndSize, float rotationAngle, uint color)
        {
            DXQuad quad = graphics.Quad;

            quad.ModulationColor = color;

            if (rotationAngle == 0.0f)
            {
                quad.Coord0 = new PointF(positionAndSize.X - 0.5f, positionAndSize.Y - 0.5f);
                quad.Coord1 = new PointF(quad.Coord0.X, positionAndSize.Bottom - 0.5f);
                quad.Coord2 = new PointF(positionAndSize.Right - 0.5f, quad.Coord0.Y);
                quad.Coord3 = new PointF(quad.Coord2.X, quad.Coord1.Y);
            }
            else
            {
                // rotation:
                // x <- x * cos - y * sin
                // y <- x * sin + y * cos
                float sin = (float)Math.Sin(-rotationAngle);
                float cos = (float)Math.Cos(-rotationAngle);
                float wc  = (positionAndSize.Width * 0.5f) * cos;
                float ws  = (positionAndSize.Width * 0.5f) * sin;
                float hc  = (positionAndSize.Height * 0.5f) * cos;
                float hs  = (positionAndSize.Height * 0.5f) * sin;

                PointF rotatedCoord0 = new PointF(hs - wc, -hc - wc);
                PointF rotatedCoord1 = new PointF(hs + wc, -hc + ws);

                quad.Coord0 = new PointF(
                    (rotatedCoord0.X + positionAndSize.Width * 0.5f) + (positionAndSize.X - 0.5f),
                    (rotatedCoord0.Y + positionAndSize.Height * 0.5f) + (positionAndSize.Y - 0.5f));
                quad.Coord1 = new PointF(
                    (-rotatedCoord1.X + positionAndSize.Width * 0.5f) + (positionAndSize.X - 0.5f),
                    (-rotatedCoord1.Y + positionAndSize.Height * 0.5f) + (positionAndSize.Y - 0.5f));
                quad.Coord2 = new PointF(
                    (rotatedCoord1.X + positionAndSize.Width * 0.5f) + (positionAndSize.X - 0.5f),
                    (rotatedCoord1.Y + positionAndSize.Height * 0.5f) + (positionAndSize.Y - 0.5f));
                quad.Coord3 = new PointF(
                    (-rotatedCoord0.X + positionAndSize.Width * 0.5f) + (positionAndSize.X - 0.5f),
                    (-rotatedCoord0.Y + positionAndSize.Height * 0.5f) + (positionAndSize.Y - 0.5f));
            }

            graphics.RenderMonochromaticQuad();
        }
Esempio n. 4
0
        /// <summary>Render the silhouette for this image at the given position and size.</summary>
        /// <param name="positionAndSize">Position and size of the rendered image.</param>
        /// <param name="rotationAngle">Rotation angle. The rotation axis goes through the center of this image.</param>
        /// <param name="color">Color of the silhouette in A8R8G8B8 format.</param>
        public void RenderSilhouette(RectangleF positionAndSize, float rotationAngle, uint color)
        {
            float horizontalScaleFactor = positionAndSize.Width / imageLocation.Width;
            float verticalScaleFactor   = positionAndSize.Height / imageLocation.Height;

            DXQuad q = videoTexture.Graphics.Quad;

            q.Texture            = videoTexture.Texture;
            q.ModulationColor    = color;
            q.TextureCoordinates = textureCoordinates;

            float right  = imageLocation.Width * 0.5f * horizontalScaleFactor;
            float left   = -right;
            float bottom = imageLocation.Height * 0.5f * verticalScaleFactor;
            float top    = -bottom;

            PointF offset = new PointF(
                imageLocation.Width * 0.5f * horizontalScaleFactor + positionAndSize.X - 0.5f,
                imageLocation.Height * 0.5f * verticalScaleFactor + positionAndSize.Y - 0.5f);

            if (rotationAngle != 0.0f)
            {
                // rotation:
                // x <- x * cos - y * sin
                // y <- x * sin + y * cos
                float sin = (float)Math.Sin(-rotationAngle);
                float cos = (float)Math.Cos(-rotationAngle);

                q.Coord0 = new PointF(left * cos - top * sin + offset.X, left * sin + top * cos + offset.Y);
                q.Coord1 = new PointF(left * cos - bottom * sin + offset.X, left * sin + bottom * cos + offset.Y);
                q.Coord2 = new PointF(right * cos - top * sin + offset.X, right * sin + top * cos + offset.Y);
                q.Coord3 = new PointF(right * cos - bottom * sin + offset.X, right * sin + bottom * cos + offset.Y);
            }
            else
            {
                q.Coord0 = new PointF(left + offset.X, top + offset.Y);
                q.Coord1 = new PointF(left + offset.X, bottom + offset.Y);
                q.Coord2 = new PointF(right + offset.X, top + offset.Y);
                q.Coord3 = new PointF(right + offset.X, bottom + offset.Y);
            }

            videoTexture.Graphics.RenderTexturedQuadSilhouette();
        }
Esempio n. 5
0
        /// <summary>Render this image at the given position and size, ignoring any transparency mask.</summary>
        /// <param name="positionAndSize">Position and size of the rendered image.</param>
        public void RenderIgnoreMask(RectangleF positionAndSize)
        {
            int   mipMapLevel           = 0;
            float horizontalScaleFactor = positionAndSize.Width / imageLocation.Width;
            float verticalScaleFactor   = positionAndSize.Height / imageLocation.Height;
            float mipMapFactor          = Math.Max(horizontalScaleFactor, verticalScaleFactor);

            while (mipMapLevel < (int)tileSet.DetailLevel || (mipMapFactor <= 0.5f && mipMapLevel < tesselation.Length - 1))
            {
                ++mipMapLevel;
                mipMapFactor *= 2.0f;
            }

            Quad[] tess = tesselation[mipMapLevel];

            for (int i = 0; i < tess.Length; ++i)
            {
                DXQuad q = tileSet.Graphics.Quad;

                q.Texture            = (tess[i].Tile == null ? null : tess[i].Tile.Texture);
                q.ModulationColor    = 0xFFFFFFFF;
                q.TextureCoordinates = tess[i].TextureCoordinates;

                float left   = tess[i].Coordinates.Left * horizontalScaleFactor;
                float right  = tess[i].Coordinates.Right * horizontalScaleFactor;
                float top    = tess[i].Coordinates.Top * verticalScaleFactor;
                float bottom = tess[i].Coordinates.Bottom * verticalScaleFactor;

                PointF offset = new PointF(
                    imageLocation.Width * 0.5f * horizontalScaleFactor + positionAndSize.X - 0.5f,
                    imageLocation.Height * 0.5f * verticalScaleFactor + positionAndSize.Y - 0.5f);

                q.Coord0 = new PointF(left + offset.X, top + offset.Y);
                q.Coord1 = new PointF(left + offset.X, bottom + offset.Y);
                q.Coord2 = new PointF(right + offset.X, top + offset.Y);
                q.Coord3 = new PointF(right + offset.X, bottom + offset.Y);

                tileSet.Graphics.RenderTexturedQuadIgnoreMask();
            }
        }