当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.VertexPositionColor类代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.VertexPositionColor的典型用法代码示例。如果您正苦于以下问题:C# VertexPositionColor类的具体用法?C# VertexPositionColor怎么用?C# VertexPositionColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VertexPositionColor类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了VertexPositionColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        public static void Draw(VertexPositionColor[] Points, Texture2D Texture)
        {
            //PUT IN DRAW CODE FOR PARTICLES HERE
            mGraphics.Peek.Device().RenderState.PointSpriteEnable = true;
            mGraphics.Peek.ToggleAlphaBlending(true);
            mGraphics.Peek.Device().RenderState.DepthBufferWriteEnable = false;
            mGraphics.Peek.Device().VertexDeclaration = mGraphics.Peek.vdPositionColor;
            mEffect.Peek.PointEffect().Parameters["WVPMatrix"].SetValue(Matrix.Identity * mCamera.Peek.ReturnCamera().View * mCamera.Peek.ReturnCamera().Projection);
            mEffect.Peek.PointEffect().Parameters["SpriteTexture"].SetValue(Texture);
            mEffect.Peek.PointEffect().Parameters["ViewportHeight"].SetValue(mGraphics.Peek.Device().Viewport.Height);
            mEffect.Peek.PointEffect().Parameters["ViewportHeight"].SetValue(25.0f);

            mEffect.Peek.PointEffect().Begin();
            for (int i = 0; i < mEffect.Peek.PointEffect().CurrentTechnique.Passes.Count; i++)
            {
                mEffect.Peek.PointEffect().CurrentTechnique.Passes[i].Begin();
                mGraphics.Peek.Device().DrawUserPrimitives<VertexPositionColor>(PrimitiveType.PointList, Points, 0, Points.Length);
                mEffect.Peek.PointEffect().CurrentTechnique.Passes[i].End();
            }
            mEffect.Peek.PointEffect().End();

            mGraphics.Peek.Device().RenderState.PointSpriteEnable = false;
            mGraphics.Peek.Device().RenderState.DepthBufferWriteEnable = true;
            mGraphics.Peek.ToggleAlphaBlending(false);
        }
开发者ID:apolaskey,项目名称:Inkwell,代码行数:25,代码来源:Particle.cs

示例2: RenderVertexPositionColorList

        public static void RenderVertexPositionColorList(GraphicsDevice gd, 
            BasicEffect effect, Matrix world, Matrix view, Matrix proj,
            VertexPositionColor[] vertices, VertexDeclaration vertexDeclaration,
            VertexBuffer vertex_buffer)
        {
            // gd.VertexDeclaration = vertexDeclaration;

              effect.World = world;
              effect.View = view;
              effect.Projection = proj;
              effect.VertexColorEnabled = true;

              if (vertex_buffer == null)
              {
            vertex_buffer = new VertexBuffer(gd, typeof(VertexPositionColor), vertices.Length, BufferUsage.WriteOnly);
            vertex_buffer.SetData<VertexPositionColor>(vertices);
              }

              foreach (EffectPass pass in effect.CurrentTechnique.Passes)
              {
              pass.Apply();
            gd.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, vertices.Length / 3);

              }
        }
开发者ID:DigitalLibrarian,项目名称:xna-forever,代码行数:25,代码来源:Renderer.cs

示例3: AABBTree

        public static AABBTree AABBTree(Model model, AABBNodeInfo tree_info)
        {
            List<TriangleVertexIndices> indices = new List<TriangleVertexIndices>();
              List<Vector3> points = new List<Vector3>();
              AABBFactory.ExtractData(model, points, indices, true);

              VertexPositionColor[] vertices = new VertexPositionColor[indices.Count * 3];

              List<float[]> triangles = new List<float[]>();

              int i = 0;
              foreach (TriangleVertexIndices index in indices)
              {
            vertices[i++] = new VertexPositionColor(points[index.I0], Color.White);
            vertices[i++] = new VertexPositionColor(points[index.I1], Color.White);
            vertices[i++] = new VertexPositionColor(points[index.I2], Color.White);

            float[] tri = new float[3];
            tri[0] = points[index.I0].X;
            tri[1] = points[index.I1].Y;
            tri[2] = points[index.I2].Z;
            triangles.Add(tri);
              }
              return new AABBTree(triangles, tree_info);
        }
开发者ID:DigitalLibrarian,项目名称:xna-forever,代码行数:25,代码来源:AABBFactory.cs

