modeling

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PositionAttribute  = "Position"
	NormalAttribute    = "Normal"
	ColorAttribute     = "Color"
	TexCoordAttribute  = "TexCoord"
	ClassAttribute     = "Class"
	IntensityAttribute = "Intensity"
	JointAttribute     = "Joint"
	WeightAttribute    = "Weight"
)

Variables

This section is empty.

Functions

func Clamp

func Clamp(v, min, max float64) float64

func Multiply3x3by3x1

func Multiply3x3by3x1(m Matrix, v vector3.Float64) vector3.Float64

func ToNormal

func ToNormal(inEulerAngle vector3.Float64) vector3.Float64

Types

type CollapsableMesh

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

func NewCollapsableMesh

func NewCollapsableMesh(m Mesh) CollapsableMesh

func (*CollapsableMesh) CollapseTri

func (cm *CollapsableMesh) CollapseTri(tri int)

func (CollapsableMesh) ToMesh

func (cm CollapsableMesh) ToMesh() Mesh

type Line

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

func (Line) BoundingBox

func (l Line) BoundingBox(atr string) geometry.AABB

func (Line) ClosestPoint

func (l Line) ClosestPoint(atr string, point vector3.Float64) vector3.Float64

func (Line) P1 added in v0.2.0

func (l Line) P1() int

P1 is the first point on our triangle, which is an index to the vertices array of a mesh

func (Line) P2 added in v0.2.0

func (l Line) P2() int

P2 is the second point on our triangle, which is an index to the vertices array of a mesh

func (Line) Scope

func (l Line) Scope(attribute string) trees.Element

type Material

type Material struct {
	Name string

	// Account for light that is scattered about the entire scene
	AmbientColor color.Color

	// The main color
	DiffuseColor color.Color

	// Color seen where the surface is shiny and mirror like
	SpecularColor color.Color

	// Typically between 0 - 1000, with a high value resulting in a tight,
	// concentrated highlight
	//
	// Defines the focus of the specular highlight
	SpecularHighlight float64

	// Index of refraction, between 0.001 to 10, 1.0 means light does not bend
	// as it passes through the object
	OpticalDensity float64

	// Specifies how much this material dissolves into the background. A factor
	// of 0.0 is fully opaque. A factor of 1.0 is completely transparent.
	Transparency float64

	ColorTextureURI *string

	NormalTextureURI *string

	SpecularTextureURI *string
}

Material is just a clone of obj's MTL format at the moment cause man this problem scares me.

func DefaultColorMaterial

func DefaultColorMaterial(c color.Color) Material

func DefaultMaterial

func DefaultMaterial() Material

type Matrix

type Matrix [][]float64

Matrix is row major

func Multiply3x3

func Multiply3x3(m1, m2 Matrix) Matrix

func Rx

func Rx(theta float64) Matrix

func RxT

func RxT(theta float64) Matrix

func Ry

func Ry(theta float64) Matrix

func RyT

func RyT(theta float64) Matrix

func Rz

func Rz(theta float64) Matrix

func RzT

func RzT(theta float64) Matrix

func Transpose

func Transpose(in Matrix) Matrix

type Mesh

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

func EmptyMesh

func EmptyMesh() Mesh

Creates a new triangle mesh with no vertices or attribute data

func MeshFromView

func MeshFromView(view MeshView) Mesh

func NewLineStripMesh

func NewLineStripMesh(
	v3Data map[string][]vector3.Float64,
	v2Data map[string][]vector2.Float64,
	v1Data map[string][]float64,
	materials []MeshMaterial,
) Mesh

func NewMesh

func NewMesh(indices []int) Mesh

New Mesh creates a new mesh with all empty attribute data arrays stripped.

func NewPointCloud

func NewPointCloud(
	v3Data map[string][]vector3.Float64,
	v2Data map[string][]vector2.Float64,
	v1Data map[string][]float64,
	materials []MeshMaterial,
) Mesh

func NewTexturedMesh

func NewTexturedMesh(
	triangles []int,
	vertices []vector3.Float64,
	normals []vector3.Float64,
	uvs []vector2.Float64,
) Mesh

func (Mesh) Append

func (m Mesh) Append(other Mesh) Mesh

func (Mesh) AttributeLength

func (m Mesh) AttributeLength() int

func (Mesh) BoundingBox

func (m Mesh) BoundingBox(atr string) geometry.AABB

func (Mesh) CalculateFlatNormals

func (m Mesh) CalculateFlatNormals() Mesh

func (Mesh) CalculateSmoothNormals

func (m Mesh) CalculateSmoothNormals() Mesh

func (Mesh) CenterFloat3Attribute

func (m Mesh) CenterFloat3Attribute(atr string) Mesh

func (Mesh) FlipTriWinding added in v0.4.0

func (m Mesh) FlipTriWinding() Mesh

func (Mesh) Float1Attributes

func (m Mesh) Float1Attributes() []string

func (Mesh) Float2Attributes

func (m Mesh) Float2Attributes() []string

func (Mesh) Float3Attributes

func (m Mesh) Float3Attributes() []string

func (Mesh) Float4Attributes added in v0.5.0

func (m Mesh) Float4Attributes() []string

func (Mesh) HasFloat1Attribute

func (m Mesh) HasFloat1Attribute(atr string) bool

func (Mesh) HasFloat2Attribute

func (m Mesh) HasFloat2Attribute(atr string) bool

func (Mesh) HasFloat3Attribute

func (m Mesh) HasFloat3Attribute(atr string) bool

func (Mesh) HasFloat4Attribute added in v0.5.0

func (m Mesh) HasFloat4Attribute(atr string) bool

func (Mesh) HasVertexAttribute

func (m Mesh) HasVertexAttribute(atr string) bool

func (Mesh) LineStrip

func (m Mesh) LineStrip(i int) Line

func (Mesh) Materials

func (m Mesh) Materials() []MeshMaterial

func (Mesh) ModifyFloat1Attribute

func (m Mesh) ModifyFloat1Attribute(atr string, f func(i int, v float64) float64) Mesh

func (Mesh) ModifyFloat1AttributeParallel

func (m Mesh) ModifyFloat1AttributeParallel(atr string, f func(i int, v float64) float64) Mesh

func (Mesh) ModifyFloat1AttributeParallelWithPoolSize

func (m Mesh) ModifyFloat1AttributeParallelWithPoolSize(atr string, size int, f func(i int, v float64) float64) Mesh

func (Mesh) ModifyFloat2Attribute

func (m Mesh) ModifyFloat2Attribute(atr string, f func(i int, v vector2.Float64) vector2.Float64) Mesh

func (Mesh) ModifyFloat2AttributeParallel

func (m Mesh) ModifyFloat2AttributeParallel(atr string, f func(i int, v vector2.Float64) vector2.Float64) Mesh

func (Mesh) ModifyFloat2AttributeParallelWithPoolSize

func (m Mesh) ModifyFloat2AttributeParallelWithPoolSize(atr string, size int, f func(i int, v vector2.Float64) vector2.Float64) Mesh

func (Mesh) ModifyFloat3Attribute

func (m Mesh) ModifyFloat3Attribute(atr string, f func(i int, v vector3.Float64) vector3.Float64) Mesh

func (Mesh) ModifyFloat3AttributeParallel

func (m Mesh) ModifyFloat3AttributeParallel(atr string, f func(i int, v vector3.Float64) vector3.Float64) Mesh

func (Mesh) ModifyFloat3AttributeParallelWithPoolSize

func (m Mesh) ModifyFloat3AttributeParallelWithPoolSize(atr string, size int, f func(i int, v vector3.Float64) vector3.Float64) Mesh

func (Mesh) OctTree added in v0.3.0

func (m Mesh) OctTree() *trees.OctTree

func (Mesh) OctTreeDepth added in v0.3.0

func (m Mesh) OctTreeDepth(depth int) *trees.OctTree

