Documentation
¶
Overview ¶
Spatial data types & helpers for use in 3D apps (AABB, Frustum, bounding volumes etc)
Index ¶
- type AaBb
- func (me *AaBb) BoundingSphere(center *unum.Vec3) (radius float64)
- func (me *AaBb) Clear()
- func (me *AaBb) ResetMinMax()
- func (me *AaBb) SetCenterExtent()
- func (me *AaBb) SetMinMax()
- func (me *AaBb) Transform(mat *unum.Mat4)
- func (me *AaBb) UpdateMinMax(vec *unum.Vec3)
- func (me *AaBb) UpdateMinMaxFrom(aabb *AaBb)
- type Bounds
- type Frustum
- func (me *Frustum) HasPoint(pos, point *unum.Vec3, zNear, zFar float64) bool
- func (me *Frustum) HasSphere(pos, center *unum.Vec3, radius, zNear, zFar float64) (fullyInside, intersect bool)
- func (me *Frustum) UpdateAxes(dir, upVector, upAxis *unum.Vec3)
- func (me *Frustum) UpdateAxesCoordsPlanes(persp *Perspective, pos, dir, upVector, upAxis *unum.Vec3)
- func (me *Frustum) UpdateCoords(persp *Perspective, pos *unum.Vec3)
- func (me *Frustum) UpdatePlanes()
- func (me *Frustum) UpdatePlanesGH(mat *unum.Mat4, normalize bool)
- func (me *Frustum) UpdateRatio(persp *Perspective, aspectRatio float64)
- type FrustumCoords
- type FrustumPlane
- type MeshDescF3
- type MeshDescF3V
- type MeshDescVA2
- type MeshDescVA3
- type MeshDescriptor
- func MeshDescriptorCube() (meshDescriptor *MeshDescriptor, err error)
- func MeshDescriptorPlane() (meshDescriptor *MeshDescriptor, err error)
- func MeshDescriptorPyramid() (meshDescriptor *MeshDescriptor, err error)
- func MeshDescriptorQuad() (meshDescriptor *MeshDescriptor, err error)
- func MeshDescriptorTri() (meshDescriptor *MeshDescriptor, err error)
- type MeshFaceBase
- type MeshProvider
- type Perspective
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AaBb ¶
type AaBb struct {
Min, Max, Center, Extent unum.Vec3
}
func (*AaBb) BoundingSphere ¶
func (*AaBb) ResetMinMax ¶
func (me *AaBb) ResetMinMax()
func (*AaBb) SetCenterExtent ¶
func (me *AaBb) SetCenterExtent()
func (*AaBb) UpdateMinMax ¶
func (me *AaBb) UpdateMinMax(vec *unum.Vec3)
func (*AaBb) UpdateMinMaxFrom ¶
type Frustum ¶
type Frustum struct { Bounding Bounds Planes [6]FrustumPlane Axes struct{ X, Y, Z unum.Vec3 } Near, Far FrustumCoords // contains filtered or unexported fields }
func (*Frustum) UpdateAxes ¶
func (me *Frustum) UpdateAxes(dir, upVector, upAxis *unum.Vec3)
func (*Frustum) UpdateAxesCoordsPlanes ¶
func (me *Frustum) UpdateAxesCoordsPlanes(persp *Perspective, pos, dir, upVector, upAxis *unum.Vec3)
func (*Frustum) UpdateCoords ¶
func (me *Frustum) UpdateCoords(persp *Perspective, pos *unum.Vec3)
func (*Frustum) UpdatePlanes ¶
func (me *Frustum) UpdatePlanes()
func (*Frustum) UpdatePlanesGH ¶
Gribb/Hartmann: "Fast Extraction of Viewing Frustum Planes from the WorldView-Projection Matrix"
func (*Frustum) UpdateRatio ¶
func (me *Frustum) UpdateRatio(persp *Perspective, aspectRatio float64)
type FrustumCoords ¶
type FrustumCoords struct { unum.Vec2 C, TL, TR, BL, BR unum.Vec3 // contains filtered or unexported fields }
type FrustumPlane ¶
type FrustumPlane struct {
unum.Vec4
}
func (*FrustumPlane) Normalize ¶
func (me *FrustumPlane) Normalize()
type MeshDescF3 ¶
type MeshDescF3 struct { // The indexed vertices making up this triangle face. V [3]MeshDescF3V // ID, Tags MeshFaceBase }
Represents an indexed triangle face.
func NewMeshDescF3 ¶
func NewMeshDescF3(tags, id string, verts ...MeshDescF3V) (me *MeshDescF3)
Creates and initializes a new MeshDescF3V with the specified tags, ID and verts, and returns it. tags may be empty or contain multiple classification tags separated by spaces, which will be split into Tags.
type MeshDescF3V ¶
type MeshDescF3V struct { // Index of the vertex position PosIndex uint32 // Index of the texture-coordinate. TexCoordIndex uint32 // Index of the vertex normal. NormalIndex uint32 }
Represents an indexed vertex in a MeshDescF3.
type MeshDescVA2 ¶
type MeshDescVA2 [2]float32
Represents a 2-component vertex attribute in a MeshDescriptor. (such as for example texture-coordinates)
type MeshDescVA3 ¶
type MeshDescVA3 [3]float32
Represents a 3-component vertex attribute in a MeshDescriptor (such as for example vertex-normals)
func (*MeshDescVA3) ToVec3 ¶
func (me *MeshDescVA3) ToVec3(vec *unum.Vec3)
type MeshDescriptor ¶
type MeshDescriptor struct { // Vertex positions Positions []MeshDescVA3 // Vertex texture coordinates TexCoords []MeshDescVA2 // Vertex normals Normals []MeshDescVA3 // Indexed triangle definitions Faces []MeshDescF3 }
Represents yet-unprocessed, descriptive mesh source data.
func MeshDescriptorCube ¶
func MeshDescriptorCube() (meshDescriptor *MeshDescriptor, err error)
A MeshProvider that creates MeshDescriptor for a cube with extents -1 .. 1. args is ignored and err is always nil. The returned MeshDescriptor contains 12 triangle faces with IDs "t0" through "t11". These faces are classified in 6 distinct tags: "front","back","top","bottom","right","left".
func MeshDescriptorPlane ¶
func MeshDescriptorPlane() (meshDescriptor *MeshDescriptor, err error)
A MeshProvider that creates MeshDescriptor for a flat ground plane with extents -1 .. 1. args is ignored and err is always nil. The returned MeshDescriptor contains 2 triangle faces with IDs "t0" through "t1". These faces are all classified with tag: "plane".
func MeshDescriptorPyramid ¶
func MeshDescriptorPyramid() (meshDescriptor *MeshDescriptor, err error)
A MeshProvider that creates MeshDescriptor for a pyramid with extents -1 .. 1. args is ignored and err is always nil. The returned MeshDescriptor contains 4 triangle faces with IDs "t0" through "t3". These faces are all classified with tag: "pyr".
func MeshDescriptorQuad ¶
func MeshDescriptorQuad() (meshDescriptor *MeshDescriptor, err error)
A MeshProvider that creates MeshDescriptor for a quad with extents -1 .. 1. args is ignored and err is always nil. The returned MeshDescriptor contains 2 triangle faces with IDs "t0" through "t1". These faces are all classified with tag: "quad".
func MeshDescriptorTri ¶
func MeshDescriptorTri() (meshDescriptor *MeshDescriptor, err error)
A MeshProvider that creates MeshDescriptor for a triangle with extents -1 .. 1. args is ignored and err is always nil. The returned MeshDescriptor contains 1 triangle face with ID "t0" and tag "tri".
func (*MeshDescriptor) AddFaces ¶
func (me *MeshDescriptor) AddFaces(faces ...*MeshDescF3)
Adds all specified Faces to this MeshDescriptor.
func (*MeshDescriptor) AddNormals ¶
func (me *MeshDescriptor) AddNormals(normals ...MeshDescVA3)
Adds all the specified Normals to this MeshDescriptor.
func (*MeshDescriptor) AddPositions ¶
func (me *MeshDescriptor) AddPositions(positions ...MeshDescVA3)
Adds all specified Positions to this MeshDescriptor.
func (*MeshDescriptor) AddTexCoords ¶
func (me *MeshDescriptor) AddTexCoords(texCoords ...MeshDescVA2)
Adds all the specified TexCoords to this MeshDescriptor.
type MeshFaceBase ¶
type MeshProvider ¶
type MeshProvider func() (*MeshDescriptor, error)
type Perspective ¶
type Perspective struct { // Whether this is a perspective-projection camera. Defaults to true. // If false, no projection transformation is applied. Enabled bool // Vertical field-of-view angle. FovY struct { // In degrees. Defaults to 37.8493. Deg float64 // Deg-in-radians, times 0.5. This should always be kept in sync with Deg. RadHalf float64 } // Distance of the far-plane from the camera. ZFar float64 // Distance of the near-plane from the camera. ZNear float64 }