#include <OSGTextVectorGlyph.h>
Inheritance diagram for osg::TextVectorGlyph:

Definition at line 64 of file OSGTextVectorGlyph.h.
|
|
Defines a contour Definition at line 102 of file OSGTextVectorGlyph.h. |
|
|
Defines an outline Definition at line 105 of file OSGTextVectorGlyph.h. |
|
|
Defines a vector containing the edge normals along a polygon contour. Definition at line 150 of file OSGTextVectorGlyph.h. |
|
|
Defines the map of polygon outlines (level -> outline) Definition at line 264 of file OSGTextVectorGlyph.h. |
|
|
Defines the map of normal outlines (level -> edge normal outline) Definition at line 270 of file OSGTextVectorGlyph.h. |
|
|
Defines the glyph index Definition at line 65 of file OSGTextGlyph.h. |
|
|
Defines symbolic constants for the orientation of a contour. Definition at line 222 of file OSGTextVectorGlyph.h.
|
|
|
Defines the invalid glyph index Definition at line 68 of file OSGTextGlyph.h. 00068 { INVALID_INDEX = -1 };
|
|
|
Destroys the VectorGlyph object. Definition at line 66 of file OSGTextVectorGlyph.cpp.
|
|
|
Creates a new VectorGlyph object. Definition at line 51 of file OSGTextVectorGlyph.inl. 00052 : TextGlyph(), _width(0.f), _height(0.f), 00053 _horiBearingX(0.f), _horiBearingY(0.f), _vertBearingX(0.f), _vertBearingY(0.f), 00054 _outline(), _polygonOutlineMap(), 00055 _normalMap(), _contourOrientations() 00056 {}
|
|
|
Copy constructor (not implemented!) |
|
|
Returns the width of the glyph.
Implements osg::TextGlyph. Definition at line 73 of file OSGTextVectorGlyph.cpp. References _width. 00074 { return _width; }
|
|
|
Returns the height of the glyph.
Implements osg::TextGlyph. Definition at line 81 of file OSGTextVectorGlyph.cpp. References _height. 00082 { return _height; }
|
|
|
Returns the x bearing of the glyph for horizontal layout. The x bearing is the distance from the origin to the left border of the glyph.
Implements osg::TextGlyph. Definition at line 89 of file OSGTextVectorGlyph.cpp. References _horiBearingX. 00090 { return _horiBearingX; }
|
|
|
Returns the y bearing of the glyph for horizontal layout. The y bearing is the distance from the origin to the top border of the glyph.
Implements osg::TextGlyph. Definition at line 97 of file OSGTextVectorGlyph.cpp. References _horiBearingY. 00098 { return _horiBearingY; }
|
|
|
Returns the x bearing of the glyph for vertical layout. The x bearing is the distance from the origin to the left border of the glyph.
Implements osg::TextGlyph. Definition at line 105 of file OSGTextVectorGlyph.cpp. References _vertBearingX. 00106 { return _vertBearingX; }
|
|
|
Returns the y bearing of the glyph for vertical layout. The y bearing is the distance from the origin to the top border of the glyph.
Implements osg::TextGlyph. Definition at line 113 of file OSGTextVectorGlyph.cpp. References _vertBearingY. 00114 { return _vertBearingY; }
|
|
|
Returns the contours that describe the outline of the glyph.
Definition at line 48 of file OSGTextVectorGlyph.inl. References _outline. 00048 { return _outline; }
|
|
|
Returns a polygon outline containing only on-curve points. The contours contained in this outline are not closed!
Definition at line 317 of file OSGTextVectorGlyph.cpp. References _outline, _polygonOutlineMap, osg::TextVectorGlyph::PolygonOutline::contours, osg::TextVectorGlyph::PolygonOutline::coords, osg::evalBezierCurve(), GLdouble, osg::gluTessBeginDataCB(), osg::gluTessCombineDataCB(), osg::gluTessEndDataCB(), and osg::gluTessVertexDataCB(). Referenced by computeContourOrientations(), osg::TextVectorFace::fillGeo(), and getNormals(). 00318 { 00319 // Try to find the polygon outline of the specified detail level in the 00320 // cache map 00321 PolygonOutlineMap::const_iterator it = _polygonOutlineMap.find(level); 00322 if (it != _polygonOutlineMap.end()) 00323 // We already have that level - return the corresponding outline 00324 return it->second; 00325 00326 // We did not find that level, so we have to create it 00327 PolygonOutline &newOutline = _polygonOutlineMap.insert(PolygonOutlineMap::value_type(level, PolygonOutline())).first->second; 00328 00329 // Calculate the bezier curves for this level 00330 Outline::const_iterator oIt; 00331 for (oIt = _outline.begin(); oIt != _outline.end(); ++oIt) 00332 { 00333 UInt32 size = oIt->size(); 00334 if (size > 0) 00335 { 00336 size -= 1; 00337 UInt32 index = 0; 00338 while (index < size) 00339 evalBezierCurve(*oIt, index, level, newOutline.coords); 00340 newOutline.contours.push_back(newOutline.coords.size()); 00341 } 00342 } 00343 00344 // Calculate the faces 00345 00346 // Create a new GLU tesselator object 00347 GLUtesselator *tess = gluNewTess(); 00348 if (tess == 0) 00349 return newOutline; 00350 00351 // hint to the GLU tesselator that all points lie in the xy-plane 00352 gluTessNormal(tess, 0.0, 0.0, 1.0); 00353 // set the winding rule 00354 gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); 00355 00356 // register GLU Tesselator callback methods 00357 gluTessCallback(tess, 00358 GLU_TESS_BEGIN_DATA, 00359 reinterpret_cast<OSGGLUfuncptr>(gluTessBeginDataCB)); 00360 gluTessCallback(tess, 00361 GLU_TESS_END_DATA, 00362 reinterpret_cast<OSGGLUfuncptr>(gluTessEndDataCB)); 00363 gluTessCallback(tess, 00364 GLU_TESS_COMBINE_DATA, 00365 reinterpret_cast<OSGGLUfuncptr>(gluTessCombineDataCB)); 00366 gluTessCallback(tess, 00367 GLU_TESS_VERTEX_DATA, 00368 reinterpret_cast<OSGGLUfuncptr>(gluTessVertexDataCB)); 00369 00370 // make shared data structure available to callbacks */ 00371 gluTessBeginPolygon(tess, &newOutline); 00372 00373 vector<UInt32>::const_iterator cIt; 00374 UInt32 coordIndex = 0; 00375 for (cIt = newOutline.contours.begin(); cIt != newOutline.contours.end(); ++cIt) 00376 { 00377 // begin new contour 00378 gluTessBeginContour(tess); 00379 00380 while (coordIndex < *cIt) 00381 { 00382 GLdouble coords[3]; 00383 assert(coordIndex < newOutline.coords.size()); 00384 coords[0] = newOutline.coords[coordIndex].x(); 00385 coords[1] = newOutline.coords[coordIndex].y(); 00386 coords[2] = 0.f; 00387 gluTessVertex(tess, coords, reinterpret_cast<void*>(coordIndex++)); 00388 } 00389 00390 // end of contour 00391 gluTessEndContour(tess); 00392 } 00393 00394 // trigger tesselator action 00395 gluTessEndPolygon(tess); 00396 00397 // clean up 00398 gluDeleteTess(tess); 00399 00400 return newOutline; 00401 }
|
|
|
Returns an edge normal outline of the specified detail level
Definition at line 425 of file OSGTextVectorGlyph.cpp. References _contourOrientations, _normalMap, computeContourOrientations(), osg::computeEdgeNormal(), osg::TextVectorGlyph::PolygonOutline::contours, osg::TextVectorGlyph::PolygonOutline::coords, CW, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), getLines(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), osg::osgabs(), osg::osgacos(), and start. Referenced by osg::TextVectorFace::fillGeo(). 00426 { 00427 // Try to find the normal outline of the specified detail level in the 00428 // cache map 00429 NormalMap::const_iterator it = _normalMap.find(level); 00430 if (it != _normalMap.end()) 00431 // We already have that level - return the corresponding outline 00432 return it->second; 00433 00434 // We did not find that level, so we have to create it 00435 Normals &normals = _normalMap.insert(NormalMap::value_type(level, Normals())).first->second; 00436 00437 // get the polygon outline of this glyph at the desired detail level 00438 // The contours of this outline are not closed! 00439 const PolygonOutline &outline = getLines(level); 00440 00441 // compute the contour orientations when they are not available 00442 if (_contourOrientations.empty()) 00443 computeContourOrientations(); 00444 00445 UInt32 start = 0, end, index = 0; 00446 vector<UInt32>::const_iterator iIt; 00447 vector<Orientation>::const_iterator oriIt = _contourOrientations.begin(); 00448 for (iIt = outline.contours.begin(); iIt != outline.contours.end(); ++iIt, ++oriIt) 00449 { 00450 end = *iIt; 00451 00452 assert(end - 1 < outline.coords.size()); 00453 assert(start < outline.coords.size()); 00454 assert(oriIt != _contourOrientations.end()); 00455 Vec2f prevEdgeNormal = computeEdgeNormal(outline.coords[end - 1], 00456 outline.coords[start], 00457 (*oriIt) == CW); 00458 while (index < end) 00459 { 00460 UInt32 nextIndex = index + 1; 00461 if (nextIndex >= end) 00462 nextIndex = start; 00463 00464 assert(index < outline.coords.size()); 00465 assert(nextIndex < outline.coords.size()); 00466 Vec2f nextEdgeNormal = computeEdgeNormal(outline.coords[index], outline.coords[nextIndex], (*oriIt) == CW); 00467 Vec2f meanEdgeNormal = prevEdgeNormal + nextEdgeNormal; 00468 meanEdgeNormal.normalize(); 00469 Real32 edgeAngle = osgacos(osgabs(prevEdgeNormal.dot(nextEdgeNormal))); 00470 normals.push_back(VertexNormal(nextEdgeNormal, meanEdgeNormal, edgeAngle)); 00471 00472 //the outgoing edge of this vertex is the incoming of the next vertex 00473 prevEdgeNormal = nextEdgeNormal; 00474 00475 ++index; 00476 } 00477 00478 start = end; 00479 } 00480 00481 return normals; 00482 }
|
|
|
Returns the orientations of the outlines.
Definition at line 489 of file OSGTextVectorGlyph.cpp. References _contourOrientations, and computeContourOrientations(). Referenced by osg::TextVectorFace::fillGeo(). 00490 { 00491 // compute the contour orientations when they are not available 00492 if (_contourOrientations.empty()) 00493 computeContourOrientations(); 00494 return _contourOrientations; 00495 }
|
|
|
Copy operator (not implemented!) |
|
|
Computes the orientation of each contour Definition at line 586 of file OSGTextVectorGlyph.cpp. References _contourOrientations, CCW, osg::computeEdgeNormal(), osg::TextVectorGlyph::PolygonOutline::contours, osg::TextVectorGlyph::PolygonOutline::coords, CW, osg::Eps, getLines(), osg::isInteriorPoint(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), and start. Referenced by getContourOrientations(), and getNormals(). 00587 { 00588 // get the simplest outline available as it should suffice for the 00589 // orientation check 00590 const PolygonOutline &outline = getLines(0); 00591 UInt32 start = 0, end; 00592 vector<UInt32>::const_iterator it; 00593 for (it = outline.contours.begin(); it != outline.contours.end(); ++it) 00594 { 00595 end = *it; 00596 00597 // return value does not matter 00598 if (end - start < 3) 00599 _contourOrientations.push_back(CCW); 00600 00601 assert(start + 2 < outline.coords.size()); 00602 Vec2f en1 = computeEdgeNormal(outline.coords[start], outline.coords[start + 1], false); 00603 Vec2f en2 = computeEdgeNormal(outline.coords[start + 1], outline.coords[start + 2], false); 00604 // compute the mean of the edge normals at vertex 0. 00605 Vec2f testNormal = en1 + en2; 00606 testNormal.normalize(); 00607 // calculate the displacement of vertex 0 along its mean edge normal 00608 Vec2f testPoint = outline.coords[start + 1] + testNormal * (1000.f * Eps); 00609 00610 if (isInteriorPoint(testPoint, outline, GLU_TESS_WINDING_NONZERO)) 00611 _contourOrientations.push_back(CW); 00612 else 00613 _contourOrientations.push_back(CCW); 00614 00615 start = end; 00616 } 00617 }
|
|
|
Returns the index of the glyph.
Definition at line 43 of file OSGTextGlyph.inl. References osg::TextGlyph::_glyphIndex. 00043 { return _glyphIndex; }
|
|
|
Returns the advance of the glyph for horizontal layout. The advance is the distance to the next character on the base line.
Definition at line 46 of file OSGTextGlyph.inl. References osg::TextGlyph::_horiAdvance. 00046 { return _horiAdvance; }
|
|
|
Returns the advance of the glyph for vertical layout. The advance is the distance to the next character on the base line. This value is usually negative!
Definition at line 49 of file OSGTextGlyph.inl. References osg::TextGlyph::_vertAdvance. 00049 { return _vertAdvance; }
|
|
|
Needs access to constructor Definition at line 68 of file OSGTextVectorGlyph.h. |
|
|
The width of the glyph Definition at line 240 of file OSGTextVectorGlyph.h. Referenced by getWidth(). |
|
|
The height of the glyph Definition at line 243 of file OSGTextVectorGlyph.h. Referenced by getHeight(). |
|
|
The x bearing of the glyph for horizontal layout Definition at line 246 of file OSGTextVectorGlyph.h. Referenced by getHoriBearingX(). |
|
|
The y bearing of the glyph for horizontal layout Definition at line 249 of file OSGTextVectorGlyph.h. Referenced by getHoriBearingY(). |
|
|
The x bearing of the glyph for vertical layout Definition at line 252 of file OSGTextVectorGlyph.h. Referenced by getVertBearingX(). |
|
|
The y bearing of the glyph for vertical layout Definition at line 255 of file OSGTextVectorGlyph.h. Referenced by getVertBearingY(). |
|
|
The original outline information Definition at line 258 of file OSGTextVectorGlyph.h. Referenced by getLines(), and getOutline(). |
|
|
The vector of contour orientations Definition at line 261 of file OSGTextVectorGlyph.h. Referenced by computeContourOrientations(), getContourOrientations(), and getNormals(). |
|
|
The map of polygon outlines (level -> outline) Definition at line 267 of file OSGTextVectorGlyph.h. Referenced by getLines(). |
|
|
The map of normal outlines (level -> edge normal outline) Definition at line 273 of file OSGTextVectorGlyph.h. Referenced by getNormals(). |
|
|
The index of the glyph Definition at line 145 of file OSGTextGlyph.h. Referenced by osg::TextGlyph::getGlyphIndex(). |
|
|
The advance of the glyph for horizontal layout Definition at line 148 of file OSGTextGlyph.h. Referenced by osg::TextGlyph::getHoriAdvance(). |
|
|
The advance of the glyph for vertical layout Definition at line 151 of file OSGTextGlyph.h. Referenced by osg::TextGlyph::getVertAdvance(). |
1.4.3