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


C# Microsoft.DrawUserIndexedPrimitives方法代码示例

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


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

示例1: Draw

        public override void Draw(Microsoft.Xna.Framework.Graphics.GraphicsDevice device, Camera cam)
        {
            if (!useWorldSpace)
            {
                //transform local positions to world space
                for (int i = 0; i < pointCnt; i++)
                {
                    transformedPositions[i] = transform.TransformPoint(positions[i]);
                }
                Rebuild(transformedPositions, pointCnt, cam.transform.position);
            }
            else
            {
                Rebuild(positions, pointCnt, cam.transform.position);
            }

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

            cam.BasicEffect.VertexColorEnabled = true;
            cam.BasicEffect.LightingEnabled = false;

            foreach (EffectPass pass in cam.BasicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawUserIndexedPrimitives<VertexPositionColorTexture>(
                    PrimitiveType.TriangleList,
                    vertexPositionColorTextures,
                    0,
                    pointCnt * 2,
                    triangleIndexData,
                    0,
                    (pointCnt-1) * 2
                );
            }
        }
开发者ID:Joelone,项目名称:FFWD,代码行数:36,代码来源:LineRenderer.cs

示例2: OnDraw

        public override void OnDraw(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice,
                                    VikingXNA.Scene scene,
                                    Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect)
        {
            if (this.oldMouse == null)
                return;

            if (basicEffect == null)
                throw new ArgumentNullException("basicEffect");

            if (scene == null)
                throw new ArgumentNullException("scene");

            //Draw a line from the selected location to the new location if we are holding left button down
            if (this.oldMouse.Button == MouseButtons.Left)
            {
                SectionLocationsViewModel sectionAnnotations = AnnotationOverlay.GetAnnotationsForSection(Parent.Section.Number);
                if (sectionAnnotations == null)
                    return;

                GridVector2 selectedPos = selected.VolumePosition;
                /*bool found = sectionAnnotations.TryGetPositionForLocation(selected, out selectedPos);
                if (found == false)
                    return;
                */

                //PORT XNA 4
                /*
                VertexDeclaration oldVertexDeclaration = graphicsDevice.VertexDeclaration;
                graphicsDevice.VertexDeclaration = Parent.VertexPositionColorDeclaration;
                graphicsDevice.RenderState.PointSize = 5.0f;
                */

                basicEffect.Texture = null;
                basicEffect.TextureEnabled = false;
                basicEffect.VertexColorEnabled = true;

                //PORT XNA 4
                //basicEffect.CommitChanges();

                //Draw the new location
                if (LocType != null && selected.Section == Parent.Section.Number)
                {
                    Microsoft.Xna.Framework.Color color = new Microsoft.Xna.Framework.Color(LocType.Color.R,
                        LocType.Color.G,
                        LocType.Color.B,
                        128);

                    GlobalPrimitives.DrawCircle(graphicsDevice, basicEffect, this.oldWorldPosition, selected.Radius, color);
                }
                else
                {

                    VertexPositionColor[] verts = new VertexPositionColor[] {
                                                        new VertexPositionColor(new Vector3((float)selectedPos.X, (float)selectedPos.Y, 0f), Color.Gold),
                                                        new VertexPositionColor(new Vector3((float)this.oldWorldPosition.X, (float)oldWorldPosition.Y, 0f), Color.Gold)};

                    int[] indicies = new int[] { 0, 1 };

                    //PORT XNA 4
                    //basicEffect.Begin();

                    foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                    {
                        //PORT XNA 4
                        //pass.Begin();
                        pass.Apply();

                        if (verts != null && verts.Length > 0)
                            graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, verts, 0, verts.Length, indicies, 0, indicies.Length / 2);

                        //PORT XNA 4
                        //pass.End();
                    }

                    //PORT XNA 4
                    //basicEffect.End();
                }

                //PORT XNA 4
                //graphicsDevice.VertexDeclaration = oldVertexDeclaration;
            }

            basicEffect.VertexColorEnabled = false;
            //PORT XNA 4
            //basicEffect.CommitChanges();

            base.OnDraw(graphicsDevice, scene, basicEffect);
        }
