From 3ac94784fcef189219a4b1e57e1bed5ec1a7a9c5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 22 Aug 2005 15:13:04 +0000 Subject: [PATCH] From Geoff Michel, added normal definition for tesselation --- include/osgUtil/Tesselator | 11 +++++++++++ src/osgUtil/Tesselator.cpp | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/osgUtil/Tesselator b/include/osgUtil/Tesselator index 0981402ff..b9048b9e9 100644 --- a/include/osgUtil/Tesselator +++ b/include/osgUtil/Tesselator @@ -77,6 +77,14 @@ class OSGUTIL_EXPORT Tesselator : public osg::Referenced * as well as Polygons so as to not break old codes relying on this function name. */ void retesselatePolygons(osg::Geometry &cxgeom); + /** Define the normal to the tesselated polygon - this provides a hint how to + * tesselate the contours; see gluTessNormal in red book or man pages. + * GWM July 2005. Can improve teselation + * "For example, if you know that all polygons lie in the x-y plane, + * call gluTessNormal(tess, 0.0, 0.0, 1.0) before rendering any polygons." + */ + void setTesselationNormal(const osg::Vec3 norm) { tessNormal=norm;} + osg::Geometry::PrimitiveSetList getContours() { return _Contours;} typedef std::vector VertexPointList; @@ -225,6 +233,9 @@ class OSGUTIL_EXPORT Tesselator : public osg::Referenced /** count number of primitives in a geometry to get right no. of norms/colurs etc for per_primitive attributes. */ unsigned int _index; + + /** the gluTessNormal for tesselation hint */ + osg::Vec3 tessNormal; }; } diff --git a/src/osgUtil/Tesselator.cpp b/src/osgUtil/Tesselator.cpp index 63fa06a9a..261d90e4c 100644 --- a/src/osgUtil/Tesselator.cpp +++ b/src/osgUtil/Tesselator.cpp @@ -35,8 +35,6 @@ Tesselator::~Tesselator() reset(); } - - void Tesselator::beginTesselation() { reset(); @@ -48,6 +46,7 @@ void Tesselator::beginTesselation() gluTessCallback(_tobj, GLU_TESS_END_DATA, (GLU_TESS_CALLBACK) endCallback); gluTessCallback(_tobj, GLU_TESS_COMBINE_DATA,(GLU_TESS_CALLBACK) combineCallback); gluTessCallback(_tobj, GLU_TESS_ERROR_DATA, (GLU_TESS_CALLBACK) errorCallback); + if (tessNormal.length()>0.0) gluTessNormal(_tobj, tessNormal.x(), tessNormal.y(), tessNormal.z()); gluTessBeginPolygon(_tobj,this); }