示例4: ReferenceAxis

        private ReferenceAxis()
        {
            vertices = new VertexPositionColor[3][];
            for (int x = 0; x < 3; x++)
            {
                vertices[x] = new VertexPositionColor[2];
                for (int y = 0; y < 2; y++)
                    vertices[x][y] = new VertexPositionColor();
            }

            vertices[0][0].Color = Color.Red;
            vertices[0][1].Color = Color.Red;
            vertices[1][0].Color = Color.Green;
            vertices[1][1].Color = Color.Green;
            vertices[2][0].Color = Color.Blue;
            vertices[2][1].Color = Color.Blue;

            // the first vertex is at the origin
            vertices[0][0].Position = Vector3.Zero;
            vertices[1][0].Position = Vector3.Zero;
            vertices[2][0].Position = Vector3.Zero;

            Size = 10;
            CreateLines();
        }
开发者ID:tuannsofta,项目名称:kinect4bag,代码行数:25,代码来源:ReferenceAxis.cs

示例5: InitializeGraphics

        public static void InitializeGraphics(GraphicsDevice graphicsDevice,
                                              Triangle[] triangles,
                                              Guid id)
        {
            var basicEffect = new BasicEffect(graphicsDevice)
                                  {
                                      LightingEnabled = false,
                                      VertexColorEnabled = false
                                  };

            var index = 0;
            var vertices = new VertexPositionColor[triangles.SelectMany(i => i.Points).Count()];

            foreach (var point in triangles.SelectMany(triangle => triangle.Points))
                vertices[index++] = new VertexPositionColor(new Vector3(point.X,
                                                                        point.Y,
                                                                        point.Z),
                                                            Color.White);

            var vertexBuffer = new VertexBuffer(graphicsDevice,
                                                typeof (VertexPositionColor),
                                                vertices.Length,
                                                BufferUsage.None);
            vertexBuffer.SetData(vertices);

            Subscriptions.Add(id, new RendererHelperData
                                       {
                                           BasicEffect = basicEffect,
                                           VertexBuffer = vertexBuffer
                                       });
        }
开发者ID:naighes,项目名称:AsteroidChallenge,代码行数:31,代码来源:TrianglesRenderer.cs

示例6: CollisionElement

 public CollisionElement(GraphicsDevice device)
 {
     _texture = new Texture2D(device, 1, 1);
     _texture.SetData(new Color[]{ Color.White });
     BoxCoords = new Rectangle();
     TriangleCoords = new VertexPositionColor[3];
 }
开发者ID:Grinderofl,项目名称:FlackoGame,代码行数:7,代码来源:CollisionElement.cs

示例7: InitVertices

        private void InitVertices()
        {
            vertices = new VertexPositionColor[30];

            vertices[0] = new VertexPositionColor(new Vector3(0, 0, 0), Color.White);
            vertices[1] = new VertexPositionColor(Vector3.Right * 5, Color.White);
            vertices[2] = new VertexPositionColor(new Vector3(5, 0, 0), Color.White);
            vertices[3] = new VertexPositionColor(new Vector3(4.5f, 0.5f, 0), Color.White);
            vertices[4] = new VertexPositionColor(new Vector3(5, 0, 0), Color.White);
            vertices[5] = new VertexPositionColor(new Vector3(4.5f, -0.5f, 0), Color.White);

            vertices[6] = new VertexPositionColor(new Vector3(0, 0, 0), Color.White);
            vertices[7] = new VertexPositionColor(Vector3.Up * 5, Color.White);
            vertices[8] = new VertexPositionColor(new Vector3(0, 5, 0), Color.White);
            vertices[9] = new VertexPositionColor(new Vector3(0.5f, 4.5f, 0), Color.White);
            vertices[10] = new VertexPositionColor(new Vector3(0, 5, 0), Color.White);
            vertices[11] = new VertexPositionColor(new Vector3(-0.5f, 4.5f, 0), Color.White);

            vertices[12] = new VertexPositionColor(new Vector3(0, 0, 0), Color.White);
            vertices[13] = new VertexPositionColor(-Vector3.Forward * 5, Color.White);
            vertices[14] = new VertexPositionColor(new Vector3(0, 0, 5), Color.White);
            vertices[15] = new VertexPositionColor(new Vector3(0, 0.5f, 4.5f), Color.White);
            vertices[16] = new VertexPositionColor(new Vector3(0, 0, 5), Color.White);
            vertices[17] = new VertexPositionColor(new Vector3(0, -0.5f, 4.5f), Color.White);
        }
开发者ID:kamilk,项目名称:asteroids,代码行数:25,代码来源:CoordCross.cs

示例8: Initialize

 public override void Initialize()
 {
    Sommets1 = new VertexPositionColor[NB_SOMMETS];
    Sommets2 = new VertexPositionColor[NB_SOMMETS];
    PositionsSommets = new Vector3[NB_POSITIONS_SOMMETS];
    base.Initialize();
 }
