コード例 #1
0
ファイル: Chunk.cs プロジェクト: xposure/BOTA
 public Chunk(ChunkManager cm, int x, int y, int z, GraphicsDevice device)
     : base(device, new Dimensions(new int[] { Constants.CHUNK_SIZE, Constants.CHUNK_SIZE, Constants.CHUNK_SIZE }))
 {
     this.cm = cm;
     this.x = x;
     this.y = y;
     this.z = z;
     this.aabb = new BoundingBox(WorldPosition, WorldPosition + Vector3.One * Constants.CHUNK_SIZE);
 }
コード例 #2
0
ファイル: ChunkColumn.cs プロジェクト: xposure/BOTA
        public ChunkColumn(ChunkManager cm, int x, int z, GraphicsDevice device)
        {
            this.x = x;
            this.z = z;
            this.aabb = new BoundingBox(WorldPosition, WorldPosition +
                new Vector3(Constants.CHUNK_SIZE, Constants.CHUNK_HEIGHT, Constants.CHUNK_SIZE));
            this.device = device;

            for (var y = 0; y < chunks.Length; y++)
                chunks[y] = new Chunk(cm, x, y, z, device);
        }
コード例 #3
0
ファイル: Chunk.cs プロジェクト: xposure/BOTA
        public void Generate(ChunkManager cm)
        {
            var h = new int[] { 0, Constants.CHUNK_SIZE };
            var w = new int[] { 0, Constants.CHUNK_SIZE };
            var l = new int[] { 0, Constants.CHUNK_SIZE };

            //int[] d = { h[0] - l[0], h[1] - l[1], h[2] - l[2] };
            int[] d = { Constants.CHUNK_SIZE, Constants.CHUNK_SIZE, Constants.CHUNK_SIZE };
            cm.WorldGenerator.GetChunk(x, z, y, this);
        }
コード例 #4
0
ファイル: Chunk.cs プロジェクト: xposure/BOTA
 public void UpdateMesh(ChunkManager cm)
 {
     SurfaceExtractor.ExtractMesh(this);
 }
コード例 #5
0
ファイル: Game1.cs プロジェクト: xposure/BOTA
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            instance = this;

            base.Initialize();

            _chunkManager = new ChunkManager(this.GraphicsDevice);

            //var data = new uint[3 * 3 *3];
            //for(var i =0;i < data.Length;i++){
            //    if((i % 4) == 0)
            //        data[i] = 0xffffff;
            //}

            //_volume = new Volume(_chunkManager, 0, 0, 0, data, new Dimensions(new int[] { 3, 3, 3 }));

            sceneCamera = new Camera(this.GraphicsDevice);

            //float tilt = MathHelper.ToRadians(0);  // 0 degree angle
            //// Use the world matrix to tilt the cube along x and y axes.
            //worldMatrix = Matrix.CreateRotationX(tilt) * Matrix.CreateRotationY(tilt);
            //viewMatrix = Matrix.CreateLookAt(new Vector3(zoom, zoom, zoom), Vector3.Zero, Vector3.Up);

            //projectionMatrix = Matrix.CreatePerspectiveFieldOfView(
            //    MathHelper.ToRadians(45),  // 45 degree angle
            //    (float)GraphicsDevice.Viewport.Width /
            //    (float)GraphicsDevice.Viewport.Height,
            //    1.0f, 10000.0f);

            basicEffect = new BasicEffect(graphics.GraphicsDevice);

            basicEffect.World = Matrix.Identity;
            basicEffect.View = Matrix.Identity;
            basicEffect.Projection = sceneCamera.Projection;

            // primitive color
            basicEffect.AmbientLightColor = new Vector3(0.1f, 0.1f, 0.1f);
            basicEffect.DiffuseColor = new Vector3(1.0f, 1.0f, 1.0f);
            basicEffect.SpecularColor = new Vector3(0.25f, 0.25f, 0.25f);
            basicEffect.SpecularPower = 5.0f;
            basicEffect.Alpha = 1.0f;
            basicEffect.VertexColorEnabled = true;
            //basicEffect.FogEnabled = true;
            //basicEffect.FogColor = new Vector3(0, 0, 0);
            //basicEffect.FogStart = 10;
            //basicEffect.FogEnd = 100;
            wireFrame = new BasicEffect(graphics.GraphicsDevice);

            wireFrame.World = Matrix.Identity;
            wireFrame.View = Matrix.Identity;
            wireFrame.Projection = sceneCamera.Projection;

            // primitive color
            wireFrame.AmbientLightColor = new Vector3(0.1f, 0.1f, 0.1f);
            wireFrame.DiffuseColor = new Vector3(1.0f, 1.0f, 1.0f);
            wireFrame.SpecularColor = new Vector3(0.25f, 0.25f, 0.25f);
            wireFrame.SpecularPower = 5.0f;
            wireFrame.Alpha = 1.0f;
            wireFrame.VertexColorEnabled = false;
            wireFrame.LightingEnabled = true;

            basicEffect.LightingEnabled = true;
            if (basicEffect.LightingEnabled)
            {
                basicEffect.DirectionalLight0.Enabled = true; // enable each light individually
                if (basicEffect.DirectionalLight0.Enabled)
                {
                    // x direction
                    basicEffect.AmbientLightColor = new Vector3(1, 1, 1);
                    basicEffect.DirectionalLight0.DiffuseColor = new Vector3(0.1f, 0.1f, 0.1f); // range is 0 to 1
                    basicEffect.DirectionalLight0.Direction = Vector3.Normalize(new Vector3(-0.25f, -1, -0.5f));
                    // points from the light to the origin of the scene
                    basicEffect.DirectionalLight0.SpecularColor = Vector3.Zero;
                    //basicEffect.DirectionalLight0.SpecularColor = Vector3.One;
                }
            }

            mouseState = Mouse.GetState();
            keyboardState = Keyboard.GetState();

            //_chunkManager.Initialize();
            var generator = new DefaultWorldGenerator();
            world = new World(GraphicsDevice, 192, 128);
            world.Generate(generator);

            arialFont = Content.Load<SpriteFont>("fonts/arial");
            voxelEffect = Content.Load<Effect>("shaders/voxelshader");

            selection = new VoxelVolume(this.GraphicsDevice, new Dimensions(new int[] { world.Size, 1, world.Size }));
        }
コード例 #6
0
ファイル: ChunkColumn.cs プロジェクト: xposure/BOTA
 public void UpdateMesh(ChunkManager cm)
 {
     for (var y = 0; y < chunks.Length; y++)
         chunks[y].UpdateMesh(cm);
 }
コード例 #7
0
ファイル: ChunkColumn.cs プロジェクト: xposure/BOTA
 public void Init(ChunkManager cm)
 {
     for (var y = 0; y < chunks.Length; y++)
         chunks[y].Generate(cm);
 }