Ejemplo n.º 1
0
        //private static Vector2[] uv = new Vector2[]{new Vector2(1,0), new Vector2(0,0), new Vector2(0,1), new Vector2(1,1)};
        public List<Vertex> GetVertices(OctreeNode node, Block block, Chunk chunk, World world)
        {
            List<Vertex> vertices = new List<Vertex>();

            int x = (int)(chunk.GetWorldLocation().X + node.origin.X),
                y = (int)(chunk.GetWorldLocation().Y + node.origin.Y),
                z = (int)(chunk.GetWorldLocation().Z + node.origin.Z);

            for(int face = 0; face < 6; face++){
                Vector2[] uv = block.GetUV(face);
                Block block2 = world.GetBlock(x + (addsX[face] * node.blockSize), y + (addsX[face + 6] * node.blockSize), z + (addsX[face + 12] * node.blockSize));
                if(!block2.material.solid)
                {
                    int baseCorner = face * 4;
                    for(int corner = 0; corner < 4; corner++){
                        Vertex vertex = new Vertex(corners[quadsOrder[baseCorner + corner]] * node.blockSize);
                        vertex.position += node.origin - new Vector3(node.blockSize / 2f, node.blockSize / 2f, node.blockSize / 2f);
                        vertex.color = block.material.color * brightness[face];
                        vertex.normal.X = node.blockSize;
                        vertex.normal.Y = block.GetSheetX(face);
                        vertex.normal.Z = block.GetSheetY(face);
                        vertex.texCoord = uv[corner];
                        vertices.Add(vertex);
                        triangles += 2;
                    }
                }
            }
            return vertices;
        }
Ejemplo n.º 2
0
 public Biome()
 {
     moistureZoneHigh = 0;
     moistureZoneLow = 0;
     heightZoneHigh = 0;
     heightZoneLow = 0;
     topBlock = Block.empty;
 }
Ejemplo n.º 3
0
 public void CheckBlock(int x, int y, int z, int addX, int addY, int addZ, Block otherblock, World world)
 {
     Block other = world.GetBlock (x + addX, y + addY, z + addZ);
     if (other == Block.empty) {
         world.SetBlockSilent (x + addX, y + addY, z + addZ, Block.water);
         world.AddToUpdateQueue (x + addX, y + addY, z + addZ, x, y, z, otherblock);
     }
 }
Ejemplo n.º 4
0
 public Biome(int moistHigh, int moistLow, int heightHigh, int heightLow, Block block)
 {
     this.moistureZoneHigh = moistHigh;
     this.moistureZoneLow = moistLow;
     this.heightZoneHigh = heightHigh;
     this.heightZoneLow = heightLow;
     this.topBlock = block;
 }
Ejemplo n.º 5
0
 public NearbyUpdate(int x, int y, int z, int oriX, int oriY, int oriZ, Block block, World world)
 {
     this.x = x;
     this.y = y;
     this.z = z;
     this.oriX = oriX;
     this.oriY = oriY;
     this.oriZ = oriZ;
     this.block = block;
     this.world = world;
 }
Ejemplo n.º 6
0
        public override void OnNearbyBlockUpdate(int x, int y, int z, int otherX, int otherY, int otherZ, Block otherblock, World world)
        {
            base.OnNearbyBlockUpdate (x, y, z, otherX, otherY, otherZ, otherblock, world);

            for(int i = 0; i < 5; i++)
            {
                int x1 = checks[i], y1 = checks[i + 5], z1 = checks[i + 10];
                if(otherblock != Block.water || (x1 != otherX && y1 != otherY && z1 != otherZ))
                {
                    CheckBlock(x,y,z,x1,y1,z1, otherblock, world);
                }
            }
        }
Ejemplo n.º 7
0
 public void SetBlock(int x, int y, int z, Block block)
 {
     if (storage != null) {
         storage.SetBlockId(x,y,z, block.blockID);
     }
 }
Ejemplo n.º 8
0
 public virtual void OnNearbyBlockUpdate(int x, int y, int z, int otherX, int otherY, int otherZ, Block otherblock, World world)
 {
 }
Ejemplo n.º 9
0
 public override void OnNearbyBlockUpdate(int x, int y, int z, int otherX, int otherY, int otherZ, Block otherblock, World world)
 {
     base.OnNearbyBlockUpdate (x, y, z, otherX, otherY, otherZ, otherblock, world);
 }
Ejemplo n.º 10
0
 public void SetBlockSilent(Vector3 loc, Block block)
 {
     GetBlockdataRefresh(loc).blockID = block.blockID;
 }
Ejemplo n.º 11
0
 public void SetBlockSilent(int x, int y, int z, Block block)
 {
     GetBlockdataRefresh(x, y, z).blockID = block.blockID;
 }
Ejemplo n.º 12
0
 public BlockStorage(int scale, Block defaultBlock)
 {
     topNode = new OctreeNode(32, defaultBlock.blockID, 5, new OpenTK.Vector3(16, 16, 16));
     this.scale = scale;
     isOutdated = true;
 }
Ejemplo n.º 13
0
 public void SetBlock(int x, int y, int z, Block block)
 {
     GetBlockdataRefresh(x, y, z).blockID = block.blockID;
     AddNearbyBlocksToUpdateQueue(x, y, z, block);
 }
Ejemplo n.º 14
0
 private void Init(int chunkX, int chunkY, int chunkZ, Block defaultBlock, World world)
 {
     this.world = world;
     storage = new BlockStorage(scale, defaultBlock);
     renderer = new ChunkRenderer(this);
     chunkPos = new Vector3(chunkX, chunkY, chunkZ);
     worldPos = chunkPos * scale;
 }
Ejemplo n.º 15
0
 public void AddToUpdateQueue(int x, int y, int z, int oriX, int oriY, int oriZ, Block block)
 {
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y, z, oriX, oriY, oriZ, block, this));
 }
Ejemplo n.º 16
0
 public void AddToUpdateQueue(Vector3 loc, int oriX, int oriY, int oriZ, Block block)
 {
     nearbyUpdateQueue.Add(new NearbyUpdate((int)loc.X, (int)loc.Y, (int)loc.Z, oriX, oriY, oriZ, block, this));
 }
Ejemplo n.º 17
0
 public void AddNearbyBlocksToUpdateQueue(int x, int y, int z, Block block)
 {
     nearbyUpdateQueue.Add(new NearbyUpdate(x + 1, y, z, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y + 1, z, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y, z + 1, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x - 1, y, z, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y - 1, z, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y, z - 1, x, y, z, block, this));
 }
Ejemplo n.º 18
0
 public void AddNearbyBlocksToUpdateQueue(Vector3 loc, Block block)
 {
     int x = (int)loc.X, y = (int)loc.Y, z = (int)loc.Z;
     nearbyUpdateQueue.Add(new NearbyUpdate(x + 1, y, z, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y + 1, z, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y, z + 1, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x - 1, y, z, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y - 1, z, x, y, z, block, this));
     nearbyUpdateQueue.Add(new NearbyUpdate(x, y, z - 1, x, y, z, block, this));
 }
Ejemplo n.º 19
0
 public Chunk(int chunkX, int chunkY, int chunkZ, Block defaultBlock, World world)
 {
     Init (chunkX, chunkY, chunkZ, defaultBlock, world);
 }
Ejemplo n.º 20
0
 public void SetBlock(Vector3 loc, Block block)
 {
     GetBlockdataRefresh(loc).blockID = block.blockID;
     AddNearbyBlocksToUpdateQueue(loc, block);
 }