Ejemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            GraphicsDevice.RenderState.DepthBufferEnable = false;

            GraphicsDevice.VertexDeclaration = backdropVertexDeclaration;

            bfx.Begin();
            foreach (EffectPass pass in bfx.CurrentTechnique.Passes)
            {
                pass.Begin();

                GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, backdropVertices, 0, 2);

                pass.End();
            }
            bfx.End();

            GraphicsDevice.RenderState.DepthBufferEnable = true;

            grid.Draw(gameTime);

            DrawGridPieces(gameTime);

            DrawUnitAnimations(gameTime);

            sprite.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
            if (!gameEnded && enemyPieces.Count > 0 && playerPieces.Count > 0)
            {
                DrawTurnQueue(gameTime);
            }

            DrawActions(gameTime);

            DrawHoverInfoBubble(gameTime);

            if (gameEnded)
            {
                string textResult   = gameWon ? String.Format("Level {0} completed!", level) : String.Format("level {0} failed!", level);
                string textContinue = gameWon ? "Press 'RETURN' to continue." : "Press 'ENTER' to try again.";

                Vector2 textResultSize   = uiUnitFont.MeasureString(textResult);
                Vector2 textContinueSize = uiUnitFont.MeasureString(textContinue);

                sprite.DrawString(uiUnitFont, textResult, new Vector2((GraphicsDevice.Viewport.Width / 2) - (textResultSize.X / 2), (GraphicsDevice.Viewport.Height / 5) - (textResultSize.Y / 2)), Color.Black);
                sprite.DrawString(uiUnitFont, textContinue, new Vector2((GraphicsDevice.Viewport.Width / 2) - (textContinueSize.X / 2), (GraphicsDevice.Viewport.Height / 5) - (textContinueSize.Y / 2) + 18), Color.Black);
            }

            if (!gameStarted || levelIntroIsFading)
            {
                Color levelIntroColor       = Color.White;
                Color levelIntroColorShadow = Color.Gray;

                levelIntroColor.A       = (byte)(255.0f * levelIntroAlpha);
                levelIntroColorShadow.A = (byte)(255.0f * levelIntroAlpha);

                string  text         = String.Format("Level {0}", level);
                Vector2 textSize     = levelFont.MeasureString(text);
                Vector2 textPosition = new Vector2((GraphicsDevice.Viewport.Width / 2) - (textSize.X / 2), (GraphicsDevice.Viewport.Height / 2) - (textSize.Y / 2));

                sprite.DrawString(levelFont, text, textPosition + Vector2.One, levelIntroColorShadow);
                sprite.DrawString(levelFont, text, textPosition, levelIntroColor);
            }

            sprite.End();

            base.Draw(gameTime);
        }
        /// <summary>
        /// Dibuja nodos por nivel de detalle
        /// </summary>
        /// <param name="gameTime">Tiempo de juego</param>
        /// <param name="lod">Nivel de detalle</param>
        private void LODDraw(GameTime gameTime, LOD lod)
        {
            Color nodeColor = Color.White;

            if (lod == LOD.High)
            {
                nodeColor = Color.Red;
            }
            else if (lod == LOD.Medium)
            {
                nodeColor = Color.Orange;
            }
            else if (lod == LOD.Low)
            {
                nodeColor = Color.Green;
            }

            SceneryInfoNodeDrawn[] nodes = m_Scenery.Scenery.GetNodesDrawn(lod);
            int numVerts = ((nodes.Length * 4) > _MaxNodeVertexes) ? _MaxNodeVertexes : (nodes.Length * 4);

            if ((numVerts > 0) && (m_Scenery.Scenery.Width > 2))
            {
                // Inicializar el buffer de vértices
                int     n     = 0;
                Vector3 pos   = new Vector3();
                float   scale = (1.0f / m_Scenery.Scenery.Width) * 100.0f;
                for (int i = 0; i <= numVerts - 4; i += 4)
                {
                    SceneryInfoNodeDrawn node = nodes[n++];

                    pos.X             = scale * node.UpperLeft.X + 10.0f;
                    pos.Y             = scale * node.UpperLeft.Y + 10.0f;
                    pos.Z             = 0.0f;
                    m_NodeVertexes[i] = new VertexPositionColor(pos, nodeColor);

                    pos.X = scale * node.LowerRight.X + 10.0f;
                    pos.Y = scale * node.UpperLeft.Y + 10.0f;
                    pos.Z = 0.0f;
                    m_NodeVertexes[i + 1] = new VertexPositionColor(pos, nodeColor);

                    pos.X = scale * node.LowerRight.X + 10.0f;
                    pos.Y = scale * node.LowerRight.Y + 10.0f;
                    pos.Z = 0.0f;
                    m_NodeVertexes[i + 2] = new VertexPositionColor(pos, nodeColor);

                    pos.X = scale * node.UpperLeft.X + 10.0f;
                    pos.Y = scale * node.LowerRight.Y + 10.0f;
                    pos.Z = 0.0f;
                    m_NodeVertexes[i + 3] = new VertexPositionColor(pos, nodeColor);
                }

                // Establecer los vértices en el buffer de vértices
                //m_NodesVertexBuffer.SetData<VertexPositionColor>(
                //    m_NodeVertexes,
                //    0,
                //    numVerts,
                //    SetDataOptions.Discard);
                m_NodesVertexBuffer.SetData <VertexPositionColor>(m_NodeVertexes, 0, numVerts);

                // Crear la lista de líneas para los nodos

                // 4 líneas por nodo y 4 vértices por nodo
                int numLines   = numVerts;
                int numIndexes = numLines * 2;
                int v          = 0;
                for (int i = 0; i <= numIndexes - 8; i += 8)
                {
                    m_NodeIndexes[i + 0] = (short)(v + 0); m_NodeIndexes[i + 1] = (short)(v + 1);
                    m_NodeIndexes[i + 2] = (short)(v + 1); m_NodeIndexes[i + 3] = (short)(v + 2);
                    m_NodeIndexes[i + 4] = (short)(v + 2); m_NodeIndexes[i + 5] = (short)(v + 3);
                    m_NodeIndexes[i + 6] = (short)(v + 3); m_NodeIndexes[i + 7] = (short)(v + 0);
                    v += 4;
                }

                // Establecer los índices en el buffer de índices
                //m_NodesIndexBuffer.SetData<short>(
                //    m_NodeIndexes,
                //    0,
                //    numIndexes,
                //    SetDataOptions.Discard);
                m_NodesIndexBuffer.SetData <short>(m_NodeIndexes, 0, numIndexes);

                // Dibujar la lista de líneas
                m_Effect.Begin(SaveStateMode.SaveState);

                foreach (EffectPass pass in m_Effect.CurrentTechnique.Passes)
                {
                    pass.Begin();

                    this.GraphicsDevice.VertexDeclaration = m_NodesVertexDeclaration;
                    this.GraphicsDevice.Vertices[0].SetSource(m_NodesVertexBuffer, 0, VertexPositionColor.SizeInBytes);
                    this.GraphicsDevice.Indices = m_NodesIndexBuffer;

                    this.GraphicsDevice.DrawIndexedPrimitives(
                        PrimitiveType.LineList,
                        0,
                        0,
                        numVerts,
                        0,
                        numLines);

                    pass.End();
                }

                m_Effect.End();

                //Vaciar el dispositivo
                this.GraphicsDevice.VertexDeclaration = null;
                this.GraphicsDevice.Vertices[0].SetSource(null, 0, 0);
                this.GraphicsDevice.Indices = null;
            }
        }
Ejemplo n.º 3
0
        public static void DrawBoundingBox(BoundingBox boundingBox, Matrix view, Matrix projection)
        {
            if (_boxVertexBuffer == null) //was never setup
            {
                float alpha = 0.5f;
                if (_boxVertexDeclaration == null)
                {
                    _boxVertexDeclaration = new VertexDeclaration(ResourceMgr.Instance.Game.GraphicsDevice, VertexPositionColor.VertexElements);
                }
                _boxVertexBuffer = new VertexBuffer(ResourceMgr.Instance.Game.GraphicsDevice, VertexPositionColor.SizeInBytes * 24, BufferUsage.WriteOnly);
                if (_boxIndexBuffer == null)
                {
                    _boxIndexBuffer = new IndexBuffer(ResourceMgr.Instance.Game.GraphicsDevice, 2 /*bytes*/ * 6 * 6, BufferUsage.WriteOnly, IndexElementSize.SixteenBits);
                    short[] indices = new short[36];
                    indices[0]  = 0;
                    indices[1]  = 1;
                    indices[2]  = 2;
                    indices[3]  = 1;
                    indices[4]  = 3;
                    indices[5]  = 2;
                    indices[6]  = 4;
                    indices[7]  = 5;
                    indices[8]  = 6;
                    indices[9]  = 6;
                    indices[10] = 5;
                    indices[11] = 7;
                    indices[12] = 8;
                    indices[13] = 9;
                    indices[14] = 10;
                    indices[15] = 8;
                    indices[16] = 11;
                    indices[17] = 9;
                    indices[18] = 12;
                    indices[19] = 13;
                    indices[20] = 14;
                    indices[21] = 12;
                    indices[22] = 14;
                    indices[23] = 15;
                    indices[24] = 16;
                    indices[25] = 17;
                    indices[26] = 18;
                    indices[27] = 19;
                    indices[28] = 17;
                    indices[29] = 16;
                    indices[30] = 20;
                    indices[31] = 21;
                    indices[32] = 22;
                    indices[33] = 23;
                    indices[34] = 20;
                    indices[35] = 22;
                    _boxIndexBuffer.SetData <short>(indices);
                }
                _boxEffect = new BasicEffect(ResourceMgr.Instance.Game.GraphicsDevice, null);
                _boxEffect.VertexColorEnabled = true;
                _boxEffect.Alpha = alpha;
                VertexPositionColor[] vertices = new VertexPositionColor[24];

                Vector3 topLeftFront     = new Vector3(-0.5f, 0.5f, 0.5f);
                Vector3 bottomLeftFront  = new Vector3(-0.5f, -0.5f, 0.5f);
                Vector3 topRightFront    = new Vector3(0.5f, 0.5f, 0.5f);
                Vector3 bottomRightFront = new Vector3(0.5f, -0.5f, 0.5f);
                Vector3 topLeftBack      = new Vector3(-0.5f, 0.5f, -0.5f);
                Vector3 topRightBack     = new Vector3(0.5f, 0.5f, -0.5f);
                Vector3 bottomLeftBack   = new Vector3(-0.5f, -0.5f, -0.5f);
                Vector3 bottomRightBack  = new Vector3(0.5f, -0.5f, -0.5f);

                //front
                vertices[0] = new VertexPositionColor(topLeftFront, Color.Red);
                vertices[1] = new VertexPositionColor(bottomLeftFront, Color.Red);
                vertices[2] = new VertexPositionColor(topRightFront, Color.Red);
                vertices[3] = new VertexPositionColor(bottomRightFront, Color.Red);

                //back
                vertices[4] = new VertexPositionColor(topLeftBack, Color.Orange);
                vertices[5] = new VertexPositionColor(topRightBack, Color.Orange);
                vertices[6] = new VertexPositionColor(bottomLeftBack, Color.Orange);
                vertices[7] = new VertexPositionColor(bottomRightBack, Color.Orange);

                //top
                vertices[8]  = new VertexPositionColor(topLeftFront, Color.Yellow);
                vertices[9]  = new VertexPositionColor(topRightBack, Color.Yellow);
                vertices[10] = new VertexPositionColor(topLeftBack, Color.Yellow);
                vertices[11] = new VertexPositionColor(topRightFront, Color.Yellow);

                //bottom
                vertices[12] = new VertexPositionColor(bottomLeftFront, Color.Purple);
                vertices[13] = new VertexPositionColor(bottomLeftBack, Color.Purple);
                vertices[14] = new VertexPositionColor(bottomRightBack, Color.Purple);
                vertices[15] = new VertexPositionColor(bottomRightFront, Color.Purple);

                //left
                vertices[16] = new VertexPositionColor(topLeftFront, Color.Blue);
                vertices[17] = new VertexPositionColor(bottomLeftBack, Color.Blue);
                vertices[18] = new VertexPositionColor(bottomLeftFront, Color.Blue);
                vertices[19] = new VertexPositionColor(topLeftBack, Color.Blue);

                //right
                vertices[20] = new VertexPositionColor(topRightFront, Color.Green);
                vertices[21] = new VertexPositionColor(bottomRightFront, Color.Green);
                vertices[22] = new VertexPositionColor(bottomRightBack, Color.Green);
                vertices[23] = new VertexPositionColor(topRightBack, Color.Green);

                _boxVertexBuffer.SetData <VertexPositionColor>(vertices);
            }

            Matrix scale = Matrix.CreateScale(boundingBox.Max.X - boundingBox.Min.X,
                                              boundingBox.Max.Y - boundingBox.Min.Y,
                                              boundingBox.Max.Z - boundingBox.Min.Z);
            Matrix translation = Matrix.CreateTranslation(BoxCenter(boundingBox));
            Matrix adjustment  = scale * translation;

            ResourceMgr.Instance.Game.GraphicsDevice.RenderState.CullMode = CullMode.None;
            ResourceMgr.Instance.Game.GraphicsDevice.Vertices[0].SetSource(_boxVertexBuffer, 0, VertexPositionColor.SizeInBytes);
            ResourceMgr.Instance.Game.GraphicsDevice.Indices = _boxIndexBuffer;
            VertexDeclaration old = ResourceMgr.Instance.Game.GraphicsDevice.VertexDeclaration;

            ResourceMgr.Instance.Game.GraphicsDevice.VertexDeclaration = _boxVertexDeclaration;

            ResourceMgr.Instance.Game.GraphicsDevice.RenderState.AlphaBlendEnable = true;
            ResourceMgr.Instance.Game.GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
            ResourceMgr.Instance.Game.GraphicsDevice.RenderState.SourceBlend      = Blend.SourceAlpha;

            _boxEffect.Begin();
            _boxEffect.View       = view;
            _boxEffect.Projection = projection;
            _boxEffect.World      = adjustment;
            foreach (EffectPass pass in _boxEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                ResourceMgr.Instance.Game.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 24, 0, 12);
                pass.End();
            }
            _boxEffect.End();

            ResourceMgr.Instance.Game.GraphicsDevice.VertexDeclaration    = old;
            ResourceMgr.Instance.Game.GraphicsDevice.RenderState.CullMode = CullMode.CullCounterClockwiseFace;

            ResourceMgr.Instance.Game.GraphicsDevice.RenderState.AlphaBlendEnable = false;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Draw Balls in Space
            // Get Aspect Ratio
            float aspectRatio = m_GraphicsDev.PreferredBackBufferWidth /
                                m_GraphicsDev.PreferredBackBufferHeight;

            // Get Matrix
            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                                                                    aspectRatio,
                                                                    1,
                                                                    10000);

            m_baseFx.View       = m_cam.ViewMatrix;
            m_baseFx.Projection = projection;

            foreach (StickyBall ball in m_BallList)
            {
                m_baseFx.World = ball.Transform;
                Vector3 dir = ball.Position;
                dir.Normalize();
                m_baseFx.DirectionalLight0.Direction = dir;

                foreach (ModelMesh mesh in m_BallModel.Meshes)
                {
                    foreach (ModelMeshPart mp in mesh.MeshParts)
                    {
                        m_baseFx.GraphicsDevice.VertexDeclaration = mp.VertexDeclaration;

                        m_baseFx.Begin();
                        foreach (EffectPass pass in m_baseFx.CurrentTechnique.Passes)
                        {
                            pass.Begin();

                            m_baseFx.GraphicsDevice.Indices = mesh.IndexBuffer;

                            m_baseFx.GraphicsDevice.Vertices[0].SetSource(
                                mesh.VertexBuffer,
                                mp.StreamOffset,
                                mp.VertexStride);

                            m_baseFx.GraphicsDevice.DrawIndexedPrimitives(
                                PrimitiveType.TriangleList,
                                mp.BaseVertex, 0,
                                mp.NumVertices,
                                mp.StartIndex,
                                mp.PrimitiveCount);

                            pass.End();
                        }
                        m_baseFx.End();
                    }
                }
            }

            for (int xP = 0; xP < 40; xP++)
            {
                for (int yP = 0; yP < 1; yP++)
                {
                    for (int zP = 0; zP < 40; zP++)
                    {
                        int alterYPoint = (yP + yScan) % 40;

                        Vector3 gravPoint = new Vector3(
                            xP * 5.0f - 100.0f,
                            alterYPoint * 5.0f - 100.0f,
                            zP * 5.0f - 100.0f);

                        m_DebugRenderComp.WorldLine(
                            new Color(1, 0, 0, (yP + 0.5f) / 5.5f),
                            gravPoint,
                            gravPoint + (m_GravityPoints[xP, alterYPoint, zP] * 5.0f));
                    }
                }
            }

            base.Draw(gameTime);
        }
