mesh

package module
v0.0.0-...-275f7fa Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package mesh contains methods for baking areas into GLTF meshes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeDetailedMesh

func EncodeDetailedMesh(a *area.Area, t Transformer) (doc *gltf.Document, err error)

EncodeDetailedMesh

func FASTFLOOR

func FASTFLOOR(x float64) int

func Noise1

func Noise1(x float64) float64

1D simplex noise

func Noise2

func Noise2(x, y float64) float64

2D simplex noise

func Noise3

func Noise3(x, y, z float64) float64

3D simplex noise

func Q

func Q(cond bool, v1 float64, v2 float64) float64

Types

type BaseTransform

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

func (*BaseTransform) ConvertTo3D

func (b *BaseTransform) ConvertTo3D(h hex.Hex, actual hex.HexFractional) [3]float32

func (*BaseTransform) EdgeColor

func (b *BaseTransform) EdgeColor(h hex.Hex, direction int) (top, bottom [3]uint8)

func (*BaseTransform) EdgeSlopeStrength

func (b *BaseTransform) EdgeSlopeStrength() float32

func (*BaseTransform) HexColor

func (b *BaseTransform) HexColor(h hex.Hex) [3]uint8

func (*BaseTransform) PaintEdge

func (b *BaseTransform) PaintEdge(h hex.Hex, direction int) bool

func (*BaseTransform) PointColor

func (b *BaseTransform) PointColor(h hex.Hex, direction int) [3]uint8

type Transformer

type Transformer interface {
	// ConvertTo3D converts some hex vector to 3D cartesian space.
	//
	// glTF defines +Y as up, +Z as forward, and -X as right.
	ConvertTo3D(h hex.Hex, actual hex.HexFractional) [3]float32
	// HexColor sets the color for the center vertex of each hex.
	HexColor(h hex.Hex) [3]uint8
	// PointColor sets the color for a hex point vertex that
	// is shared by the hexes h, h.Direction(direction), and h.Direction(direction+1).
	//
	// You can use this in a fancy shader to draw borders around
	// hexes if you make it different from HexColor().
	PointColor(h hex.Hex, direction int) [3]uint8
	// EdgeColor returns the color of the rectangle that sits between
	// h and h.Neigbor(direction). This is not used by EncodeDetailed,
	// since that rectangle doesn't exist.
	EdgeColor(h hex.Hex, direction int) (top, bottom [3]uint8)
	// PaintEdge should return true if you want to draw the vertical edge between hexes
	// of different heights.
	PaintEdge(h hex.Hex, direction int) bool
	// EdgeSlopeStrength determines if hexes of different heights are shear (0.0) or
	// VERY sloped (1.0).
	EdgeSlopeStrength() float32
}

Transformer converts 2-dimensional cartesian space into three dimensions. Use this to select which dimension is "up" and do stretching if needed.

Jump to

Keyboard shortcuts

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