Documentation
¶
Overview ¶
Package poly cuts the polygons of a model file into triangles (a fan when the polygon is convex, ear clipping when it is not); the loaders of OBJ and PLY share it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Triangulator ¶
type Triangulator struct {
// contains filtered or unexported fields
}
Triangulator cuts polygons into triangles. It keeps its work arrays between polygons.
func (*Triangulator) Cut ¶
func (tr *Triangulator) Cut(pos []float64, corners []int32, out []int32) []int32
Cut appends the triangles of the polygon to out, as numbers of its corners: a triangle is three consecutive numbers, in the winding of the polygon. pos are the positions of all the vertices of the file, three numbers each, and corners the vertices of the polygon in them. A convex polygon is cut as a fan from its first corner; a concave one by ear clipping on the plane that is the most face-on to the polygon. A polygon with no area is cut as a fan too, and the triangles that have none are the business of the renderer.