func (Mesh) OctTreeWithAttributeAndDepth added in v0.3.0

func (m Mesh) OctTreeWithAttributeAndDepth(atr string, depth int) *trees.OctTree

func (Mesh) PrimitiveCount

func (m Mesh) PrimitiveCount() int

func (Mesh) RemoveUnusedIndices

func (m Mesh) RemoveUnusedIndices() Mesh

func (Mesh) Rotate

func (m Mesh) Rotate(q Quaternion) Mesh

func (Mesh) RotateAttribute3D

func (m Mesh) RotateAttribute3D(attribute string, q Quaternion) Mesh

func (Mesh) Scale

func (m Mesh) Scale(origin, amount vector3.Float64) Mesh

Scale(o, a) is shorthand for ScaleAttribute3D("Position", o, a)

func (Mesh) ScaleAttribute3D

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

func (Mesh) ScanFloat1Attribute

func (m Mesh) ScanFloat1Attribute(atr string, f func(i int, v float64)) Mesh

func (Mesh) ScanFloat1AttributeParallel

func (m Mesh) ScanFloat1AttributeParallel(atr string, f func(i int, v float64)) Mesh

func (Mesh) ScanFloat1AttributeParallelWithPoolSize

func (m Mesh) ScanFloat1AttributeParallelWithPoolSize(atr string, size int, f func(i int, v float64)) Mesh

func (Mesh) ScanFloat2Attribute

func (m Mesh) ScanFloat2Attribute(atr string, f func(i int, v vector2.Float64)) Mesh

func (Mesh) ScanFloat2AttributeParallel

func (m Mesh) ScanFloat2AttributeParallel(atr string, f func(i int, v vector2.Float64)) Mesh

func (Mesh) ScanFloat2AttributeParallelWithPoolSize

func (m Mesh) ScanFloat2AttributeParallelWithPoolSize(atr string, size int, f func(i int, v vector2.Float64)) Mesh

func (Mesh) ScanFloat3Attribute

func (m Mesh) ScanFloat3Attribute(atr string, f func(i int, v vector3.Float64)) Mesh

func (Mesh) ScanFloat3AttributeParallel

func (m Mesh) ScanFloat3AttributeParallel(atr string, f func(i int, v vector3.Float64)) Mesh

func (Mesh) ScanFloat3AttributeParallelWithPoolSize

func (m Mesh) ScanFloat3AttributeParallelWithPoolSize(atr string, size int, f func(i int, v vector3.Float64)) Mesh

func (Mesh) ScanFloat4Attribute added in v0.5.0

func (m Mesh) ScanFloat4Attribute(atr string, f func(i int, v vector4.Float64)) Mesh

func (Mesh) ScanPrimitives

func (m Mesh) ScanPrimitives(f func(i int, p Primitive)) Mesh

func (Mesh) ScanPrimitivesParallel

func (m Mesh) ScanPrimitivesParallel(f func(i int, p Primitive)) Mesh

func (Mesh) ScanPrimitivesParallelWithPoolSize

func (m Mesh) ScanPrimitivesParallelWithPoolSize(size int, f func(i int, p Primitive)) Mesh

func (Mesh) SetFloat1Attribute

func (m Mesh) SetFloat1Attribute(attr string, data []float64) Mesh

func (Mesh) SetFloat1Data added in v0.5.0

func (m Mesh) SetFloat1Data(data map[string][]float64) Mesh

func (Mesh) SetFloat2Attribute

func (m Mesh) SetFloat2Attribute(attr string, data []vector2.Float64) Mesh

func (Mesh) SetFloat2Data added in v0.5.0

func (m Mesh) SetFloat2Data(data map[string][]vector2.Float64) Mesh

func (Mesh) SetFloat3Attribute

func (m Mesh) SetFloat3Attribute(attr string, data []vector3.Float64) Mesh

func (Mesh) SetFloat3Data added in v0.5.0

func (m Mesh) SetFloat3Data(data map[string][]vector3.Float64) Mesh

