From c1b1a091faeea50c59ac4546611cb500e286da40 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 27 Apr 2003 10:58:39 +0000 Subject: [PATCH] From Tree, addition of ; after MACRO_'s to help with Java port. From Tree + Robert, Addition of LEFT_BASE_LINE,RIGHT_BASE_LINE,CENTER_BASE_LINE Alignment options in Text. --- include/osg/AnimationPath | 4 ++-- include/osg/ConvexPlanarOccluder | 2 +- include/osg/Shape | 18 +++++++++--------- include/osg/ShapeDrawable | 2 +- include/osgText/Text | 29 +++++++++++++++++++++++++++-- src/osgPlugins/osgText/IO_Text.cpp | 7 ++++++- src/osgText/Text.cpp | 4 +++- 7 files changed, 49 insertions(+), 17 deletions(-) diff --git a/include/osg/AnimationPath b/include/osg/AnimationPath index a7f58e8f0..efbbba6d5 100644 --- a/include/osg/AnimationPath +++ b/include/osg/AnimationPath @@ -37,7 +37,7 @@ class SG_EXPORT AnimationPath : public virtual osg::Object _timeControlPointMap(ap._timeControlPointMap), _loopMode(ap._loopMode) {} - META_Object(osg,AnimationPath) + META_Object(osg,AnimationPath); struct ControlPoint { @@ -162,7 +162,7 @@ class SG_EXPORT AnimationPathCallback : public NodeCallback _animationTime(apc._animationTime) {} - META_Object(osg,AnimationPathCallback) + META_Object(osg,AnimationPathCallback); AnimationPathCallback(AnimationPath* ap,double timeOffset=0.0f,double timeMultiplier=1.0f): _animationPath(ap), diff --git a/include/osg/ConvexPlanarOccluder b/include/osg/ConvexPlanarOccluder index 138e40da0..4bd75a6f4 100644 --- a/include/osg/ConvexPlanarOccluder +++ b/include/osg/ConvexPlanarOccluder @@ -34,7 +34,7 @@ class SG_EXPORT ConvexPlanarOccluder : public Object _occluder(cpo._occluder), _holeList(cpo._holeList) {} - META_Object(osg,ConvexPlanarOccluder) + META_Object(osg,ConvexPlanarOccluder); void setOccluder(const ConvexPlanarPolygon& cpp) { _occluder = cpp; } diff --git a/include/osg/Shape b/include/osg/Shape index 3e3b5227b..8e10f5d87 100644 --- a/include/osg/Shape +++ b/include/osg/Shape @@ -153,7 +153,7 @@ class Sphere : public Shape _center(sphere._center), _radius(sphere._radius) {} - META_Shape(osg, Sphere) + META_Shape(osg, Sphere); inline bool valid() const { return _radius>=0.0f; } @@ -200,7 +200,7 @@ class Box : public Shape _halfLengths(box._halfLengths), _rotation(box._rotation) {} - META_Shape(osg, Box) + META_Shape(osg, Box); inline bool valid() const { return _halfLengths.x()>=0.0f; } @@ -254,7 +254,7 @@ class Cone : public Shape _height(cone._height), _rotation(cone._rotation) {} - META_Shape(osg, Cone) + META_Shape(osg, Cone); inline bool valid() const { return _radius>=0.0f; } @@ -314,7 +314,7 @@ class Cylinder : public Shape _height(cylinder._height), _rotation(cylinder._rotation) {} - META_Shape(osg, Cylinder) + META_Shape(osg, Cylinder); inline bool valid() const { return _radius>=0.0f; } @@ -359,7 +359,7 @@ class InfinitePlane : public Shape, public Plane Shape(plane,copyop), Plane(plane) {} - META_Shape(osg, InfinitePlane) + META_Shape(osg, InfinitePlane); protected: @@ -377,7 +377,7 @@ class TriangleMesh : public Shape _vertices(mesh._vertices), _indices(mesh._indices) {} - META_Shape(osg, TriangleMesh) + META_Shape(osg, TriangleMesh); void setVertices(Vec3Array* vertices) { _vertices = vertices; } @@ -407,7 +407,7 @@ class ConvexHull : public TriangleMesh ConvexHull(const ConvexHull& hull,const CopyOp& copyop=CopyOp::SHALLOW_COPY): TriangleMesh(hull,copyop) {} - META_Shape(osg, TriangleMesh) + META_Shape(osg, TriangleMesh); protected: @@ -477,7 +477,7 @@ class SG_EXPORT Grid : public HeightField Grid(const Grid& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY); - META_Shape(osg,Grid) + META_Shape(osg,Grid); void allocateGrid(unsigned int numColumns,unsigned int numRows); @@ -512,7 +512,7 @@ class CompositeShape : public Shape Shape(cs,copyop), _children(cs._children) {} - META_Shape(osg, CompositeShape) + META_Shape(osg, CompositeShape); /** Set the shape that encloses all of the children.*/ void setShape(Shape* shape) { _shape = shape; } diff --git a/include/osg/ShapeDrawable b/include/osg/ShapeDrawable index fb1f821d9..24d6381e5 100644 --- a/include/osg/ShapeDrawable +++ b/include/osg/ShapeDrawable @@ -51,7 +51,7 @@ class TessellationHints : public Object _createBody(tess._createBody), _createBottom(tess._createBottom) {} - META_Object(osg,TessellationHints) + META_Object(osg,TessellationHints); enum TessellationMode diff --git a/include/osgText/Text b/include/osgText/Text index 065888634..76fe33111 100644 --- a/include/osgText/Text +++ b/include/osgText/Text @@ -133,7 +133,11 @@ public: RIGHT_TOP, RIGHT_CENTER, RIGHT_BOTTOM, - BASE_LINE /// default. + + LEFT_BASE_LINE, + CENTER_BASE_LINE, + RIGHT_BASE_LINE, + BASE_LINE = LEFT_BASE_LINE /// default. }; @@ -240,17 +244,38 @@ protected: osg::Vec4 _color; unsigned int _drawMode; +public: + // internal structures, variable and methods used for rendering of characters. - struct GlyphQuads + struct OSGTEXT_EXPORT GlyphQuads { typedef std::vector Coords; typedef std::vector TexCoords; Coords _coords; TexCoords _texcoords; + + Coords& getCoords() { return _coords; } + const Coords& getCoords() const { return _coords; } + + TexCoords& getTexCoords() { return _texcoords; } + const TexCoords& getTexCoords() const { return _texcoords; } }; + typedef std::map,GlyphQuads> TextureGlyphQuadMap; + /** Direct Access to GlyphQuads */ + const GlyphQuads* getGlyphQuad(unsigned int index) const + { + if (index>=_textureGlyphQuadMap.size()) return NULL; + + TextureGlyphQuadMap::const_iterator itGlyph = _textureGlyphQuadMap.begin(); + while((index--) && (itGlyph!=_textureGlyphQuadMap.end())) itGlyph++; + return &itGlyph->second; + } + +protected: + // iternal map used for rendering. Set up by the computeGlyphRepresentation() method. TextureGlyphQuadMap _textureGlyphQuadMap; diff --git a/src/osgPlugins/osgText/IO_Text.cpp b/src/osgPlugins/osgText/IO_Text.cpp index 506425d35..3c3fae9a4 100644 --- a/src/osgPlugins/osgText/IO_Text.cpp +++ b/src/osgPlugins/osgText/IO_Text.cpp @@ -97,6 +97,9 @@ bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr) else if (str=="RIGHT_TOP") text.setAlignment(osgText::Text::RIGHT_TOP); else if (str=="RIGHT_CENTER") text.setAlignment(osgText::Text::RIGHT_CENTER); else if (str=="RIGHT_BOTTOM") text.setAlignment(osgText::Text::RIGHT_BOTTOM); + else if (str=="LEFT_BASE_LINE") text.setAlignment(osgText::Text::LEFT_BASE_LINE); + else if (str=="CENTER_BASE_LINE") text.setAlignment(osgText::Text::CENTER_BASE_LINE); + else if (str=="RIGHT_BASE_LINE") text.setAlignment(osgText::Text::RIGHT_BASE_LINE); else if (str=="BASE_LINE") text.setAlignment(osgText::Text::BASE_LINE); fr += 2; itAdvanced = true; @@ -255,7 +258,9 @@ bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw) case osgText::Text::RIGHT_CENTER: fw << "RIGHT_CENTER" << std::endl; break; case osgText::Text::RIGHT_BOTTOM: fw << "RIGHT_BOTTOM" << std::endl; break; - case osgText::Text::BASE_LINE: fw << "BASE_LINE" << std::endl; break; + case osgText::Text::LEFT_BASE_LINE: fw << "LEFT_BASE_LINE" << std::endl; break; + case osgText::Text::CENTER_BASE_LINE:fw << "CENTER_BASE_LINE" << std::endl; break; + case osgText::Text::RIGHT_BASE_LINE: fw << "RIGHT_BASE_LINE" << std::endl; break; }; diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index 349c419e1..7cc840832 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -416,7 +416,9 @@ void Text::computePositions() case RIGHT_TOP: _offset.set(_textBB.xMax(),_textBB.yMax(),_textBB.zMin()); break; case RIGHT_CENTER: _offset.set(_textBB.xMax(),(_textBB.yMax()+_textBB.yMin())*0.5f,_textBB.zMin()); break; case RIGHT_BOTTOM: _offset.set(_textBB.xMax(),_textBB.yMin(),_textBB.zMin()); break; - case BASE_LINE: _offset.set(0.0f,0.0f,0.0f); break; + case LEFT_BASE_LINE: _offset.set(0.0f,0.0f,0.0f); break; + case CENTER_BASE_LINE: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,0.0f,0.0f); break; + case RIGHT_BASE_LINE: _offset.set((_textBB.xMax()+_textBB.xMin()),0.0f,0.0f); break; } // adjust offset for axis alignment