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


C# BasicEffect.Begin方法代码示例

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


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

示例1: 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.RenderState.FillMode = FillMode.Solid;
            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
                device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, cubeLineVertices, 0, 8, cubeLineIndices, 0, 12);
                pass.End();
            }
            basicEffect.End();
        }
开发者ID:bradleat,项目名称:trafps,代码行数:33,代码来源:XNAUtils.cs

示例2: DrawLine

        public void DrawLine(Vector3 or, Vector3 end, Color c)
        {
            #if DEBUG
            BasicEffect effect;
            GraphicsDeviceManager gdm = ResourcesManager.GetInstance().GetGraphicsDeviceManager();

            VertexPositionColor[] v = new VertexPositionColor[2];
            v[0] = new VertexPositionColor(or, c);
            v[1] = new VertexPositionColor(end, c);

            effect = new BasicEffect(gdm.GraphicsDevice, null);

            Camera cam = CameraManager.GetInstance().GetActiveCamera();
            effect.View = cam.GetViewMatrix();
            effect.Projection = cam.GetProjectionMatrix();
            effect.VertexColorEnabled = true;

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                gdm.GraphicsDevice.VertexDeclaration = new VertexDeclaration(gdm.GraphicsDevice, VertexPositionColor.VertexElements);
                gdm.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineStrip, v, 0, 1);
                pass.End();
            }
            effect.End();
            #endif
        }
开发者ID:doanhtdpl,项目名称:karts,代码行数:28,代码来源:DrawDebugManager.cs

示例3: 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;
            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
                device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, sphereLineVertices, 0, 3);
                pass.End();
            }
            basicEffect.End();
        }
开发者ID:bradleat,项目名称:trafps,代码行数:31,代码来源:XNAUtils.cs

示例4: Draw

        public void Draw()
        {
            Engine.Device.RenderState.CullMode = CullMode.CullClockwiseFace;
            Matrix worldMatrix = Matrix.CreateTranslation(0, 0, -TILES_Z+1);
            worldMatrix *= Matrix.CreateScale(10, 1, 10);
            BasicEffect effect = new BasicEffect(Engine.Device, null);
            effect.World = worldMatrix;
            effect.View = Engine.Camera.View;
            effect.Projection = Engine.Camera.Projection;
            effect.Texture = Engine.ContentManager.Load<Texture2D>("Content\\Textures\\grass");
            effect.TextureEnabled = true;
            Engine.Device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            Engine.Device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                Engine.Device.Vertices[0].SetSource(vb, 0, VertexPositionNormalTexture.SizeInBytes);
                Engine.Device.Indices = ib;
                Engine.Device.VertexDeclaration = new VertexDeclaration(Engine.Device, VertexPositionNormalTexture.VertexElements);
                Engine.Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, TILES_X * TILES_Z, 0, (TILES_X - 1) * (TILES_Z - 1) * 2);
            }
            effect.End();
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:25,代码来源:HeightmapTerrain.cs

示例5: Draw

 public void Draw(BasicEffect effect)
 {
     effect.Begin();
     foreach (EffectPass current in effect.CurrentTechnique.Passes)
     {
         current.Begin();
         this.graphics.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, this.vertices, 0, this.vertices.Length, this.indices, 0, this.vertices.Length - 1);
         current.End();
     }
     effect.End();
 }
开发者ID:Jiwan,项目名称:ROSE-Camera-Editor,代码行数:11,代码来源:CameraMotion.cs

