Hi,

computation of bb (without tranform cache) doesnt count with text 
alignment(variable _offset).


Code:
/*virtual*/ osg::BoundingBox BentleyText::computeBound() const
{
    osg::BoundingBox  bbox;

    if (_textBB.valid())
    {
        for(unsigned int i=0;i<_autoTransformCache.size();++i)
        {
            if (_autoTransformCache[i]._traversalNumber>=0)
            {
                osg::Matrix& matrix = _autoTransformCache[i]._matrix;
                
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix);
                
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())*matrix);
            }
        }


        if (!bbox.valid())
        {
            // Provide a fallback in cases where no bounding box has been been 
setup so far.
            // Note, assume a scaling of 1.0 for 
_characterSizeMode!=OBJECT_COORDS as the
            // for screen space coordinates size modes we don't know what scale 
will be used until
            // the text is actually rendered, but we haven't to assume 
something otherwise the
            // text label will be culled by view or small feature culling on 
first frame.
            if (_autoRotateToScreen)
            {
                // use bounding sphere encompassing the maximum size of the 
text centered on the _position
                double radius = _textBB.radius();
                osg::Vec3 diagonal(radius, radius, radius);
                bbox.set(_position-diagonal, _position+diagonal);
            }
            else
            {
                osg::Matrix matrix;
                matrix.makeTranslate(_position);
                matrix.preMultRotate(_rotation);
                                //matrix.preMultTranslate(-_offset); --- this 
line shoudl be added !!!!!
                
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix);
                
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())*matrix);
            }
        }
    }

    return bbox;
}



 
... 

Thank you!

Cheers,
Filip

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45355#45355





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to