Example #1
0
        public ChunkModule(TrueCraftGame game)
        {
            Game = game;

            ChunkRenderer = new ChunkRenderer(Game.Client.World, Game, Game.BlockRepository);
            Game.Client.ChunkLoaded += (sender, e) => ChunkRenderer.Enqueue(e.Chunk);
            Game.Client.ChunkUnloaded += (sender, e) => UnloadChunk(e.Chunk);
            Game.Client.ChunkModified += (sender, e) => ChunkRenderer.Enqueue(e.Chunk, true);
            ChunkRenderer.MeshCompleted += MeshCompleted;
            ChunkRenderer.Start();

            OpaqueEffect = new BasicEffect(Game.GraphicsDevice);
            OpaqueEffect.TextureEnabled = true;
            OpaqueEffect.Texture = Game.TextureMapper.GetTexture("terrain.png");
            OpaqueEffect.FogEnabled = true;
            OpaqueEffect.FogStart = 512f;
            OpaqueEffect.FogEnd = 1000f;
            OpaqueEffect.FogColor = Color.CornflowerBlue.ToVector3();
            OpaqueEffect.VertexColorEnabled = true;

            TransparentEffect = new AlphaTestEffect(Game.GraphicsDevice);
            TransparentEffect.AlphaFunction = CompareFunction.Greater;
            TransparentEffect.ReferenceAlpha = 127;
            TransparentEffect.Texture = Game.TextureMapper.GetTexture("terrain.png");
            TransparentEffect.VertexColorEnabled = true;

            ChunkMeshes = new List<ChunkMesh>();
            IncomingChunks = new ConcurrentBag<Mesh>();
            ActiveMeshes = new HashSet<Coordinates2D>();
        }
Example #2
0
        public ChunkModule(TrueCraftGame game)
        {
            Game = game;

            ChunkRenderer                = new ChunkRenderer(Game.Client.World, Game, Game.BlockRepository);
            Game.Client.ChunkLoaded     += Game_Client_ChunkLoaded;
            Game.Client.ChunkUnloaded   += (sender, e) => UnloadChunk(e.Chunk);
            Game.Client.ChunkModified   += Game_Client_ChunkModified;
            Game.Client.BlockChanged    += Game_Client_BlockChanged;
            ChunkRenderer.MeshCompleted += MeshCompleted;
            ChunkRenderer.Start();
            WorldLighting = new WorldLighting(Game.Client.World.World, Game.BlockRepository);

            OpaqueEffect = new BasicEffect(Game.GraphicsDevice);
            OpaqueEffect.TextureEnabled     = true;
            OpaqueEffect.Texture            = Game.TextureMapper.GetTexture("terrain.png");
            OpaqueEffect.FogEnabled         = true;
            OpaqueEffect.FogStart           = 0;
            OpaqueEffect.FogEnd             = Game.Camera.Frustum.Far.D * 0.8f;
            OpaqueEffect.VertexColorEnabled = true;
            OpaqueEffect.LightingEnabled    = true;

            TransparentEffect = new AlphaTestEffect(Game.GraphicsDevice);
            TransparentEffect.AlphaFunction      = CompareFunction.Greater;
            TransparentEffect.ReferenceAlpha     = 127;
            TransparentEffect.Texture            = Game.TextureMapper.GetTexture("terrain.png");
            TransparentEffect.VertexColorEnabled = true;
            OpaqueEffect.LightingEnabled         = true;

            ChunkMeshes    = new List <ChunkMesh>();
            IncomingChunks = new ConcurrentBag <Mesh>();
            ActiveMeshes   = new HashSet <Coordinates2D>();
        }
Example #3
0
        public ChunkModule(TrueCraftGame game)
        {
            Game = game;

            ChunkRenderer                = new ChunkRenderer(Game.Client.World, Game, Game.BlockRepository);
            Game.Client.ChunkLoaded     += (sender, e) => ChunkRenderer.Enqueue(e.Chunk);
            Game.Client.ChunkUnloaded   += (sender, e) => UnloadChunk(e.Chunk);
            Game.Client.ChunkModified   += (sender, e) => ChunkRenderer.Enqueue(e.Chunk, true);
            ChunkRenderer.MeshCompleted += MeshCompleted;
            ChunkRenderer.Start();

            OpaqueEffect = new BasicEffect(Game.GraphicsDevice);
            OpaqueEffect.TextureEnabled     = true;
            OpaqueEffect.Texture            = Game.TextureMapper.GetTexture("terrain.png");
            OpaqueEffect.FogEnabled         = true;
            OpaqueEffect.FogStart           = 512f;
            OpaqueEffect.FogEnd             = 1000f;
            OpaqueEffect.FogColor           = Color.CornflowerBlue.ToVector3();
            OpaqueEffect.VertexColorEnabled = true;

            TransparentEffect = new AlphaTestEffect(Game.GraphicsDevice);
            TransparentEffect.AlphaFunction      = CompareFunction.Greater;
            TransparentEffect.ReferenceAlpha     = 127;
            TransparentEffect.Texture            = Game.TextureMapper.GetTexture("terrain.png");
            TransparentEffect.VertexColorEnabled = true;

            ChunkMeshes    = new List <ChunkMesh>();
            IncomingChunks = new ConcurrentBag <Mesh>();
            ActiveMeshes   = new HashSet <Coordinates2D>();
        }
