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


C# ICamera.GetMatrices方法代码示例

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


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

示例1: Render

        public void Render(GameTime gameTime, ICamera camera)
        {
            if (_basicEffect != null)
            {
                // Set the effect's parameters.
                Matrix projectionMatrix, viewMatrix;
                camera.GetMatrices(out projectionMatrix, out viewMatrix);

                _basicEffect.Projection = projectionMatrix;
                _basicEffect.View = viewMatrix;
                _basicEffect.World = SceneNode.Transformation;

                // Set the rasterizer state.
                _graphics.DepthStencilState = DepthStencilState.Default;
                _graphics.BlendState = BlendState.AlphaBlend;
                _graphics.RasterizerState = _rasterizerState;

                // Draw the vertex buffer.
                foreach (var effectPass in _basicEffect.CurrentTechnique.Passes)
                {
                    effectPass.Apply();
                    _graphics.DrawUserPrimitives(PrimitiveType.TriangleList, _particleVertices, 0, _particles.Length, VertexPositionColor.VertexDeclaration);
                }
            }
        }
开发者ID:jwvdiermen,项目名称:LD28,代码行数:25,代码来源:DustCloud.cs

示例2: Draw

        /// <summary>
        /// This method draws the terrain.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <param name="camera">The camera.</param>
        public void Draw(GameTime gameTime, ICamera camera)
        {
            _graphics.RasterizerState = _rasterizerState;
            _graphics.DepthStencilState = DepthStencilState.Default;

            // Set the debug effect's parameters.
            Matrix projectionMatrix, viewMatrix;
            camera.GetMatrices(out projectionMatrix, out viewMatrix);

            // Draw the enabled quads.
            foreach (var quadTree in _blockGrid)
            {
                _effect.Projection = projectionMatrix;
                _effect.View = viewMatrix;
                _effect.World = quadTree.SceneNode.Transformation;
                foreach (var effectPass in _effect.CurrentTechnique.Passes)
                {
                    effectPass.Apply();
                    quadTree.Draw(true);
                }
            }

            if (DebugEnabled)
            {
                _graphics.RasterizerState = _debugRasterizerState;

                // Draw the enabled quads.
                _debugEffect.DiffuseColor = new Vector3(0.0f, 0.0f, 1.0f);
                foreach (var quadTree in _blockGrid)
                {
                    _debugEffect.Projection = projectionMatrix;
                    _debugEffect.View = viewMatrix;
                    _debugEffect.World = quadTree.SceneNode.Transformation;
                    foreach (var effectPass in _debugEffect.CurrentTechnique.Passes)
                    {
                        effectPass.Apply();
                        quadTree.Draw(true);
                    }
                }

                // Draw the disabled quads.
                _debugEffect.DiffuseColor = new Vector3(1.0f, 0.0f, 0.0f);
                foreach (var quadTree in _blockGrid)
                {
                    _debugEffect.Projection = projectionMatrix;
                    _debugEffect.View = viewMatrix;
                    _debugEffect.World = quadTree.SceneNode.Transformation;
                    foreach (var effectPass in _debugEffect.CurrentTechnique.Passes)
                    {
                        effectPass.Apply();
                        quadTree.Draw(false);
                    }
                }
            }
        }
开发者ID:jwvdiermen,项目名称:LD28,代码行数:60,代码来源:Terrain.cs

示例3: Render

        public void Render(GameTime gameTime, ICamera camera)
        {
            if (_basicEffect != null)
            {
                // Generate the vertices and indices.
                var screenSize = camera.ScreenSize;
                var halfWidth = (screenSize.X / 2.0f) * 1.01f;
                var halfHeight = (screenSize.Y / 2.0f) * 1.01f;
                var uv = screenSize / Scale;

                var vertices = new[]
                {
                    new VertexPositionColorTexture
                    {
                        Position = new Vector3(-halfWidth, -halfHeight, 0.0f),
                        TextureCoordinate = new Vector2(0.0f, 0.0f),
                        Color = Color.White
                    },
                    new VertexPositionColorTexture
                    {
                        Position = new Vector3(halfWidth, -halfHeight, 0.0f),
                        TextureCoordinate = new Vector2(uv.X, 0.0f),
                        Color = Color.White
                    },
                    new VertexPositionColorTexture
                    {
                        Position = new Vector3(halfWidth, halfHeight, 0.0f),
                        TextureCoordinate = new Vector2(uv.X, uv.Y),
                        Color = Color.White
                    },
                    new VertexPositionColorTexture
                    {
                        Position = new Vector3(-halfWidth, halfHeight, 0.0f),
                        TextureCoordinate = new Vector2(0.0f, uv.Y),
                        Color = Color.White
                    }
                };

                var indices = new short[] { 0, 3, 1, 1, 3, 2 };

                // Set the effect's parameters.
                Matrix projectionMatrix, viewMatrix;
                camera.GetMatrices(out projectionMatrix, out viewMatrix);

                _basicEffect.Projection = projectionMatrix;
                _basicEffect.View = Matrix.Identity;
                _basicEffect.World = Matrix.Identity;

                // Set the device states.
                _graphics.BlendState = BlendState.Opaque;
                _graphics.RasterizerState = _rasterizerState;
                _graphics.SamplerStates[0] = SamplerState.LinearWrap;

                // Draw.
                foreach (var effectPass in _basicEffect.CurrentTechnique.Passes)
                {
                    effectPass.Apply();
                    _graphics.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0,
                                                        indices.Length / 3);
                }
            }
        }
