mesh

package
v0.0.0-...-9c88ebf Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: BSD-3-Clause Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Prec = 10

Prec sets the precision when writing .obj data.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Mesh
	// contains filtered or unexported fields
}

Builder is inteded to help build meshes. Extrusions are more useful and this will probably be deprecated.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creats a builder.

func (*Builder) Add

func (b *Builder) Add(p []d3.Pt) error

Add a facet

func (*Builder) Solid

func (b *Builder) Solid() bool

Solid is true if the mesh is solid.

type Extrusion

type Extrusion struct {
	// contains filtered or unexported fields
}

Extrusion creates a mesh by extruding the perimeter by transormations.

func NewExtrusion

func NewExtrusion(face []d3.Pt) *Extrusion

NewExtrusion takes a face as the start of an extrusion.

func (*Extrusion) Close

func (e *Extrusion) Close() Mesh

Close the mesh turning the current perimeter into a face.

func (*Extrusion) EdgeExtrude

func (e *Extrusion) EdgeExtrude(t *d3.T) *Extrusion

EdgeExtrude performs an extrusion then subdivides each edge in to 3 segments. The points from the starting permeter are lined to the subdivision points. This allows the extrusion to increase the number of facets.

func (*Extrusion) EdgeMerge

func (e *Extrusion) EdgeMerge(t *d3.T) *Extrusion

EdgeMerge is the opposite of EdgeExtrude, merging 3 points into one.

func (*Extrusion) Extrude

func (e *Extrusion) Extrude(ts ...*d3.T) *Extrusion

Extrude the current perimeter via a set of transformations.

type Mesh

type Mesh struct {
	Pts      []d3.Pt
	Polygons [][]uint32
}

Mesh defines a solid with polygon facets.

func Extrude

func Extrude(face []d3.Pt, v d3.V) Mesh

Extrude creates a mesh by extruding a face.

func ReadObj

func ReadObj(reader io.Reader) (*Mesh, error)

ReadObj tries to read the .obj format into a mesh.

func (Mesh) Edges

func (m Mesh) Edges() []solid.IdxEdge

Edges converts the index values into edges making sure there are no duplicates.

func (Mesh) Face

func (m Mesh) Face(idx int) []d3.Pt

Face tranlates the index values in a face into Pts.

func (Mesh) String

func (m Mesh) String() string

String version of the mesh in .obj format.

func (Mesh) T

func (m Mesh) T(t *d3.T) Mesh

T applies a transform to all the points in the mesh.

func (Mesh) TriangleMesh

func (m Mesh) TriangleMesh() (TriangleMesh, error)

TriangleMesh generated from a normal mesh.

func (*Mesh) WriteObj

func (m *Mesh) WriteObj(writer io.Writer) error

WriteObj writes the mesh in .obj format to the writer

type TriangleMesh

type TriangleMesh struct {
	Pts      []d3.Pt
	Polygons [][][3]uint32
}

TriangleMesh is a mesh comprised only of triangles.

func (TriangleMesh) Edges

func (m TriangleMesh) Edges() (original []solid.IdxEdge, subFacet []solid.IdxEdge)

Edges returns the edges in the mesh. Original contains the edges that were in the original mesh and subFacet is the edges creates when facets were subdivided into triangles.

func (TriangleMesh) Face

func (m TriangleMesh) Face(idx int) [][3]d3.Pt

Face converts a face from index values to Pt values.

func (TriangleMesh) GetTriangleCount

func (m TriangleMesh) GetTriangleCount() int

GetTriangleCount returns the number of triangles in a mesh.

func (TriangleMesh) T

func (m TriangleMesh) T(t *d3.T) TriangleMesh

T applies a transformation to all the points in the mesh.

Jump to

Keyboard shortcuts

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