开发者ID:abordt,项目名称:Viking,代码行数:89,代码来源:LocationObjCommand.cs

示例3: OnDraw

        public override void OnDraw(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, VikingXNA.Scene scene, Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect)
        {
            if (CommandActive == false)
                return;

            //PORT XNA 4
            //VertexDeclaration oldVertexDeclaration = graphicsDevice.VertexDeclaration;

            //PORT XNA 4
            //graphicsDevice.VertexDeclaration = Parent.VertexPositionColorDeclaration;

            basicEffect.VertexColorEnabled = true;
            basicEffect.TextureEnabled = false;
            //PORT XNA 4
            //basicEffect.CommitChanges();

            VertexPositionColor[] verts = new VertexPositionColor[] { new VertexPositionColor( new Vector3((float)MyRect.Left, (float)MyRect.Bottom, 1), Color.Yellow),
                                                                       new VertexPositionColor( new Vector3((float)MyRect.Right, (float)MyRect.Bottom, 1), Color.Yellow),
                                                                        new VertexPositionColor( new Vector3((float)MyRect.Right, (float)MyRect.Top, 1), Color.Yellow),
                                                                         new VertexPositionColor( new Vector3((float)MyRect.Left, (float)MyRect.Top, 1), Color.Yellow)};

            Color CrossColor = new Color(Color.Yellow.R, Color.Yellow.G, Color.Yellow.B, 0.25f);
            float EightWidth = (float)(MyRect.Width / 16);
            float EightHeight = (float)(MyRect.Height / 16);

            VertexPositionColor[] crossVerts = new VertexPositionColor[] { new VertexPositionColor( new Vector3((float)MyRect.Center.X - EightWidth, (float)MyRect.Center.Y, 1), CrossColor),
                                                                       new VertexPositionColor( new Vector3((float)MyRect.Center.X + EightWidth, (float)MyRect.Center.Y, 1), CrossColor),
                                                                        new VertexPositionColor( new Vector3((float)MyRect.Center.X, (float)MyRect.Center.Y - EightHeight, 1), CrossColor),
                                                                         new VertexPositionColor( new Vector3((float)MyRect.Center.X, (float)MyRect.Center.Y + EightHeight, 1), CrossColor)};

            int[] indicies = new int[] { 0, 1, 2, 3, 0 };
            int[] crossIndicies = new int[] { 0, 1, 2, 3 };

            //PORT XNA 4
            //basicEffect.Begin();

            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                //PORT XNA 4
                //pass.Begin();
                pass.Apply();

                //if(gridIndicies.Count > 0)

            //    MyRect.Draw(graphicsDevice);

                graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, verts, 0, verts.Length, indicies, 0, indicies.Length - 1);
                graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, crossVerts, 0, crossVerts.Length, crossIndicies, 0, crossIndicies.Length / 2);

            //                graphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.verticies, 0, verticies.Length, gridIndicies, 0, gridIndicies.Length / 3);
                // graphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.verticies, 0, verticies.Length / 3);
                //  GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, GridVerticies, 0, GridVerticies.Length, GridIndicies, 2, 2);
                // graphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.verticies, 0, verticies.Length, gridIndicies, 0, 1);

                //PORT XNA 4
                //pass.End();
            }

            //PORT XNA 4
            //basicEffect.End();

            //PORT XNA 4
            //graphicsDevice.VertexDeclaration = oldVertexDeclaration;

            basicEffect.TextureEnabled = true;
            basicEffect.VertexColorEnabled = false;

            base.OnDraw(graphicsDevice,scene, basicEffect);
        }
开发者ID:abordt,项目名称:Viking,代码行数:69,代码来源:RectangleCommand.cs


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