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


C# GraphicsDevice.DrawUserPrimitives方法代码示例

本文整理汇总了C#中GraphicsDevice.DrawUserPrimitives方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.DrawUserPrimitives方法的具体用法?C# GraphicsDevice.DrawUserPrimitives怎么用?C# GraphicsDevice.DrawUserPrimitives使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice.DrawUserPrimitives方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: Draw

        public static void Draw(Matrix World, Matrix View, Matrix Projection, GraphicsDevice graphics, Matrix world)
        {
            //World, View, Projection
            efeito.World = world;
            efeito.View = View;
            efeito.Projection = Projection;

            //Iluminação
            efeito.VertexColorEnabled = true;

            //Fog
            efeito.FogEnabled = true;
            efeito.FogColor = Vector3.Zero;
            efeito.FogStart = Camera.nearPlane;
            efeito.FogEnd = Camera.farPlaneShort;

            //Load the buffer
            vertexBuffer.SetData(vertexList);

            // Send the vertex buffer to the device
            graphics.SetVertexBuffer(vertexBuffer);

            foreach (EffectPass pass in efeito.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.DrawUserPrimitives(PrimitiveType.LineList, vertexList, 0, 3);
            }
        }
开发者ID:pedroabgmarques,项目名称:IP3D,代码行数:28,代码来源:Create3DAxis.cs

示例3: 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

示例4: drawBigbuffer

        public void drawBigbuffer(DrawabeElement element, int[] index, Camera came, GraphicsDevice graphicsDevice, bool trans)
        {
            WIREFRAME_RASTERIZER_STATE = new RasterizerState() { CullMode = CullMode.CullClockwiseFace, FillMode = FillMode.Solid };

            graphicsDevice.RasterizerState = WIREFRAME_RASTERIZER_STATE;

            // draw in wireframe

            if (trans)
            {
                graphicsDevice.BlendState = BlendState.AlphaBlend;

            }
            else
            {
                graphicsDevice.BlendState = BlendState.Opaque;
            }

            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            //   effect.DiffuseColor = Color.Red.ToVector3();
            element.effect.View = came.getview();
            element.effect.CurrentTechnique.Passes[0].Apply();
            // vb.GetData<VertexPositionNormalTexture>(vertexData);

            graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, element.vpc, 0, element.vpc.Count() / 3);
            // graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, vertexData.Count(), index, 0, index.Count() / 3);
        }
开发者ID:Jupotter,项目名称:Nameless-Tales,代码行数:28,代码来源:DrawThings.cs

示例5: Draw

        public void Draw(GraphicsDevice device, Matrix view, Matrix projection, SpriteBatch batch, SpriteFont font)
        {
            vertices[0] = new VertexPositionColor(from, color);
            vertices[1] = new VertexPositionColor(to,   color);

            Vector3 delt = Vector3.Multiply(Vector3.Subtract(to, from), 0.1f);

            Vector3 perp = Vector3.Cross(Vector3.Forward, delt);
            Vector3 arrowBase = Vector3.Subtract(to, delt);

            vertices[2] = new VertexPositionColor(Vector3.Add(arrowBase, perp), color);
            vertices[3] = new VertexPositionColor(to, color);
            vertices[4] = new VertexPositionColor(Vector3.Subtract(arrowBase, perp), color);
            vertices[5] = new VertexPositionColor(to, color);

            effect.World = Matrix.Identity;
            effect.View = view;
            effect.Projection = projection;
            effect.VertexColorEnabled = true;
            effect.LightingEnabled = false;

            for (int i = 0; i < effect.CurrentTechnique.Passes.Count; ++i)
            {
                effect.CurrentTechnique.Passes[i].Apply();
                device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, 3);
            }

            Vector3 txtPos = device.Viewport.Project(Vector3.Lerp(from, to, 0.5f), projection, view, Matrix.Identity);
            Console.WriteLine(txtPos.ToString());
            batch.DrawString(font, text, new Vector2(txtPos.X + 20, txtPos.Y - 10), color);
        }
开发者ID:omanamos,项目名称:kinect-nao,代码行数:31,代码来源:LabelledVector.cs

示例6: Render

        public void Render(GraphicsDevice graphicsDevice)
        {
            // If we don't have _P, grab it from the current gameInstance.
            // We can't do this in the constructor because we are created in the property bag's constructor!
            if (_P == null)
                _P = gameInstance.propertyBag;

            // Draw the skybox.
            Matrix viewMatrix = _P.playerCamera.ViewMatrix;
            Matrix projectionMatrix = _P.playerCamera.ProjectionMatrix;

            effect.CurrentTechnique = effect.Techniques["Skyplane"];
            effect.Parameters["xWorld"].SetValue(Matrix.Identity);
            effect.Parameters["xView"].SetValue(viewMatrix);
            effect.Parameters["xProjection"].SetValue(projectionMatrix);
            effect.Parameters["xTexture"].SetValue(texNoise);
            effect.Parameters["xTime"].SetValue(effectTime);
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                graphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Point;
                graphicsDevice.RenderState.CullMode = CullMode.None;
                graphicsDevice.RenderState.DepthBufferEnable = false;
                graphicsDevice.VertexDeclaration = vertexDeclaration;
                graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3);
                graphicsDevice.RenderState.DepthBufferEnable = true;
                pass.End();
            }
            effect.End();
        }
