public Chunk(GraphicsDevice device, Texture2D[] texture, Texture2D map, ReadHue hue, int xPos, int zPos, Tank tank) { _stoneTexture = texture[0]; _dirtTexture = texture[1]; _grassTexture = texture[2]; _dynamicTexture = texture[3]; _device = device; _xPos = xPos; _zPos = zPos; _tank = tank; isSetVoxelSmal = false; nrChunksX = 16; nrChunksY = 32; nrChunksZ = 16; //x = 1f; chunkData = hue.GetChunkData(xPos, zPos); ConvertToDoubleVoxelsInChunk(); isSetVoxelSmal = tank.isVoxelSmall; Init(); if (stoneVertices.Count > 0) { _stoneBuffer = new VertexBuffer(device, VertexPositionTexture.VertexDeclaration, stoneVertices.Count, BufferUsage.WriteOnly); _stoneBuffer.SetData <VertexPositionTexture>(stoneVertices.ToArray()); } if (dirtVertices.Count > 0) { _dirtBuffer = new VertexBuffer(device, VertexPositionTexture.VertexDeclaration, dirtVertices.Count, BufferUsage.WriteOnly); _dirtBuffer.SetData <VertexPositionTexture>(dirtVertices.ToArray()); } if (grassVertices.Count > 0) { _grassBuffer = new VertexBuffer(device, VertexPositionTexture.VertexDeclaration, grassVertices.Count, BufferUsage.WriteOnly); _grassBuffer.SetData <VertexPositionTexture>(grassVertices.ToArray()); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); //test = Content.Load<Model>("test"); Texture2D[] textures = new Texture2D[4]; textures[0] = Content.Load<Texture2D>("stone"); textures[1] = Content.Load<Texture2D>("dirt"); textures[2] = Content.Load<Texture2D>("grass"); textures[3] = Content.Load<Texture2D>("dot"); map = Content.Load<Texture2D>("berg"); effect = new BasicEffect(GraphicsDevice); tank = new Tank(); tank.Load(Content); hue = new ReadHue(map, this.GraphicsDevice, textures, tank); tank.ReadHueForTank(hue); fCamera = new FlyingCamera(); this.camera = new Camera(GraphicsDevice, new Vector3(0, 0, 0)); }