Ejemplo n.º 1
0
        /// <summary>
        /// Dessine cette cellule.
        /// </summary>
        public override void Draw()
        {
            if (!m_genTask.IsRessourceReady)
            {
                throw new Exception("Unable to draw this ressource when it is not ready !");
            }

            // Dessine la cellule.
            var device = Scene.GetGraphicsDevice().ImmediateContext;

            device.InputAssembler.SetIndexBuffer(Generation.ModelGenerator.GetIndexBuffer(GridResolution), Format.R32_UInt, 0);
            device.InputAssembler.PrimitiveTopology = (PrimitiveTopology.TriangleList);
            device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(m_genTask.Ressource.VertexBuffer, Graphics.VertexPositionTextureNormal.Vertex.Stride, 0));

            RasterizerStateDescription rsd = new RasterizerStateDescription()
            {
                CullMode                 = CullMode.Back,
                DepthBias                = 0,
                DepthBiasClamp           = 0.0f,
                FillMode                 = RasterizerFillMode,
                IsAntialiasedLineEnabled = true,
                IsDepthClipEnabled       = true,
                IsFrontCounterclockwise  = false,
                IsMultisampleEnabled     = false,
                IsScissorEnabled         = false,
                SlopeScaledDepthBias     = 0.0f
            };
            RasterizerState rs = RasterizerState.FromDescription(Scene.GetGraphicsDevice(), rsd);

            device.Rasterizer.State = rs;

            // Variables
            Graphics.BasicEffect effect = Scene.GetGraphicsEngine().BasicEffect;
            effect.Apply(Matrix.Identity, Scene.Instance.Camera.View, Scene.Instance.Camera.Projection, m_material);
            device.DrawIndexed(Generation.ModelGenerator.GetIndexBuffer(GridResolution).Description.SizeInBytes / sizeof(int), 0, 0);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Charge les effets qui doivent être initialisés après la création du moteur.
 /// </summary>
 public void LoadFX()
 {
     BasicEffect = new BasicEffect(Scene.GetGraphicsDevice());
     WaterEffect = new WaterEffect(Scene.GetGraphicsDevice());
     AtmosphereEffect = new AtmosphereEffect(Scene.GetGraphicsDevice());
 }