//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; }
public Biome() { moistureZoneHigh = 0; moistureZoneLow = 0; heightZoneHigh = 0; heightZoneLow = 0; topBlock = Block.empty; }
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); } }
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; }
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; }
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); } } }
public void SetBlock(int x, int y, int z, Block block) { if (storage != null) { storage.SetBlockId(x,y,z, block.blockID); } }
public virtual void OnNearbyBlockUpdate(int x, int y, int z, int otherX, int otherY, int otherZ, Block otherblock, World world) { }
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); }
public void SetBlockSilent(Vector3 loc, Block block) { GetBlockdataRefresh(loc).blockID = block.blockID; }
public void SetBlockSilent(int x, int y, int z, Block block) { GetBlockdataRefresh(x, y, z).blockID = block.blockID; }
public BlockStorage(int scale, Block defaultBlock) { topNode = new OctreeNode(32, defaultBlock.blockID, 5, new OpenTK.Vector3(16, 16, 16)); this.scale = scale; isOutdated = true; }
public void SetBlock(int x, int y, int z, Block block) { GetBlockdataRefresh(x, y, z).blockID = block.blockID; AddNearbyBlocksToUpdateQueue(x, y, z, block); }
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; }
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)); }
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)); }
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)); }
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)); }
public Chunk(int chunkX, int chunkY, int chunkZ, Block defaultBlock, World world) { Init (chunkX, chunkY, chunkZ, defaultBlock, world); }
public void SetBlock(Vector3 loc, Block block) { GetBlockdataRefresh(loc).blockID = block.blockID; AddNearbyBlocksToUpdateQueue(loc, block); }