func (Mesh) SetFloat4Attribute added in v0.5.0

func (m Mesh) SetFloat4Attribute(attr string, data []vector4.Float64) Mesh

func (Mesh) SetFloat4Data added in v0.5.0

func (m Mesh) SetFloat4Data(data map[string][]vector4.Float64) Mesh

func (Mesh) SetMaterial

func (m Mesh) SetMaterial(mat Material) Mesh

func (Mesh) SetMaterials added in v0.5.0

func (m Mesh) SetMaterials(mat []MeshMaterial) Mesh

func (Mesh) SliceByPlaneWithAttribute

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

func (Mesh) SmoothLaplacian

func (m Mesh) SmoothLaplacian(iterations int, smoothingFactor float64) Mesh

func (Mesh) SplitOnUniqueMaterials

func (m Mesh) SplitOnUniqueMaterials() []Mesh

SplitOnUniqueMaterials generates a mesh per material,

func (Mesh) Topology

func (m Mesh) Topology() Topology

func (Mesh) Translate

func (m Mesh) Translate(v vector3.Float64) Mesh

Translate(v) is shorthand for TranslateAttribute3D(V, "Position")

func (Mesh) TranslateAttribute3D

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

func (Mesh) Tri

func (m Mesh) Tri(i int) Tri

func (Mesh) Unweld

func (m Mesh) Unweld() Mesh

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

func (Mesh) VertexNeighborTable

func (m Mesh) VertexNeighborTable() VertexLUT

func (Mesh) View

func (m Mesh) View() MeshView

View exposes the underlying data to be modified. Using this breaks the immutable design of the system, but required for some mesh processing.

Modifying the data stored in the mesh found here will directly update the mesh, and side-steps any type of validation we could have done previously.

If you make changes to this view, assume the mesh and all ancestors of said mesh have just become garbage.

func (Mesh) WeldByFloat3Attribute

func (m Mesh) WeldByFloat3Attribute(attribute string, decimalPlace int) Mesh

type MeshMaterial

type MeshMaterial struct {
	PrimitiveCount int
	Material       *Material
}

type MeshView

type MeshView struct {
	Float3Data map[string][]vector3.Float64
	Float2Data map[string][]vector2.Float64
	Float1Data map[string][]float64
	Indices    []int
}

type Point

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

func (Point) BoundingBox

func (p Point) BoundingBox(atr string) geometry.AABB

func (Point) Clips

func (p Point) Clips(plane geometry.Plane, atr string) bool

func (Point) ClosestPoint

func (p Point) ClosestPoint(atr string, point vector3.Float64) vector3.Float64

func (Point) Scope

func (p Point) Scope(attribute string) trees.Element

type Primitive

type Primitive interface {
	BoundingBox(attribute string) geometry.AABB
	ClosestPoint(attribute string, p vector3.Float64) vector3.Float64
	Scope(attribute string) trees.Element
}

type Quaternion

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

Quaternion is a 4 component imaginary number thingy for rotating 3D meshes.

func NewQuaternion

func NewQuaternion(v vector3.Float64, w float64) Quaternion

NewQuaternion creates a quaternion

func QuaternionZero

func QuaternionZero() Quaternion

QuaternionZero returns a quaternion with 0 for all it's components

func UnitQuaternionFromTheta

func UnitQuaternionFromTheta(theta float64, v vector3.Float64) Quaternion

UnitQuaternionFromTheta takes a vector and angle and builds a unit quaternion in the form (cos(theta/2.0), sin(theta/2.0))

Resources Used:

https://www.youtube.com/watch?v=mHVwd8gYLnI
https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation

func (Quaternion) Rotate

Rotate takes a given vector and rotates it with by this quaternion.

Resources Used:

https://gamedev.stackexchange.com/questions/28395

type Topology

type Topology int
const (
	TriangleTopology Topology = iota
	PointTopology
	QuadTopology
	LineTopology
	LineStripTopology
	LineLoopTopology
)

func (Topology) IndexSize

