meshops

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 15 Imported by: 0

README

Mesh Operations

A package serving for the implementation of common mesh operations.

Implemented Operations

Center Attribute

Calculates the AABB for the attribute specified (most commonly position, but could be used for anything like UV Coordinates) and offsets all vertice data by the center of the AABB.

Flat Normals

We set each vertices normal to be equal to the face's normal. If the vertice is used for multiple faces, a face is arbitrarily chosen. If you want to avoid this behavior, you should run Unweld first

Flip Winding
Laplacian Smoothing
Normalize Attribute
Remove Null Faces
Remove Unreferenced Vertices
Rotate Attribute
Scale Attribute
Smooth Normals
Translate Attribute
Unweld
Vertex Color Space
Color Grading LUT
Filter Float 1
Filter Float 2
Filter Float 3
Filter Float 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequireTriangleTopology  = errors.New("mesh is required to have a triangle topology")
	ErrRequireLineTopology      = errors.New("mesh is required to have a line topology")
	ErrRequirePointTopology     = errors.New("mesh is required to have a point topology")
	ErrRequireDifferentTopology = errors.New("mesh does not have required topology")
)

Functions

func CenterFloat3Attribute

func CenterFloat3Attribute(m modeling.Mesh, attr string) modeling.Mesh

func ColorGradingLut added in v0.11.0

func ColorGradingLut(m modeling.Mesh, lut image.Image, attr string) modeling.Mesh

func CropFloat3Attribute added in v0.10.0

func CropFloat3Attribute(m modeling.Mesh, attr string, boundingBox geometry.AABB) modeling.Mesh

func FilterFloat1 added in v0.11.0

func FilterFloat1(m modeling.Mesh, attribute string, filter func(v float64) bool) modeling.Mesh

func FilterFloat2 added in v0.11.0

func FilterFloat2(m modeling.Mesh, attribute string, filter func(v vector2.Float64) bool) modeling.Mesh

func FilterFloat3 added in v0.11.0

func FilterFloat3(m modeling.Mesh, attribute string, filter func(v vector3.Float64) bool) modeling.Mesh

func FilterFloat4 added in v0.11.0

func FilterFloat4(m modeling.Mesh, attribute string, filter func(v vector4.Float64) bool) modeling.Mesh

func FlatNormals

func FlatNormals(m modeling.Mesh) modeling.Mesh

func FlipTriangleWinding

func FlipTriangleWinding(m modeling.Mesh) modeling.Mesh

func LaplacianSmooth

func LaplacianSmooth(m modeling.Mesh, attribute string, iterations int, smoothingFactor float64) modeling.Mesh

func LaplacianSmoothAlongAxis

func LaplacianSmoothAlongAxis(m modeling.Mesh, attribute string, iterations int, smoothingFactor float64, axis vector3.Float64) modeling.Mesh

func Nodes added in v0.11.0

func Nodes() *refutil.TypeFactory

func NormalizeAttribute2D added in v0.9.0

func NormalizeAttribute2D(m modeling.Mesh, attribute string) modeling.Mesh

func NormalizeAttribute3D added in v0.9.0

func NormalizeAttribute3D(m modeling.Mesh, attribute string) modeling.Mesh

func RemoveNullFaces3D added in v0.10.0

func RemoveNullFaces3D(m modeling.Mesh, attribute string, minArea float64) modeling.Mesh

func RemovedUnreferencedVertices

func RemovedUnreferencedVertices(m modeling.Mesh) modeling.Mesh

func RequireTopology added in v0.11.0

func RequireTopology(m modeling.Mesh, topo modeling.Topology) error

func RequireV1Attribute added in v0.11.0

func RequireV1Attribute(m modeling.Mesh, attr string) error

func RequireV2Attribute added in v0.11.0

func RequireV2Attribute(m modeling.Mesh, attr string) error

func RequireV3Attribute added in v0.11.0

func RequireV3Attribute(m modeling.Mesh, attr string) error

func RequireV4Attribute added in v0.11.0

func RequireV4Attribute(m modeling.Mesh, attr string) error

func RotateAttribute3D

