Documentation ¶
Overview ¶
Package binvox provides functions for reading and writing binvox files. See: http://www.patrickmin.com/binvox/binvox.html for more information.
Index ¶
- Variables
- func TriangleLess(t []*gl.Triangle) func(a, b int) bool
- type BinVOX
- func (b *BinVOX) Add(x, y, z int)
- func (b *BinVOX) AddColor(x, y, z int, c Color)
- func (b *BinVOX) Dim() int
- func (b *BinVOX) Get(x, y, z int) (color Color, ok bool)
- func (b *BinVOX) MBB() *gl.Box
- func (b *BinVOX) ManifoldMesh() *gl.Mesh
- func (b *BinVOX) MarchingCubes() *gl.Mesh
- func (b *BinVOX) String() string
- func (b *BinVOX) ToMesh() *gl.Mesh
- func (b *BinVOX) Voxelize(mesh *gl.Mesh) error
- func (b *BinVOX) VoxelizeZ(mesh *gl.Mesh, zi int) error
- func (b *BinVOX) VoxelsPerMM() float64
- func (b *BinVOX) Write(filename string, sx, sy, sz, nx, ny, nz int) error
- type Color
- type ColorVoxelMap
- type Key
- type WhiteVoxelMap
Constants ¶
This section is empty.
Variables ¶
var ( Black = Color{0, 0, 0, 1} White = Color{1, 1, 1, 1} )
Functions ¶
Types ¶
type BinVOX ¶
type BinVOX struct {
NX, NY, NZ int // number of voxels in each dimension
TX, TY, TZ float64 // translation (location of origin in world space)
Scale float64 // uniform scale in millimeters
// WhiteVoxels represents a map of (white) voxels.
WhiteVoxels WhiteVoxelMap
// ColorVoxels represents a map of full-color voxels.
ColorVoxels ColorVoxelMap
}
BinVOX represents a voxel model (or subregion) in binvox format. Voxels have uniform dimensions in X, Y, and Z and can be thought of as 3D "pixels".
NX, NY, and NZ are the number of voxels in each dimension and must be positive (non-zero).
Scale represents the uniform scale of this subregion's largest dimension (in millimeters). So if "dim = max(NX,NY,NZ)", then there are dim/Scale voxels per millimeter in each direction.
Translating the subregion to (TX,TY,TZ) will correctly place this region in world space (in millimeters).
func Read ¶
Read reads a binvox file and returns a BinVOX using WhiteVoxels. sx, sy, sz are the starting indices for reading a model. nx, ny, nz are the number of voxels to read in each direction (0=all).
func (*BinVOX) ManifoldMesh ¶
func (*BinVOX) MarchingCubes ¶
func (*BinVOX) Voxelize ¶
Voxelize voxelizes a subregion of the mesh using (b.TX,b.TY,b.TZ) as the origin. The voxelized subregion will be: (0,0,0)-(b.NX-1,b.NY-1,b.NZ-1) (inclusive). b.Scale determines the scale of the voxelization. See Dim and VoxelsPerMM.
Voxelize overwrites the WhiteVoxels slice in b.
func (*BinVOX) VoxelsPerMM ¶
VoxelsPerMM returns the number of voxels per millimeter.
type ColorVoxelMap ¶
ColorVoxelMap respresents the voxel model as a map of full-color voxels.
type WhiteVoxelMap ¶
type WhiteVoxelMap map[Key]struct{}
WhiteVoxelMap respresents the voxel model as a map of (white) voxels.