當前位置: 首頁>>代碼示例>>C#>>正文


C# Graphics.RasterizerState類代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.RasterizerState的典型用法代碼示例。如果您正苦於以下問題:C# RasterizerState類的具體用法?C# RasterizerState怎麽用?C# RasterizerState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RasterizerState類屬於Microsoft.Xna.Framework.Graphics命名空間,在下文中一共展示了RasterizerState類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Draw

        public override void Draw(GameTime gameTime)
        {
            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            rs.FillMode = FillMode.WireFrame;
            this.device.RasterizerState = rs;

            Viewport viewport = this.device.Viewport;
            this.defaultEfft.World = Matrix.CreateTranslation(new Vector3(-this.witdth/2, -this.heigh/2, -100.0f));
            this.defaultEfft.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                                                                              viewport.AspectRatio,
                                                                              5.0f,
                                                                              200.0f);

            foreach (EffectPass pass in this.defaultEfft.CurrentTechnique.Passes)
            {
                pass.Apply();
                foreach (VertexPositionColor[] row in this.pointMatrics)
                {
                    this.device.DrawUserPrimitives(PrimitiveType.TriangleStrip,
                                                row, 0, row.Length - 2,
                                                VertexPositionColor.VertexDeclaration);
                }

            }
            base.Draw(gameTime);
        }
開發者ID:kobe1home,項目名稱:Project_Origin,代碼行數:27,代碼來源:Map.cs.LOCAL.8028.cs

示例2: DrawAll

        public override void DrawAll(GameTime gameTime)
        {
            device.Clear(Color.DarkSlateBlue);

            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            rs.FillMode = FillMode.Solid;
            device.RasterizerState = rs;

            effect.TextureEnabled = true;

            effect.World = Matrix.Identity;

            effect.View = viewMatrix;
            effect.Projection = projectionMatrix;

            effect.LightingEnabled = true;
            effect.EnableDefaultLighting();

            device.SetVertexBuffer(vertexBuffer);

            UpdateCamera();

            DrawBall();
            DrawStaticWorld();
            DrawSky();

            drawBonuses();
            DrawBallData();

            base.Draw(gameTime);
        }
開發者ID:pavluntiy,項目名稱:superProject,代碼行數:32,代碼來源:Gaming.cs

示例3: HighlightModule

 static HighlightModule()
 {
     var color = Color.Black;
     CubeVerticies = new[]
     {
         new VertexPositionColor(new XVector3(0, 0, 1), color),
         new VertexPositionColor(new XVector3(1, 0, 1), color),
         new VertexPositionColor(new XVector3(1, 1, 1), color),
         new VertexPositionColor(new XVector3(0, 1, 1), color),
         new VertexPositionColor(new XVector3(0, 0, 0), color),
         new VertexPositionColor(new XVector3(1, 0, 0), color),
         new VertexPositionColor(new XVector3(1, 1, 0), color),
         new VertexPositionColor(new XVector3(0, 1, 0), color)
     };
     CubeIndicies = new short[]
     {
         0, 1,   1, 2,   2, 3,   3, 0,
         0, 4,   4, 7,   7, 6,   6, 2,
         1, 5,   5, 4,   3, 7,   6, 5
     };
     DestructionBlendState = new BlendState
     {
         ColorSourceBlend = Blend.DestinationColor,
         ColorDestinationBlend = Blend.SourceColor,
         AlphaSourceBlend = Blend.DestinationAlpha,
         AlphaDestinationBlend = Blend.SourceAlpha
     };
     RasterizerState = new RasterizerState
     {
         DepthBias = -3,
         SlopeScaleDepthBias = -3
     };
 }
開發者ID:Zoxive,項目名稱:TrueCraft,代碼行數:33,代碼來源:HighlightModule.cs