func (t Topology) IndexSize() int

func (Topology) String

func (t Topology) String() string

type Tri

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

Tri provides utility functions to a specific underlying mesh

func (Tri) Average added in v0.3.0

func (t Tri) Average(attr string) vector3.Float64

func (Tri) BoundingBox

func (t Tri) BoundingBox(atr string) geometry.AABB

func (Tri) Bounds

func (t Tri) Bounds() geometry.AABB

func (Tri) ClosestPoint

func (t Tri) ClosestPoint(atr string, p vector3.Float64) vector3.Float64

func (Tri) L1

func (t Tri) L1(atr string) geometry.Line3D

func (Tri) L2

func (t Tri) L2(atr string) geometry.Line3D

func (Tri) L3

func (t Tri) L3(atr string) geometry.Line3D

func (Tri) LineIntersects added in v0.3.0

func (t Tri) LineIntersects(line geometry.Line3D) (vector3.Float64, bool)

func (Tri) P1

func (t Tri) P1() int

P1 is the first point on our triangle, which is an index to the vertices array of a mesh

func (Tri) P1Vec1Attr added in v0.4.0

func (t Tri) P1Vec1Attr(atr string) float64

func (Tri) P1Vec2Attr added in v0.4.0

func (t Tri) P1Vec2Attr(atr string) vector2.Float64

func (Tri) P1Vec3Attr

func (t Tri) P1Vec3Attr(atr string) vector3.Float64

func (Tri) P2

func (t Tri) P2() int

P2 is the second point on our triangle, which is an index to the vertices array of a mesh

func (Tri) P2Vec1Attr added in v0.4.0

func (t Tri) P2Vec1Attr(atr string) float64

func (Tri) P2Vec2Attr added in v0.4.0

func (t Tri) P2Vec2Attr(atr string) vector2.Float64

func (Tri) P2Vec3Attr

func (t Tri) P2Vec3Attr(atr string) vector3.Float64

func (Tri) P3

func (t Tri) P3() int

P3 is the third point on our triangle, which is an index to the vertices array of a mesh

func (Tri) P3Vec1Attr added in v0.4.0

func (t Tri) P3Vec1Attr(atr string) float64

func (Tri) P3Vec2Attr added in v0.4.0

func (t Tri) P3Vec2Attr(atr string) vector2.Float64

func (Tri) P3Vec3Attr

func (t Tri) P3Vec3Attr(atr string) vector3.Float64

func (Tri) Plane

func (t Tri) Plane(attr string) geometry.Plane

func (Tri) Scope

func (t Tri) Scope(atr string) trees.Element

func (Tri) UniqueVertices

func (t Tri) UniqueVertices() bool

Valid determines whether or not the contains 3 unique vertices.

type VectorInt

type VectorInt struct {
	X int
	Y int
	Z int
}

func Vector3ToInt

func Vector3ToInt(v vector3.Float64, power int) VectorInt

func (VectorInt) String

func (v VectorInt) String() string

func (VectorInt) Sub

func (v VectorInt) Sub(other VectorInt) VectorInt

func (VectorInt) ToRegularVector

func (v VectorInt) ToRegularVector() vector3.Float64

type VertexLUT

type VertexLUT map[int]map[int]struct{}

func (VertexLUT) AddLookup

func (vLUT VertexLUT) AddLookup(from, to int)

func (VertexLUT) Count

func (vLUT VertexLUT) Count(v int) int
func (vLUT VertexLUT) Link(v1, v2 int)

func (VertexLUT) Lookup

func (vLUT VertexLUT) Lookup(v int) map[int]struct{}

func (VertexLUT) Remove

func (vLUT VertexLUT) Remove(v int) map[int]struct{}
func (vLUT VertexLUT) RemoveLink(v1, v2 int)

func (VertexLUT) RemoveLookup

func (vLUT VertexLUT) RemoveLookup(from, to int)

func (VertexLUT) RemoveVertex

func (vLUT VertexLUT) RemoveVertex(v int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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