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 main() {
loadedMesh, _ := obj.Load("test-models/stanford-bunny.obj")
resolution := 10.
canvas := marching.NewMarchingCanvas(resolution)
canvas.AddFieldParallel(marching.Mesh(
loadedMesh.Transform(
meshops.Center3DTransformer{},
meshops.Scale3DTransformer{
Amount: vector3.New(12, 12, 12),
},
),
.1,
10,
))
obj.Save("chunky-bunny.obj", canvas.MarchParallel(.3))
}
Results in:
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
- curves - Common curves used in animation like cubic bezier curves.
- 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
- sdf - SDF implementations of different geometry primitives, along with common math functions. Basically slowly picking through Inigo Quilez's Distfunction article as I need them in my different projects.
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]
Other Examples
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
- Primitive Meshes
- Cube
- Sphere
- Cylinder
- Quad
- Circle
- Cone
- Capsule
- Hemisphere
- Rounded Cube
- SDFs
- Box
- Line
- Plane
- Sphere
- Rounded Cylinder
- Rounded Box
- Torus
- Box Frame
- Cone
- Rounded Cone
- Elipsoid
- Triangle
Things I want to implement eventually...
- 3D Tesselation
- Slice By Octree
- Poisson Reconstruction
- Buncha texture patterns
- Noise...
- Splines...
- Spheres...
Resources
Resources either directly contributing to the code, or are just interesting finds while researching.
Developing
If you so happen to want to build a configurator example, my preferred workflow is:
Set up the example to use the generator
package that allows you to quickly spin up a web viewer to visualize the geoemetry of your program.
Use air to live reload the examples as you build them out.
Set cmd = "go build -o ./tmp/main.exe ./examples/MY_EXAMPLE"
air serve --port 8080
As you hit save on your go code, the webserver will restart, and the web page will automatically refresh itself.