示例4: Draw

        protected override void Draw(GameTime gameTime)
        {
            RasterizerState rasterizerState1 = new RasterizerState();
            rasterizerState1.CullMode = CullMode.None;
            rasterizerState1.FillMode = FillMode.WireFrame; // for å se kun streker av trekanten
            //rasterizerState1.FillMode = FillMode.Solid; // for å fylle med hel farge
            device.RasterizerState = rasterizerState1;

            device.Clear(Color.Black);

            // Setter world
            world = Matrix.Identity;
            // Setter world-matrisa på effect-objektet (verteks-shaderen)
            effect.World = world;

            // Starter tegning - må bruke effect-objektet
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                // Angir primitivtype, aktuelle vertekser, en offsetverdi og antall
                // primitiver (her 1 siden verteksene beskriver en trekant)
                device.DrawUserPrimitives(PrimitiveType.TriangleStrip, sider, 0, 8, VertexPositionColor.VertexDeclaration);
                device.DrawUserPrimitives(PrimitiveType.TriangleStrip, topp, 0, 2, VertexPositionColor.VertexDeclaration);
                device.DrawUserPrimitives(PrimitiveType.TriangleStrip, bunn, 0, 2, VertexPositionColor.VertexDeclaration);

            }

            base.Draw(gameTime);
        }
開發者ID:unk1nd,項目名稱:Innlevering1_dataGFX,代碼行數:29,代碼來源:Del2.cs

示例5: DefaultLightContext

 public DefaultLightContext(
     Texture2D deferredColorMap, 
     Texture2D deferredNormalMap,
     Texture2D deferredDepthMap, 
     Texture2D deferredSpecularMap,
     RenderTarget2D diffuseLightRenderTarget,
     RenderTarget2D specularLightRenderTarget,
     BlendState lightBlendState,
     RasterizerState rasterizerStateCullNone,
     RasterizerState rasterizerStateCullClockwiseFace, 
     RasterizerState rasterizerStateCullCounterClockwiseFace, 
     Vector2 halfPixel)
 {
     DeferredColorMap = deferredColorMap;
     DeferredNormalMap = deferredNormalMap;
     DeferredDepthMap = deferredDepthMap;
     DeferredSpecularMap = deferredSpecularMap;
     DiffuseLightRenderTarget = diffuseLightRenderTarget;
     SpecularLightRenderTarget = specularLightRenderTarget;
     LightBlendState = lightBlendState;
     RasterizerStateCullNone = rasterizerStateCullNone;
     RasterizerStateCullClockwiseFace = rasterizerStateCullClockwiseFace;
     RasterizerStateCullCounterClockwiseFace = rasterizerStateCullCounterClockwiseFace;
     HalfPixel = halfPixel;
 }
開發者ID:RedpointGames,項目名稱:Protogame,代碼行數:25,代碼來源:DefaultLightContext.cs

示例6: Draw

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            if (karoGame.KaroGameManager == null ||
                !(karoGame.KaroGameManager.CurrentState is ComputerState))
            {
                // Not loading, stop execution.
                return;
            }

            RasterizerState rs = new RasterizerState();
            rs.DepthBias = -10f;
            RasterizerState rsold = Game.GraphicsDevice.RasterizerState;
            Game.GraphicsDevice.RasterizerState = rs;
            foreach (ModelMesh mesh in _beachBall.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.View = _view;
                    effect.Projection = _projection;
                    effect.World = Matrix.CreateRotationZ(1.5f) *
                        Matrix.CreateRotationX(_rotation) *
                        Matrix.CreateTranslation(_position) *
                        Matrix.CreateTranslation(_offset);
                }
                mesh.Draw();
            }
            Game.GraphicsDevice.RasterizerState = rsold;
        }
開發者ID:Bakkes,項目名稱:Karo,代碼行數:30,代碼來源:BeachBallComponent.cs

示例7: Draw

        public override void Draw(GameTime gameTime)
        {
            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            device.RasterizerState = rs;

            viewMatrix = Game1.Instance.Camera.getView();
            projectionMatrix = Game1.Instance.Camera.getProjection();

            Matrix worldMatrix = Matrix.Identity;
            effect.CurrentTechnique = effect.Techniques["Colored"];
            effect.Parameters["xView"].SetValue(viewMatrix);
            effect.Parameters["xProjection"].SetValue(projectionMatrix);
            effect.Parameters["xWorld"].SetValue(worldMatrix);
            Vector3 lightDirection = new Vector3(1.0f, -1.0f, -1.0f);
            lightDirection.Normalize();
            effect.Parameters["xLightDirection"].SetValue(lightDirection);
            effect.Parameters["xAmbient"].SetValue(0.1f);
            effect.Parameters["xEnableLighting"].SetValue(true);

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

                device.Indices = myIndexBuffer;
                device.SetVertexBuffer(myVertexBuffer);
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indices.Length / 3);
            }

            base.Draw(gameTime);
        }