Ejemplo n.º 5
0
        public static void Draw(GameTime gameTime, Matrix view, Matrix projection)
        {
            // Update our effect with the matrices.
            effect.View       = view;
            effect.Projection = projection;

            // Calculate the total number of vertices we're going to be rendering.
            int vertexCount = 0;

            foreach (var shape in activeShapes)
            {
                vertexCount += shape.LineCount * 2;
            }

            // If we have some vertices to draw
            if (vertexCount > 0)
            {
                // Make sure our array is large enough
                if (verts.Length < vertexCount)
                {
                    // If we have to resize, we make our array twice as large as necessary so
                    // we hopefully won't have to resize it for a while.
                    verts = new VertexPositionColor[vertexCount * 2];
                }

                // Now go through the shapes again to move the vertices to our array and
                // add up the number of lines to draw.
                int lineCount = 0;
                int vertIndex = 0;
                foreach (DebugShape shape in activeShapes)
                {
                    lineCount += shape.LineCount;
                    int shapeVerts = shape.LineCount * 2;
                    for (int i = 0; i < shapeVerts; i++)
                    {
                        verts[vertIndex++] = shape.Vertices[i];
                    }
                }

                // Start our effect to begin rendering.
                effect.Begin();

                // We draw in a loop because the Reach profile only supports 65,535 primitives. While it's
                // not incredibly likely, if a game tries to render more than 65,535 lines we don't want to
                // crash. We handle this by doing a loop and drawing as many lines as we can at a time, capped
                // at our limit. We then move ahead in our vertex array and draw the next set of lines.
                int vertexOffset = 0;
                while (lineCount > 0)
                {
                    // Figure out how many lines we're going to draw
                    int linesToDraw = Math.Min(lineCount, 65535);

                    // Draw the lines
                    graphics.DrawUserPrimitives(PrimitiveType.LineList, verts, vertexOffset, linesToDraw);

                    // Move our vertex offset ahead based on the lines we drew
                    vertexOffset += linesToDraw * 2;

                    // Remove these lines from our total line count
                    lineCount -= linesToDraw;
                }
                effect.End();
            }

            // Go through our active shapes and retire any shapes that have expired to the
            // cache list.
            bool resort = false;

            for (int i = activeShapes.Count - 1; i >= 0; i--)
            {
                DebugShape s = activeShapes[i];
                s.Lifetime -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (s.Lifetime <= 0)
                {
                    cachedShapes.Add(s);
                    activeShapes.RemoveAt(i);
                    resort = true;
                }
            }

            // If we move any shapes around, we need to resort the cached list
            // to ensure that the smallest shapes are first in the list.
            if (resort)
            {
                cachedShapes.Sort(CachedShapesSort);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draws the static body
        /// </summary>
        ///
        public virtual void Draw()
        {
            // Rotation Disabled for Static Shapes

            /*if (Keyboard.GetState().IsKeyDown(Keys.Left))
             * {
             *  angle = 0.01f;
             *  //angle = MathHelper.Clamp(angle, -360, 360);
             *  Rotate(angle);
             * }
             * else if (Keyboard.GetState().IsKeyDown(Keys.Right))
             * {
             *  angle = -0.01f;
             *  //angle = MathHelper.Clamp(angle, -360, 360);
             *  Rotate(angle);
             * }*/


            //show bounding box
            if (Keyboard.GetState().IsKeyDown(Keys.B))
            {
                batch.Begin(PrimitiveType.LineList);
                //top line
                batch.AddVertex(new Vector2(BoundingBox.l, BoundingBox.t), Color.Green);
                batch.AddVertex(new Vector2(BoundingBox.r, BoundingBox.t), Color.Green);

                //left line
                batch.AddVertex(new Vector2(BoundingBox.l, BoundingBox.t), Color.Green);
                batch.AddVertex(new Vector2(BoundingBox.l, BoundingBox.b), Color.Green);

                //right line
                batch.AddVertex(new Vector2(BoundingBox.r, BoundingBox.t), Color.Green);
                batch.AddVertex(new Vector2(BoundingBox.r, BoundingBox.b), Color.Green);

                //bottom line
                batch.AddVertex(new Vector2(BoundingBox.l, BoundingBox.b), Color.Green);
                batch.AddVertex(new Vector2(BoundingBox.r, BoundingBox.b), Color.Green);
                batch.End();
            }

            graphics.VertexDeclaration = vertDecl;
            graphics.Indices           = indexBuffer;
            graphics.Vertices[0].SetSource(vertBuffer, 0, VertexPositionColor.SizeInBytes);

            // if holding 'W' key, render in wireframe
            if (Keyboard.GetState().IsKeyDown(Keys.W))
            {
                graphics.RenderState.FillMode = FillMode.WireFrame;
            }
            else
            {
                graphics.RenderState.FillMode = FillMode.Solid;
            }

            effect.Begin();
            effect.World = Matrix.CreateTranslation(new Vector3(GetScreenPosition(), 0));
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numVertices, 0, numPrimitives);
                pass.End();
            }
            effect.End();
        }
Ejemplo n.º 7
0
    public void Draw(Matrix projectionMatrix, Matrix viewMatrix)
    {
        if (!IsEnabled)
        {
            return;
        }

        mBasicEffect.Projection = projectionMatrix;
        mBasicEffect.World      = Matrix.Identity;
        mBasicEffect.View       = viewMatrix;

        bool savedDepthBuffer = mGraphicsDevice.RenderState.DepthBufferEnable;

        mGraphicsDevice.RenderState.DepthBufferEnable = true;

        #region Triangle primitives.
        // Change device states.
        FillMode savedFillMode = mGraphicsDevice.RenderState.FillMode;
        mGraphicsDevice.RenderState.FillMode = FillMode.WireFrame;
        mGraphicsDevice.VertexDeclaration    = mVertexDeclaration;

        foreach (Primitive p in mTrianglePrimitives)
        {
            // Index buffer.
            short[] triListIndices = new short[p.mVertices.Count];

            // Populate the array with references to indices in the vertex buffer.
            for (int i = 0; i < triListIndices.Length; i++)
            {
                triListIndices[i] = (short)i;
            }

            // Vertex buffer setup.
            VertexBuffer vertexBuffer = new VertexBuffer(
                mGraphicsDevice,
                VertexPositionColor.SizeInBytes * p.mVertices.Count,
                BufferUsage.None);

            vertexBuffer.SetData <VertexPositionColor>(p.mVertices.ToArray());

            // Effect setup.
            mBasicEffect.DiffuseColor = p.mColor.ToVector3();

            mBasicEffect.Begin();

            foreach (EffectPass pass in mBasicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();

                mGraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColor>(
                    PrimitiveType.TriangleList,
                    p.mVertices.ToArray(),                      // Vertex data.
                    0,                                          // Vertex buffer offset for each element in index buffer.
                    p.mVertices.Count,                          // # of vertices.
                    triListIndices,                             // Index buffer.
                    0,                                          // First index element to read.
                    p.mVertices.Count / 3                       // # of primitives to draw.
                    );

                pass.End();
            }
            mBasicEffect.End();
        }

        // Reset changed device states.
        mGraphicsDevice.RenderState.FillMode = savedFillMode;

        mTrianglePrimitives.Clear();
        #endregion

        #region Line primitives.
        foreach (Primitive p in mLinePrimitives)
        {
            // Index buffer.
            short[] lineListIndices = new short[p.mVertices.Count];

            // Populate the array with references to indices in the vertex buffer.
            for (int i = 0; i < lineListIndices.Length - 1; i += 2)
            {
                lineListIndices[i]     = (short)(i);
                lineListIndices[i + 1] = (short)(i + 1);
            }

            // Vertex buffer setup.
            VertexBuffer vertexBuffer = new VertexBuffer(
                mGraphicsDevice,
                VertexPositionColor.SizeInBytes * p.mVertices.Count,
                BufferUsage.None);

            vertexBuffer.SetData <VertexPositionColor>(p.mVertices.ToArray());

            // Effect setup.
            mBasicEffect.DiffuseColor = p.mColor.ToVector3();

            mGraphicsDevice.VertexDeclaration = mVertexDeclaration;

            mBasicEffect.Begin();

            foreach (EffectPass pass in mBasicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();

                mGraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColor>(
                    PrimitiveType.LineStrip,
                    p.mVertices.ToArray(),                      // Vertex data.
                    0,                                          // Vertex buffer offset for each element in index buffer.
                    p.mVertices.Count,                          // # of vertices.
                    lineListIndices,                            // Index buffer.
                    0,                                          // First index element to read.
                    p.mVertices.Count - 1                       // # of primitives to draw.
                    );

                pass.End();
            }
            mBasicEffect.End();
        }

        mLinePrimitives.Clear();
        #endregion

        #region Point primitives.
        foreach (Primitive p in mPointPrimitives)
        {
            if (p.mVertices.Count > 0)
            {
                // Vertex buffer setup.
                VertexBuffer pointVertexBuffer = new VertexBuffer(
                    mGraphicsDevice,
                    VertexPositionColor.SizeInBytes * p.mVertices.Count,
                    BufferUsage.None);

                pointVertexBuffer.SetData <VertexPositionColor>(p.mVertices.ToArray());

                // Effect setup.
                mBasicEffect.DiffuseColor = p.mColor.ToVector3();

                mGraphicsDevice.VertexDeclaration = mVertexDeclaration;

                mBasicEffect.Begin();

                foreach (EffectPass pass in mBasicEffect.CurrentTechnique.Passes)
                {
                    pass.Begin();

                    mGraphicsDevice.DrawUserPrimitives <VertexPositionColor>(
                        PrimitiveType.PointList,
                        p.mVertices.ToArray(),
                        0,
                        p.mVertices.Count
                        );

                    pass.End();
                }
                mBasicEffect.End();
            }
        }

        mPointPrimitives.Clear();
        #endregion

        #region Screen text.
        // Change device states.
        savedFillMode = mGraphicsDevice.RenderState.FillMode;
        mGraphicsDevice.RenderState.FillMode = FillMode.Solid;

        mBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);

        foreach (ScreenTextPrimitive st in mScreenText)
        {
            mBatch.DrawString(mFont, st.mText, st.mPos, st.mColor);
        }

        mBatch.End();

        // Reset changed device states.
        mGraphicsDevice.RenderState.FillMode = savedFillMode;

        mScreenText.Clear();
        #endregion

        mGraphicsDevice.RenderState.DepthBufferEnable = savedDepthBuffer;
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Allows physics to draw itself information, only if DebugMode state is activated
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Draw()
        {
            _camera = CamerasManager.Instance.GetActiveCamera();

            graphicsDevice.VertexDeclaration = new VertexDeclaration(graphicsDevice, VertexPositionColor.VertexElements);


            _visualizationEffect.World      = Matrix.Identity;
            _visualizationEffect.View       = _camera.View;
            _visualizationEffect.Projection = _camera.Projection;

            DebugRenderable data = Scene.GetDebugRenderable();

            _visualizationEffect.Begin();

            foreach (EffectPass pass in _visualizationEffect.CurrentTechnique.Passes)
            {
                pass.Begin();

                if (data.PointCount > 0)
                {
                    DebugPoint[] points = data.GetDebugPoints();

                    graphicsDevice.DrawUserPrimitives(PrimitiveType.PointList, points, 0, points.Length);
                }

                if (data.LineCount > 0)
                {
                    DebugLine[] lines = data.GetDebugLines();

                    var vertices = new VertexPositionColor[data.LineCount * 2];
                    for (int x = 0; x < data.LineCount; x++)
                    {
                        DebugLine line = lines[x];

                        vertices[x * 2 + 0] = new VertexPositionColor(line.Point0, Int32ToColor(line.Color));
                        vertices[x * 2 + 1] = new VertexPositionColor(line.Point1, Int32ToColor(line.Color));
                    }

                    graphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, vertices, 0, lines.Length);
                }

                if (data.TriangleCount > 0)
                {
                    DebugTriangle[] triangles = data.GetDebugTriangles();

                    var vertices = new VertexPositionColor[data.TriangleCount * 3];
                    for (int x = 0; x < data.TriangleCount; x++)
                    {
                        DebugTriangle triangle = triangles[x];

                        vertices[x * 3 + 0] = new VertexPositionColor(triangle.Point0, Int32ToColor(triangle.Color));
                        vertices[x * 3 + 1] = new VertexPositionColor(triangle.Point1, Int32ToColor(triangle.Color));
                        vertices[x * 3 + 2] = new VertexPositionColor(triangle.Point2, Int32ToColor(triangle.Color));
                    }

                    graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, triangles.Length);
                }

                pass.End();
            }

            _visualizationEffect.End();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Renders the scene.
        /// </summary>
        private void mWinForm_OnFrameRender(GraphicsDevice pDevice)
        {
            Device.RenderState.DepthBufferEnable      = true;
            Device.RenderState.DepthBufferWriteEnable = true;
            Device.RenderState.AlphaBlendEnable       = false;
            Device.RenderState.PointSize = 10.0f;

            // Configure effects
            m_HeadEffect.World      = this.mWorldMat;
            m_HeadEffect.View       = mViewMat;
            m_HeadEffect.Projection = mProjectionMat;

            m_BodyEffect.World      = this.mWorldMat;
            m_BodyEffect.View       = mViewMat;
            m_BodyEffect.Projection = mProjectionMat;

            m_SkeletonEffect.World      = this.mWorldMat;
            m_SkeletonEffect.View       = mViewMat;
            m_SkeletonEffect.Projection = mProjectionMat;
            m_SkeletonEffect.EnableDefaultLighting();

            if (m_RenderSim.GetHeadTexture() != null)
            {
                m_HeadEffect.Texture        = m_RenderSim.GetHeadTexture();
                m_HeadEffect.TextureEnabled = true;

                m_HeadEffect.EnableDefaultLighting();
            }

            if (m_RenderSim.GetBodyTexture() != null)
            {
                m_BodyEffect.Texture        = m_RenderSim.GetBodyTexture();
                m_BodyEffect.TextureEnabled = true;

                m_BodyEffect.EnableDefaultLighting();
            }

            m_HeadEffect.CommitChanges();
            m_BodyEffect.CommitChanges();
            m_SkeletonEffect.CommitChanges();

            if (m_LoadBodyComplete)
            {
                if (!m_RenderSkeleton)
                {
                    foreach (Face Fce in m_RenderSim.GetBodyMesh().FaceData)
                    {
                        // Draw
                        m_BodyEffect.Begin();
                        m_BodyEffect.Techniques[0].Passes[0].Begin();

                        VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                        Vertex[0] = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexA];
                        Vertex[1] = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexB];
                        Vertex[2] = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexC];

                        Vertex[0].TextureCoordinate = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexA].TextureCoordinate;
                        Vertex[1].TextureCoordinate = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexB].TextureCoordinate;
                        Vertex[2].TextureCoordinate = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexC].TextureCoordinate;

                        pDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                                                                                 Vertex, 0, 1);

                        m_BodyEffect.Techniques[0].Passes[0].End();
                        m_BodyEffect.End();
                    }

                    m_RenderSim.GetBodyMesh().TransformVertices(m_RenderSim.SimSkeleton.RootBone);
                    m_RenderSim.GetBodyMesh().ProcessMesh(m_RenderSim.SimSkeleton, false);
                }
                else
                {
                    DrawSkeleton(m_RenderSim.SimSkeleton);
                }
            }

            if (m_LoadHeadComplete)
            {
                foreach (Face Fce in m_RenderSim.GetHeadMesh().FaceData)
                {
                    // Draw
                    m_HeadEffect.Begin();
                    m_HeadEffect.Techniques[0].Passes[0].Begin();

                    VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                    Vertex[0] = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexA];
                    Vertex[1] = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexB];
                    Vertex[2] = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexC];

                    Vertex[0].TextureCoordinate = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexA].TextureCoordinate;
                    Vertex[1].TextureCoordinate = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexB].TextureCoordinate;
                    Vertex[2].TextureCoordinate = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexC].TextureCoordinate;

                    pDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                                                                             Vertex, 0, 1);

                    m_HeadEffect.Techniques[0].Passes[0].End();
                    m_HeadEffect.End();
                }

                m_RenderSim.GetHeadMesh().ProcessMesh(m_RenderSim.SimSkeleton, true);
            }
        }