开发者ID:jwvdiermen,项目名称:LD28,代码行数:62,代码来源:BackgroundSprite.cs

示例4: Render

        public void Render(GameTime gameTime, ICamera camera)
        {
            if (m_vertexBuffer != null && m_indexBuffer != null && m_basicEffect != null)
            {
                // Set the effect's parameters.
                Matrix projectionMatrix, viewMatrix;
                camera.GetMatrices(out projectionMatrix, out viewMatrix);

                m_basicEffect.Projection = projectionMatrix;
                m_basicEffect.View = viewMatrix;
                m_basicEffect.World =
                    Matrix.CreateRotationZ(MathHelper.ToRadians(this.SceneNode.Rotation)) *
                    Matrix.CreateTranslation(new Vector3(this.SceneNode.Position, this.SceneNode.Depth)) *
                    Matrix.CreateScale(new Vector3(this.SceneNode.Scale, 1.0f));

                // Set the rasterizer state.
                m_graphics.BlendState = BlendState.AlphaBlend;
                m_graphics.RasterizerState = m_rasterizerState;

                // Draw the vertex buffer.
                m_graphics.SetVertexBuffer(m_vertexBuffer);
                m_graphics.Indices = m_indexBuffer;

                foreach (var effectPass in m_basicEffect.CurrentTechnique.Passes)
                {
                    effectPass.Apply();
                    m_graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, m_vertexBuffer.VertexCount, 0, m_indexBuffer.IndexCount / 3);
                }
            }
        }
开发者ID:jwvdiermen,项目名称:LD23,代码行数:30,代码来源:Atmosphere.cs

示例5: Render

        public void Render(GameTime gameTime, ICamera camera)
        {
            if (_vertexBuffer != null)
            {
                // Set the effect's parameters.
                Matrix projectionMatrix, viewMatrix;
                camera.GetMatrices(out projectionMatrix, out viewMatrix);

                _basicEffect.Projection = projectionMatrix;
                _basicEffect.View = viewMatrix;
                _basicEffect.World = SceneNode.Transformation;

                _basicEffect.DiffuseColor = this.Color;

                // Set the rasterizer state.
                _graphics.RasterizerState = _rasterizerState;

                // Draw the vertex buffer.
                foreach (var effectPass in _basicEffect.CurrentTechnique.Passes)
                {
                    effectPass.Apply();

                    _graphics.SetVertexBuffer(_vertexBuffer);
                    _graphics.DrawPrimitives(PrimitiveType.LineStrip, 0, _vertexBuffer.VertexCount - 1);
                }
            }
        }
开发者ID:jwvdiermen,项目名称:LD28,代码行数:27,代码来源:CircleRenderable.cs

示例6: Render

        public void Render(GameTime gameTime, ICamera camera)
        {
            if (_vertexBuffer != null && _indexBuffer != null && _basicEffect != null)
            {
                // Set the effect's parameters.
                Matrix projectionMatrix, viewMatrix;
                camera.GetMatrices(out projectionMatrix, out viewMatrix);

                _basicEffect.Projection = projectionMatrix;
                _basicEffect.View = viewMatrix;
                _basicEffect.World = SceneNode.Transformation;

                // Set the rasterizer state.
                _graphics.DepthStencilState = DepthStencilState.Default;
                _graphics.BlendState = BlendState;
                _graphics.RasterizerState = RasterizerState;
                _graphics.SamplerStates[0] = SamplerState;

                // Draw the vertex buffer.
                foreach (var effectPass in _basicEffect.CurrentTechnique.Passes)
                {
                    effectPass.Apply();

                    _graphics.SetVertexBuffer(_vertexBuffer);
                    _graphics.Indices = _indexBuffer;

                    _graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertexBuffer.VertexCount, 0,
                                                     _indexBuffer.IndexCount / 3);
                }
            }
        }
开发者ID:jwvdiermen,项目名称:LD28,代码行数:31,代码来源:StaticSprite.cs


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