示例6: Draw

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionNormalTexture.VertexElements);
            effect = new BasicEffect(GraphicsDevice, null);

            effect.World = worldRotation * worldTranslation;
            effect.View = camera.view;
            effect.Projection = camera.project;
            effect.Texture = tex[0];
            effect.TextureEnabled = true;

            //loads a side, changes texture, loads next side, repeat
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.ffront, 0, 2);
                pass.End();

                effect.Texture = tex[1];
                effect.TextureEnabled = true;
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.bback, 0, 2);
                pass.End();

                effect.Texture = tex[2];
                effect.TextureEnabled = true;
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.lleft, 0, 2);
                pass.End();

                effect.Texture = tex[3];
                effect.TextureEnabled = true;
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.rright, 0, 2);
                pass.End();

                effect.Texture = tex[4];
                effect.TextureEnabled = true;
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.ttop, 0, 2);
                pass.End();

                effect.Texture = tex[5];
                effect.TextureEnabled = true;
                pass.Begin();
                GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.bbot, 0, 2);
                pass.End();
            }
            effect.End();
            base.Draw(gameTime);
        }
开发者ID:hatRiot,项目名称:XNA,代码行数:53,代码来源:Game1.cs

示例7: Draw

 public void Draw(GraphicsDevice graphics, BasicEffect effect)
 {
     effect.LightingEnabled = true;
     effect.AmbientLightColor = new Vector3(1f, 1f, 1f);
     effect.Texture = this.texture;
     effect.TextureEnabled = true;
     effect.Alpha = this.Materiel.alpha;
     effect.Begin();
     graphics.RenderState.AlphaBlendEnable = Convert.ToBoolean(this.Materiel.alpha_enabled);
     if (Convert.ToBoolean(this.Materiel.alpha_enabled))
     {
         graphics.RenderState.AlphaTestEnable = Convert.ToBoolean(this.Materiel.alpha_test_enabled);
         if (this.Materiel.blending_mode == 1)
         {
             graphics.RenderState.SourceBlend = Blend.One;
         }
         else
         {
             graphics.RenderState.SourceBlend = Blend.SourceAlpha;
         }
         if (this.Materiel.blending_mode == 1)
         {
             graphics.RenderState.DestinationBlend = Blend.One;
         }
         else
         {
             graphics.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
         }
         graphics.RenderState.ReferenceAlpha = (int)this.Materiel.alpha_ref_enabled;
         graphics.RenderState.AlphaFunction = CompareFunction.GreaterEqual;
         graphics.RenderState.BlendFunction = BlendFunction.Add;
     }
     else
     {
         graphics.RenderState.AlphaTestEnable = false;
         graphics.RenderState.SourceBlend = Blend.One;
         graphics.RenderState.DestinationBlend = Blend.Zero;
         graphics.RenderState.ReferenceAlpha = 0;
         graphics.RenderState.AlphaFunction = CompareFunction.Always;
         graphics.RenderState.BlendFunction = BlendFunction.Add;
     }
     for (int i = 0; i < effect.CurrentTechnique.Passes.Count; i++)
     {
         effect.CurrentTechnique.Passes[i].Begin();
         graphics.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.vertex, 0, this.vertex.Length, this.Indices, 0, this.Indices.Length / 3);
         effect.CurrentTechnique.Passes[i].End();
     }
     effect.End();
 }
开发者ID:Jiwan,项目名称:ROSE-Content-Importer,代码行数:49,代码来源:ZMS.cs

示例8: Draw3DLine

 /// <summary>
 /// Method to draw a line in 3D
 /// </summary>
 /// <param name="color">Color of line</param>
 /// <param name="point1">first point</param>
 /// <param name="point2">second point</param>
 /// <param name="effect">Basic effects object</param>
 /// <param name="gfxDevice">Graphics device</param>
 /// <param name="projection">Projection matrix</param>
 /// <param name="view">view matrix</param>
 /// <param name="world">world matrix</param>
 public static void Draw3DLine(Microsoft.Xna.Framework.Graphics.Color color, Vector3 point1, Vector3 point2, BasicEffect effect, GraphicsDevice gfxDevice, Matrix projection, Matrix view, Matrix world)
 {
     VertexPositionColor[] vertexList = new VertexPositionColor[2];
     vertexList[0] = new VertexPositionColor(point1, color);
     vertexList[1] = new VertexPositionColor(point2, color);
     gfxDevice.VertexDeclaration = new VertexDeclaration(gfxDevice,VertexPositionColor.VertexElements);
     effect.Projection = projection;
     effect.View = view;
     effect.World = world;
     effect.Begin();
     foreach (EffectPass pass in effect.CurrentTechnique.Passes)
     {
         pass.Begin();
         gfxDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertexList, 0, 1);
         pass.End();
     }
     effect.End();
 }