Ejemplo n.º 10
0
        protected override void Draw()
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            GraphicsDevice.VertexDeclaration             = vertexDeclaration;
            GraphicsDevice.RenderState.DepthBufferEnable = true;

            GraphicsDevice.RenderState.CullMode = CullMode.None;

            textureEffect.World      = World;
            textureEffect.View       = View;
            textureEffect.Projection = Projection;

            textureEffect.EnableDefaultLighting();

            textureEffect.TextureEnabled = true;
            textureEffect.Texture        = glassTexture;

            textureEffect.DirectionalLight0.Enabled       = true;
            textureEffect.DirectionalLight0.DiffuseColor  = Vector3.One;
            textureEffect.DirectionalLight0.Direction     = Vector3.Normalize(new Vector3(1.0f, 1.0f, -1.0f));
            textureEffect.DirectionalLight0.SpecularColor = Vector3.One;

            textureEffect.Begin();

            foreach (EffectPass pass in textureEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                for (int i = 0; i < vertexData.Count; i++)
                {
                    GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                                                                                           vertexData[i], 0, vertexData[i].Length, indexData[i], 0, indexData[i].Length / 3);
                }

                /*GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                 *  vertexData, 0, vertexData.Length, indexDataTriangles, 0, indexDataTriangles.Length / 3);              */

                pass.End();
            }

            textureEffect.End();

            /* colorEffect.World = World;
             * colorEffect.View = View;
             * colorEffect.Projection = Projection;
             *
             * GraphicsDevice.VertexDeclaration = vertexDeclaration2;
             *
             * colorEffect.Begin();
             *
             * foreach (EffectPass pass in colorEffect.CurrentTechnique.Passes)
             * {
             *   pass.Begin();
             *
             *   GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
             * vertexData, 0, vertexData.Length, indexDataTriangles, 0, indexDataTriangles.Length / 3);
             *
             *
             *   pass.End();
             * }
             *
             * colorEffect.End();*/
        }
