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


C# GraphicsDevice.DrawUserIndexedPrimitives方法代码示例

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


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

示例1: DoDraw

        internal int DoDraw(GraphicsDevice device, Camera cam)
        {
            if (currentIndexIndex == 0)
            {
                return 0;
            }

            cam.BasicEffect.World = Matrix.Identity;
            cam.BasicEffect.VertexColorEnabled = hasColors;
            cam.BasicEffect.LightingEnabled = (!hasColors) && Light.HasLights;

            currentMaterial.SetTextureState(cam.BasicEffect);
            currentMaterial.SetBlendState(device);

            #if DEBUG
            if (Camera.logRenderCalls)
            {
                Debug.LogFormat("==> Dyn batch draw: {0} RQ {4} on {1} verts {2}, indices {3}", currentMaterial.mainTexture, cam.gameObject, currentVertexIndex, currentIndexIndex, currentMaterial.finalRenderQueue);
            }
            #endif

            foreach (EffectPass pass in cam.BasicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                if (hasColors)
                {
                    device.DrawUserIndexedPrimitives(
                        PrimitiveType.TriangleList,
                        vertexColorData,
                        0,
                        currentVertexIndex,
                        indexData,
                        0,
                        currentIndexIndex / 3
                    );
                }
                else
                {
                    device.DrawUserIndexedPrimitives(
                        PrimitiveType.TriangleList,
                        vertexData,
                        0,
                        currentVertexIndex,
                        indexData,
                        0,
                        currentIndexIndex / 3
                    );
                }
            }

            EndBatch();
            return 1;
        }
开发者ID:CodeHelix,项目名称:FFWD,代码行数:53,代码来源:DynamicBatchRenderer.cs

示例2: Draw

        public static void Draw(GraphicsDevice graphics, BasicEffect efeito, BasicEffect efeitoDeepWater)
        {
            //World, View, Projection
            efeito.World = Matrix.Identity; //* Matrix.CreateTranslation(new Vector3(- (float)(altura-1) / 2, -altura/6, - (float)(altura-1) / 2));
            efeito.View = Camera.View;
            efeito.Projection = Camera.Projection;

            //DEBUG
            //Desenhar normais
            //if (Camera.drawNormals)
            //{
            //    DebugShapeRenderer.SetWorld(efeito.World);
            //    for (int i = 0; i < vertexes.Length; i++)
            //    {
            //        DebugShapeRenderer.AddLine(vertexes[i].Position, vertexes[i].Position + vertexes[i].Normal, Color.Red);
            //    }
            //}

            // Define os filtros desejados

            graphics.SamplerStates[0] = sampler;

            // Commit the changes to basic effect so it knows you made modifications
            efeito.CurrentTechnique.Passes[0].Apply();

            //Desenhar
            for (int i = 0; i < width - 1; i++)
            {
                graphics.DrawUserIndexedPrimitives(PrimitiveType.TriangleStrip, vertexes, i * width,
                    width * 2, indexes, 0, width * 2 - 2);
            }

            //Levantar todos os vértices
            for (int i = 0; i < vertexes.Length; i++)
            {
                vertexes[i].Position.Y = vertexes[i].Position.Y + 0.21f;
            }

            //Desenhar novamente
            for (int i = 0; i < width - 1; i++)
            {
                graphics.DrawUserIndexedPrimitives(PrimitiveType.TriangleStrip, vertexes, i * width,
                    width * 2, indexes, 0, width * 2 - 2);
            }

            //Baixar todos os vértices
            for (int i = 0; i < vertexes.Length; i++)
            {
                vertexes[i].Position.Y = vertexes[i].Position.Y - 0.21f;
            }
        }
开发者ID:pedroabgmarques,项目名称:IP3D---3DTank,代码行数:51,代码来源:Water.cs

示例3: Draw

        // REVISIT This has magic numbers based on the size of the rendering area, need to fix.
        public void Draw(GraphicsDevice device, BasicEffect effect)
        {
            effect.View = viewMatrix;
            effect.World = Matrix.CreateFromQuaternion(Quaternion.Inverse( quatRotation )) * Matrix.CreateScale(0.5f) * Matrix.CreateTranslation(new Vector3(-2.75f,-1.5f,0) );

            effect.CurrentTechnique.Passes[0].Apply();

            device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, orthoVertices, 0, 6, orthoIndices, 0, 3);

            device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, letterXVertices, 0, 4, letterXIndices, 0, 2);

            device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, letterYVertices, 0, 4, letterYIndices, 0, 3);

            device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, letterZVertices, 0, 4, letterZIndices, 0, 3);
        }
