コード例 #1
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw triangles
            device.RenderState.CullMode = CullMode.None;
            basicEffect.World           = Matrix.Identity;
            basicEffect.View            = fpsCam.ViewMatrix;
            basicEffect.Projection      = fpsCam.ProjectionMatrix;
            basicEffect.Texture         = myTexture;
            basicEffect.TextureEnabled  = true;

            device.SamplerStates[0].BorderColor = Color.LightSeaGreen;
            device.SamplerStates[0].AddressU    = TextureAddressMode.Border;
            device.SamplerStates[0].AddressV    = TextureAddressMode.Border;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserPrimitives <VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, 1);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }
コード例 #2
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //render track
            basicEffect.World      = Matrix.Identity;
            basicEffect.View       = fpsCam.ViewMatrix;
            basicEffect.Projection = fpsCam.ProjectionMatrix;

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

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleStrip, trackVertices, 0, trackVertices.Length - 2);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }
コード例 #3
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw triangles
            device.RenderState.CullMode = CullMode.None;
            basicEffect.World           = Matrix.Identity;
            basicEffect.View            = fpsCam.ViewMatrix;
            basicEffect.Projection      = fpsCam.ProjectionMatrix;
            basicEffect.Texture         = myTexture;
            basicEffect.TextureEnabled  = true;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.Vertices[0].SetSource(vertBuffer, 0, VertexPositionTexture.SizeInBytes);
                device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }
コード例 #4
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            //draw coordcross
            cCross.Draw(viewMatrix, projectionMatrix);

            //draw model
            Matrix worldMatrix = Matrix.CreateScale(1.0f / 5000.0f) * Matrix.CreateFromQuaternion(spacecraftRotation) * Matrix.CreateTranslation(spacecraftPosition);

            spacecraftModel.CopyAbsoluteBoneTransformsTo(modelTransforms);
            foreach (ModelMesh mesh in spacecraftModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World      = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
                    effect.View       = viewMatrix;
                    effect.Projection = projectionMatrix;
                }
                mesh.Draw();
            }

            base.Draw(gameTime);
        }
コード例 #5
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw triangles
            basicEffect.World      = Matrix.Identity;
            basicEffect.View       = fpsCam.ViewMatrix;
            basicEffect.Projection = fpsCam.ProjectionMatrix;

            basicEffect.Texture        = myTexture;
            basicEffect.TextureEnabled = true;

            float time = (float)gameTime.TotalGameTime.TotalMilliseconds / 1000.0f;

            basicEffect.EnableDefaultLighting();
            basicEffect.DirectionalLight0.Direction = Vector3.Transform(new Vector3(1, 0, 0), Matrix.CreateRotationY(time));
            basicEffect.DirectionalLight1.Enabled   = false;
            basicEffect.DirectionalLight2.Enabled   = false;
            basicEffect.SpecularColor = new Vector3(0, 0, 0);


            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserIndexedPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, indices.Length / 3);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }
コード例 #6
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            float time = (float)gameTime.TotalGameTime.TotalMilliseconds / 1000.0f;

            //draw triangles
            device.RenderState.CullMode = CullMode.None;
            effect.Parameters["xWorld"].SetValue(Matrix.Identity);
            effect.Parameters["xView"].SetValue(fpsCam.ViewMatrix);
            effect.Parameters["xProjection"].SetValue(fpsCam.ProjectionMatrix);
            effect.Parameters["xTexture"].SetValue(myTexture);
            effect.Parameters["xTime"].SetValue(time);

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.Vertices[0].SetSource(vertBuffer, 0, MyCustomVertexFormat.SizeInBytes);
                device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
                pass.End();
            }
            effect.End();

            base.Draw(gameTime);
        }
コード例 #7
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw primitives
            basicEffect.World              = Matrix.Identity;
            basicEffect.View               = fpsCam.ViewMatrix;
            basicEffect.Projection         = fpsCam.ProjectionMatrix;
            basicEffect.VertexColorEnabled = true;
            basicEffect.TextureEnabled     = false;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineStrip, straightVertices, 0, straightVertices.Length - 1);
                device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineStrip, crVertices1, 0, crVertices1.Length - 1);
                device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineStrip, crVertices2, 0, crVertices2.Length - 1);
                device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineStrip, crVertices3, 0, crVertices3.Length - 1);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }
コード例 #8
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            //draw model
            Matrix worldMatrix = Matrix.CreateScale(0.003f) * Matrix.CreateTranslation(0, 0, 0);

            myModel.CopyAbsoluteBoneTransformsTo(modelTransforms);
            foreach (ModelMesh mesh in myModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World      = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
                    effect.View       = fpsCam.ViewMatrix;
                    effect.Projection = fpsCam.ProjectionMatrix;
                }
                mesh.Draw();
            }

            //draw coordcross
            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            base.Draw(gameTime);

            List <string> ppEffectsList = new List <string>();

            ppEffectsList.Add("HorBlur");
            ppEffectsList.Add("VerBlurAndGlow");

            postProcessor.Parameters["xBlurSize"].SetValue(0.5f);
            postProcessor.PostProcess(ppEffectsList);
        }
コード例 #9
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(quatCam.ViewMatrix, quatCam.ProjectionMatrix);

            //draw billboards
            basicEffect.World          = Matrix.Identity;
            basicEffect.View           = quatCam.ViewMatrix;
            basicEffect.Projection     = quatCam.ProjectionMatrix;
            basicEffect.TextureEnabled = true;
            basicEffect.Texture        = myTexture;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserPrimitives <VertexPositionTexture>(PrimitiveType.TriangleList, billboardVertices, 0, billboardList.Count * 2);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }
コード例 #10
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(quatCam.ViewMatrix, quatCam.ProjectionMatrix);

            //draw billboards
            bbEffect.CurrentTechnique = bbEffect.Techniques["SpheBillboard"];
            bbEffect.Parameters["xWorld"].SetValue(Matrix.Identity);
            bbEffect.Parameters["xProjection"].SetValue(quatCam.ProjectionMatrix);
            bbEffect.Parameters["xView"].SetValue(quatCam.ViewMatrix);

            bbEffect.Parameters["xCamPos"].SetValue(quatCam.Position);
            bbEffect.Parameters["xCamUp"].SetValue(quatCam.UpVector);
            bbEffect.Parameters["xBillboardTexture"].SetValue(myTexture);

            bbEffect.Begin();
            foreach (EffectPass pass in bbEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserPrimitives <VertexPositionTexture>(PrimitiveType.TriangleList, billboardVertices, 0, billboardList.Count * 2);
                pass.End();
            }
            bbEffect.End();


            base.Draw(gameTime);
        }
コード例 #11
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw triangles
            device.RenderState.CullMode    = CullMode.None;
            basicEffect.World              = Matrix.Identity;
            basicEffect.View               = fpsCam.ViewMatrix;
            basicEffect.Projection         = fpsCam.ProjectionMatrix;
            basicEffect.VertexColorEnabled = true;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.PointList, vertices, 0, 12);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }
コード例 #12
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(viewMatrix, projectionMatrix);

            base.Draw(gameTime);
        }
コード例 #13
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            //draw coordcross
            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            base.Draw(gameTime);
        }
コード例 #14
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            //render coordcross using specified View and Projection matrices
            cCross.Draw(viewMatrix, projectionMatrix);

            base.Draw(gameTime);
        }
コード例 #15
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw terrain
            terrain.Draw(Matrix.Identity, fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            base.Draw(gameTime);
        }
コード例 #16
0
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            //draw coordcross
            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            terrain.Draw(Matrix.Identity, fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            base.Draw(gameTime);
        }
コード例 #17
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            ICameraInterface camera;

            camera = (ICameraInterface)Services.GetService(typeof(ICameraInterface));

            cCross.Draw(camera.ViewMatrix, camera.ProjectionMatrix);

            base.Draw(gameTime);
        }
コード例 #18
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            device.RenderState.CullMode = CullMode.None;
            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            DrawTerrain();
            DrawOrthoGrid();
            device.Indices = null;

            base.Draw(gameTime);
        }
