Documentation
¶
Index ¶
- Variables
- func CenterOfBoundingBoxOfShapes(shapes []Shape) vector.Vector2
- func Clamp(v, min, max float64) float64
- func Multiply3x3by3x1(m Matrix, v vector.Vector3) vector.Vector3
- func ToNormal(inEulerAngle vector.Vector3) vector.Vector3
- type AABB
- func (aabb AABB) Contains(p vector.Vector3) bool
- func (aabb *AABB) EncapsulateBounds(b AABB)
- func (aabb *AABB) EncapsulatePoint(p vector.Vector3)
- func (aabb *AABB) Expand(amount float64)
- func (aabb AABB) Max() vector.Vector3
- func (aabb AABB) Min() vector.Vector3
- func (aabb *AABB) SetMinMax(min, max vector.Vector3)
- func (aabb AABB) Size() vector.Vector3
- type CollapsableMesh
- type Line2D
- func (l Line2D) ClosestPointOnLine(p vector.Vector2) vector.Vector2
- func (l Line2D) Dir() vector.Vector2
- func (l Line2D) GetEndPoint() vector.Vector2
- func (l Line2D) GetStartPoint() vector.Vector2
- func (l Line2D) Intersection(other Line2D) (vector.Vector2, error)
- func (l Line2D) Intersects(other Line2D) bool
- func (l Line2D) ScaleOutwards(amount float64) Line2D
- type Line3D
- func (l Line3D) GetEndPoint() vector.Vector3
- func (l Line3D) GetStartPoint() vector.Vector3
- func (l Line3D) ScaleOutwards(amount float64) Line3D
- func (l Line3D) SetEndPoint(newEnd vector.Vector3) Line3D
- func (l Line3D) SetStartPoint(newStart vector.Vector3) Line3D
- func (l Line3D) Translate(amt vector.Vector3) Line3D
- func (l Line3D) YIntersection(x float64, z float64) float64
- type Material
- type Matrix
- type Mesh
- func (m Mesh) Append(other Mesh) Mesh
- func (m Mesh) CalculateFlatNormals() Mesh
- func (m Mesh) CalculateSmoothNormals() Mesh
- func (m Mesh) Materials() []MeshMaterial
- func (m Mesh) ModifyUVs(f func(v vector.Vector3, uv vector.Vector2) vector.Vector2) Mesh
- func (m Mesh) ModifyVertices(f func(v vector.Vector3) vector.Vector3) Mesh
- func (m Mesh) RemoveDegenerateTriangles(sideLength float64) Mesh
- func (m Mesh) RemoveUnusedIndices() Mesh
- func (m Mesh) Rotate(q Quaternion) Mesh
- func (m Mesh) Scale(origin, amount vector.Vector3) Mesh
- func (m Mesh) SetMaterial(mat Material) Mesh
- func (m Mesh) SmoothLaplacian(iterations int, smoothingFactor float64) Mesh
- func (m Mesh) SplitOnUniqueMaterials() []Mesh
- func (m Mesh) Translate(v vector.Vector3) Mesh
- func (m Mesh) Tri(i int) Tri
- func (m Mesh) TriCount() int
- func (m Mesh) VertexNeighborTable() VertexLUT
- func (m Mesh) View() MeshView
- func (m Mesh) WeldByVertices(decimalPlace int) Mesh
- type MeshMaterial
- type MeshView
- type Orientation
- type Quaternion
- type Shape
- func (s Shape) GetBoundingBoxDimensions() (width, height float64)
- func (s Shape) GetBounds() (vector.Vector2, vector.Vector2)
- func (s Shape) IsInside(p vector.Vector2) bool
- func (s Shape) Len() int
- func (s Shape) Less(i, j int) bool
- func (s Shape) RandomPointInShape() vector.Vector2
- func (s Shape) Rotate(amount float64, pivot vector.Vector2) Shape
- func (s Shape) Scale(amount float64, origin vector.Vector2) Shape
- func (s Shape) Split(vericalLine float64) ([]Shape, []Shape)
- func (s Shape) Swap(i, j int)
- func (s Shape) Translate(amount vector.Vector2) Shape
- type Tri
- type VectorInt
- type VertexLUT
- func (vLUT VertexLUT) AddLookup(from, to int)
- func (vLUT VertexLUT) Count(v int) int
- func (vLUT VertexLUT) Link(v1, v2 int)
- func (vLUT VertexLUT) Lookup(v int) map[int]struct{}
- func (vLUT VertexLUT) Remove(v int) map[int]struct{}
- func (vLUT VertexLUT) RemoveLink(v1, v2 int)
- func (vLUT VertexLUT) RemoveLookup(from, to int)
- func (vLUT VertexLUT) RemoveVertex(v int)
Constants ¶
This section is empty.
Variables ¶
var ErrNoIntersection = errors.New("no intersection")
ErrNoIntersection is thrown when Intersection() contains no intersection
Functions ¶
func CenterOfBoundingBoxOfShapes ¶
CenterOfBoundingBoxOfShapes finds the center point of the smallest box that could be drawn to encompas all shapes passed in.
Types ¶
type AABB ¶
type AABB struct {
// contains filtered or unexported fields
}
func (*AABB) EncapsulateBounds ¶
func (*AABB) EncapsulatePoint ¶
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 Line2D ¶
type Line2D struct {
// contains filtered or unexported fields
}
Line2D represents a line segment
func (Line2D) ClosestPointOnLine ¶
func (Line2D) GetEndPoint ¶
GetEndPoint returns the end point of the line segment
func (Line2D) GetStartPoint ¶
GetStartPoint returns the starting point of the line segment
func (Line2D) Intersection ¶
Intersection finds where two lines intersect https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
func (Line2D) Intersects ¶
Intersects determines whether two lines intersect eachother
func (Line2D) ScaleOutwards ¶
ScaleOutwards multiplies the current length of the line by extending it out further in the two different directions it's heading
type Line3D ¶
type Line3D struct {
// contains filtered or unexported fields
}
Line3D is a series of ordered points that make up a line segment through 3D space.
func (Line3D) GetEndPoint ¶
GetEndPoint returns the end point of the line segment
func (Line3D) GetStartPoint ¶
GetStartPoint returns the starting point of the line segment
func (Line3D) ScaleOutwards ¶
ScaleOutwards assumes line segment 3d is only two points multiplies the current length of the line by extending it out further in the two different directions it's heading
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 DefaultMaterial ¶
func DefaultMaterial() Material
type Mesh ¶
type Mesh struct {
// contains filtered or unexported fields
}
func MeshFromView ¶
func NewMeshWithMaterials ¶
func (Mesh) CalculateFlatNormals ¶
func (Mesh) CalculateSmoothNormals ¶
func (Mesh) Materials ¶
func (m Mesh) Materials() []MeshMaterial
func (Mesh) ModifyVertices ¶
func (Mesh) RemoveDegenerateTriangles ¶
func (Mesh) RemoveUnusedIndices ¶
func (Mesh) Rotate ¶
func (m Mesh) Rotate(q Quaternion) Mesh
func (Mesh) SetMaterial ¶
func (Mesh) SmoothLaplacian ¶
func (Mesh) SplitOnUniqueMaterials ¶
SplitOnUniqueMaterials generates a mesh per material,
func (Mesh) VertexNeighborTable ¶
func (Mesh) View ¶
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) WeldByVertices ¶
type MeshMaterial ¶
type Orientation ¶
type Orientation int
const ( Colinear Orientation = iota Clockwise Counterclockwise )
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 vector.Vector3, 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 vector.Vector3) 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
type Shape ¶
Shape is a flat (2D) arrangement of points.
func (Shape) GetBoundingBoxDimensions ¶
func (Shape) IsInside ¶
IsInside returns true if the point p lies inside the polygon[] with n vertices
func (Shape) Less ¶
Less determines which point is more oriented more clockwise from the center than the other
func (Shape) RandomPointInShape ¶
RandomPointInShape returns a random point inside of the shape
func (Shape) Rotate ¶
Rotate will rotate all points in the shape around the pivot by the passed in amount
func (Shape) Split ¶
Split figures out which points land on which side of the vertical line and builds new shapes from that
type Tri ¶
type Tri struct {
// contains filtered or unexported fields
}
Tri provides utility functions to a specific underlying mesh
func (Tri) P1 ¶
P1 is the first point on our triangle, which is an index to the vertices array of a mesh
func (Tri) P2 ¶
P2 is the second point on our triangle, which is an index to the vertices array of a mesh
func (Tri) P3 ¶
P3 is the third point on our triangle, which is an index to the vertices array of a mesh
func (Tri) UniqueVertices ¶
Valid determines whether or not the contains 3 unique vertices.