开发者ID:nthfloor,项目名称:Nebulon12,代码行数:29,代码来源:Algorithms.cs

示例9: Draw

        public void Draw(GraphicsDevice gd, Camera camera)
        {
            effect = new BasicEffect(gd, null);

            effect.Begin();

            effect.World = Matrix.Identity;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes) {

                pass.Begin();

                effect.Texture = texture;

                RenderFloor(gd, camera);

                pass.End();
            }

            effect.End();
        }
开发者ID:wbobeirne,项目名称:Voxel-Editor,代码行数:21,代码来源:Floor.cs

示例10: Draw

        public override void Draw(Microsoft.Xna.Framework.Graphics.GraphicsDevice device)
        {
            if (Mesh == null) { return; }

            var effect = new BasicEffect(device, null);
            effect.World = World;
            effect.View = View;
            effect.Projection = Projection;
            effect.Begin();
            if (Texture != null)
            {
                effect.TextureEnabled = true;
                effect.Texture = Texture;
            }

            foreach (var pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                Mesh.Draw(device);
                pass.End();
            }
            effect.End();
        }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:23,代码来源:MeshPreviewComponent.cs

示例11: Draw

        public void Draw(Matrix projection, Matrix view)
        {
            // draw the bounding box
            BasicEffect basicEffect = new BasicEffect(GraphicsDevice, null);
            basicEffect.VertexColorEnabled = true;

            basicEffect.World = Matrix.Identity;
            basicEffect.View = view;
            basicEffect.Projection = projection;

            basicEffect.Begin();

            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                    PrimitiveType.LineList,
                    boundVertices,
                    0,  // vertex buffer offset to add to each element of the index buffer
                    4,  // number of vertices in pointList
                    boundIndices,  // the index buffer
                    0,  // first index element to read
                    4   // number of primitives to draw
                );

                GraphicsDevice.RenderState.PointSize = 2;
                GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(
                    PrimitiveType.PointList,
                    gridVerts,
                    0,  // index of the first vertex to draw
                    gridSize * gridSize / 2   // number of primitives
                );
                GraphicsDevice.RenderState.FillMode = FillMode.Solid;
                pass.End();
            }
            basicEffect.End();
        }
开发者ID:mythicalprogrammer,项目名称:Beasty,代码行数:37,代码来源:DisplayGrid.cs

示例12: Draw

 public void Draw(GraphicsDevice device, BasicEffect effect)
 {
     CalculateWorldMatrix();
     effect.World = World;
     effect.Begin();
     foreach (EffectPass pass in effect.CurrentTechnique.Passes)
     {
         pass.Begin();
         device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, Vertices, 0, Vertices.Length, Indices, 0, Indices.Length / 3);
         //VertexPositionColor[] lineVerts = new VertexPositionColor[6]{  new VertexPositionColor( -Vector3.One, Color.Blue), 
         //     new VertexPositionColor(-Vector3.One+LocalForward , Color.Blue),
         //     new VertexPositionColor( -Vector3.One, Color.Red), 
         // new VertexPositionColor(-Vector3.One+ LocalLeft , Color.Red),
         // new VertexPositionColor( -Vector3.One, Color.Green), 
         //new VertexPositionColor(Vector3.Transform((Vector3.One +LocalUp),Quaternion.Inverse( Rotation)) , Color.Green), };
         //device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, lineVerts, 0, lineVerts.Length, new short[] { 0, 1, 2, 3, 4, 5 }, 0, 3);
         pass.End();
     }
     effect.End();
 }
开发者ID:kholdfuzion,项目名称:halo2x-sunfish,代码行数:20,代码来源:ModelEditor.cs

示例13: Run

        public void Run()
        {
            using (var form = EmptyWindow.CreateForm())
            {
                PresentationParameters presentationParameters = EmptyWindow.CreatePresentationParameters();

                var device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware,
                    form.Handle, presentationParameters);

                Vertex[] vertices = CreateVertices();

                var vertexBuffer = new VertexBuffer(device,
                    typeof(Vertex), vertices.Length, BufferUsage.None);

                vertexBuffer.SetData(vertices, 0, vertices.Length);

                var indices = CreateIndices();
                var indexBuffer = new IndexBuffer(device,
                    sizeof (int) * indices.Length, BufferUsage.None,
                    IndexElementSize.ThirtyTwoBits);
                indexBuffer.SetData(indices);

                VertexDeclaration vertexDeclaration = TriangleWithVertexBuffer.CreateVertexDeclaration(device);

                var basicEffect = new BasicEffect(device, new EffectPool())
                {
                    LightingEnabled = false,
                    TextureEnabled = false,
                    VertexColorEnabled = true
                };

                Application.Idle +=
                    delegate
                    {
                        device.Clear(Color.Blue);

                        device.VertexDeclaration = vertexDeclaration;
                        device.Vertices[0].SetSource(vertexBuffer, 0, 24);
                        device.Indices = indexBuffer;
                        device.RenderState.CullMode = CullMode.None;

                        basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(
                            (float)(System.Math.PI / 3), 800f / 600.0f, 0.01f, 100f);
                        basicEffect.View = Matrix.CreateLookAt(
                            new Vector3(0, 0, -3), new Vector3(), new Vector3(0, 1, 0));
                        basicEffect.World = Matrix.Identity;

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

                            device.DrawIndexedPrimitives(PrimitiveType.TriangleList,
                                0, 0, vertices.Length, 0, 2);

                            pass.End();
                        }

                        basicEffect.End();

                        device.Present();

                        Application.DoEvents();
                    };

                Application.Run(form);
            }
        }
开发者ID:Christof,项目名称:afterglow,代码行数:68,代码来源:QuadWithVertexAndIndexBuffer.cs

示例14: Render

        public void Render(GraphicsDevice device, BasicEffect basicEffect, ObjectShip ship, LevelBackgroundGF levelBackground)
        {
            basicEffect.World = Matrix.Identity;

            basicEffect.LightingEnabled = false;
            device.RenderState.DepthBufferEnable = false;
            device.RenderState.CullMode = CullMode.None;

            device.RenderState.PointSpriteEnable = true;
            //device.RenderState.PointScaleEnable = true ;
            device.RenderState.PointSize = 10.0f;
            device.RenderState.PointSizeMin = 0.00f;
            device.RenderState.PointSizeMax = 100.00f;
            //device.RenderState.PointScaleA = 0.00f;
            //device.RenderState.PointScaleB = 0.00f;
            //device.RenderState.PointScaleC = 1.00f;

            device.RenderState.AlphaBlendEnable = true;
            device.RenderState.SourceBlend = Blend.One;
            device.RenderState.DestinationBlend = Blend.One;

            basicEffect.Texture = texture;
            basicEffect.TextureEnabled = true;

            int count = 0;

            bool hackColliding = false;
            for(int i = 0; i < 6; i++)
            {
                Vector3 v = ship.colisionPoints[i];
                //v = Vector3.TransformCoordinate(v, ship.renderMatrix);
                v = Vector3.Transform(v, ship.renderMatrix);

            ////                Vector3 v = ship.Position;
            ////                v.Y = v.Y + (float)(ship.boundingBoxMax.Y * ship.scale * Math.Cos(ship.Rotation.Z));
            ////                v.X = v.X - (float)(ship.boundingBoxMax.Y * ship.scale * Math.Sin(ship.Rotation.Z));
                bool collide = levelBackground.CheckCollision(v);

                VertexPositionColor pv;
                pv.Position = v;
                pv.Color = collide ? Color.Yellow : Color.White;

                if(collide)
                {
                    vertices[count] = pv;
                    count++;
                }

                hackColliding |= collide;
            }
            if(!ship.hackColliding && hackColliding)
            {
                ship.Position = ship.OldPosition;
                ship.Speed = -ship.Speed * 0.3f;
                SoundHandler.Checkpoint();
            }
            ship.hackColliding = hackColliding;

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

            //// Unlock the vertex buffer
            //vertexBuffer.Unlock();
            //// Render any remaining particles
            if (count > 0)
            {
                basicEffect.Begin();
                foreach(EffectPass pass in basicEffect.CurrentTechnique.Passes)
                {
                    pass.Begin();

                    device.DrawUserPrimitives(PrimitiveType.PointList, vertices, 0, count);

                    pass.End();
                }
                basicEffect.End();
            }

            //// Reset render states
            //device.RenderState.PointSpriteEnable = false;
            //device.RenderState.PointScaleEnable = false;

            //device.RenderState.PointSpriteEnable = true;
            //device.RenderState.PointScaleEnable = true ;
            //device.RenderState.AlphaBlendEnable = false;

            device.RenderState.PointSpriteEnable = false;
            device.RenderState.DepthBufferWriteEnable = true;
            device.RenderState.SourceBlend = Blend.SourceAlpha;
            device.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
        }
开发者ID:StefRave,项目名称:TurboGravityLemmingRakettiForce,代码行数:90,代码来源:Bullet.cs

示例15: DrawSphere

        public void DrawSphere(Vector3 c, float rad, Color color)
        {
            #if DEBUG
            Matrix sphereMatrix = Matrix.CreateScale(rad) * Matrix.CreateTranslation(c);
            int iCountVerts = 0;

            //create the loop on the XY plane first
            for (float a = 0f; a <= MathHelper.TwoPi; a += BSPHERE_STEP)
            {
                Vector3 position =
                    new Vector3((float)Math.Cos(a), (float)Math.Sin(a), 0f);
                position = Vector3.Transform(position, sphereMatrix);

                BSphereVerts[iCountVerts++] = new VertexPositionColor(position, color);
            }

            //next on the XZ plane
            for (float a = 0f; a <= MathHelper.TwoPi; a += BSPHERE_STEP)
            {
                Vector3 position =
                    new Vector3((float)Math.Cos(a), 0f, (float)Math.Sin(a));
                position = Vector3.Transform(position, sphereMatrix);

                BSphereVerts[iCountVerts++] = new VertexPositionColor(position, color);
            }

            //finally on the YZ plane
            for (float a = 0f; a <= MathHelper.TwoPi; a += BSPHERE_STEP)
            {
                Vector3 position =
                    new Vector3(0f, (float)Math.Cos(a), (float)Math.Sin(a));
                position = Vector3.Transform(position, sphereMatrix);

                BSphereVerts[iCountVerts++] = new VertexPositionColor(position, color);
            }

            BasicEffect effect;
            GraphicsDeviceManager gdm = ResourcesManager.GetInstance().GetGraphicsDeviceManager();
            effect = new BasicEffect(gdm.GraphicsDevice, null);

            Camera cam = CameraManager.GetInstance().GetActiveCamera();
            effect.View = cam.GetViewMatrix();
            effect.Projection = cam.GetProjectionMatrix();
            effect.VertexColorEnabled = true;

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                gdm.GraphicsDevice.VertexDeclaration = new VertexDeclaration(gdm.GraphicsDevice, VertexPositionColor.VertexElements);
                gdm.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, BSphereVerts, 0, iCountVerts / 2);
                pass.End();
            }
            effect.End();
            #endif
        }
开发者ID:doanhtdpl,项目名称:karts,代码行数:56,代码来源:DrawDebugManager.cs


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