func RotateAttribute3D(m modeling.Mesh, attribute string, q quaternion.Quaternion) modeling.Mesh

func ScaleAttribute2D added in v0.10.0

func ScaleAttribute2D(m modeling.Mesh, attribute string, origin, amount vector2.Float64) modeling.Mesh

func ScaleAttribute3D

func ScaleAttribute3D(m modeling.Mesh, attribute string, origin, amount vector3.Float64) modeling.Mesh

func SliceByPlaneWithAttribute

func SliceByPlaneWithAttribute(m modeling.Mesh, plane geometry.Plane, attribute string) (modeling.Mesh, modeling.Mesh)

func SmoothNormals

func SmoothNormals(m modeling.Mesh) modeling.Mesh

func SmoothNormalsImplicitWeld added in v0.17.0

func SmoothNormalsImplicitWeld(m modeling.Mesh, distance float64) modeling.Mesh

func SplitOnUniqueMaterials

func SplitOnUniqueMaterials(m modeling.Mesh) []modeling.Mesh

func TranslateAttribute3D

func TranslateAttribute3D(m modeling.Mesh, attribute string, amount vector3.Float64) modeling.Mesh

func Unweld

func Unweld(m modeling.Mesh) modeling.Mesh

Unweld duplicates all vertex data such that no two primitive indices share any one vertex

func VertexColorSpace added in v0.9.0

func VertexColorSpace(m modeling.Mesh, attribute string, transformation VertexColorSpaceTransformation) modeling.Mesh

Types

type CenterAttribute3DTransformer

type CenterAttribute3DTransformer struct {
	Attribute string
}

func (CenterAttribute3DTransformer) Transform