コード例 #19
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            //draw coordcross
            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            BoundingFrustum cameraFrustrum = new BoundingFrustum(fpsCam.ViewMatrix * fpsCam.ProjectionMatrix);

            QTNode.NodesRendered = 0;
            rootNode.Draw(Matrix.CreateTranslation(-250, -20, 250), fpsCam.ViewMatrix, fpsCam.ProjectionMatrix, cameraFrustrum);
            Window.Title = string.Format("{0} nodes rendered", QTNode.NodesRendered);

            base.Draw(gameTime);
        }
コード例 #20
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            device.ResolveBackBuffer(resolveTexture);


            device.Clear(Color.Tomato);
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.None);
            spriteBatch.Draw(resolveTexture, new Vector2(100, 100), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #21
0
        protected override void Draw(GameTime gameTime)
        {
            device.SetRenderTarget(0, renderTarget);
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, rendertargetProjectionMatrix);

            device.SetRenderTarget(0, null);
            Texture2D resolvedTexture = renderTarget.GetTexture();

            graphics.GraphicsDevice.Clear(Color.Tomato);
            spriteBatch.Begin();
            spriteBatch.Draw(resolvedTexture, new Vector2(100, 100), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #22
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            int             modelsDrawn = 0;
            BoundingFrustum cameraSight = new BoundingFrustum(fpsCam.ViewMatrix * fpsCam.ProjectionMatrix);

            for (int x = 0; x < 5; x++)
            {
                for (int z = 0; z < 5; z++)
                {
                    Matrix         worldMatrix = Matrix.CreateScale(0.001f) * Matrix.CreateTranslation(x * 5 - 10, 0, z * 5 - 10);
                    BoundingSphere origSphere  = (BoundingSphere)myModel.Tag;
                    BoundingSphere transSphere = origSphere.Transform(worldMatrix);

                    ContainmentType containmentType = cameraSight.Contains(transSphere);

                    if (containmentType != ContainmentType.Disjoint)
                    {
                        modelsDrawn++;
                        //draw model
                        myModel.CopyAbsoluteBoneTransformsTo(modelTransforms);
                        foreach (ModelMesh mesh in myModel.Meshes)
                        {
                            foreach (BasicEffect effect in mesh.Effects)
                            {
                                effect.EnableDefaultLighting();
                                effect.World      = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
                                effect.View       = fpsCam.ViewMatrix;
                                effect.Projection = fpsCam.ProjectionMatrix;
                            }
                            mesh.Draw();
                        }
                    }
                }
            }
            Window.Title = string.Format("Models actually drawn: {0}", modelsDrawn);

            //draw coordcross
            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            base.Draw(gameTime);
        }
コード例 #23
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1, 0);

            cCross.Draw(quatCam.ViewMatrix, quatCam.ProjectionMatrix);

            if (explosionVertices != null)
            {
                //draw billboards
                expEffect.CurrentTechnique = expEffect.Techniques["Explosion"];
                expEffect.Parameters["xWorld"].SetValue(Matrix.Identity);
                expEffect.Parameters["xProjection"].SetValue(quatCam.ProjectionMatrix);
                expEffect.Parameters["xView"].SetValue(quatCam.ViewMatrix);

                expEffect.Parameters["xCamPos"].SetValue(quatCam.Position);
                expEffect.Parameters["xExplosionTexture"].SetValue(myTexture);
                expEffect.Parameters["xCamUp"].SetValue(quatCam.UpVector);
                expEffect.Parameters["xTime"].SetValue((float)gameTime.TotalGameTime.TotalMilliseconds);

                device.RenderState.AlphaBlendEnable       = true;
                device.RenderState.SourceBlend            = Blend.SourceAlpha;
                device.RenderState.DestinationBlend       = Blend.One;
                device.RenderState.DepthBufferWriteEnable = false;

                expEffect.Begin();
                foreach (EffectPass pass in expEffect.CurrentTechnique.Passes)
                {
                    pass.Begin();
                    device.VertexDeclaration = myVertexDeclaration;
                    device.DrawUserPrimitives <VertexExplosion>(PrimitiveType.TriangleList, explosionVertices, 0, explosionVertices.Length / 3);
                    pass.End();
                }
                expEffect.End();

                device.RenderState.DepthBufferWriteEnable = true;
            }

            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.None);
            spriteBatch.DrawString(spriteFont, "Hit Space to initiate an explosion!", new Vector2(20, 20), Color.Red);
            spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #24
