Documentation ¶
Index ¶
- Constants
- type Buffer
- type ColorVec
- type Data
- type Source
- type Terrain
- func (t *Terrain) AltitudeAt(pos world.Vec2f) float32
- func (t *Terrain) At(aabb world.AABB) *Data
- func (t *Terrain) AtPos(pos world.Vec2f) byte
- func (t *Terrain) Clamp(aabb world.AABB) world.AABB
- func (t *Terrain) Collides(entity *world.Entity, seconds float32) bool
- func (t *Terrain) Debug()
- func (t *Terrain) Decode(data *Data) (raw []byte, err error)
- func (t *Terrain) LandAt(pos world.Vec2f) bool
- func (t *Terrain) Render(size int) image.Image
- func (t *Terrain) Repair()
- func (t *Terrain) Sculpt(pos world.Vec2f, amount float32)
Constants ¶
View Source
const ( // Start of sand layer (right above water) SandLevel = 255 / 2 // Start of grass layer (right above sand) GrassLevel = SandLevel + 1*resolution )
View Source
const ( // Seed default seed. Seed = int64(56) // OffsetX the default x offset from the origin in world space. OffsetX = -128 * Scale // OffsetY the default y offset from the origin in world space. OffsetY = -128 * Scale )
View Source
const Scale = 25
Scale pixel width/height in meters. Converts from world space to terrain space.
View Source
const (
Size = 2048
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer writes 4 bits of a byte and uses run length encoding. Each byte is 4 bits of data followed by 4 bits of count - 1.
type Data ¶
type Data struct { world.AABB Data []byte `json:"data"` // Data is a possibly compressed terrain heightmap. Stride int `json:"stride"` // Stride is width of Data. Length int `json:"length"` // Length is uncompressed length of Data for faster reading. }
Data describes part of a heightmap. It may be in a compressed format.
type Terrain ¶
type Terrain struct {
// contains filtered or unexported fields
}
Terrain is a compressed implementation of terrain.Terrain. It represents each terrain pixel with 4 bits of precision.
func (*Terrain) AltitudeAt ¶
Returns altitude (in meters) above sea level
func (*Terrain) Clamp ¶
Clamp clamps a bounding box to what At will send. It's useful for caching terrain data.
func (*Terrain) Collides ¶
Collides returns if an entity collides with the terrain given a time step in seconds.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.