Added Text::getCharacterCorners(...) method to help applications that want to find out the positions of characters being rendered.
This commit is contained in:
parent
d60b9714fe
commit
7f97b9f999
@ -182,9 +182,13 @@ public:
|
|||||||
virtual void accept(osg::PrimitiveFunctor& pf) const;
|
virtual void accept(osg::PrimitiveFunctor& pf) const;
|
||||||
|
|
||||||
|
|
||||||
|
/** Get the coordinates of the character corners in local coordinates. Use Text::getMatrix() or Text::computeMatrix(..) to get the transform into model coordinates (see TextBase header.) */
|
||||||
|
bool getCharacterCorners(unsigned int index, osg::Vec3& bottomLeft, osg::Vec3& bottomRight, osg::Vec3& topLef, osg::Vec3& topRight) const;
|
||||||
|
|
||||||
/** Resize any per context GLObject buffers to specified size. */
|
/** Resize any per context GLObject buffers to specified size. */
|
||||||
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||||
|
|
||||||
|
|
||||||
/** If State is non-zero, this function releases OpenGL objects for
|
/** If State is non-zero, this function releases OpenGL objects for
|
||||||
* the specified graphics context. Otherwise, releases OpenGL objexts
|
* the specified graphics context. Otherwise, releases OpenGL objexts
|
||||||
* for all graphics contexts. */
|
* for all graphics contexts. */
|
||||||
|
@ -279,10 +279,12 @@ public:
|
|||||||
void getCoord(unsigned int i, osg::Vec2& c) const { c.set((*_coords)[i].x(), (*_coords)[i].y()); }
|
void getCoord(unsigned int i, osg::Vec2& c) const { c.set((*_coords)[i].x(), (*_coords)[i].y()); }
|
||||||
void getCoord(unsigned int i, osg::Vec3& c) const { c = (*_coords)[i]; }
|
void getCoord(unsigned int i, osg::Vec3& c) const { c = (*_coords)[i]; }
|
||||||
|
|
||||||
|
/** Get the cached internal matrix used to provide positioning of text. The cached matrix is originally computed by computeMatrix(..). */
|
||||||
/** Get the internal matrix used to provide positioning of text.*/
|
|
||||||
const osg::Matrix& getMatrix() const { return _matrix; }
|
const osg::Matrix& getMatrix() const { return _matrix; }
|
||||||
|
|
||||||
|
/** compute the matrix that positions the text in model space for the given viewpoint.*/
|
||||||
|
bool computeMatrix(osg::Matrix& matrix, osg::State* state=0) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~TextBase();
|
virtual ~TextBase();
|
||||||
@ -295,8 +297,6 @@ protected:
|
|||||||
|
|
||||||
osg::VertexArrayState* createVertexArrayState(osg::RenderInfo& renderInfo) const;
|
osg::VertexArrayState* createVertexArrayState(osg::RenderInfo& renderInfo) const;
|
||||||
|
|
||||||
bool computeMatrix(osg::Matrix& matrix, osg::State* state=0) const;
|
|
||||||
|
|
||||||
void positionCursor(const osg::Vec2 & endOfLine_coords, osg::Vec2 & cursor, unsigned int linelength);
|
void positionCursor(const osg::Vec2 & endOfLine_coords, osg::Vec2 & cursor, unsigned int linelength);
|
||||||
String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
|
String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
|
||||||
void computePositions();
|
void computePositions();
|
||||||
|
@ -1301,6 +1301,21 @@ void Text::accept(osg::PrimitiveFunctor& pf) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Text::getCharacterCorners(unsigned int index, osg::Vec3& bottomLeft, osg::Vec3& bottomRight, osg::Vec3& topLeft, osg::Vec3& topRight) const
|
||||||
|
{
|
||||||
|
if (_coords) return false;
|
||||||
|
|
||||||
|
if ((index*4+4)>static_cast<unsigned int>(_coords->size())) return false;
|
||||||
|
|
||||||
|
unsigned int base = index*4;
|
||||||
|
topLeft = (*_coords)[base];
|
||||||
|
bottomLeft = (*_coords)[base+1];
|
||||||
|
bottomRight = (*_coords)[base+2];
|
||||||
|
topRight = (*_coords)[base+3];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Text::resizeGLObjectBuffers(unsigned int maxSize)
|
void Text::resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
{
|
{
|
||||||
TextBase::resizeGLObjectBuffers(maxSize);
|
TextBase::resizeGLObjectBuffers(maxSize);
|
||||||
|
Loading…
Reference in New Issue
Block a user