开发者ID:GlennSandoval,项目名称:Infiniminer,代码行数:31,代码来源:SkyboxEngine.cs

示例7: DrawTile

        public static void DrawTile(Camera aCamera, GraphicsDevice aDevice, int xPos, int yPos, int width, int height, Color aColor)
        {
            if (_Effect2D == null)
                Initialize(aCamera, aDevice);

            // TODO: All of this has to be fixed.  This is the most ineffecient drawing code ever.
            Matrix world = Matrix.CreateTranslation(new Vector3(xPos, yPos, 0.0f));

            _Effect2D.World = world;

            VertexPositionColor[] tileVerts = new VertexPositionColor[] {
                new VertexPositionColor(new Vector3(0.0f, 0.0f, 0.0f), aColor),
                new VertexPositionColor(new Vector3(width, 0.0f, 0.0f), aColor),
                new VertexPositionColor(new Vector3(width, height, 0.0f), aColor),
                new VertexPositionColor(new Vector3(0.0f, 0.0f, 0.0f), aColor),
                new VertexPositionColor(new Vector3(width, height, 0.0f), aColor),
                new VertexPositionColor(new Vector3(0.0f, height, 0.0f), aColor)
            };

            _Effect2D.Begin();
            foreach (EffectPass pass in _Effect2D.CurrentTechnique.Passes)
            {
                pass.Begin();
                aDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, tileVerts, 0, 2);
                pass.End();
            }
            _Effect2D.End();
        }
开发者ID:darrentorpey,项目名称:define_yourself,代码行数:28,代码来源:DrawUtil.cs

示例8: Draw

        public override void Draw(GraphicsDevice device, GameTime gameTime)
        {
            if (!setup)
            {
                SetUpVertices(device);
                SetUpCamera(device);
                setup = true;
            }

            Matrix worldMatrix = Matrix.Identity;
            shader.CurrentTechnique = shader.Techniques["Textured"];
            shader.Parameters["xWorld"].SetValue(worldMatrix);
            shader.Parameters["xView"].SetValue(viewMatrix);
            shader.Parameters["xProjection"].SetValue(projectionMatrix);
            shader.Parameters["xTexture"].SetValue(snow);
            shader.Begin();

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

                device.VertexDeclaration = texturedVertexDeclaration;
                device.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 2);

                pass.End();
            }
            shader.End();

            particleSystem.SetWorldViewProjectionMatrices(Matrix.Identity, viewMatrix, projectionMatrix);

            particleSystem.Draw();
        }
开发者ID:ncallaway,项目名称:Song-of-Ice,代码行数:32,代码来源:SnowHelper.cs

示例9: draw3d

 public override void draw3d(Microsoft.Xna.Framework.GameTime gameTime, GameState.AbstractGameState state, GraphicsDevice device)
 {
     device.DepthStencilState = DepthStencilState.Default;
     foreach (int id in entityIds[0])
     {
        Model3D modelComponent = entityManager.getEntity(id).getComponent<Model3D>();
        Effect effect = EffectLibrary.basicEffect;
        effect.CurrentTechnique = effect.Techniques["Textured"];
        effect.Parameters["xWorld"].SetValue(Matrix.CreateScale(modelComponent.getScale() * 10)
            * Matrix.CreateFromQuaternion(modelComponent.getRotation()) * Matrix.CreateTranslation(modelComponent.getLocation()));
        effect.Parameters["xView"].SetValue(viewMatrix);
        effect.Parameters["xProjection"].SetValue(projectionMatrix);
        effect.Parameters["xEnableLighting"].SetValue(true);
        Vector3 light = new Vector3(2, -20, 0);
        light.Normalize();
        effect.Parameters["xLightDirection"].SetValue(light);
        effect.Parameters["xAmbient"].SetValue(0.4f);
        effect.Parameters["xTexture"].SetValue(EditorContent.face);
        foreach (EffectPass pass in effect.CurrentTechnique.Passes)
        {
            pass.Apply();
            VertexPositionNormalTexture[] vertices = ModelLibrary.getModelFromId(modelComponent.getModelIndex()).getVertices();
            device.DrawUserPrimitives(PrimitiveType.TriangleList, vertices
                , 0, vertices.Length / 3, VertexPositionNormalTexture.VertexDeclaration);
        }
     }
 }
开发者ID:AliMohsen,项目名称:untitled-game,代码行数:27,代码来源:MapDraw3DService.cs

示例10: Draw

 /// <summary>
 /// Draw
 /// </summary>
 /// <param name="graphicsDevice"></param>
 /// <param name="basicEffect"></param>
 public override void Draw(GraphicsDevice graphicsDevice, BasicEffect basicEffect)
 {
     if (this.IsVisible)
     {
         basicEffect.CurrentTechnique.Passes[0].Apply();
         graphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, CameraTransform(this.Vertices), 0, 1);
     }
 }