開發者ID:DarrenLyne,項目名稱:Game-Engine-Assignment1,代碼行數:31,代碼來源:MarsTerrain.cs

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

示例9: Draw

        public override void Draw()
        {
            MilkShake.Graphics.SamplerStates[0] = new SamplerState()
            {
                AddressU = TextureAddressMode.Wrap,
                AddressV = TextureAddressMode.Clamp,
                AddressW = TextureAddressMode.Wrap
            };

            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            rs.FillMode = (KeyboardInput.isKeyDown(Keys.LeftShift)) ? FillMode.WireFrame : FillMode.Solid;
            rs.MultiSampleAntiAlias = true;
            MilkShake.Graphics.RasterizerState = rs;

            _effect.TextureEnabled = true;
            _effect.Texture = _texture.Texture;
            _effect.LightingEnabled = false;
            _effect.VertexColorEnabled = false;

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

                foreach (VertexPositionTexture[] currentQuad in _renderVerticies.Values)
                {
                    MilkShake.GraphicsManager.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, currentQuad, 0, 2, VertexPositionTexture.VertexDeclaration);
                }
            }

            base.Draw();
        }
開發者ID:lucas-jones,項目名稱:MilkShake-old,代碼行數:32,代碼來源:TextureGiftWrapRenderer.cs

示例10: Initialize

        /// <summary>
        /// Inicializa os componentes da camara
        /// </summary>
        /// <param name="graphics">Instância de GraphicsDevice</param>
        public static void Initialize(GraphicsDevice graphics)
        {
            //Posição inicial da camâra
            position = new Vector3(0, 3, 15);
            //Inicializar as matrizes world, view e projection
            World = Matrix.Identity;
            UpdateViewMatrix();
            Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45),
                graphics.Viewport.AspectRatio,
                nearPlane,
                farPlane);

            //Criar e definir o resterizerState a utilizar para desenhar a geometria
            RasterizerState rasterizerState = new RasterizerState();
            //Desenha todas as faces, independentemente da orientação
            rasterizerState.CullMode = CullMode.None;
            //rasterizerState.FillMode = FillMode.WireFrame;
            rasterizerState.MultiSampleAntiAlias = true;
            graphics.RasterizerState = rasterizerState;

            //Coloca o rato no centro do ecrã
            Mouse.SetPosition(graphics.Viewport.Width / 2, graphics.Viewport.Height / 2);

            originalMouseState = Mouse.GetState();
        }
開發者ID:pedroabgmarques,項目名稱:IP3D,代碼行數:29,代碼來源:Camera.cs

示例11: Draw

        protected override void Draw(GameTime gameTime)
        {
            float time = (float)gameTime.TotalGameTime.TotalMilliseconds / 100.0f;
            RasterizerState rs = new RasterizerState();
            if (_geometryAndSettings.WireFramesOnly)
            {
                rs.FillMode = FillMode.WireFrame;
            }
            rs.CullMode = CullMode.None; // CullCounterClockwiseFace;

            _geometryAndSettings.device.RasterizerState = rs;

            DrawRefractionMap();
            DrawReflectionMap();

            Color bgColor = new Color(0.94140625f, 0.7421875f, 0.21484375f);

            _geometryAndSettings.device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, bgColor, 1.0f, 0);

            DrawSkyDome(_geometryAndSettings.viewMatrix);

            DrawTerrain(_geometryAndSettings.viewMatrix);

            DrawWater(time / 10);

            base.Draw(gameTime);
        }
開發者ID:mikerandrup,項目名稱:XNA_WaterFlow3D,代碼行數:27,代碼來源:WaterFlowSim.cs

示例12: Draw

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            mDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);

            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            mDevice.RasterizerState = rs;

            effect.Parameters["xView"].SetValue(viewMatrix);
            effect.Parameters["xProjection"].SetValue(projectionMatrix);
            effect.Parameters["xWorld"].SetValue(Matrix.Identity);
            effect.Parameters["xTexture"].SetValue(mTerrain.getTexture());

            effect.CurrentTechnique = effect.Techniques["Textured"];
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                mTerrain.draw(mDevice);
            }

            effect.CurrentTechnique = effect.Techniques["Colored"];
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                mXWing.draw(viewMatrix, projectionMatrix);
                mTable.draw(viewMatrix, projectionMatrix);
                mSkydome.draw(viewMatrix, projectionMatrix);
            }

            base.Draw(gameTime);
        }