func (cat CenterAttribute3DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type ColorGradingLutTransformer added in v0.11.0

type ColorGradingLutTransformer struct {
	Attribute string

	LUT image.Image
}

func (ColorGradingLutTransformer) Transform added in v0.11.0

func (cglt ColorGradingLutTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type CombineNode added in v0.12.0

type CombineNodeData added in v0.12.0

type CombineNodeData struct {
	A nodes.NodeOutput[modeling.Mesh]
	B nodes.NodeOutput[modeling.Mesh]
}

func (CombineNodeData) Process added in v0.12.0

func (cnd CombineNodeData) Process() (modeling.Mesh, error)

type CropAttribute3DNode added in v0.10.0

type CropAttribute3DNode = nodes.StructNode[modeling.Mesh, CropAttribute3DNodeData]

type CropAttribute3DNodeData added in v0.11.0

type CropAttribute3DNodeData struct {
	Attribute nodes.NodeOutput[string]
	Mesh      nodes.NodeOutput[modeling.Mesh]
	AABB      nodes.NodeOutput[geometry.AABB]
}

func (CropAttribute3DNodeData) Process added in v0.11.0

func (ca3dn CropAttribute3DNodeData) Process() (modeling.Mesh, error)

type CropAttribute3DTransformer added in v0.10.0

type CropAttribute3DTransformer struct {
	Attribute   string
	BoundingBox geometry.AABB
}

func (CropAttribute3DTransformer) Transform added in v0.10.0

func (cat CropAttribute3DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type CustomTransformer

type CustomTransformer struct {
	Func func(m modeling.Mesh) (results modeling.Mesh, err error)
}

func (CustomTransformer) Transform

func (ct CustomTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type FilterFloat1Transformer added in v0.11.0

type FilterFloat1Transformer struct {
	Attribute string
	Filter    func(v float64) bool
}

func (FilterFloat1Transformer) Transform added in v0.11.0

func (fft FilterFloat1Transformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type FilterFloat2Transformer added in v0.11.0

type FilterFloat2Transformer struct {
	Attribute string
	Filter    func(v vector2.Float64) bool
}

func (FilterFloat2Transformer) Transform added in v0.11.0

func (fft FilterFloat2Transformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type FilterFloat3Transformer added in v0.11.0

type FilterFloat3Transformer struct {
	Attribute string
	Filter    func(v vector3.Float64) bool
}

func (FilterFloat3Transformer) Transform added in v0.11.0

func (fft FilterFloat3Transformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type FilterFloat4Transformer added in v0.11.0

type FilterFloat4Transformer struct {
	Attribute string
	Filter    func(v vector4.Float64) bool
}

func (FilterFloat4Transformer) Transform added in v0.11.0

func (fft FilterFloat4Transformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type FlatNormalsTransformer

type FlatNormalsTransformer struct{}

func (FlatNormalsTransformer) Transform

func (fnt FlatNormalsTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type FlipTriangleWindingTransformer

type FlipTriangleWindingTransformer struct {
	Attribute string
}

func (FlipTriangleWindingTransformer) Transform

func (cat FlipTriangleWindingTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type LaplacianSmoothNode added in v0.10.0

type LaplacianSmoothNode = nodes.StructNode[modeling.Mesh, LaplacianSmoothNodeData]

type LaplacianSmoothNodeData added in v0.11.0

type LaplacianSmoothNodeData struct {
	Mesh            nodes.NodeOutput[modeling.Mesh]
	Attribute       nodes.NodeOutput[string]
	Iterations      nodes.NodeOutput[int]
	SmoothingFactor nodes.NodeOutput[float64]
}

func (LaplacianSmoothNodeData) Process added in v0.11.0

func (lp LaplacianSmoothNodeData) Process() (modeling.Mesh, error)

type LaplacianSmoothTransformer

type LaplacianSmoothTransformer struct {
	Attribute       string
	Iterations      int
	SmoothingFactor float64
}

func (LaplacianSmoothTransformer) Transform

func (lst LaplacianSmoothTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type NormalizeAttribute2DTransformer added in v0.9.0

type NormalizeAttribute2DTransformer struct {
	Attribute string
}

func (NormalizeAttribute2DTransformer) Transform added in v0.9.0

func (st NormalizeAttribute2DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type NormalizeAttribute3DTransformer added in v0.9.0

type NormalizeAttribute3DTransformer struct {
	Attribute string
}

Finds the vector with the longest length and scales all vectors within the mesh attribute by (1 / longestLength)

func (NormalizeAttribute3DTransformer) Transform added in v0.9.0

func (st NormalizeAttribute3DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type RemoveNullFaces3DTransformer added in v0.10.0

type RemoveNullFaces3DTransformer struct {
	Attribute string
	MinArea   float64
}

func (RemoveNullFaces3DTransformer) Transform added in v0.10.0

func (rnft RemoveNullFaces3DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type RemovedUnreferencedVerticesTransformer

type RemovedUnreferencedVerticesTransformer struct{}

func (RemovedUnreferencedVerticesTransformer) Transform

func (fnt RemovedUnreferencedVerticesTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type RotateAttribute3DNode added in v0.15.0

type RotateAttribute3DNode = nodes.StructNode[modeling.Mesh, RotateAttribute3DNodeData]

type RotateAttribute3DNodeData added in v0.15.0

type RotateAttribute3DNodeData struct {
	Attribute nodes.NodeOutput[string]
	Mesh      nodes.NodeOutput[modeling.Mesh]
	Amount    nodes.NodeOutput[quaternion.Quaternion]
}

func (RotateAttribute3DNodeData) Process added in v0.15.0

func (ra3dn RotateAttribute3DNodeData) Process() (modeling.Mesh, error)

type RotateAttribute3DTransformer

type RotateAttribute3DTransformer struct {
	Attribute string
	Amount    quaternion.Quaternion
}

func (RotateAttribute3DTransformer) Transform

func (rat RotateAttribute3DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type ScaleAttribute2DTransformer added in v0.10.0

type ScaleAttribute2DTransformer struct {
	Attribute string
	Origin    vector2.Float64
	Amount    vector2.Float64
}

func (ScaleAttribute2DTransformer) Transform added in v0.10.0

func (st ScaleAttribute2DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type ScaleAttribute3DNode added in v0.11.0

type ScaleAttribute3DNode = nodes.StructNode[modeling.Mesh, ScaleAttribute3DNodeData]

type ScaleAttribute3DNodeData added in v0.11.0

type ScaleAttribute3DNodeData struct {
	Attribute nodes.NodeOutput[string]
	Mesh      nodes.NodeOutput[modeling.Mesh]
	Amount    nodes.NodeOutput[vector3.Float64]
	Origin    nodes.NodeOutput[vector3.Float64]
}

func (ScaleAttribute3DNodeData) Process added in v0.11.0

func (sa3dn ScaleAttribute3DNodeData) Process() (modeling.Mesh, error)

type ScaleAttribute3DTransformer

type ScaleAttribute3DTransformer struct {
	Attribute string
	Origin    vector3.Float64
	Amount    vector3.Float64
}

func (ScaleAttribute3DTransformer) Transform

func (st ScaleAttribute3DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type SliceByPlaneTransformer

type SliceByPlaneTransformer struct {
	Attribute   string
	SliceToKeep SliceByPlaneTransformerSide
	Plane       geometry.Plane
}

func (SliceByPlaneTransformer) Transform

func (sbpt SliceByPlaneTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type SliceByPlaneTransformerSide

type SliceByPlaneTransformerSide int
const (
	AbovePlane SliceByPlaneTransformerSide = iota
	BelowPlane
)

type SmoothNormalsImplicitWeldNode added in v0.17.0

type SmoothNormalsImplicitWeldNode = nodes.StructNode[modeling.Mesh, SmoothNormalsImplicitWeldNodeData]

type SmoothNormalsImplicitWeldNodeData added in v0.17.0

type SmoothNormalsImplicitWeldNodeData struct {
	Mesh     nodes.NodeOutput[modeling.Mesh]
	Distance nodes.NodeOutput[float64]
}

func (SmoothNormalsImplicitWeldNodeData) Process added in v0.17.0

type SmoothNormalsImplicitWeldTransformer added in v0.17.0

type SmoothNormalsImplicitWeldTransformer struct {
	Distance float64
}

func (SmoothNormalsImplicitWeldTransformer) Transform added in v0.17.0

func (smt SmoothNormalsImplicitWeldTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type SmoothNormalsNode added in v0.10.0

type SmoothNormalsNode = nodes.StructNode[modeling.Mesh, SmoothNormalsNodeData]

type SmoothNormalsNodeData added in v0.11.0

type SmoothNormalsNodeData struct {
	Mesh nodes.NodeOutput[modeling.Mesh]
}

func (SmoothNormalsNodeData) Process added in v0.11.0

func (snn SmoothNormalsNodeData) Process() (modeling.Mesh, error)

type SmoothNormalsTransformer

type SmoothNormalsTransformer struct{}

func (SmoothNormalsTransformer) Transform

func (smt SmoothNormalsTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type TranslateAttribute3DNode added in v0.10.0

type TranslateAttribute3DNode = nodes.StructNode[modeling.Mesh, TranslateAttribute3DNodeData]

type TranslateAttribute3DNodeData added in v0.11.0

type TranslateAttribute3DNodeData struct {
	Attribute nodes.NodeOutput[string]
	Mesh      nodes.NodeOutput[modeling.Mesh]
	Amount    nodes.NodeOutput[vector3.Float64]
}

func (TranslateAttribute3DNodeData) Process added in v0.11.0

func (ta3dn TranslateAttribute3DNodeData) Process() (modeling.Mesh, error)

type TranslateAttribute3DTransformer

type TranslateAttribute3DTransformer struct {
	Attribute string
	Amount    vector3.Float64
}

func (TranslateAttribute3DTransformer) Transform

func (tat TranslateAttribute3DTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type UnweldTransformer

type UnweldTransformer struct{}

func (UnweldTransformer) Transform

func (fnt UnweldTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

type VertexColorSpaceTransformation added in v0.9.0

type VertexColorSpaceTransformation int
const (
	VertexColorSpaceSRGBToLinear VertexColorSpaceTransformation = iota
	VertexColorSpaceLinearToSRGB
)

type VertexColorSpaceTransformer added in v0.9.0

type VertexColorSpaceTransformer struct {
	Attribute      string
	Transformation VertexColorSpaceTransformation
}

func (VertexColorSpaceTransformer) Transform added in v0.9.0

func (vcst VertexColorSpaceTransformer) Transform(m modeling.Mesh) (results modeling.Mesh, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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