开发者ID:Zuver,项目名称:capture-the-flag,代码行数:13,代码来源:LinePrimitive.cs

示例11: Draw

 public override void Draw(GraphicsDevice graphicsDevice, Effect effect)
 {
     foreach (var pass in effect.CurrentTechnique.Passes)
     {
         pass.Apply();
         graphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, Vertices, 0, 1);
     }
 }
开发者ID:ruicaridade,项目名称:IP3D,代码行数:8,代码来源:RainDrop.cs

示例12: Draw

 public void Draw( GraphicsDevice graphics, Effect effect, GameTime gameTime )
 {
     effect.Parameters[ "modelTexture" ]?.SetValue( Texture );
     foreach ( EffectPass pass in effect.CurrentTechnique.Passes )
     {
         pass.Apply();
         graphics.DrawUserPrimitives( PrimitiveType.TriangleList, mVertexData, 0, 2 );
     }
 }
开发者ID:armorproof,项目名称:COMP7051Assn3,代码行数:9,代码来源:MazeWall.cs

示例13: DrawPixel

 public static void DrawPixel( GraphicsDevice gd, int x, int y, Color color, Texture2D target )
 {
     SetupForPrimitiveDraw(gd);
     gd.DrawUserPrimitives(
         PrimitiveType.LineList, new [] {
             new PrimitiveVertex(x, y, color),
             new PrimitiveVertex(x + 1, y, color)
         }, 0, 1, PrimitiveVertexDeclaration
     );
 }
开发者ID:Gayo,项目名称:XNAVERGE,代码行数:10,代码来源:Box.cs

示例14: Draw

 public static void Draw(float yPos, float worldScreenWidth, GraphicsDevice gd, Game1 game, GameTime gameTime, Random rand, Viewport viewport)
 {
     float xPosition = 0.0f;
     float yPosition = -yPos;
     float zPosition = 0.0f;
     if (PrimitiveDrawing.shaking)
     {
         PrimitiveDrawing.shakeTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
         if ((double)PrimitiveDrawing.shakeTimer >= (double)PrimitiveDrawing.shakeDuration)
         {
             PrimitiveDrawing.shaking = false;
             PrimitiveDrawing.shakeTimer = PrimitiveDrawing.shakeDuration;
         }
         float num1 = PrimitiveDrawing.shakeTimer / PrimitiveDrawing.shakeDuration;
         float num2 = PrimitiveDrawing.shakeMagnitude * (float)(1.0 - (double)num1 * (double)num1);
         xPosition = (float)(rand.NextDouble() * 2.0 - 1.0) * num2;
         yPosition += (float)(rand.NextDouble() * 2.0 - 1.0) * num2;
     }
     PrimitiveDrawing.basicEffect = new BasicEffect(gd)
     {
         Projection = Matrix.CreateOrthographic(worldScreenWidth, worldScreenWidth / gd.Viewport.AspectRatio, 0.0f, 1f),
         View = Matrix.CreateTranslation(xPosition, yPosition, zPosition),
         VertexColorEnabled = true
     };
     foreach (Body body in PrimitiveDrawing.world.BodyList)
     {
         if (body != game.highScoreLine || body.UserData == (ValueType)Mine.MineColor)
             PrimitiveDrawing.DrawBody(body);
     }
     PrimitiveDrawing.DrawBody(game.highScoreLine);
     gd.Viewport = viewport;
     foreach (EffectPass effectPass in PrimitiveDrawing.basicEffect.CurrentTechnique.Passes)
     {
         effectPass.Apply();
         if (PrimitiveDrawing.TriangleVerts.Count > 0)
             gd.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, PrimitiveDrawing.TriangleVerts.ToArray(), 0, PrimitiveDrawing.TriangleVerts.Count / 3);
         if (PrimitiveDrawing.LineVerts.Count > 0)
             gd.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, PrimitiveDrawing.LineVerts.ToArray(), 0, PrimitiveDrawing.LineVerts.Count / 2);
     }
     PrimitiveDrawing.LineVerts.Clear();
     PrimitiveDrawing.TriangleVerts.Clear();
 }
开发者ID:Learn-app-ios,项目名称:FallingBombs,代码行数:42,代码来源:PrimitiveDrawing.cs

示例15: LineList

        public static void LineList(GraphicsDevice g, VertexPositionColor[] lines)
        {
            BasicEffect e = Shaders.Primitive;

            e.Begin();
            e.CurrentTechnique.Passes[0].Begin();
            g.VertexDeclaration = new VertexDeclaration(g, VertexPositionColor.VertexElements);
            g.DrawUserPrimitives(PrimitiveType.LineList, lines, 0, lines.Length / 2);
            e.CurrentTechnique.Passes[0].End();
            e.End();
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:11,代码来源:Draw.cs


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