开发者ID:karmoka,项目名称:ProjetFinalIntegrationSIM,代码行数:7,代码来源:CubeColoré.cs

示例9: Draw

        public static void Draw(this Fixture fixture, GraphicsDevice graphics, Color color, Matrix? matrix = null)
        {
            VertexPositionColor[] vertices;

            switch (fixture.ShapeType)
            {
                case ShapeType.Polygon:
                    {
                        vertices = ((PolygonShape)fixture.Shape).ToVertices(color, matrix);
                    }
                    break;
                case ShapeType.Circle:
                    {
                        CircleShape circle = ((CircleShape)fixture.Shape);

                        vertices = new VertexPositionColor[]
                    {
                        new VertexPositionColor(new Vector3(Vector2.Transform(Vector2.Zero, matrix ?? Matrix.Identity), 0.0f), color),
                        new VertexPositionColor(new Vector3(Vector2.Transform(new Vector2(circle.Radius), matrix ?? Matrix.Identity), 0.0f), color)
                    };
                    }
                    break;
                default: throw new InvalidOperationException(String.Format("Unable to render ShapeType {0}", fixture.ShapeType));
            }

            graphics.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, vertices, 0, vertices.Length - 1);
        }
开发者ID:simon-engledew,项目名称:square-battle,代码行数:27,代码来源:FixtureExtensions.cs

示例10: DrawSphereSpikes

        public static void DrawSphereSpikes(BoundingSphere sphere, GraphicsDevice device, BasicEffect basicEffect, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix)
        {
            Vector3 up = sphere.Center + sphere.Radius * Vector3.Up;
            Vector3 down = sphere.Center + sphere.Radius * Vector3.Down;
            Vector3 right = sphere.Center + sphere.Radius * Vector3.Right;
            Vector3 left = sphere.Center + sphere.Radius * Vector3.Left;
            Vector3 forward = sphere.Center + sphere.Radius * Vector3.Forward;
            Vector3 back = sphere.Center + sphere.Radius * Vector3.Backward;

            VertexPositionColor[] sphereLineVertices = new VertexPositionColor[6];
            sphereLineVertices[0] = new VertexPositionColor(up, Color.White);
            sphereLineVertices[1] = new VertexPositionColor(down, Color.White);
            sphereLineVertices[2] = new VertexPositionColor(left, Color.White);
            sphereLineVertices[3] = new VertexPositionColor(right, Color.White);
            sphereLineVertices[4] = new VertexPositionColor(forward, Color.White);
            sphereLineVertices[5] = new VertexPositionColor(back, Color.White);

            basicEffect.World = worldMatrix;
            basicEffect.View = viewMatrix;
            basicEffect.Projection = projectionMatrix;
            basicEffect.VertexColorEnabled = true;
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
               // device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
                device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, sphereLineVertices, 0, 3);
            }
        }
开发者ID:vvolkgang,项目名称:WarZ,代码行数:28,代码来源:XNAUtils.cs

示例11: ChangeColour

 /// <summary>
 /// Change the colour of an existing list of type VertexPositionColor
 /// </summary>
 /// <param name="pointList">Array of points</param>
 /// <param name="colour">The colour e.g. Color.White or Color.Red</param>
 public void ChangeColour(ref VertexPositionColor[] pointList, Color colour)
 {
     for (int i = 0; i < pointList.Length; i++)
     {
         pointList[i].Color = colour;
     }
 }
开发者ID:dargonesti,项目名称:AsteroidsGame,代码行数:12,代码来源:Shapes.cs

示例12: DrawBoundingBox

        public static void DrawBoundingBox(BoundingBox bBox, GraphicsDevice device, BasicEffect basicEffect, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix)
        {
            Vector3 v1 = bBox.Min;
            Vector3 v2 = bBox.Max;

            VertexPositionColor[] cubeLineVertices = new VertexPositionColor[8];
            cubeLineVertices[0] = new VertexPositionColor(v1, Color.White);
            cubeLineVertices[1] = new VertexPositionColor(new Vector3(v2.X, v1.Y, v1.Z), Color.Red);
            cubeLineVertices[2] = new VertexPositionColor(new Vector3(v2.X, v1.Y, v2.Z), Color.Green);
            cubeLineVertices[3] = new VertexPositionColor(new Vector3(v1.X, v1.Y, v2.Z), Color.Blue);

            cubeLineVertices[4] = new VertexPositionColor(new Vector3(v1.X, v2.Y, v1.Z), Color.White);
            cubeLineVertices[5] = new VertexPositionColor(new Vector3(v2.X, v2.Y, v1.Z), Color.Red);
            cubeLineVertices[6] = new VertexPositionColor(v2, Color.Green);
            cubeLineVertices[7] = new VertexPositionColor(new Vector3(v1.X, v2.Y, v2.Z), Color.Blue);

            short[] cubeLineIndices = { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 };

            basicEffect.World = worldMatrix;
            basicEffect.View = viewMatrix;
            basicEffect.Projection = projectionMatrix;
            basicEffect.VertexColorEnabled = true;

            device.RasterizerState = _solidRasterizer;
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, cubeLineVertices, 0, 8, cubeLineIndices, 0, 12);
            }
        }
