Documentation ¶
Overview ¶
Package geometry implements several primitive geometry generators.
Index ¶
- Constants
- type Box
- type Circle
- type Cylinder
- type Geometry
- func (g *Geometry) AddGroup(start, count, matIndex int) *Group
- func (g *Geometry) AddGroupList(groups []Group)
- func (g *Geometry) AddVBO(vbo *gls.VBO)
- func (g *Geometry) ApplyMatrix(m *math32.Matrix4)
- func (g *Geometry) Area() float32
- func (g *Geometry) AttributeName(atype gls.AttribType) string
- func (g *Geometry) BoundingBox() math32.Box3
- func (g *Geometry) BoundingSphere() math32.Sphere
- func (g *Geometry) Dispose()
- func (g *Geometry) GetGeometry() *Geometry
- func (g *Geometry) GroupAt(idx int) *Group
- func (g *Geometry) GroupCount() int
- func (g *Geometry) Incref() *Geometry
- func (g *Geometry) Indexed() bool
- func (g *Geometry) Indices() math32.ArrayU32
- func (g *Geometry) Init()
- func (g *Geometry) Items() int
- func (g *Geometry) OperateOnVertexNormals(cb func(normal *math32.Vector3) bool)
- func (g *Geometry) OperateOnVertices(cb func(vertex *math32.Vector3) bool)
- func (g *Geometry) ProjectOntoAxis(localAxis *math32.Vector3) (float32, float32)
- func (g *Geometry) ReadFaces(cb func(vA, vB, vC math32.Vector3) bool)
- func (g *Geometry) ReadVertexNormals(cb func(vertex math32.Vector3) bool)
- func (g *Geometry) ReadVertices(cb func(vertex math32.Vector3) bool)
- func (g *Geometry) RenderSetup(gs *gls.GLS)
- func (g *Geometry) RotationalInertia(mass float32) math32.Matrix3
- func (g *Geometry) SetAttributeName(atype gls.AttribType, attribName string)
- func (g *Geometry) SetIndices(indices math32.ArrayU32)
- func (g *Geometry) SetVAO(handle uint32)
- func (g *Geometry) VAO() uint32
- func (g *Geometry) VBO(atype gls.AttribType) *gls.VBO
- func (g *Geometry) VBOName(name string) *gls.VBO
- func (g *Geometry) VBOs() []*gls.VBO
- func (g *Geometry) Volume() float32
- type Group
- type IGeometry
- type MorphGeometry
- func (mg *MorphGeometry) ActiveMorphTargets() ([]*Geometry, []float32)
- func (mg *MorphGeometry) AddMorphTargetDeltas(morphTargetDeltas ...*Geometry)
- func (mg *MorphGeometry) AddMorphTargets(morphTargets ...*Geometry)
- func (mg *MorphGeometry) ComputeMorphed(weights []float32) *Geometry
- func (mg *MorphGeometry) Dispose()
- func (mg *MorphGeometry) GetGeometry() *Geometry
- func (mg *MorphGeometry) RenderSetup(gs *gls.GLS)
- func (mg *MorphGeometry) SetIndices(indices math32.ArrayU32)
- func (mg *MorphGeometry) SetWeights(weights []float32)
- func (mg *MorphGeometry) UpdateTargetAttributes(morphTargets []*Geometry)
- func (mg *MorphGeometry) Weights() []float32
- type Plane
- type Sphere
- type Torus
Constants ¶
const MaxActiveMorphTargets = 8
MaxActiveMorphTargets is the maximum number of active morph targets.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Box ¶
type Box struct { Geometry Width float32 Height float32 Length float32 WidthSegments int // > 0 HeightSegments int // > 0 LengthSegments int // > 0 }
Box represents the geometry of a rectangular cuboid. See https://en.wikipedia.org/wiki/Cuboid#Rectangular_cuboid for more details. A Box geometry is defined by its width, height, and length and also by the number of segments in each dimension.
func NewSegmentedBox ¶
func NewSegmentedBox(width, height, length float32, widthSegments, heightSegments, lengthSegments int) *Box
NewSegmentedBox creates a box geometry of the specified size and with the specified number of segments in each dimension. This is the Box constructor with most tunable parameters.
func NewSegmentedCube ¶
NewSegmentedCube creates a cube geometry of the specified size and number of segments.
type Circle ¶
type Circle struct { Geometry Radius float64 Segments int // >= 3 ThetaStart float64 ThetaLength float64 }
Circle represents the geometry of a filled circle (i.e. a disk) The center of the circle is at the origin, and theta runs counter-clockwise on the XY plane, starting at (x,y,z)=(1,0,0).
func NewCircle ¶
NewCircle creates a new circle geometry with the specified radius and number of radial segments/triangles (minimum 3).
func NewCircleSector ¶
NewCircleSector creates a new circle or circular sector geometry with the specified radius, number of radial segments/triangles (minimum 3), sector start angle in radians (thetaStart), and sector size angle in radians (thetaLength). This is the Circle constructor with most tunable parameters.
type Cylinder ¶
type Cylinder struct { Geometry RadiusTop float64 RadiusBottom float64 Height float64 RadialSegments int HeightSegments int ThetaStart float64 ThetaLength float64 Top bool Bottom bool }
Cylinder represents a cylinder geometry
type Geometry ¶
type Geometry struct { ShaderDefines gls.ShaderDefines // Geometry-specific shader defines // contains filtered or unexported fields }
Geometry encapsulates a three-dimensional vertex-based geometry.
func NewGeometry ¶
func NewGeometry() *Geometry
NewGeometry creates and returns a pointer to a new Geometry.
func (*Geometry) AddGroupList ¶
AddGroupList adds the specified list of groups to this geometry.
func (*Geometry) ApplyMatrix ¶
ApplyMatrix multiplies each of the geometry position vertices by the specified matrix and apply the correspondent normal transform matrix to the geometry normal vectors. The geometry's bounding box and sphere are recomputed if needed.
func (*Geometry) Area ¶
Area returns the surface area. NOTE: This only works for triangle-based meshes.
func (*Geometry) AttributeName ¶
func (g *Geometry) AttributeName(atype gls.AttribType) string
AttributeName returns the name of the VBO attribute associated with the provided attribute type.
func (*Geometry) BoundingBox ¶
BoundingBox computes the bounding box of the geometry if necessary and returns is value.
func (*Geometry) BoundingSphere ¶
BoundingSphere computes the bounding sphere of this geometry if necessary and returns its value.
func (*Geometry) Dispose ¶
func (g *Geometry) Dispose()
Dispose decrements this geometry reference count and if possible releases OpenGL resources, C memory and VBOs associated with this geometry.
func (*Geometry) GetGeometry ¶
GetGeometry satisfies the IGeometry interface.
func (*Geometry) GroupCount ¶
GroupCount returns the number of geometry groups (for multimaterial).
func (*Geometry) Incref ¶
Incref increments the reference count for this geometry and returns a pointer to the geometry. It should be used when this geometry is shared by another Graphic object.
func (*Geometry) Items ¶
Items returns the number of items in the first VBO. (The number of items should be same for all VBOs) An item is a complete group of attributes in the VBO buffer.
func (*Geometry) OperateOnVertexNormals ¶
OperateOnVertexNormals iterates over all the vertex normals and calls the specified callback function with a pointer to each normal. The vertex pointers can be modified inside the callback and the modifications will be applied to the buffer at each iteration. The callback function returns false to continue or true to break.
func (*Geometry) OperateOnVertices ¶
OperateOnVertices iterates over all the vertices and calls the specified callback function with a pointer to each vertex. The vertex pointers can be modified inside the callback and the modifications will be applied to the buffer at each iteration. The callback function returns false to continue or true to break.
func (*Geometry) ProjectOntoAxis ¶
ProjectOntoAxis projects the geometry onto the specified axis, effectively squashing it into a line passing through the local origin. Returns the maximum and the minimum values on that line (i.e. signed distances from the local origin).
func (*Geometry) ReadFaces ¶
ReadFaces iterates over all the vertices and calls the specified callback function with face-forming vertex triples. The callback function returns false to continue or true to break.
func (*Geometry) ReadVertexNormals ¶
ReadVertexNormals iterates over all the vertex normals and calls the specified callback function with the value of each normal. The callback function returns false to continue or true to break.
func (*Geometry) ReadVertices ¶
ReadVertices iterates over all the vertices and calls the specified callback function with the value of each vertex. The callback function returns false to continue or true to break.
func (*Geometry) RenderSetup ¶
RenderSetup is called by the renderer before drawing the geometry.
func (*Geometry) RotationalInertia ¶
RotationalInertia returns the rotational inertia tensor, also known as the moment of inertia. This assumes constant density of 1 (kg/m^2). To adjust for a different constant density simply scale the returning matrix by the density.
func (*Geometry) SetAttributeName ¶
func (g *Geometry) SetAttributeName(atype gls.AttribType, attribName string)
SetAttributeName sets the name of the VBO attribute associated with the provided attribute type.
func (*Geometry) SetIndices ¶
SetIndices sets the indices array for this geometry.
func (*Geometry) VBO ¶
func (g *Geometry) VBO(atype gls.AttribType) *gls.VBO
VBO returns a pointer to this geometry's VBO which contain the specified attribute. Returns nil if the VBO is not found.
func (*Geometry) VBOName ¶
VBOName returns a pointer to this geometry's VBO which contain the specified attribute. Returns nil if the VBO is not found.
type Group ¶
type Group struct { Start int // Index of first element of the group Count int // Number of elements in the group Matindex int // Material index for this group Matid string // Material id used when loading external models }
Group is a geometry group object.
type MorphGeometry ¶
type MorphGeometry struct {
// contains filtered or unexported fields
}
MorphGeometry represents a base geometry and its morph targets.
func NewMorphGeometry ¶
func NewMorphGeometry(baseGeometry *Geometry) *MorphGeometry
NewMorphGeometry creates and returns a pointer to a new MorphGeometry.
func (*MorphGeometry) ActiveMorphTargets ¶
func (mg *MorphGeometry) ActiveMorphTargets() ([]*Geometry, []float32)
ActiveMorphTargets sorts the morph targets by weight and returns the top n morph targets with largest weight.
func (*MorphGeometry) AddMorphTargetDeltas ¶
func (mg *MorphGeometry) AddMorphTargetDeltas(morphTargetDeltas ...*Geometry)
AddMorphTargetDeltas add multiple morph target deltas to the morph geometry.
func (*MorphGeometry) AddMorphTargets ¶
func (mg *MorphGeometry) AddMorphTargets(morphTargets ...*Geometry)
AddMorphTargets add multiple morph targets to the morph geometry. Morph target deltas are calculated internally and the morph target geometries are altered to hold the deltas instead.
func (*MorphGeometry) ComputeMorphed ¶
func (mg *MorphGeometry) ComputeMorphed(weights []float32) *Geometry
ComputeMorphed computes a morphed geometry from the provided morph target weights. Note that morphing is usually computed by the GPU in shaders. This CPU implementation allows users to obtain an instance of a morphed geometry if so desired (loosing morphing ability).
func (*MorphGeometry) Dispose ¶
func (mg *MorphGeometry) Dispose()
Dispose releases, if possible, OpenGL resources, C memory and VBOs associated with the base geometry and morph targets.
func (*MorphGeometry) GetGeometry ¶
func (mg *MorphGeometry) GetGeometry() *Geometry
GetGeometry satisfies the IGeometry interface.
func (*MorphGeometry) RenderSetup ¶
func (mg *MorphGeometry) RenderSetup(gs *gls.GLS)
RenderSetup is called by the renderer before drawing the geometry.
func (*MorphGeometry) SetIndices ¶
func (mg *MorphGeometry) SetIndices(indices math32.ArrayU32)
SetIndices sets the indices array for this geometry.
func (*MorphGeometry) SetWeights ¶
func (mg *MorphGeometry) SetWeights(weights []float32)
SetWeights sets the morph target weights.
func (*MorphGeometry) UpdateTargetAttributes ¶
func (mg *MorphGeometry) UpdateTargetAttributes(morphTargets []*Geometry)
UpdateTargetAttributes updates the attribute names of the specified morph targets in order.
func (*MorphGeometry) Weights ¶
func (mg *MorphGeometry) Weights() []float32
Weights returns the morph target weights.
type Plane ¶
Plane represents a plane geometry
type Sphere ¶
type Sphere struct { Geometry Radius float64 WidthSegments int HeightSegments int PhiStart float64 PhiLength float64 ThetaStart float64 ThetaLength float64 }
Sphere represents a sphere geometry