Ejemplo n.º 11
0
        public void Render()
        {
            if (selectedBoneIndex < 0 || renderedBonesCount == 0)
            {
                return;
            }
            Color DefaultBoneColor = new Color(Color.White, 0.35f);

            Armature.Bone selectedBone     = null;
            Vector3       selectedBoneProj = Vector3.Zero;

            VertexPositionColor[] points = new VertexPositionColor[renderedBonesCount];
            int j = 0;

            for (int i = 0; i < visibleBones.Count; i++)
            {
                Vector3 boneProj = visibleBonesProjections[i];
                if (boneProj.Z < 0)
                {
                    continue;
                }
                Color color;
                if (i == selectedBoneIndex)
                {
                    color            = Color.Red;
                    selectedBone     = visibleBones[i];
                    selectedBoneProj = boneProj;
                }
                else
                {
                    color = DefaultBoneColor;
                }
                points[j] = new VertexPositionColor(boneProj, color);
                j++;
            }

            graphicsDevice.RenderState.PointSize = 5;
            graphicsDevice.VertexDeclaration     = vertexDeclaration;

            graphicsDevice.RenderState.AlphaBlendEnable = true;
            graphicsDevice.RenderState.SourceBlend      = Blend.SourceAlpha;
            graphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;

            basicEffect.VertexColorEnabled = true;
            basicEffect.World      = Matrix.Identity;
            basicEffect.View       = viewMatrix;
            basicEffect.Projection = projectionMatrix;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                graphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.PointList, points, 0, points.Length);
                pass.End();
            }
            basicEffect.End();

            graphicsDevice.RenderState.AlphaBlendEnable = false;

            if (game.DisplayBoneNames && selectedBone != null)
            {
                spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
                int    x     = (int)Math.Round(selectedBoneProj.X);
                int    y     = (int)Math.Round(screenHeight - 1 - selectedBoneProj.Y - font.LineSpacing - 3);
                string label = selectedBone.name;
                spriteBatch.DrawString(font, label, new Vector2(x + 1, y + 1), Color.Black);
                spriteBatch.DrawString(font, label, new Vector2(x, y), Color.Yellow);
                spriteBatch.End();
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Draws the console to the screen if the console is currently open
        /// </summary>
        /// <param name="gameTime">The current game time</param>
        public override void Draw(GameTime gameTime)
        {
            if (!Enabled)
            {
                return;
            }

            IGraphicsDeviceService graphics =
                (IGraphicsDeviceService)Game.Services.GetService(typeof(IGraphicsDeviceService));

            // measure the height of a line in the current font
            float height = (mFontHeight + mVerticalSpacing) * (mVisibleLineCount + 1);

            // create vertices for the background quad
            Vector3[] vertices = new Vector3[]
            {
                new Vector3(0, 0, 0),
                new Vector3(graphics.GraphicsDevice.Viewport.Width, 0, 0),
                new Vector3(graphics.GraphicsDevice.Viewport.Width, height, 0),
                new Vector3(0, height, 0),
            };

            // create indices for the background quad
            short[] indices = new short[] { 0, 1, 2, 2, 3, 0 };

            // set the vertex declaration
            graphics.GraphicsDevice.VertexDeclaration = mVertexDeclaration;

            // create an orthographic projection to draw the quad as a sprite
            mEffect.Projection = Matrix.CreateOrthographicOffCenter(0,
                                                                    graphics.GraphicsDevice.Viewport.Width,
                                                                    graphics.GraphicsDevice.Viewport.Height, 0,
                                                                    0, 1);

            mEffect.DiffuseColor = mBackgroundColor.ToVector3();
            mEffect.Alpha        = mBackgroundAlpha;

            // save current blending mode
            bool blend = graphics.GraphicsDevice.RenderState.AlphaBlendEnable;

            // enable alpha blending
            graphics.GraphicsDevice.RenderState.AlphaBlendEnable          = true;
            graphics.GraphicsDevice.RenderState.AlphaBlendOperation       = BlendFunction.Add;
            graphics.GraphicsDevice.RenderState.SourceBlend               = Blend.SourceAlpha;
            graphics.GraphicsDevice.RenderState.DestinationBlend          = Blend.InverseSourceAlpha;
            graphics.GraphicsDevice.RenderState.SeparateAlphaBlendEnabled = false;

            mEffect.Begin();

            // draw the quad
            foreach (EffectPass pass in mEffect.CurrentTechnique.Passes)
            {
                pass.Begin();

                graphics.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList,
                                                                  vertices, 0, 4, indices, 0, 2);

                pass.End();
            }

            mEffect.End();

            // restore previous alpha blend
            graphics.GraphicsDevice.RenderState.AlphaBlendEnable = blend;

            // begin drawing the console text
            mSpriteBatch.Begin(SpriteBlendMode.AlphaBlend,
                               SpriteSortMode.Immediate, SaveStateMode.SaveState);

            // measure and draw the prompt
            float   promptsize = mFont.MeasureString(mInputPrompt + " ").X;
            Vector2 position   = new Vector2(mHorizontalPadding, height - mFontHeight - mVerticalSpacing);

            mSpriteBatch.DrawString(mFont, mInputPrompt + " ", position, mDefaultTextColor);
            position.X += promptsize;

            // measure and draw the current input text
            string current = mCurrentText.ToString();

            float cursorpos = position.X;

            cursorpos += mFont.MeasureString(current.Substring(0, mInputPosition)).X;

            if (cursorpos >= (graphics.GraphicsDevice.Viewport.Width - mHorizontalPadding))
            {
                position.X -= (cursorpos - (graphics.GraphicsDevice.Viewport.Width - mHorizontalPadding));
            }

            mSpriteBatch.DrawString(mFont, current, position, mDefaultTextColor);
            position.Y -= (mFontHeight + mVerticalSpacing);
            position.X  = mHorizontalPadding;

            // draw log text
            int messageIndex = (mLog.Count > 0) ? (mCurrentLine) : (-1);
            int lineIndex    = mVisibleLineCount;

            while ((messageIndex >= 0) && (lineIndex > 0))
            {
                if ((mDisplayLevelThreshold > 0) && (mLog[messageIndex].Level > (uint)mDisplayLevelThreshold))
                {
                    messageIndex--;
                    continue;
                }

                string text      = mLog[messageIndex].Text;
                Color  textcolor = (mTextColors.ContainsKey(mLog[messageIndex].Level))
                    ? (mTextColors[mLog[messageIndex].Level])
                    : (mDefaultTextColor);

                if ((mDisplayOptions & ConsoleDisplayOptions.LogLevel) == ConsoleDisplayOptions.LogLevel)
                {
                    text = text.Insert(0, string.Format("[{0}] ", mLog[messageIndex].Level));
                }

                if ((mDisplayOptions & ConsoleDisplayOptions.TimeStamp) == ConsoleDisplayOptions.TimeStamp)
                {
                    TimeSpan time      = mLog[messageIndex].RealTime;
                    string   timestamp = mTimestampFormat;

                    timestamp = timestamp.Replace("{Hr}", time.Hours.ToString());
                    timestamp = timestamp.Replace("{Min}", time.Minutes.ToString());
                    timestamp = timestamp.Replace("{Sec}", time.Seconds.ToString());
                    timestamp = timestamp.Replace("{Ms}", time.Milliseconds.ToString());

                    text = text.Insert(0, timestamp + " ");
                }

                List <string> lines = GetLines(graphics.GraphicsDevice.Viewport.Width, text);

                for (int i = lines.Count - 1; i >= 0; --i)
                {
                    mSpriteBatch.DrawString(mFont, lines[i], position, textcolor);

                    position.Y -= (mFontHeight + mVerticalSpacing);

                    if (--lineIndex <= 0)
                    {
                        break;
                    }
                }

                messageIndex--;
            }

            mSpriteBatch.End();

            // draw the cursor
            if (mDrawCursor)
            {
                position.Y           = height - mFontHeight - mVerticalSpacing;
                mEffect.DiffuseColor = mDefaultTextColor.ToVector3();
                mEffect.Alpha        = 1.0f;

                if (cursorpos >= (graphics.GraphicsDevice.Viewport.Width - mHorizontalPadding))
                {
                    cursorpos -= cursorpos - (graphics.GraphicsDevice.Viewport.Width - mHorizontalPadding);
                }

                Vector3[] cursorverts = new Vector3[]
                {
                    new Vector3(cursorpos, position.Y, 0),
                    new Vector3(cursorpos, position.Y + mFontHeight, 0),
                };

                graphics.GraphicsDevice.VertexDeclaration = mVertexDeclaration;

                mEffect.Begin();
                foreach (EffectPass pass in mEffect.CurrentTechnique.Passes)
                {
                    pass.Begin();
                    graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList,
                                                               cursorverts, 0, 1);
                    pass.End();
                }
                mEffect.End();
            }

            // Handle out-of-page notification
            if (mDrawNotify && (mCurrentLine < mLog.Count - 1))
            {
                float yofs = height - mFontHeight - (mVerticalSpacing * 1.5f);
                mEffect.DiffuseColor = mDefaultTextColor.ToVector3();
                mEffect.Alpha        = 1.0f;

                Vector3[] notifyverts = new Vector3[]
                {
                    new Vector3(0, yofs, 0),
                    new Vector3(graphics.GraphicsDevice.Viewport.Width, yofs, 0),
                };

                graphics.GraphicsDevice.VertexDeclaration = mVertexDeclaration;

                mEffect.Begin();
                foreach (EffectPass pass in mEffect.CurrentTechnique.Passes)
                {
                    pass.Begin();
                    graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList,
                                                               notifyverts, 0, 1);
                    pass.End();
                }
                mEffect.End();
            }

            base.Draw(gameTime);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(bgColor);

            GraphicsDevice.RenderState.CullMode = CullMode.None;

            GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionNormalTexture.VertexElements);

            effect.Texture = pistolPete;
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleStrip, frontVertices, 0, 2);
                pass.End();
            }
            effect.End();

            effect.Texture = osuLogo;
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleStrip, backVertices, 0, 2);
                pass.End();
            }
            effect.End();

            effect.Texture = red;
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleStrip, leftVertices, 0, 2);
                pass.End();
            }
            effect.End();

            effect.Texture = blue;
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleStrip, rightVertices, 0, 2);
                pass.End();
            }
            effect.End();

            effect.Texture = orange;
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleStrip, topVertices, 0, 2);
                pass.End();
            }
            effect.End();

            effect.Texture = black;
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleStrip, bottomVertices, 0, 2);
                pass.End();
            }
            effect.End();

            base.Draw(gameTime);
        }