开发者ID:Shnagenburg,项目名称:IsoHexEditor,代码行数:16,代码来源:VectorDirectionMarker.cs

示例4: Render

        /// <summary>
        /// Renders the bounding box for debugging purposes.
        /// </summary>
        /// <param name="box">The box to render.</param>
        /// <param name="graphicsDevice">The graphics device to use when rendering.</param>
        /// <param name="view">The current view matrix.</param>
        /// <param name="projection">The current projection matrix.</param>
        /// <param name="color">The color to use drawing the lines of the box.</param>
        public static void Render(
            BoundingBox box,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color color)
        {
            if (box.Min == box.Max)
            {
                return;
            }

            if (effect == null)
            {
                effect = new BasicEffect(graphicsDevice)
                             {TextureEnabled = false, VertexColorEnabled = true, LightingEnabled = false};
            }

            Vector3[] corners = box.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                verts[i].Position = corners[i];
                verts[i].Color = color;
            }

            effect.View = view;
            effect.Projection = projection;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, verts, 0, 8, indices, 0,
                                                         indices.Length/2);
            }
        }
开发者ID:HaKDMoDz,项目名称:4DBlockEngine,代码行数:43,代码来源:BoundingBoxRenderer.cs

示例5: RenderFullscreen

 public static void RenderFullscreen(GraphicsDevice graphicsDevice)
 {
     graphicsDevice.DrawUserIndexedPrimitives<VertexPositionTexture>(
        PrimitiveType.TriangleList,
        _fullscreenVertices,
        0, 4, _indices, 0, 2);
 }
开发者ID:JaakkoLipsanen,项目名称:Flai.XNA,代码行数:7,代码来源:QuadRenderer.cs

示例6: Render

        public static void Render(BoundingBox box,
                                  GraphicsDevice graphicsDevice,
                                  Matrix view,
                                  Matrix projection,
                                  Color color)
        {
            if (_effect.IsNull())
                _effect = new BasicEffect(graphicsDevice) { VertexColorEnabled = true, LightingEnabled = false };

            var corners = box.GetCorners();

            for (var i = 0; i < 8; i++)
            {
                Vertices[i].Position = corners[i];
                Vertices[i].Color = color;
            }

            _effect.View = view;
            _effect.Projection = projection;

            foreach (var pass in _effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList,
                                                         Vertices,
                                                         0,
                                                         8,
                                                         Indices,
                                                         0,
                                                         Indices.Length / 2);
            }
        }
开发者ID:naighes,项目名称:AsteroidChallenge,代码行数:32,代码来源:BoundingBoxRenderer.cs

示例7: Render

        public override void Render(GraphicsDevice myDevice, EffectPass pass)
        {
            pass.Apply();

            myDevice.Textures[0] = Texture;
            myDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, Vertices, 0, 4, Indexes, 0, 2);
        }
开发者ID:mikeschuld,项目名称:HMEngineXNA,代码行数:7,代码来源:HMQuad.cs

示例8: Render

        public static void Render(GraphicsDevice device, Color color)
        {
            BasicEffect _effect = new BasicEffect(device);
            _effect.Texture = new Texture2D(device, 1, 1);
            _effect.Texture.SetData<Color>(new Microsoft.Xna.Framework.Color[] { color });
            _effect.TextureEnabled = true;
            //_effect.VertexColorEnabled = true;

            VertexPositionTexture[] _vertices = new VertexPositionTexture[3];

            _vertices[0].Position = new Vector3(.5f,.5f,0);
            _vertices[1].Position = new Vector3(-.5f, -.5f, 0);
            _vertices[2].Position = new Vector3(.5f, 0f, 0);

            foreach (var pass in _effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                device.DrawUserIndexedPrimitives<VertexPositionTexture>
                (
                    PrimitiveType.TriangleStrip, // same result with TriangleList
                    _vertices,
                    0,
                    _vertices.Length,
                    new int[] { 0, 1, 2 },
                    0,
                    1
                );
            }

        }
开发者ID:charbean,项目名称:StrategyClean,代码行数:31,代码来源:PlanetMap.cs

