OpenGLContext.scenegraph.polygontessellator
Class for tessellating polygons using GLU
Classes
class PolygonTessellator(
object
):
Simplified polygon tessellation for IndexedFaceSets & Fonts
OpenGLContext 2.0.0b1 has substantially improved this
class, allowing for multiple-contour tessellation, as
well as providing mechanisms for returning results
other than triangle-sets.
XXX Should have threading lock around tessContours,
as any single tessellator is non-thread-safe.
XXX Should be doing a GLU version check for this entire
module, and degrading to earlier API version if
necessary.
controller
__init__(
self
,
windingRule
= GLU_TESS_WINDING_ODD
,
ccw
= True
)
Initialise the PolygonTessellator
combine(
self
,
newPosition
,
vertices
,
weights
,
polygonData
= None
)
Blend vertices with weights to create new vertex object (GLU Tess callback)
end(
self
,
*
args
,
**
namedargs
)
Record the end of a tessellated shape (GLU Tess callback)
This method implements the "forceTriangles" semantics by
unravelling GL_TRIANGLE_FAN or GL_TRIANGLE_STRIP if
forceTriangles is true. It also manages the creating of
the final self.result data-set.
tessContours(
self
,
contours
,
forceTriangles
= 1
,
normal
= None
)
Tessellate polygon defined by (multiple) contours
Occasionally will create new vertices as a blending
of the given vertex objects.
- contours
- list of list of vertices, with each set defining a closed contour within the polygon.
- forceTriangles
- if true (default), returns a set of GL_TRIANGLES-compatible vertex specifications as a list-of-vertex-objects [ Vertex(), Vertex(), ...]
if false, returns
vertices), ...
where
type is the type to be specified for glBegin, and
vertices are a list-of-vertex-objects, with the
types being any of GL_TRIANGLES, GL_TRIANGLE_STRIP,
or GL_TRIANGLE_FAN and the vertices being compatible
with the given type.
- normal
- if specified, calls gluTessNormal with the value, restores to default after the tessellation is complete
return value -- see note on forceTriangles
tessellate(
self
,
vertices
,
forceTriangles
= 1
)
Tessellate polygon defined by vertices
Less general form of tessContours, takes a single
contour and returns the tessellation result for that
contour. See tessContours for semantics of
forceTriangles and the results (which are dependent
on the value of forceTriangles).