开发者ID:vvolkgang,项目名称:WarZ,代码行数:30,代码来源:XNAUtils.cs

示例13: StartDrawing

 private unsafe void StartDrawing(VertexFragment vertexFragment, out VertexPositionColor* vertices, out VertexPositionNormalTexture* textures, out short* indices, out short baseIndex)
 {
     textures = null;
     if (vertexFragment.PrimitiveType == PrimitiveType.LineList)
     {
         if ((this.SortMode == DrawingSortMode.Order) && (this._triangleVertexCount > 0))
         {
             Flush();
             StartLineDrawing(vertexFragment, out vertices, out indices, out baseIndex);
         }
         else
         {
             StartLineDrawing(vertexFragment, out vertices, out indices, out baseIndex);
         }
     }
     else if (vertexFragment.PrimitiveType == PrimitiveType.TriangleList)
     {
         if ((this.SortMode == DrawingSortMode.Order) && (this._lineVertexCount > 0))
         {
             Flush();
             StartTriangleDrawing(vertexFragment, out vertices, out textures, out indices, out baseIndex);
         }
         else
         {
             StartTriangleDrawing(vertexFragment, out vertices, out textures, out indices, out baseIndex);
         }
     }
     else
     {
         throw new NotSupportedException(string.Format("PrimitiveType: {0} is not supported.", vertexFragment.PrimitiveType));
     }
 }
开发者ID:mind0n,项目名称:hive,代码行数:32,代码来源:DrawingBatch.cs

示例14: DebugDrawPolyline

 public static void DebugDrawPolyline(DebugDrawContext context, params Vector2[] vertices)
 {
     var vertexData = new VertexPositionColor[vertices.Length];
     for (int i = 0; i < vertices.Length; i++)
         vertexData[i] = new VertexPositionColor(new Vector3(vertices[i], DEBUG_DRAW_Z), context.Color);
     DebugDraw(context, vertexData, PrimitiveType.LineStrip);
 }
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:7,代码来源:Graphics3D.cs

示例15: Draw

        public void Draw(GameTime gameTime, BoundingFrustum VisibleArea)
        {
            if (units.Count > 0)
            {
                VertexPositionColor[] display = new VertexPositionColor[units.Count * 2];
                int[] pointIndex = new int[units.Count];
                for (int i = 0; i < units.Count; i++)
                {
                    display[i * 2] = new VertexPositionColor(units[i].Position, DisplayColor);
                    pointIndex[i] = i * 2;
                    if (units[i].Target != null)
                    {
                        display[i * 2 + 1] = new VertexPositionColor(units[i].Target.Position, DisplayColor);
                    }
                    else
                    {
                        display[i * 2 + 1] = display[i * 2];
                    }
                }

                Manager.ResetFor3D();
                MyGame.graphics.GraphicsDevice.VertexDeclaration = UnitDeclaration;
                MyGame.graphics.GraphicsDevice.RenderState.PointSize = 5.0f;
                Manager.OrdinaryEffect.CurrentTechnique = Manager.OrdinaryEffect.Techniques["Ordinary"];
                Manager.OrdinaryEffect.Parameters["World"].SetValue(Matrix.Identity);
                Manager.OrdinaryEffect.Begin();
                Manager.OrdinaryEffect.CurrentTechnique.Passes.First<EffectPass>().Begin();
                MyGame.graphics.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, display, 0, display.Length / 2);
                MyGame.graphics.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.PointList, display, 0, display.Length
                    , pointIndex, 0, pointIndex.Length);
                Manager.OrdinaryEffect.CurrentTechnique.Passes.First<EffectPass>().End();
                Manager.OrdinaryEffect.End();
            }
        }
开发者ID:kaysoky,项目名称:RealTimeStrategyEngine,代码行数:34,代码来源:Controller.cs


注:本文中的Microsoft.Xna.Framework.Graphics.VertexPositionColor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。