Exemplo n.º 1
0
        /// <summary>
        /// Performs further custom initialization for this instance.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.viewportManager = WaveServices.ViewportManager;

            if (this.texcoord1 == null)
            {
                this.texcoord1 = new Vector2[4]
                {
                    new Vector2(0, 0),
                    new Vector2(1, 0),
                    new Vector2(1, 1),
                    new Vector2(0, 1),
                };
            }

            if (this.texcoord2 == null)
            {
                this.texcoord2 = new Vector2[4]
                {
                    new Vector2(0, 0),
                    new Vector2(1, 0),
                    new Vector2(1, 1),
                    new Vector2(0, 1),
                };
            }

            float halfWidth = this.Transform2D.Rectangle.Width;
            float halfHeight = this.Transform2D.Rectangle.Height;
            float opacity = this.Transform2D.Opacity;
            Color color = new Color(opacity, opacity, opacity, opacity);

            VertexPositionColorDualTexture[] vertices = new VertexPositionColorDualTexture[4];
            vertices[0].Position = new Vector3(0f, 0f, this.Transform2D.DrawOrder);
            vertices[0].Color = color;
            vertices[0].TexCoord = this.texcoord1[0];
            vertices[0].TexCoord2 = this.texcoord2[0];

            vertices[1].Position = new Vector3(halfWidth, 0f, this.Transform2D.DrawOrder);
            vertices[1].Color = color;
            vertices[1].TexCoord = this.texcoord1[1];
            vertices[1].TexCoord2 = this.texcoord2[1];

            vertices[2].Position = new Vector3(halfWidth, halfHeight, this.Transform2D.DrawOrder);
            vertices[2].Color = color;
            vertices[2].TexCoord = this.texcoord1[2];
            vertices[2].TexCoord2 = this.texcoord2[2];

            vertices[3].Position = new Vector3(0f, halfHeight, this.Transform2D.DrawOrder);
            vertices[3].Color = color;
            vertices[3].TexCoord = this.texcoord1[3];
            vertices[3].TexCoord2 = this.texcoord2[3];

            this.vertexBuffer = new VertexBuffer(VertexPositionColorDualTexture.VertexFormat);

            this.vertexBuffer.SetData(vertices, 4);
            this.GraphicsDevice.BindVertexBuffer(this.vertexBuffer);

            ushort[] indices = new ushort[6];
            indices[0] = 0;
            indices[1] = 1;
            indices[2] = 2;
            indices[3] = 2;
            indices[4] = 3;
            indices[5] = 0;

            this.indexBuffer = new IndexBuffer(indices);
            this.GraphicsDevice.BindIndexBuffer(this.indexBuffer);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs further custom initialization for this instance.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            if (this.texcoord1 == null)
            {
                this.texcoord1 = new Vector2[4]
                {
                    new Vector2(0, 0),
                    new Vector2(1, 0),
                    new Vector2(1, 1),
                    new Vector2(0, 1),
                };
            }

            if (this.texcoord2 == null)
            {
                this.texcoord2 = new Vector2[4]
                {
                    new Vector2(0, 0),
                    new Vector2(1, 0),
                    new Vector2(1, 1),
                    new Vector2(0, 1),
                };
            }

            Vector2 origin = this.Transform2D.Origin;
            float halfWidth = this.Transform2D.Rectangle.Width;
            float halfHeight = this.Transform2D.Rectangle.Height;
            float originCorrectionWidth = origin.X * halfWidth;
            float originCorrectionHeight = origin.Y * halfHeight;

            float opacity = this.Transform2D.GlobalOpacity;
            Color color = new Color(opacity, opacity, opacity, opacity);

            VertexPositionColorDualTexture[] vertices = new VertexPositionColorDualTexture[4];
            vertices[0].Position = new Vector3(-originCorrectionWidth, -originCorrectionHeight, 0);
            vertices[0].Color = color;
            vertices[0].TexCoord = this.texcoord1[0];
            vertices[0].TexCoord2 = this.texcoord2[0];

            vertices[1].Position = new Vector3(halfWidth - originCorrectionWidth, -originCorrectionHeight, 0);
            vertices[1].Color = color;
            vertices[1].TexCoord = this.texcoord1[1];
            vertices[1].TexCoord2 = this.texcoord2[1];

            vertices[2].Position = new Vector3(halfWidth - originCorrectionWidth, halfHeight - originCorrectionHeight, 0);
            vertices[2].Color = color;
            vertices[2].TexCoord = this.texcoord1[2];
            vertices[2].TexCoord2 = this.texcoord2[2];

            vertices[3].Position = new Vector3(-originCorrectionWidth, halfHeight - originCorrectionHeight, 0);
            vertices[3].Color = color;
            vertices[3].TexCoord = this.texcoord1[3];
            vertices[3].TexCoord2 = this.texcoord2[3];

            VertexBuffer vertexBuffer = new VertexBuffer(VertexPositionColorDualTexture.VertexFormat);
            vertexBuffer.SetData(vertices, 4);

            ushort[] indices = new ushort[6];
            indices[0] = 0;
            indices[1] = 1;
            indices[2] = 2;
            indices[3] = 2;
            indices[4] = 3;
            indices[5] = 0;

            IndexBuffer indexBuffer = new IndexBuffer(indices);

            // create the quad
            this.quadMesh = new Mesh(0, 4, 0, 2, vertexBuffer, indexBuffer, PrimitiveType.TriangleList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Performs further custom initialization for this instance.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            if (this.texcoord1 == null)
            {
                this.texcoord1 = new Vector2[4]
                {
                    new Vector2(0, 0),
                    new Vector2(1, 0),
                    new Vector2(1, 1),
                    new Vector2(0, 1),
                };
            }

            if (this.texcoord2 == null)
            {
                this.texcoord2 = new Vector2[4]
                {
                    new Vector2(0, 0),
                    new Vector2(1, 0),
                    new Vector2(1, 1),
                    new Vector2(0, 1),
                };
            }

            Vector2 origin                 = this.Transform2D.Origin;
            float   halfWidth              = this.Transform2D.Rectangle.Width;
            float   halfHeight             = this.Transform2D.Rectangle.Height;
            float   originCorrectionWidth  = origin.X * halfWidth;
            float   originCorrectionHeight = origin.Y * halfHeight;

            float opacity = this.Transform2D.GlobalOpacity;
            Color color   = new Color(opacity, opacity, opacity, opacity);

            VertexPositionColorDualTexture[] vertices = new VertexPositionColorDualTexture[4];
            vertices[0].Position  = new Vector3(-originCorrectionWidth, -originCorrectionHeight, 0);
            vertices[0].Color     = color;
            vertices[0].TexCoord  = this.texcoord1[0];
            vertices[0].TexCoord2 = this.texcoord2[0];

            vertices[1].Position  = new Vector3(halfWidth - originCorrectionWidth, -originCorrectionHeight, 0);
            vertices[1].Color     = color;
            vertices[1].TexCoord  = this.texcoord1[1];
            vertices[1].TexCoord2 = this.texcoord2[1];

            vertices[2].Position  = new Vector3(halfWidth - originCorrectionWidth, halfHeight - originCorrectionHeight, 0);
            vertices[2].Color     = color;
            vertices[2].TexCoord  = this.texcoord1[2];
            vertices[2].TexCoord2 = this.texcoord2[2];

            vertices[3].Position  = new Vector3(-originCorrectionWidth, halfHeight - originCorrectionHeight, 0);
            vertices[3].Color     = color;
            vertices[3].TexCoord  = this.texcoord1[3];
            vertices[3].TexCoord2 = this.texcoord2[3];

            VertexBuffer vertexBuffer = new VertexBuffer(VertexPositionColorDualTexture.VertexFormat);

            vertexBuffer.SetData(vertices, 4);

            ushort[] indices = new ushort[6];
            indices[0] = 0;
            indices[1] = 1;
            indices[2] = 2;
            indices[3] = 2;
            indices[4] = 3;
            indices[5] = 0;

            IndexBuffer indexBuffer = new IndexBuffer(indices);

            // create the quad
            this.quadMesh = new Mesh(0, 4, 0, 2, vertexBuffer, indexBuffer, PrimitiveType.TriangleList);
        }