Example #4
0
        public ChunkModule(TrueCraftGame game)
        {
            Game = game;

            ChunkRenderer = new ChunkRenderer(Game.Client.World, Game, Game.BlockRepository);
            Game.Client.ChunkLoaded += Game_Client_ChunkLoaded;
            Game.Client.ChunkUnloaded += (sender, e) => UnloadChunk(e.Chunk);
            Game.Client.ChunkModified += Game_Client_ChunkModified;
            Game.Client.BlockChanged += Game_Client_BlockChanged;
            ChunkRenderer.MeshCompleted += MeshCompleted;
            ChunkRenderer.Start();
            WorldLighting = new WorldLighting(Game.Client.World.World, Game.BlockRepository);

            OpaqueEffect = new BasicEffect(Game.GraphicsDevice);
            OpaqueEffect.TextureEnabled = true;
            OpaqueEffect.Texture = Game.TextureMapper.GetTexture("terrain.png");
            OpaqueEffect.FogEnabled = true;
            OpaqueEffect.FogStart = 0;
            OpaqueEffect.FogEnd = Game.Camera.Frustum.Far.D * 0.8f;
            OpaqueEffect.VertexColorEnabled = true;
            OpaqueEffect.LightingEnabled = true;

            TransparentEffect = new AlphaTestEffect(Game.GraphicsDevice);
            TransparentEffect.AlphaFunction = CompareFunction.Greater;
            TransparentEffect.ReferenceAlpha = 127;
            TransparentEffect.Texture = Game.TextureMapper.GetTexture("terrain.png");
            TransparentEffect.VertexColorEnabled = true;
            OpaqueEffect.LightingEnabled = true;

            ChunkMeshes = new List<ChunkMesh>();
            IncomingChunks = new ConcurrentBag<Mesh>();
            ActiveMeshes = new HashSet<Coordinates2D>();
        }
Example #5
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            graphics.SynchronizeWithVerticalRetrace = true;
            graphics.PreferredBackBufferWidth       = 1920;
            graphics.PreferredBackBufferHeight      = 1080;

            graphics.ApplyChanges();

            System.Windows.Forms.Form frm = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(Window.Handle);
            frm.Location        = new System.Drawing.Point(0, 0);
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            frm.Text            = "XChunk";

            _spriteFont = Content.Load <SpriteFont>("debug");

            IsFixedTimeStep = false;

            Camera        = new Camera(GraphicsDevice, 0.007f, 1f);
            chunkRenderer = new ChunkRenderer(GraphicsDevice, Content, ChunkRenderer.Technique.Optimization_Memory);
            chunkRenderer.Start();
        }
Example #6
0
        protected override void Initialize()
        {
            Interfaces  = new List <IGameInterface>();
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            base.Initialize(); // (calls LoadContent)
            ChunkConverter      = new ChunkRenderer(this, Client.World.World.BlockRepository);
            Client.ChunkLoaded += (sender, e) => ChunkConverter.Enqueue(e.Chunk);
            //Client.ChunkModified += (sender, e) => ChunkConverter.Enqueue(e.Chunk, true);
            ChunkConverter.MeshCompleted += ChunkConverter_MeshGenerated;
            ChunkConverter.Start();
            Client.PropertyChanged += HandleClientPropertyChanged;
            Client.Connect(EndPoint);
            var centerX = GraphicsDevice.Viewport.Width / 2;
            var centerY = GraphicsDevice.Viewport.Height / 2;

            Mouse.SetPosition(centerX, centerY);
            Camera = new Camera(GraphicsDevice.Viewport.AspectRatio, 70.0f, 0.25f, 1000.0f);
            UpdateCamera();
            Window.ClientSizeChanged  += (sender, e) => CreateRenderTarget();
            MouseComponent.Move       += OnMouseComponentMove;
            KeyboardComponent.KeyDown += OnKeyboardKeyDown;
            KeyboardComponent.KeyUp   += OnKeyboardKeyUp;
            CreateRenderTarget();
        }
Example #7
0
 protected override void Initialize()
 {
     Interfaces = new List<IGameInterface>();
     SpriteBatch = new SpriteBatch(GraphicsDevice);
     base.Initialize(); // (calls LoadContent)
     ChunkConverter = new ChunkRenderer(this, Client.World.World.BlockRepository);
     Client.ChunkLoaded += (sender, e) => ChunkConverter.Enqueue(e.Chunk);
     //Client.ChunkModified += (sender, e) => ChunkConverter.Enqueue(e.Chunk, true);
     ChunkConverter.MeshCompleted += ChunkConverter_MeshGenerated;
     ChunkConverter.Start();
     Client.PropertyChanged += HandleClientPropertyChanged;
     Client.Connect(EndPoint);
     var centerX = GraphicsDevice.Viewport.Width / 2;
     var centerY = GraphicsDevice.Viewport.Height / 2;
     Mouse.SetPosition(centerX, centerY);
     Camera = new Camera(GraphicsDevice.Viewport.AspectRatio, 70.0f, 0.25f, 1000.0f);
     UpdateCamera();
     Window.ClientSizeChanged += (sender, e) => CreateRenderTarget();
     MouseComponent.Move += OnMouseComponentMove;
     KeyboardComponent.KeyDown += OnKeyboardKeyDown;
     KeyboardComponent.KeyUp += OnKeyboardKeyUp;
     CreateRenderTarget();
 }