protected void brushStroke(Map map, Map.Coordinate center, int brushSize, Func<Map.Coordinate, Map.CellState> function, bool fill = true, bool empty = true) { Vector3 pos = map.GetRelativePosition(center); List<Map.Coordinate> coords = new List<Map.Coordinate>(); for (Map.Coordinate x = center.Move(Direction.NegativeX, this.BrushSize - 1); x.X < center.X + this.BrushSize; x.X++) { for (Map.Coordinate y = x.Move(Direction.NegativeY, this.BrushSize - 1); y.Y < center.Y + this.BrushSize; y.Y++) { for (Map.Coordinate z = y.Move(Direction.NegativeZ, this.BrushSize - 1); z.Z < center.Z + this.BrushSize; z.Z++) { if ((pos - map.GetRelativePosition(z)).Length() <= this.BrushSize) coords.Add(new Map.Coordinate { X = z.X, Y = z.Y, Z = z.Z, Data = function(z) }); } } } if (empty) map.Empty(coords.Where(x => x.Data.ID == 0)); if (fill) { foreach (Map.Coordinate coord in coords) map.Fill(coord, coord.Data); } }
protected void brushStroke(Map map, Map.Coordinate center, int brushSize, Map.CellState state) { Vector3 pos = map.GetRelativePosition(center); List<Map.Coordinate> coords = new List<Map.Coordinate>(); for (Map.Coordinate x = center.Move(Direction.NegativeX, this.BrushSize - 1); x.X < center.X + this.BrushSize; x.X++) { for (Map.Coordinate y = x.Move(Direction.NegativeY, this.BrushSize - 1); y.Y < center.Y + this.BrushSize; y.Y++) { for (Map.Coordinate z = y.Move(Direction.NegativeZ, this.BrushSize - 1); z.Z < center.Z + this.BrushSize; z.Z++) { if ((pos - map.GetRelativePosition(z)).Length() <= this.BrushSize) coords.Add(z); } } } if (state.ID == 0) map.Empty(coords); else { foreach (Map.Coordinate coord in coords) map.Fill(coord, state); } }
public Map.CellState GetValue(Map map, Map.Coordinate coord) { coord.X -= map.MinX; coord.Y -= map.MinY; coord.Z -= map.MinZ; float value = this.density(coord); if (value > this.PrimaryFillThreshold) { // We are filling in material in this cell // Determine whether to fill in with primary or secondary material Map.CellState state; if (this.density(coord.Move(0, 2, 0)) < this.PrimaryFillThreshold // We're on the top of a ground formation && this.noise3d(new Vector3(coord.X, coord.Y, coord.Z) / this.SecondaryOctave) > this.SecondaryFillThreshold) // Modulate by another noise function state = this.secondaryFillValue; else state = this.primaryFillValue; return state; } return new Map.CellState(); }