polyform

module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT

README

Polyform

Coverage Go Report Card

Library for generating and editing 3D geometry and it's associated data implemented in 100% golang.

If Polyform contributes to an academic publication, cite it as:

@misc{polyform,
  title = {Polyform},
  author = {Eli Davis},
  note = {https://www.github.com/EliCDavis/polyform},
  year = {2023}
}

Processing Example

Reads in a obj and applies the cube marching algorithm over the meshes 3D SDF.

package main

import (
  "github.com/EliCDavis/polyform/formats/obj"
  "github.com/EliCDavis/polyform/modeling"
  "github.com/EliCDavis/polyform/modeling/marching"
  "github.com/EliCDavis/polyform/modeling/meshops"
  "github.com/EliCDavis/vector"
)

func check(err error) {
  if err != nil {
    panic(err)
  }
}

func main() {
  loadedMesh, err := obj.Load("test-models/stanford-bunny.obj")
  check(err)

  resolution := 10.
  canvas := marching.NewMarchingCanvas(resolution)

  canvas.AddFieldParallel(marching.Mesh(
    loadedMesh.Transform(
      meshops.Center3DTransformer{},
      meshops.Scale3DTransformer{
        Amount: vector3.New(12, 12, 12),
      },
    ),
    .1,
    10,
  ))
  check(obj.Save("chunky-bunny.obj", canvas.MarchParallel(.3)))
}

Results in:

Chunky Bunny

Helpful Procedural Generation Sub Packages

  • Modeling
    • meshops - All currently implemented algorithms for transforming meshes.
    • marching - Multi-threaded Cube Marching algorithm and utilities.
    • extrude - Functionality for generating geometry from 2D shapes.
    • repeat - Functionality for copying geometry in common patterns.
    • primitives - Functionality pertaining to generating common geometry.
    • triangulation - Generating meshes from a set of 2D points.
  • Drawing
    • coloring - Color utilities for blending multiple colors together using weights.
    • texturing - Image processing utilities like generating Normal maps or blurring images.
  • Math
    • noise - Utilities around noise functions for common usecases like stacking multiple samples of perlin noise from different frequencies.
    • sample - Serves as a group of definitions for defining a mapping from one numeric value to another
    • curves - Commonly curves used in animation like cubic bezier curves.

Procedural Generation Examples

You can at the different projects under the examples folder for different examples on how to procedurally generate meshes.

Evergreen Trees

This was my submission for ProcJam 2022. Pretty much uses every bit of functionality available in this repository.

[Source Here]

Evergreen Tree Demo

Evergreen Terrain Demo

Other Examples
[Source Here] ufo [Source Here] candle
[Source Here] terrain [Source Here] terrain
[Source Here] plumbob

Todo List

Progress towards V1...

  • Cube Marching
  • Bezier Curves
  • Scene Support
  • GLTF Support
  • Slice By Plane
  • Slice By Bounding Box
  • Constrained Delaunay Tesselation
  • Meshing Pipeline
  • Bones / Animations
  • Quadric Error Decimation
  • Proper Build Pipeline
  • Documentation Website

Things I want to implement eventually...

  • 3D Tesselation
  • Slice By Octree
  • Poisson Reconstruction
  • Buncha texture patterns
  • Noise...
    • Simplex
  • Splines...
    • Catmull
    • B Spline
  • Spheres...
    • Ico
    • Quad

Resources

Resources either directly contributing to the code here or are just interesting finds while researching.

Jump to

Keyboard shortcuts

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