開發者ID:mattgmg1990,項目名稱:Computer-Graphics-Final-Project,代碼行數:37,代碼來源:FinalProject.cs

示例13: LoadContent

        protected override void LoadContent()
        {
            map = new TiledMap(Content, "Content/HacksoiContent/test.tmx", "HacksoiContent/");

            graphics.PreferredBackBufferWidth = map.Map.Width * map.Map.TileWidth;
            graphics.PreferredBackBufferHeight = map.Map.Height * map.Map.TileHeight;
            graphics.ApplyChanges();
            centerWindow();
            
            cameraPosition = Vector2.Zero;
            screenCenter = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2f, graphics.GraphicsDevice.Viewport.Height / 2f);
            batch = new SpriteBatch(graphics.GraphicsDevice);

            basicEffect = new BasicEffect(graphics.GraphicsDevice);
            basicEffect.Projection = Matrix.CreateOrthographic(graphics.GraphicsDevice.Viewport.Width, -graphics.GraphicsDevice.Viewport.Height, 0.1f, 1000f);
            basicEffect.View = Matrix.Identity;
            basicEffect.World = Matrix.Identity;
            basicEffect.TextureEnabled = true;

            rasterizerState = new RasterizerState();
            rasterizerState.CullMode = CullMode.None;

            font = Content.Load<SpriteFont>("Font");

            LoadWorld();
        }
開發者ID:AnotherProgrammingGroup,項目名稱:Project-CS,代碼行數:26,代碼來源:HacksoiGame.cs

示例14: GdxSpriteBatch

        public GdxSpriteBatch(GraphicsDevice graphicsDevice)
        {
            if (graphicsDevice == null)
                throw new ArgumentNullException("graphicsDevice");

            _device = graphicsDevice;

            _spriteEffect = new LocalSpriteEffect(graphicsDevice);
            _matrixTransform = _spriteEffect.Parameters["MatrixTransform"];
            _spritePass = _spriteEffect.CurrentTechnique.Passes[0];

            _transformMatrix = Matrix.Identity;
            //_projectionMatrix = Matrix.CreateOrthographicOffCenter(0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0, 1);
            _projectionMatrix = XnaExt.Matrix.CreateOrthographic2D(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, -1, 0);

            Color = Color.White;

            CalculateIndexBuffer();

            _rasterizerScissorState = new RasterizerState() {
                CullMode = CullMode.None,
                ScissorTestEnable = true,
            };

            // projection uses CreateOrthographicOffCenter to create 2d projection
            // matrix with 0,0 in the upper left.
            /*_basicEffect.Projection = Matrix.CreateOrthographicOffCenter
                (0, graphicsDevice.Viewport.Width,
                graphicsDevice.Viewport.Height, 0,
                0, 1);
            this._basicEffect.World = Matrix.Identity;
            this._basicEffect.View = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward,
                Vector3.Up);*/
        }
開發者ID:jaquadro,項目名稱:MonoGdx,代碼行數:34,代碼來源:GdxSpriteBatch.cs

示例15: Game1

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            collisionSystem = new CollisionSystemPersistentSAP();
            collisionSystem.CollisionDetected += new CollisionDetectedHandler(CollisionDetected);

            world = new World(collisionSystem);

            Random rr = new Random();
            rndColors = new Color[20];
            for (int i = 0; i < 20; i++)
            {
                rndColors[i] = new Color((float)rr.NextDouble(), (float)rr.NextDouble(), (float)rr.NextDouble());
            }

            wireframe = new RasterizerState();
            wireframe.FillMode = FillMode.WireFrame;

            cullMode = new RasterizerState();
            cullMode.CullMode = CullMode.None;

            normal = new RasterizerState();
        }
開發者ID:scy7he,項目名稱:Pong,代碼行數:25,代碼來源:Game1.cs


注:本文中的Microsoft.Xna.Framework.Graphics.RasterizerState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。