terrain

package
v0.0.0-...-2a33acd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const OCEAN_DEPTH_MULTIPLIER = 2

Variables

This section is empty.

Functions

func SpawnEvergreenTree

func SpawnEvergreenTree(rand *rand.Rand, pos block.Pos, tree_height, leaves_start int32, chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func SpawnOakTree

func SpawnOakTree(pos block.Pos, tree_height, leaf_height int32, chunk_pos block.ChunkPos, c *chunk.MultiChunk)

Types

type BiomeGenerator

type BiomeGenerator interface {
	// This will fill a single block column.
	// Pos.X and pos.Z are the absolute coordinates of the chunk column.
	// Pos.Y should be ignored.
	FillColumn(pos block.Pos, c *chunk.MultiChunk)

	// This will fill an entire chunk.
	// You can call FillColumn 256 times,
	// but there are some optimizations
	// that can be done for whole chunks.
	// This will be called every time the
	// biome occupies an entire chunk.
	FillChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

	// This is a second pass over a chunk. This
	// should do things like add trees, and add
	// other details. This is called for every biome
	// the a chunk is in, so this call be called
	// multiple times for each chunk. This should allow
	// you to make trees that overlap biome borders.
	DetailChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)
}

This is an implementation-specific terrain generator. You will need this if you want to add custom biomes, but if you are making your own terrain from scratch, you do not need to use this.

type DesertGenerator

type DesertGenerator struct {
	// contains filtered or unexported fields
}

func (*DesertGenerator) DetailChunk

func (g *DesertGenerator) DetailChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*DesertGenerator) FillChunk

func (g *DesertGenerator) FillChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*DesertGenerator) FillColumn

func (g *DesertGenerator) FillColumn(pos block.Pos, c *chunk.MultiChunk)

type EvergreenGenerator

type EvergreenGenerator struct {
	// contains filtered or unexported fields
}

func (*EvergreenGenerator) DetailChunk

func (g *EvergreenGenerator) DetailChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*EvergreenGenerator) FillChunk

func (g *EvergreenGenerator) FillChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*EvergreenGenerator) FillColumn

func (g *EvergreenGenerator) FillColumn(pos block.Pos, c *chunk.MultiChunk)

type ForestGenerator

type ForestGenerator struct {
	// contains filtered or unexported fields
}

func (*ForestGenerator) DetailChunk

func (g *ForestGenerator) DetailChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*ForestGenerator) FillChunk

func (g *ForestGenerator) FillChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*ForestGenerator) FillColumn

func (g *ForestGenerator) FillColumn(pos block.Pos, c *chunk.MultiChunk)

type MemeGenerator

type MemeGenerator struct {
	// contains filtered or unexported fields
}

func (*MemeGenerator) DetailChunk

func (g *MemeGenerator) DetailChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*MemeGenerator) FillChunk

func (g *MemeGenerator) FillChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*MemeGenerator) FillColumn

func (g *MemeGenerator) FillColumn(pos block.Pos, c *chunk.MultiChunk)

type OceanGenerator

type OceanGenerator struct {
	// contains filtered or unexported fields
}

func (*OceanGenerator) DetailChunk

func (g *OceanGenerator) DetailChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*OceanGenerator) FillChunk

func (g *OceanGenerator) FillChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*OceanGenerator) FillColumn

func (g *OceanGenerator) FillColumn(pos block.Pos, c *chunk.MultiChunk)

type SolidGenerator

type SolidGenerator struct {
	// contains filtered or unexported fields
}

func (*SolidGenerator) DetailChunk

func (g *SolidGenerator) DetailChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*SolidGenerator) FillChunk

func (g *SolidGenerator) FillChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)

func (*SolidGenerator) FillColumn

func (g *SolidGenerator) FillColumn(pos block.Pos, c *chunk.MultiChunk)

type VoronoiWorldGenerator

type VoronoiWorldGenerator struct {
	// Y position that oceans start at
	SeaLevel int32
	// contains filtered or unexported fields
}

This is the default world generator. You can add biomes to this generator, until Lock() is called. This uses a voronoi map, combined with noise maps to generate the biome regions. It also uses a global height, temperature and humidity map.

func NewVoronoi

func NewVoronoi(seed int64) *VoronoiWorldGenerator

This returns a new VoronoiBiomeGenerator, given a world seed. This generator will have no biomes. Call Init() to add the default biomes, and/or AddBiome to add your own biomes into the mix.

func (*VoronoiWorldGenerator) AddBiome

func (g *VoronoiWorldGenerator) AddBiome(biome BiomeGenerator)

This adds a biome to the world. It will do nothing if Lock() has already been called.

func (*VoronoiWorldGenerator) BiomeAt

This returns the biome at the block. pos.Y is ignored. The biome is an index into g.biomes, and will always be within [0, len(g.biomes)-1].

func (*VoronoiWorldGenerator) ExactHeight

func (g *VoronoiWorldGenerator) ExactHeight(pos block.Pos) float64

This returns the height as a float. Same as HeightAt, but can be used if you need a more precise value.

func (*VoronoiWorldGenerator) FillChunk

func (g *VoronoiWorldGenerator) FillChunk(chunk_pos block.ChunkPos, chunk *chunk.MultiChunk)

This is used internally, to generate chunks. You may call this function, if you want to restore a chunk to it's generated state. Since chunks are not aware of their position in the world, you can mix and match chunk positions. If you want the default look, make sure you pass in the correct chunk_pos to this function.

func (*VoronoiWorldGenerator) HeightAt

func (g *VoronoiWorldGenerator) HeightAt(pos block.Pos) int32

This returns the expected height at that point in the world. This should be used as a baseline. Things like oceans or mountains will add to this value, whereas things like deserts probably shouldn't modify this value.

func (*VoronoiWorldGenerator) HeightMap

func (g *VoronoiWorldGenerator) HeightMap() util.NoiseSampler

Returns the global height map. This should be used as the base height of the world, to make biome borders look nice.

func (*VoronoiWorldGenerator) HumidityMap

func (g *VoronoiWorldGenerator) HumidityMap() util.NoiseSampler

Returns the global humidity map. This should not be needed, as the generator automatically uses this in FillChunk().

func (*VoronoiWorldGenerator) Init

func (g *VoronoiWorldGenerator) Init()

This adds all of the default biomes, which are expected to be used with this generator. This is not necessary, but is the simplest option if you just want to add a new biome to the pre-existing generation. If you want to make a new world, with all new terrain, you should not call this function.

func (*VoronoiWorldGenerator) Lock

func (g *VoronoiWorldGenerator) Lock()

This locks the generator, and prevents any biomes from being added. You must call this before generating any terrain.

func (*VoronoiWorldGenerator) MinHeight

func (g *VoronoiWorldGenerator) MinHeight(chunk_pos block.ChunkPos) int32

func (*VoronoiWorldGenerator) TempuratureMap

func (g *VoronoiWorldGenerator) TempuratureMap() util.NoiseSampler

Returns the global temperature map. This should not be needed, as the generator automatically uses this in FillChunk().

type WorldGenerator

type WorldGenerator interface {
	// This will fill an entire chunk.
	FillChunk(chunk_pos block.ChunkPos, c *chunk.MultiChunk)
	// This will do things like add default biomes,
	// setup noise maps, etc.
	Init()
	// This will lock the world generator. This is used
	// to make sure no biomes are added after terrain
	// starts generating. In your implementation, you
	// can just leave this blank.
	Lock()
}

This is what needs to be passed into the world. If you want to add biomes, you should use the default generator, and add BiomeGenerators to that.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL