Ballz.GameSession.Renderer.WaterRenderer.LoadContent C# (CSharp) 메소드

LoadContent() 공개 메소드

public LoadContent ( ) : void
리턴 void
        public void LoadContent()
        {
            if (NOWATER)
                return;

            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            ParticleEffect = new BasicEffect(Game.GraphicsDevice);
            ParticleEffect.EnableDefaultLighting();
            ParticleEffect.DiffuseColor = new Vector3(1, 1, 1);
            ParticleEffect.VertexColorEnabled = true;
            ParticleEffect.LightingEnabled = false;
            ParticleEffect.TextureEnabled = false;

            WaterEffect = Game.Content.Load<Effect>("Effects/Water");

            WaterRenderTarget = new RenderTarget2D(Game.GraphicsDevice, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height);

            MetaBallTexture = new Texture2D(Game.GraphicsDevice, MetaBallWidth, MetaBallWidth);
            var metaBallData = new byte[MetaBallWidth * MetaBallWidth * 4];
            int i = 0;
            for(int x = 0; x < MetaBallWidth; x++)
            {
                for(int y = 0; y < MetaBallWidth; y++)
                {
                    var dx = x - MetaBallRadius;
                    var dy = y - MetaBallRadius;
                    var distance = Math.Sqrt(dx * dx + dy * dy) / MetaBallRadius;
                    var blob = 1 - (0.1 + 0.9 * distance);
                    var b = (byte)(127 * Math.Max(0, Math.Min(1, blob)));
                    metaBallData[i++] = b;
                    metaBallData[i++] = b;
                    metaBallData[i++] = b;
                    metaBallData[i++] = 255;// (byte)(d > 14 ? 0 : 128);
                }
            }
            MetaBallTexture.SetData(metaBallData);

            FullscreenQuad = new VertexPositionTexture[]
            {
                new VertexPositionTexture(new Vector3(0, 0, 0.5f), new Vector2(0, 1)),
                new VertexPositionTexture(new Vector3(1, 1, 0.5f), new Vector2(1, 0)),
                new VertexPositionTexture(new Vector3(0, 1, 0.5f), new Vector2(0, 0)),
                new VertexPositionTexture(new Vector3(0, 0, 0.5f), new Vector2(0, 1)),
                new VertexPositionTexture(new Vector3(1, 0, 0.5f), new Vector2(1, 1)),
                new VertexPositionTexture(new Vector3(1, 1, 0.5f), new Vector2(1, 0)),
            };
        }

Usage Example

예제 #1
0
        protected override void LoadContent()
        {
            LineEffect = new BasicEffect(Game.GraphicsDevice);
            LineEffect.EnableDefaultLighting();
            LineEffect.DiffuseColor       = new Vector3(1, 1, 1);
            LineEffect.VertexColorEnabled = true;
            LineEffect.LightingEnabled    = false;
            LineEffect.TextureEnabled     = false;

            sphereVertices = new VertexPositionColor[18];

            for (int i = 0; i <= 16; i++)
            {
                float angle = (float)Math.PI * 2.0f * (float)i / 16;
                sphereVertices[i].Color    = Color.GreenYellow;
                sphereVertices[i].Position = new Vector3(Sin(angle), Cos(angle), 0);
            }

            sphereVertices[17].Color    = Color.GreenYellow;
            sphereVertices[17].Position = Vector3.Zero;

            Matrix terrainWorld = Matrix.CreateScale(0.03f);

            spriteBatch  = new SpriteBatch(Game.GraphicsDevice);
            whiteTexture = new Texture2D(Game.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            whiteTexture.SetData(new Color[1]
            {
                Color.White
            });

            WaterRenderer.LoadContent();

            base.LoadContent();
        }
All Usage Examples Of Ballz.GameSession.Renderer.WaterRenderer::LoadContent