Пример #1
0
        public void Render(GraphicsDevice graphicsDevice, GameTime gameTime)
        {
            RegenerateDirtyVertexLists();

            graphicsDevice.BlendState        = BlendState.Opaque;
            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            for (BlockTexture blockTexture = BlockTexture.None + 1; blockTexture < BlockTexture.MAXIMUM; blockTexture++)
            {
                for (uint r = 0; r < NUMREGIONS; r++)
                {
                    // Figure out if we should be rendering translucently.
                    bool renderTranslucent = false;
                    if (blockTexture == BlockTexture.TransRed || blockTexture == BlockTexture.TransBlue)
                    {
                        renderTranslucent = true;
                    }

                    // If this is empty, don't render it.
                    DynamicVertexBuffer regionBuffer = vertexBuffers[(byte)blockTexture, r];
                    if (regionBuffer == null)
                    {
                        continue;
                    }

                    // If this isn't in our view frustum, don't render it.
                    BoundingSphere  regionBounds    = new BoundingSphere(GetRegionCenter(r), REGIONSIZE);
                    BoundingFrustum boundingFrustum = new BoundingFrustum(gameInstance.propertyBag.playerCamera.ViewMatrix * gameInstance.propertyBag.playerCamera.ProjectionMatrix);
                    if (boundingFrustum.Contains(regionBounds) == ContainmentType.Disjoint)
                    {
                        continue;
                    }

                    // Make sure our vertex buffer is clean.
                    if (vertexListDirty[(byte)blockTexture, r])
                    {
                        continue;
                    }

                    // Actually render.
                    RenderVertexList(graphicsDevice, regionBuffer, blockTextures[(byte)blockTexture].Texture, blockTextures[(byte)blockTexture].LODColor, renderTranslucent, blockTexture == BlockTexture.Lava, (float)gameTime.TotalGameTime.TotalSeconds);
                }
            }

            // Apply posteffects.
            if (bloomPosteffect != null)
            {
                bloomPosteffect.Draw(graphicsDevice);
            }
        }