示例9: Draw

        // These are all quite similar to hexagon.
        public void Draw(GraphicsDevice device, BasicEffect effect, int xOffset, int yOffset)
        {
            effect.World = HexHelper.CreateTranslationForHexGrid(xOffset, yOffset);

            effect.CurrentTechnique.Passes[0].Apply();
            device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, vertices, 0, 12, triangleStripIndices, 0, 12);
        }
开发者ID:Shnagenburg,项目名称:IsoHexEditor,代码行数:8,代码来源:HexTube.cs

示例10: Draw

        public static void Draw(this BoundingFrustum frustum, GraphicsDevice graphicsDevice, Matrix view, Matrix projection, Color color)
        {
            if (effect == null)
            {
                effect = new BasicEffect(graphicsDevice);
                effect.VertexColorEnabled = true;
                effect.LightingEnabled = false;
            }

            Vector3[] corners = frustum.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                verts[i].Position = corners[i];
                verts[i].Color = color;
            }

            effect.View = view;
            effect.Projection = projection;
            foreach (var t in effect.Techniques)
                foreach (var p in t.Passes)
                {
                    p.Apply();

                    graphicsDevice.DrawUserIndexedPrimitives(
                        PrimitiveType.LineList, verts, 0, 8,
                        indices, 0, indices.Length / 2);

                }
        }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:29,代码来源:FrustumPrimitive.cs

示例11: Draw

        public void Draw(GraphicsDevice gd)
        {
            drawEffect.World = Matrix.CreateTranslation(Position);

            drawEffect.DiffuseColor = new Vector3(1f, 1f - hitAlpha, 1f - hitAlpha);
            foreach (EffectPass pass in drawEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                AnimChunk c = shipSprite.AnimChunks[0];
                if (c == null) continue;

                if (c == null || c.VertexArray == null || c.VertexArray.Length == 0) continue;
                gd.DrawUserIndexedPrimitives<VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2);

            }

            drawEffect.World = Matrix.CreateScale(0.75f) * (Matrix.CreateRotationX(orbRotation.X) * Matrix.CreateRotationY(orbRotation.Y) * Matrix.CreateRotationZ(orbRotation.Z)) * Matrix.CreateTranslation(orbPosition);

            drawEffect.DiffuseColor = Color.White.ToVector3();

            foreach (EffectPass pass in drawEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                AnimChunk c = shipSprite.AnimChunks[1];
                if (c == null) continue;

                if (c == null || c.VertexArray == null || c.VertexArray.Length == 0) continue;
                gd.DrawUserIndexedPrimitives<VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2);
            }
        }
开发者ID:GarethIW,项目名称:VoxelShooter,代码行数:32,代码来源:Hero.cs

示例12: RenderToDevice

        public override void RenderToDevice(GraphicsDevice device, BasicEffect basicEffet)
        {
            if (Visible)
            {
                if (!basicEffet.LightingEnabled)
                {
                    if (isConstructed == false)
                        Construct();

                    using
                        (
                        VertexBuffer buffer = new VertexBuffer(
                        device,
                        VertexPositionColor.VertexDeclaration,
                        points,
                        BufferUsage.WriteOnly)
                      )
                    {
                        // Load the buffer
                        buffer.SetData(pointList);

                        // Send the vertex buffer to the device
                        device.SetVertexBuffer(buffer);
                        device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, pointList, 0, 6, lineListIndices, 0, 3);
                    }
                }
            }
        }
开发者ID:codec-abc,项目名称:3DIsoTetrisXNA,代码行数:28,代码来源:DummyObject.cs

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

示例14: Draw

 public void Draw(GraphicsDevice GraphicsDevice)
 {
     GraphicsDevice.DrawUserIndexedPrimitives
             <VertexPositionNormalTexture>(
             PrimitiveType.TriangleList,
             Vertices, 0, 4,
             Indexes, 0, 2);
 }
开发者ID:bh679,项目名称:CSCI35-Ass4-TeamBrennan,代码行数:8,代码来源:Quad.cs

示例15: Render

 public virtual void Render(GraphicsDevice device)
 {
     device.DrawUserIndexedPrimitives
         <VertexPositionNormalTexture>(
         PrimitiveType.TriangleList,
         vertices, 0, 4,
         indices, 0, 2);
 }
开发者ID:Tesserex,项目名称:Game-in-4D,代码行数:8,代码来源:Quad3D.cs


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