geometry

package
v0.0.0-...-a112006 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package geometry implements several primitive geometry generators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

type Box struct {
	Geometry
	Width          float64
	Height         float64
	Depth          float64
	WidthSegments  int
	HeightSegments int
	DepthSegments  int
}

func NewBox

func NewBox(width, height, depth float64, widthSegments, heightSegments, depthSegments int) *Box

NewBox creates and returns a pointer to a new Box geometry object. The geometry is defined by its width, height, depth and the number of segments of each dimension (minimum = 1).

type Circle

type Circle struct {
	Geometry
	Radius      float64
	Segments    int
	ThetaStart  float64
	ThetaLength float64
}

func NewCircle

func NewCircle(radius float64, segments int, thetaStart, thetaLength float64) *Circle

NewCircle creates and returns a pointer to a new Circle geometry object. The geometry is defined by its radius, the number of segments (triangles), minimum = 3, the start angle in radians for the first segment (thetaStart) and the central angle in radians (thetaLength) of the circular sector.

type Cylinder

type Cylinder struct {
	Geometry
	RadiusTop      float64
	RadiusBottom   float64
	Height         float64
	RadialSegments int
	HeightSegments int
	ThetaStart     float64
	ThetaLength    float64
	Top            bool
	Bottom         bool
}

func NewCylinder

func NewCylinder(radiusTop, radiusBottom, height float64,
	radialSegments, heightSegments int,
	thetaStart, thetaLength float64, top, bottom bool) *Cylinder

NewCylinder creates and returns a pointer to a new Cylinder geometry object.

type Geometry

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

func NewGeometry

func NewGeometry() *Geometry

func (*Geometry) AddGroup

func (g *Geometry) AddGroup(start, count, matIndex int) *Group

AddGroup adds a geometry group (for multimaterial)

func (*Geometry) AddGroupList

func (g *Geometry) AddGroupList(groups []Group)

AddGroupList adds the specified list of groups to this geometry

func (*Geometry) AddVBO

func (g *Geometry) AddVBO(vbo *gls.VBO)

AddVBO adds a Vertex Buffer Object for this geometry

func (*Geometry) ApplyMatrix

func (g *Geometry) ApplyMatrix(m *math32.Matrix4)

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) BoundingBox

func (g *Geometry) BoundingBox() math32.Box3

BoundingBox computes the bounding box of the geometry if necessary and returns is value

func (*Geometry) BoundingSphere

func (g *Geometry) BoundingSphere() math32.Sphere

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 necessary releases OpenGL resources, C memory and VBOs associated with this geometry.

func (*Geometry) GetGeometry

func (g *Geometry) GetGeometry() *Geometry

func (*Geometry) GroupAt

func (g *Geometry) GroupAt(idx int) *Group

GroupAt returns pointer to geometry group at the specified index

func (*Geometry) GroupCount

func (g *Geometry) GroupCount() int

GroupCount returns the number of geometry groups (for multimaterial)

func (*Geometry) Incref

func (g *Geometry) Incref() *Geometry

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) Indices

func (g *Geometry) Indices() math32.ArrayU32

Indices returns this geometry indices array

func (*Geometry) Init

func (g *Geometry) Init()

Init initializes the geometry

func (*Geometry) Items

func (g *Geometry) Items() int

Returns the number of items in the first VBO (The number of items should be same for all VBOs) An item is a complete vertex position (3 floats) for example

func (*Geometry) RenderSetup

func (g *Geometry) RenderSetup(gs *gls.GLS)

RenderSetup is called by the renderer before drawing the geometry

func (*Geometry) SetIndices

func (g *Geometry) SetIndices(indices math32.ArrayU32)

SetIndices sets the indices array for this geometry

func (*Geometry) VBO

func (g *Geometry) VBO(attrib string) *gls.VBO

VBO returns a pointer to this geometry VBO for 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
}

Geometry group object

type IGeometry

type IGeometry interface {
	GetGeometry() *Geometry
	RenderSetup(gs *gls.GLS)
	Dispose()
}

Interface for all geometries

type Plane

type Plane struct {
	Geometry
	Width          float32
	Height         float32
	WidthSegments  int
	HeightSegments int
}

func NewPlane

func NewPlane(width, height float32, widthSegments, heightSegments int) *Plane

NewPlane creates and returns a pointer to a Plane Geometry. The plane is defined by its width, height and the number of width and height segments. The minimum number of segments for the width and/or the height is 1. The plane is generated centered in the XY plane with Z=0.

type Sphere

type Sphere struct {
	Geometry
	Radius         float64
	WidthSegments  int
	HeightSegments int
	PhiStart       float64
	PhiLength      float64
	ThetaStart     float64
	ThetaLength    float64
}

func NewSphere

func NewSphere(radius float64, widthSegments, heightSegments int, phiStart, phiLength, thetaStart, thetaLength float64) *Sphere

type Torus

type Torus struct {
	Geometry                // embedded geometry
	Radius          float64 // Torus radius
	Tube            float64 // Diameter of the torus tube
	RadialSegments  int     // Number of radial segments
	TubularSegments int     // Number of tubular segments
	Arc             float64 // Central angle
}

func NewTorus

func NewTorus(radius, tube float64, radialSegments, tubularSegments int, arc float64) *Torus

Jump to

Keyboard shortcuts

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