genmapvoxel

package
v0.0.0-...-ce97658 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

README

genmapvoxel

This package implements a simple voxel based terrain generator. Like... really simple.

Please be aware that this is just code for experimentation and is pretty rubbish for now... It will also serve as input for the genmarchingcubes package, so I can test out how well the logic for interpolation works and whatnot.

NOTE: The stupid idea to have the origin be the center of the cube at 0,0 makes it more cumbersome to shrink the cubes vertically, since the Z axis for a standard cube ranges from -0.5 to +0.5. Yikes. I might change that.

Done

  • binary / bool voxel terrain
  • float values for voxel data (-ish)
  • hide faces that aren't visible
  • wavefront OBJ export

TODO

  • Merge faces of connected voxels?
  • Do we need the bool voxels if the float values are sufficient?
  • Maybe flatten the voxel data to a 1D array?
    • Will it be really faster if we have to calculate the index each time we want to find a voxel at a specific coordinate?

Here, have a picture:

alt text

... and with smoothing:

alt text

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Side

type Side [4]vectors.Vec3

func (Side) Shrink

func (s Side) Shrink(factor float64) Side

Shrink the side vertically by the given factor.

func (Side) Translate

func (s Side) Translate(x, y, z float64) Side

Translate translates the side by the given offset.

type World

type World struct {
	Voxels [][][]bool    // The voxel grid.
	Values [][][]float64 // Voxels values (full voxel height = 1.0).
	// contains filtered or unexported fields
}

World represents a voxel world.

func New

func New(dimX, dimY, dimZ, seed int64) *World

New returns a new voxel world generated with the given seed.

func (*World) ExportOBJ

func (w *World) ExportOBJ(filename string, smooth bool) error

ExportOBJ exports the world to an OBJ file. NOTE: If 'smooth' is true, partial voxels (the remainder of the respective noise value at the given coordinates) will be rendered with fractional height.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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