0
        protected override void Draw(GameTime gameTime)
        {
            Matrix worldMatrix = Matrix.CreateScale(0.002f) * Matrix.CreateTranslation(5, 0, 0);

            BoundingFrustum cameraSight = new BoundingFrustum(fpsCam.ViewMatrix * fpsCam.ProjectionMatrix);
            BoundingSphere  origSphere  = (BoundingSphere)myModel.Tag;
            BoundingSphere  transSphere = origSphere.Transform(worldMatrix);

            ContainmentType containmentType = cameraSight.Contains(transSphere);

            if (containmentType != ContainmentType.Disjoint)
            {
                Window.Title = "Model inside frustum";
                graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

                //draw model
                myModel.CopyAbsoluteBoneTransformsTo(modelTransforms);
                foreach (ModelMesh mesh in myModel.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();
                        effect.World      = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
                        effect.View       = fpsCam.ViewMatrix;
                        effect.Projection = fpsCam.ProjectionMatrix;
                    }
                    mesh.Draw();
                }
            }
            else
            {
                Window.Title = "Model outside frustum";
                graphics.GraphicsDevice.Clear(Color.Red);
            }

            //draw coordcross
            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            base.Draw(gameTime);
        }
コード例 #25
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw terrain
            int width  = heightData.GetLength(0);
            int height = heightData.GetLength(1);

            basicEffect.World          = Matrix.Identity;
            basicEffect.View           = fpsCam.ViewMatrix;
            basicEffect.Projection     = fpsCam.ProjectionMatrix;
            basicEffect.Texture        = grassTexture;
            basicEffect.TextureEnabled = true;

            basicEffect.EnableDefaultLighting();
            basicEffect.DirectionalLight0.Direction = new Vector3(1, -1, 1);
            basicEffect.DirectionalLight0.Enabled   = true;
            basicEffect.AmbientLightColor           = new Vector3(0.3f, 0.3f, 0.3f);
            basicEffect.DirectionalLight1.Enabled   = false;
            basicEffect.DirectionalLight2.Enabled   = false;
            basicEffect.SpecularColor = new Vector3(0, 0, 0);

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

                device.Vertices[0].SetSource(terrainVertexBuffer, 0, VertexPositionNormalTexture.SizeInBytes);
                device.Indices           = terrainIndexBuffer;
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, width * height, 0, width * 2 * (height - 1) - 2);

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

            base.Draw(gameTime);
        }
コード例 #26
0
        protected override void Draw(GameTime gameTime)
        {
            float lowestHeight  = 0;
            float highestHeight = 30;
            float interp        = (pointerPos.Y - lowestHeight) / (highestHeight - lowestHeight);
            byte  colorValue    = (byte)(255.0f * interp);
            Color clearColor    = new Color(colorValue, colorValue, colorValue);

            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, clearColor, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw terrain
            terrain.Draw(Matrix.Identity, fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
            spriteBatch.Draw(crosshair, pointerScreenPos, null, Color.White, 0, new Vector2(7, 7), 1, SpriteEffects.None, 0);
            spriteBatch.End();

            Window.Title = pointerPos.Y.ToString();

            base.Draw(gameTime);
        }
コード例 #27
0
        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw triangles
            basicEffect.World              = Matrix.CreateScale(2.0f);
            basicEffect.View               = fpsCam.ViewMatrix;
            basicEffect.Projection         = fpsCam.ProjectionMatrix;
            basicEffect.VertexColorEnabled = true;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserIndexedPrimitives <VertexPositionColor>(PrimitiveType.TriangleList, vertices, 0, 9, indices, 0, 8);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }