[osg-users] text appearing flipped and backwards
James Dickson
james.dickson at gmail.com
Fri Jul 18 13:49:31 PDT 2008
Hi,
I am having an issue with osgText::Text in that the text appears flipped and
backwards relative to the other geometry in the scene. (Please see
screenshot for what I mean)
In the attached screen shot I have written on the coords. of the billboard
geometry so hopefully the following code will make some sense:
// Go through data and plot lines.
for (_i = _testTimeLine.begin(); _i != _testTimeLine.end(); ++_i)
{
std::stringstream _caption;
_caption << *_j;
int _y = static_cast<int>(((*_j) + _minY) *
((
_height - 20) / (_maxY - _minY)));
int _x = static_cast<int>(((*_i) + _minX) *
((
_width - 20) / (_maxX - _minX)));
_x = _x + 10;
_y = _y + 10;
// If not at the beginning of the vector, draw a line, otherwise
// colour a pixel.
if (_i != _testTimeLine.begin())
{
m_graphImage->DrawLine(osg::Vec2(_prevx, _prevy),
osg::Vec2(_x, _y),
osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
}
else
{
m_graphImage->SetPixel(osg::Vec2(_x, _y),
osg::Vec3(0.0f, 0.0f, 1.0f));
}
_prevx = _x;
_prevy = _y;
// Convert texture coordinates to uv's to use as offsets.
float _u = ((float)_x) / ((float)_width);
float _v = ((float)_y) / ((float)_height);
osg::Vec3 _xoffset(_u, 0.0f, 0.0f);
osg::Vec3 _zoffset(0.0f, 0.0f, _v);
// Use offsets to create world space coordinates.
osg::Vec3 _pos = m_corner + _xoffset + _yoffset
+
_zoffset;
// Create and position text displaying data point value.
osgText::Text * _text = new osgText::Text;
_text->setFont(_font);
_text->setCharacterSize(characterSize);
_text->setPosition(_pos);
_text->setAxisAlignment(osgText::Text::XZ_PLANE);
_text->setText(_caption.str());
_captions->addDrawable(_text);
++
_j;
}
I have managed to fix it by changing the alignment setting to
REVERSE_XZ_PLANE and switching the sign of the offset coords. However I feel
this is a slight hack and wondered if there is some other 'proper' setting?
Many thanks,
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080718/b467355d/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad_text.JPG
Type: image/jpeg
Size: 38037 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080718/b467355d/attachment-0002.jpeg>
More information about the osg-users
mailing list