Further work on Bound class/Node::getBound() and Drawable::getBound() and usage in OSG codebase

This commit is contained in:
Robert Osfield 2014-05-14 16:01:40 +00:00
parent ff21af2b0d
commit 74f91037a7
30 changed files with 239 additions and 213 deletions

View File

@ -303,7 +303,7 @@ bool DePee::createHUD()
osg::BoundingBox bb; osg::BoundingBox bb;
for(unsigned int i=0;i<geode->getNumDrawables();++i) for(unsigned int i=0;i<geode->getNumDrawables();++i)
{ {
bb.expandBy(geode->getDrawable(i)->getBound()); bb.expandBy(geode->getDrawable(i)->getBoundingBox());
} }
osg::Geometry* geom = new osg::Geometry; osg::Geometry* geom = new osg::Geometry;

View File

@ -151,7 +151,7 @@ osg::Camera* createHUD()
osg::BoundingBox bb; osg::BoundingBox bb;
for(unsigned int i=0;i<geode->getNumDrawables();++i) for(unsigned int i=0;i<geode->getNumDrawables();++i)
{ {
bb.expandBy(geode->getDrawable(i)->getBound()); bb.expandBy(geode->getDrawable(i)->getBoundingBox());
} }
osg::Geometry* geom = new osg::Geometry; osg::Geometry* geom = new osg::Geometry;

View File

@ -82,7 +82,11 @@ public:
// an attempt to return a reasonable bounding box. Still does not prevent clipping of the heat map. // an attempt to return a reasonable bounding box. Still does not prevent clipping of the heat map.
virtual const osg::BoundingBox& getBoundingBox() const {return m_bounds;} virtual const osg::BoundingBox& getBoundingBox() const {return m_bounds;}
virtual osg::BoundingBox computeBoundingBox() const {return m_bounds;} virtual osg::BoundingBox computeBoundingBox() const {return m_bounds;}
#ifdef OSG_USE_BOUND
virtual osg::Bound getBound() const { return osg::Bound(m_bounds, m_bounds); }
#else
virtual const osg::BoundingSphere& getBound() const {return m_bsphere;} virtual const osg::BoundingSphere& getBound() const {return m_bsphere;}
#endif
protected: protected:
osg::BoundingBox m_bounds; osg::BoundingBox m_bounds;

View File

@ -44,13 +44,13 @@ public:
{ {
double timeStamp = nv->getFrameStamp()?nv->getFrameStamp()->getReferenceTime():0.0; double timeStamp = nv->getFrameStamp()?nv->getFrameStamp()->getReferenceTime():0.0;
unsigned int frameNumber = nv->getFrameStamp()?nv->getFrameStamp()->getFrameNumber():0; unsigned int frameNumber = nv->getFrameStamp()?nv->getFrameStamp()->getFrameNumber():0;
pagedLOD->setFrameNumberOfLastTraversal( frameNumber ); pagedLOD->setFrameNumberOfLastTraversal( frameNumber );
pagedLOD->setTimeStamp( numChildren-1, timeStamp ); pagedLOD->setTimeStamp( numChildren-1, timeStamp );
pagedLOD->setFrameNumber( numChildren-1, frameNumber ); pagedLOD->setFrameNumber( numChildren-1, frameNumber );
pagedLOD->getChild(numChildren-1)->accept(*nv); pagedLOD->getChild(numChildren-1)->accept(*nv);
} }
// Request for new child // Request for new child
if ( !pagedLOD->getDisableExternalChildrenPaging() && if ( !pagedLOD->getDisableExternalChildrenPaging() &&
nv->getDatabaseRequestHandler() && nv->getDatabaseRequestHandler() &&
@ -114,7 +114,7 @@ void PosterVisitor::apply( osg::PagedLOD& node )
for ( unsigned int i=0; i<node.getNumFileNames(); ++i ) for ( unsigned int i=0; i<node.getNumFileNames(); ++i )
{ {
if ( node.getFileName(i).empty() ) continue; if ( node.getFileName(i).empty() ) continue;
PagedNodeNameSet::iterator itr = _pagedNodeNames.find( node.getFileName(i) ); PagedNodeNameSet::iterator itr = _pagedNodeNames.find( node.getFileName(i) );
if ( itr!=_pagedNodeNames.end() ) if ( itr!=_pagedNodeNames.end() )
{ {
@ -153,10 +153,10 @@ osgUtil::Intersector* PosterIntersector::clone( osgUtil::IntersectionVisitor& iv
if ( iv.getProjectionMatrix() ) matrix.preMult( *iv.getProjectionMatrix() ); if ( iv.getProjectionMatrix() ) matrix.preMult( *iv.getProjectionMatrix() );
if ( iv.getViewMatrix() ) matrix.preMult( *iv.getViewMatrix() ); if ( iv.getViewMatrix() ) matrix.preMult( *iv.getViewMatrix() );
if ( iv.getModelMatrix() ) matrix.preMult( *iv.getModelMatrix() ); if ( iv.getModelMatrix() ) matrix.preMult( *iv.getModelMatrix() );
osg::Polytope transformedPolytope; osg::Polytope transformedPolytope;
transformedPolytope.setAndTransformProvidingInverse( _polytope, matrix ); transformedPolytope.setAndTransformProvidingInverse( _polytope, matrix );
osg::ref_ptr<PosterIntersector> pi = new PosterIntersector( transformedPolytope ); osg::ref_ptr<PosterIntersector> pi = new PosterIntersector( transformedPolytope );
pi->_intersectionVisitor = &iv; pi->_intersectionVisitor = &iv;
pi->_parent = this; pi->_parent = this;
@ -187,9 +187,9 @@ void PosterIntersector::reset()
void PosterIntersector::intersect( osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable ) void PosterIntersector::intersect( osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable )
{ {
if ( !_polytope.contains(drawable->getBound()) ) return; if ( !_polytope.contains(drawable->getBoundingBox()) ) return;
if ( iv.getDoDummyTraversal() ) return; if ( iv.getDoDummyTraversal() ) return;
// Find and collect all paged LODs in the node path // Find and collect all paged LODs in the node path
osg::NodePath& nodePath = iv.getNodePath(); osg::NodePath& nodePath = iv.getNodePath();
for ( osg::NodePath::iterator itr=nodePath.begin(); itr!=nodePath.end(); ++itr ) for ( osg::NodePath::iterator itr=nodePath.begin(); itr!=nodePath.end(); ++itr )
@ -208,7 +208,7 @@ void PosterIntersector::intersect( osgUtil::IntersectionVisitor& iv, osg::Drawab
} }
continue; continue;
} }
/*osg::LOD* lod = dynamic_cast<osg::LOD*>(*itr); /*osg::LOD* lod = dynamic_cast<osg::LOD*>(*itr);
if ( lod ) if ( lod )
{ {
@ -258,7 +258,7 @@ void PosterPrinter::frame( const osg::FrameStamp* fs, osg::Node* node )
// and advance frame when all callbacks are dispatched. // and advance frame when all callbacks are dispatched.
if ( addCullCallbacks(fs, node) ) if ( addCullCallbacks(fs, node) )
return; return;
if ( _isFinishing ) if ( _isFinishing )
{ {
if ( (fs->getFrameNumber()-_lastBindingFrame)>2 ) if ( (fs->getFrameNumber()-_lastBindingFrame)>2 )
@ -270,16 +270,16 @@ void PosterPrinter::frame( const osg::FrameStamp* fs, osg::Node* node )
std::cout << "Writing final result to file..." << std::endl; std::cout << "Writing final result to file..." << std::endl;
osgDB::writeImageFile( *_finalPoster, _outputPosterName ); osgDB::writeImageFile( *_finalPoster, _outputPosterName );
} }
// Release all cull callbacks to free unused paged nodes // Release all cull callbacks to free unused paged nodes
removeCullCallbacks( node ); removeCullCallbacks( node );
_visitor->clearNames(); _visitor->clearNames();
_isFinishing = false; _isFinishing = false;
std::cout << "Recording images finished." << std::endl; std::cout << "Recording images finished." << std::endl;
} }
} }
if ( _isRunning ) if ( _isRunning )
{ {
// Every "copy-to-image" process seems to be finished in 2 frames. // Every "copy-to-image" process seems to be finished in 2 frames.
@ -288,11 +288,11 @@ void PosterPrinter::frame( const osg::FrameStamp* fs, osg::Node* node )
{ {
// Record images and unref them to free memory // Record images and unref them to free memory
recordImages(); recordImages();
// Release all cull callbacks to free unused paged nodes // Release all cull callbacks to free unused paged nodes
removeCullCallbacks( node ); removeCullCallbacks( node );
_visitor->clearNames(); _visitor->clearNames();
if ( _camera.valid() ) if ( _camera.valid() )
{ {
std::cout << "Binding sub-camera " << _currentRow << "_" << _currentColumn std::cout << "Binding sub-camera " << _currentRow << "_" << _currentColumn
@ -325,11 +325,11 @@ bool PosterPrinter::addCullCallbacks( const osg::FrameStamp* fs, osg::Node* node
{ {
if ( !_visitor->inQueue() || done() ) if ( !_visitor->inQueue() || done() )
return false; return false;
_visitor->setAddingCallbacks( true ); _visitor->setAddingCallbacks( true );
_camera->accept( *_visitor ); _camera->accept( *_visitor );
_lastBindingFrame = fs->getFrameNumber(); _lastBindingFrame = fs->getFrameNumber();
std::cout << "Dispatching callbacks to paged nodes... " std::cout << "Dispatching callbacks to paged nodes... "
<< _visitor->inQueue() << std::endl; << _visitor->inQueue() << std::endl;
return true; return true;
@ -345,19 +345,19 @@ void PosterPrinter::bindCameraToImage( osg::Camera* camera, int row, int col )
{ {
std::stringstream stream; std::stringstream stream;
stream << "image_" << row << "_" << col; stream << "image_" << row << "_" << col;
osg::ref_ptr<osg::Image> image = new osg::Image; osg::ref_ptr<osg::Image> image = new osg::Image;
image->setName( stream.str() ); image->setName( stream.str() );
image->allocateImage( (int)_tileSize.x(), (int)_tileSize.y(), 1, GL_RGBA, GL_UNSIGNED_BYTE ); image->allocateImage( (int)_tileSize.x(), (int)_tileSize.y(), 1, GL_RGBA, GL_UNSIGNED_BYTE );
_images[TilePosition(row,col)] = image.get(); _images[TilePosition(row,col)] = image.get();
// Calculate projection matrix offset of each tile // Calculate projection matrix offset of each tile
osg::Matrix offsetMatrix = osg::Matrix offsetMatrix =
osg::Matrix::scale(_tileColumns, _tileRows, 1.0) * osg::Matrix::scale(_tileColumns, _tileRows, 1.0) *
osg::Matrix::translate(_tileColumns-1-2*col, _tileRows-1-2*row, 0.0); osg::Matrix::translate(_tileColumns-1-2*col, _tileRows-1-2*row, 0.0);
camera->setViewMatrix( _currentViewMatrix ); camera->setViewMatrix( _currentViewMatrix );
camera->setProjectionMatrix( _currentProjectionMatrix * offsetMatrix ); camera->setProjectionMatrix( _currentProjectionMatrix * offsetMatrix );
// Check intersections between the image-tile box and the model // Check intersections between the image-tile box and the model
osgUtil::IntersectionVisitor iv( _intersector.get() ); osgUtil::IntersectionVisitor iv( _intersector.get() );
iv.setReadCallback( g_pagedLoadingCallback.get() ); iv.setReadCallback( g_pagedLoadingCallback.get() );
@ -368,7 +368,7 @@ void PosterPrinter::bindCameraToImage( osg::Camera* camera, int row, int col )
// Apply a cull calback to every paged node obtained, to force the highest level displaying. // Apply a cull calback to every paged node obtained, to force the highest level displaying.
// This will be done by the PosterVisitor, who already records all the paged nodes. // This will be done by the PosterVisitor, who already records all the paged nodes.
} }
// Reattach cameras and new allocated images // Reattach cameras and new allocated images
camera->setRenderingCache( NULL ); // FIXME: Uses for reattaching camera with image, maybe inefficient? camera->setRenderingCache( NULL ); // FIXME: Uses for reattaching camera with image, maybe inefficient?
camera->detach( osg::Camera::COLOR_BUFFER ); camera->detach( osg::Camera::COLOR_BUFFER );
@ -391,7 +391,7 @@ void PosterPrinter::recordImages()
memcpy( target, source, image->s() * 4 * sizeof(unsigned char) ); memcpy( target, source, image->s() * 4 * sizeof(unsigned char) );
} }
} }
if ( _outputTiles ) if ( _outputTiles )
osgDB::writeImageFile( *image, image->getName()+"."+_outputTileExt ); osgDB::writeImageFile( *image, image->getName()+"."+_outputTileExt );
} }

View File

@ -57,13 +57,13 @@ osg::Group* createHUDText()
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different text layout // Examples of how to set up different text layout
// //
osg::Vec4 layoutColor(1.0f,1.0f,0.0f,1.0f); osg::Vec4 layoutColor(1.0f,1.0f,0.0f,1.0f);
float layoutCharacterSize = 20.0f; float layoutCharacterSize = 20.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setFont(font); text->setFont(font);
@ -107,32 +107,32 @@ osg::Group* createHUDText()
text->setText("text->setLayout(osgText::Text::VERTICAL);"); text->setText("text->setLayout(osgText::Text::VERTICAL);");
geode->addDrawable(text); geode->addDrawable(text);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different font resolution // Examples of how to set up different font resolution
// //
osg::Vec4 fontSizeColor(0.0f,1.0f,1.0f,1.0f); osg::Vec4 fontSizeColor(0.0f,1.0f,1.0f,1.0f);
float fontSizeCharacterSize = 30; float fontSizeCharacterSize = 30;
osg::Vec3 cursor = osg::Vec3(margin*2,windowHeight-margin*2,0.0f); osg::Vec3 cursor = osg::Vec3(margin*2,windowHeight-margin*2,0.0f);
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setFont(font); text->setFont(font);
text->setColor(fontSizeColor); text->setColor(fontSizeColor);
text->setCharacterSize(fontSizeCharacterSize); text->setCharacterSize(fontSizeCharacterSize);
text->setPosition(cursor); text->setPosition(cursor);
// use text that uses 10 by 10 texels as a target resolution for fonts. // use text that uses 10 by 10 texels as a target resolution for fonts.
text->setFontResolution(10,10); // blocky but small texture memory usage text->setFontResolution(10,10); // blocky but small texture memory usage
text->setText("text->setFontResolution(10,10); // blocky but small texture memory usage"); text->setText("text->setFontResolution(10,10); // blocky but small texture memory usage");
geode->addDrawable(text); geode->addDrawable(text);
} }
cursor.y() -= fontSizeCharacterSize; cursor.y() -= fontSizeCharacterSize;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
@ -140,14 +140,14 @@ osg::Group* createHUDText()
text->setColor(fontSizeColor); text->setColor(fontSizeColor);
text->setCharacterSize(fontSizeCharacterSize); text->setCharacterSize(fontSizeCharacterSize);
text->setPosition(cursor); text->setPosition(cursor);
// use text that uses 20 by 20 texels as a target resolution for fonts. // use text that uses 20 by 20 texels as a target resolution for fonts.
text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low). text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low).
text->setText("text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low)."); text->setText("text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low).");
geode->addDrawable(text); geode->addDrawable(text);
} }
cursor.y() -= fontSizeCharacterSize; cursor.y() -= fontSizeCharacterSize;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
@ -155,38 +155,38 @@ osg::Group* createHUDText()
text->setColor(fontSizeColor); text->setColor(fontSizeColor);
text->setCharacterSize(fontSizeCharacterSize); text->setCharacterSize(fontSizeCharacterSize);
text->setPosition(cursor); text->setPosition(cursor);
// use text that uses 40 by 40 texels as a target resolution for fonts. // use text that uses 40 by 40 texels as a target resolution for fonts.
text->setFontResolution(40,40); // even smoother but again higher texture memory usage. text->setFontResolution(40,40); // even smoother but again higher texture memory usage.
text->setText("text->setFontResolution(40,40); // even smoother but again higher texture memory usage."); text->setText("text->setFontResolution(40,40); // even smoother but again higher texture memory usage.");
geode->addDrawable(text); geode->addDrawable(text);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different sized text // Examples of how to set up different sized text
// //
osg::Vec4 characterSizeColor(1.0f,0.0f,1.0f,1.0f); osg::Vec4 characterSizeColor(1.0f,0.0f,1.0f,1.0f);
cursor.y() -= fontSizeCharacterSize*2.0f; cursor.y() -= fontSizeCharacterSize*2.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setFont(font); text->setFont(font);
text->setColor(characterSizeColor); text->setColor(characterSizeColor);
text->setFontResolution(20,20); text->setFontResolution(20,20);
text->setPosition(cursor); text->setPosition(cursor);
// use text that is 20 units high. // use text that is 20 units high.
text->setCharacterSize(20); // small text->setCharacterSize(20); // small
text->setText("text->setCharacterSize(20.0f); // small"); text->setText("text->setCharacterSize(20.0f); // small");
geode->addDrawable(text); geode->addDrawable(text);
} }
cursor.y() -= 30.0f; cursor.y() -= 30.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
@ -194,14 +194,14 @@ osg::Group* createHUDText()
text->setColor(characterSizeColor); text->setColor(characterSizeColor);
text->setFontResolution(30,30); text->setFontResolution(30,30);
text->setPosition(cursor); text->setPosition(cursor);
// use text that is 30 units high. // use text that is 30 units high.
text->setCharacterSize(30.0f); // medium text->setCharacterSize(30.0f); // medium
text->setText("text->setCharacterSize(30.0f); // medium"); text->setText("text->setCharacterSize(30.0f); // medium");
geode->addDrawable(text); geode->addDrawable(text);
} }
cursor.y() -= 50.0f; cursor.y() -= 50.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
@ -209,17 +209,17 @@ osg::Group* createHUDText()
text->setColor(characterSizeColor); text->setColor(characterSizeColor);
text->setFontResolution(40,40); text->setFontResolution(40,40);
text->setPosition(cursor); text->setPosition(cursor);
// use text that is 60 units high. // use text that is 60 units high.
text->setCharacterSize(60.0f); // large text->setCharacterSize(60.0f); // large
text->setText("text->setCharacterSize(60.0f); // large"); text->setText("text->setCharacterSize(60.0f); // large");
geode->addDrawable(text); geode->addDrawable(text);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different alignments // Examples of how to set up different alignments
// //
@ -227,7 +227,7 @@ osg::Group* createHUDText()
float alignmentCharacterSize = 25.0f; float alignmentCharacterSize = 25.0f;
cursor.x() = 640; cursor.x() = 640;
cursor.y() = margin*4.0f; cursor.y() = margin*4.0f;
typedef std::pair<osgText::Text::AlignmentType,std::string> AlignmentPair; typedef std::pair<osgText::Text::AlignmentType,std::string> AlignmentPair;
typedef std::vector<AlignmentPair> AlignmentList; typedef std::vector<AlignmentPair> AlignmentList;
AlignmentList alignmentList; AlignmentList alignmentList;
@ -264,49 +264,49 @@ osg::Group* createHUDText()
text->setCharacterSize(alignmentCharacterSize); text->setCharacterSize(alignmentCharacterSize);
text->setPosition(cursor); text->setPosition(cursor);
text->setDrawMode(osgText::Text::TEXT|osgText::Text::ALIGNMENT|osgText::Text::BOUNDINGBOX); text->setDrawMode(osgText::Text::TEXT|osgText::Text::ALIGNMENT|osgText::Text::BOUNDINGBOX);
text->setAlignment(itr->first); text->setAlignment(itr->first);
text->setText(itr->second); text->setText(itr->second);
alignmentGeode->addDrawable(text); alignmentGeode->addDrawable(text);
} }
} }
sequence->setMode(osg::Sequence::START); sequence->setMode(osg::Sequence::START);
sequence->setInterval(osg::Sequence::LOOP, 0, -1); sequence->setInterval(osg::Sequence::LOOP, 0, -1);
sequence->setDuration(1.0f, -1); sequence->setDuration(1.0f, -1);
rootNode->addChild(sequence); rootNode->addChild(sequence);
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different fonts... // Examples of how to set up different fonts...
// //
cursor.x() = margin*2.0f; cursor.x() = margin*2.0f;
cursor.y() = margin*2.0f; cursor.y() = margin*2.0f;
osg::Vec4 fontColor(1.0f,0.5f,0.0f,1.0f); osg::Vec4 fontColor(1.0f,0.5f,0.0f,1.0f);
float fontCharacterSize = 20.0f; float fontCharacterSize = 20.0f;
float spacing = 40.0f; float spacing = 40.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
text->setFont(0); text->setFont(0);
text->setText("text->setFont(0); // inbuilt font."); text->setText("text->setFont(0); // inbuilt font.");
geode->addDrawable(text); geode->addDrawable(text);
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
{ {
osgText::Font* arial = new osgText::Font(new osgQt::QFontImplementation(QFont("Arial"))); osgText::Font* arial = new osgText::Font(new osgQt::QFontImplementation(QFont("Arial")));
@ -314,16 +314,16 @@ osg::Group* createHUDText()
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
text->setFont(arial); text->setFont(arial);
text->setText(arial!=0? text->setText(arial!=0?
"text->setFont(\"fonts/arial.ttf\");": "text->setFont(\"fonts/arial.ttf\");":
"unable to load \"fonts/arial.ttf\""); "unable to load \"fonts/arial.ttf\"");
geode->addDrawable(text); geode->addDrawable(text);
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
{ {
osgText::Font* times = new osgText::Font(new osgQt::QFontImplementation(QFont("Times"))); osgText::Font* times = new osgText::Font(new osgQt::QFontImplementation(QFont("Times")));
@ -331,16 +331,16 @@ osg::Group* createHUDText()
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
geode->addDrawable(text); geode->addDrawable(text);
text->setFont(times); text->setFont(times);
text->setText(times!=0? text->setText(times!=0?
"text->setFont(\"fonts/times.ttf\");": "text->setFont(\"fonts/times.ttf\");":
"unable to load \"fonts/times.ttf\""); "unable to load \"fonts/times.ttf\"");
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
cursor.x() = margin*2.0f; cursor.x() = margin*2.0f;
cursor.y() = margin; cursor.y() = margin;
@ -351,34 +351,34 @@ osg::Group* createHUDText()
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
text->setFont(dirtydoz); text->setFont(dirtydoz);
text->setText(dirtydoz!=0? text->setText(dirtydoz!=0?
"text->setFont(\"fonts/dirtydoz.ttf\");": "text->setFont(\"fonts/dirtydoz.ttf\");":
"unable to load \"fonts/dirtydoz.ttf\""); "unable to load \"fonts/dirtydoz.ttf\"");
geode->addDrawable(text); geode->addDrawable(text);
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
{ {
osgText::Font* fudd = new osgText::Font(new osgQt::QFontImplementation(QFont("Times"))); osgText::Font* fudd = new osgText::Font(new osgQt::QFontImplementation(QFont("Times")));
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
text->setFont(fudd); text->setFont(fudd);
text->setText(fudd!=0? text->setText(fudd!=0?
"text->setFont(\"fonts/fudd.ttf\");": "text->setFont(\"fonts/fudd.ttf\");":
"unable to load \"fonts/fudd.ttf\""); "unable to load \"fonts/fudd.ttf\"");
geode->addDrawable(text); geode->addDrawable(text);
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
return rootNode; return rootNode;
} }
@ -391,12 +391,12 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
osg::Geode* geode = new osg::Geode; osg::Geode* geode = new osg::Geode;
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up axis/orientation alignments // Examples of how to set up axis/orientation alignments
// //
float characterSize=radius*0.2f; float characterSize=radius*0.2f;
osg::Vec3 pos(center.x()-radius*.5f,center.y()-radius*.5f,center.z()-radius*.5f); osg::Vec3 pos(center.x()-radius*.5f,center.y()-radius*.5f,center.z()-radius*.5f);
osgText::Text* text1 = new osgText::Text; osgText::Text* text1 = new osgText::Text;
@ -479,7 +479,7 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
osg::Group* rootNode = new osg::Group; osg::Group* rootNode = new osg::Group;
rootNode->addChild(geode); rootNode->addChild(geode);
return rootNode; return rootNode;
} }
class MainWindow : public QWidget { class MainWindow : public QWidget {
@ -535,7 +535,7 @@ int main(int argc, char** argv)
// prepare scene. // prepare scene.
osg::Vec3 center(0.0f,0.0f,0.0f); osg::Vec3 center(0.0f,0.0f,0.0f);
float radius = 1.0f; float radius = 1.0f;
// create the hud. // create the hud.
osg::ref_ptr<osg::Camera> camera = new osg::Camera; osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
@ -544,7 +544,7 @@ int main(int argc, char** argv)
camera->setClearMask(GL_DEPTH_BUFFER_BIT); camera->setClearMask(GL_DEPTH_BUFFER_BIT);
camera->addChild(createHUDText()); camera->addChild(createHUDText());
camera->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); camera->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
// make sure the root node is group so we can add extra nodes to it. // make sure the root node is group so we can add extra nodes to it.
osg::ref_ptr<osg::Group> group = new osg::Group; osg::ref_ptr<osg::Group> group = new osg::Group;
group->addChild(camera.get()); group->addChild(camera.get());
@ -552,7 +552,7 @@ int main(int argc, char** argv)
// The qt window // The qt window
MainWindow widget; MainWindow widget;
// set the scene to render // set the scene to render
widget.setSceneData(group.get()); widget.setSceneData(group.get());
widget.setCameraManipulator(new osgGA::TrackballManipulator); widget.setCameraManipulator(new osgGA::TrackballManipulator);

View File

@ -53,13 +53,13 @@ osg::Group* createHUDText()
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different text layout // Examples of how to set up different text layout
// //
osg::Vec4 layoutColor(1.0f,1.0f,0.0f,1.0f); osg::Vec4 layoutColor(1.0f,1.0f,0.0f,1.0f);
float layoutCharacterSize = 20.0f; float layoutCharacterSize = 20.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setFont(font); text->setFont(font);
@ -103,32 +103,32 @@ osg::Group* createHUDText()
text->setText("text->setLayout(osgText::Text::VERTICAL);"); text->setText("text->setLayout(osgText::Text::VERTICAL);");
geode->addDrawable(text); geode->addDrawable(text);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different font resolution // Examples of how to set up different font resolution
// //
osg::Vec4 fontSizeColor(0.0f,1.0f,1.0f,1.0f); osg::Vec4 fontSizeColor(0.0f,1.0f,1.0f,1.0f);
float fontSizeCharacterSize = 30; float fontSizeCharacterSize = 30;
osg::Vec3 cursor = osg::Vec3(margin*2,windowHeight-margin*2,0.0f); osg::Vec3 cursor = osg::Vec3(margin*2,windowHeight-margin*2,0.0f);
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setFont(font); text->setFont(font);
text->setColor(fontSizeColor); text->setColor(fontSizeColor);
text->setCharacterSize(fontSizeCharacterSize); text->setCharacterSize(fontSizeCharacterSize);
text->setPosition(cursor); text->setPosition(cursor);
// use text that uses 10 by 10 texels as a target resolution for fonts. // use text that uses 10 by 10 texels as a target resolution for fonts.
text->setFontResolution(10,10); // blocky but small texture memory usage text->setFontResolution(10,10); // blocky but small texture memory usage
text->setText("text->setFontResolution(10,10); // blocky but small texture memory usage"); text->setText("text->setFontResolution(10,10); // blocky but small texture memory usage");
geode->addDrawable(text); geode->addDrawable(text);
} }
cursor.y() -= fontSizeCharacterSize; cursor.y() -= fontSizeCharacterSize;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
@ -136,14 +136,14 @@ osg::Group* createHUDText()
text->setColor(fontSizeColor); text->setColor(fontSizeColor);
text->setCharacterSize(fontSizeCharacterSize); text->setCharacterSize(fontSizeCharacterSize);
text->setPosition(cursor); text->setPosition(cursor);
// use text that uses 20 by 20 texels as a target resolution for fonts. // use text that uses 20 by 20 texels as a target resolution for fonts.
text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low). text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low).
text->setText("text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low)."); text->setText("text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low).");
geode->addDrawable(text); geode->addDrawable(text);
} }
cursor.y() -= fontSizeCharacterSize; cursor.y() -= fontSizeCharacterSize;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
@ -151,38 +151,38 @@ osg::Group* createHUDText()
text->setColor(fontSizeColor); text->setColor(fontSizeColor);
text->setCharacterSize(fontSizeCharacterSize); text->setCharacterSize(fontSizeCharacterSize);
text->setPosition(cursor); text->setPosition(cursor);
// use text that uses 40 by 40 texels as a target resolution for fonts. // use text that uses 40 by 40 texels as a target resolution for fonts.
text->setFontResolution(40,40); // even smoother but again higher texture memory usage. text->setFontResolution(40,40); // even smoother but again higher texture memory usage.
text->setText("text->setFontResolution(40,40); // even smoother but again higher texture memory usage."); text->setText("text->setFontResolution(40,40); // even smoother but again higher texture memory usage.");
geode->addDrawable(text); geode->addDrawable(text);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different sized text // Examples of how to set up different sized text
// //
osg::Vec4 characterSizeColor(1.0f,0.0f,1.0f,1.0f); osg::Vec4 characterSizeColor(1.0f,0.0f,1.0f,1.0f);
cursor.y() -= fontSizeCharacterSize*2.0f; cursor.y() -= fontSizeCharacterSize*2.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setFont(font); text->setFont(font);
text->setColor(characterSizeColor); text->setColor(characterSizeColor);
text->setFontResolution(20,20); text->setFontResolution(20,20);
text->setPosition(cursor); text->setPosition(cursor);
// use text that is 20 units high. // use text that is 20 units high.
text->setCharacterSize(20); // small text->setCharacterSize(20); // small
text->setText("text->setCharacterSize(20.0f); // small"); text->setText("text->setCharacterSize(20.0f); // small");
geode->addDrawable(text); geode->addDrawable(text);
} }
cursor.y() -= 30.0f; cursor.y() -= 30.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
@ -190,14 +190,14 @@ osg::Group* createHUDText()
text->setColor(characterSizeColor); text->setColor(characterSizeColor);
text->setFontResolution(30,30); text->setFontResolution(30,30);
text->setPosition(cursor); text->setPosition(cursor);
// use text that is 30 units high. // use text that is 30 units high.
text->setCharacterSize(30.0f); // medium text->setCharacterSize(30.0f); // medium
text->setText("text->setCharacterSize(30.0f); // medium"); text->setText("text->setCharacterSize(30.0f); // medium");
geode->addDrawable(text); geode->addDrawable(text);
} }
cursor.y() -= 50.0f; cursor.y() -= 50.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
@ -205,17 +205,17 @@ osg::Group* createHUDText()
text->setColor(characterSizeColor); text->setColor(characterSizeColor);
text->setFontResolution(40,40); text->setFontResolution(40,40);
text->setPosition(cursor); text->setPosition(cursor);
// use text that is 60 units high. // use text that is 60 units high.
text->setCharacterSize(60.0f); // large text->setCharacterSize(60.0f); // large
text->setText("text->setCharacterSize(60.0f); // large"); text->setText("text->setCharacterSize(60.0f); // large");
geode->addDrawable(text); geode->addDrawable(text);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different alignments // Examples of how to set up different alignments
// //
@ -223,7 +223,7 @@ osg::Group* createHUDText()
float alignmentCharacterSize = 25.0f; float alignmentCharacterSize = 25.0f;
cursor.x() = 640; cursor.x() = 640;
cursor.y() = margin*4.0f; cursor.y() = margin*4.0f;
typedef std::pair<osgText::Text::AlignmentType,std::string> AlignmentPair; typedef std::pair<osgText::Text::AlignmentType,std::string> AlignmentPair;
typedef std::vector<AlignmentPair> AlignmentList; typedef std::vector<AlignmentPair> AlignmentList;
AlignmentList alignmentList; AlignmentList alignmentList;
@ -260,49 +260,49 @@ osg::Group* createHUDText()
text->setCharacterSize(alignmentCharacterSize); text->setCharacterSize(alignmentCharacterSize);
text->setPosition(cursor); text->setPosition(cursor);
text->setDrawMode(osgText::Text::TEXT|osgText::Text::ALIGNMENT|osgText::Text::BOUNDINGBOX); text->setDrawMode(osgText::Text::TEXT|osgText::Text::ALIGNMENT|osgText::Text::BOUNDINGBOX);
text->setAlignment(itr->first); text->setAlignment(itr->first);
text->setText(itr->second); text->setText(itr->second);
alignmentGeode->addDrawable(text); alignmentGeode->addDrawable(text);
} }
} }
sequence->setMode(osg::Sequence::START); sequence->setMode(osg::Sequence::START);
sequence->setInterval(osg::Sequence::LOOP, 0, -1); sequence->setInterval(osg::Sequence::LOOP, 0, -1);
sequence->setDuration(1.0f, -1); sequence->setDuration(1.0f, -1);
rootNode->addChild(sequence); rootNode->addChild(sequence);
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up different fonts... // Examples of how to set up different fonts...
// //
cursor.x() = margin*2.0f; cursor.x() = margin*2.0f;
cursor.y() = margin*2.0f; cursor.y() = margin*2.0f;
osg::Vec4 fontColor(1.0f,0.5f,0.0f,1.0f); osg::Vec4 fontColor(1.0f,0.5f,0.0f,1.0f);
float fontCharacterSize = 20.0f; float fontCharacterSize = 20.0f;
float spacing = 40.0f; float spacing = 40.0f;
{ {
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
text->setFont(0); text->setFont(0);
text->setText("text->setFont(0); // inbuilt font."); text->setText("text->setFont(0); // inbuilt font.");
geode->addDrawable(text); geode->addDrawable(text);
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
{ {
osgText::Font* arial = osgText::readFontFile("fonts/arial.ttf"); osgText::Font* arial = osgText::readFontFile("fonts/arial.ttf");
@ -310,16 +310,16 @@ osg::Group* createHUDText()
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
text->setFont(arial); text->setFont(arial);
text->setText(arial!=0? text->setText(arial!=0?
"text->setFont(\"fonts/arial.ttf\");": "text->setFont(\"fonts/arial.ttf\");":
"unable to load \"fonts/arial.ttf\""); "unable to load \"fonts/arial.ttf\"");
geode->addDrawable(text); geode->addDrawable(text);
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
{ {
osgText::Font* times = osgText::readFontFile("fonts/times.ttf"); osgText::Font* times = osgText::readFontFile("fonts/times.ttf");
@ -327,16 +327,16 @@ osg::Group* createHUDText()
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
geode->addDrawable(text); geode->addDrawable(text);
text->setFont(times); text->setFont(times);
text->setText(times!=0? text->setText(times!=0?
"text->setFont(\"fonts/times.ttf\");": "text->setFont(\"fonts/times.ttf\");":
"unable to load \"fonts/times.ttf\""); "unable to load \"fonts/times.ttf\"");
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
cursor.x() = margin*2.0f; cursor.x() = margin*2.0f;
cursor.y() = margin; cursor.y() = margin;
@ -347,34 +347,34 @@ osg::Group* createHUDText()
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
text->setFont(dirtydoz); text->setFont(dirtydoz);
text->setText(dirtydoz!=0? text->setText(dirtydoz!=0?
"text->setFont(\"fonts/dirtydoz.ttf\");": "text->setFont(\"fonts/dirtydoz.ttf\");":
"unable to load \"fonts/dirtydoz.ttf\""); "unable to load \"fonts/dirtydoz.ttf\"");
geode->addDrawable(text); geode->addDrawable(text);
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
{ {
osgText::Font* fudd = osgText::readFontFile("fonts/fudd.ttf"); osgText::Font* fudd = osgText::readFontFile("fonts/fudd.ttf");
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setColor(fontColor); text->setColor(fontColor);
text->setPosition(cursor); text->setPosition(cursor);
text->setCharacterSize(fontCharacterSize); text->setCharacterSize(fontCharacterSize);
text->setFont(fudd); text->setFont(fudd);
text->setText(fudd!=0? text->setText(fudd!=0?
"text->setFont(\"fonts/fudd.ttf\");": "text->setFont(\"fonts/fudd.ttf\");":
"unable to load \"fonts/fudd.ttf\""); "unable to load \"fonts/fudd.ttf\"");
geode->addDrawable(text); geode->addDrawable(text);
cursor.x() = text->getBound().xMax() + spacing ; cursor.x() = text->getBoundingBox().xMax() + spacing ;
} }
return rootNode; return rootNode;
} }
@ -386,9 +386,9 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
osg::Geode* geode = new osg::Geode; osg::Geode* geode = new osg::Geode;
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up axis/orientation alignments // Examples of how to set up axis/orientation alignments
// //
@ -477,14 +477,14 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
osg::Group* rootNode = new osg::Group; osg::Group* rootNode = new osg::Group;
rootNode->addChild(geode); rootNode->addChild(geode);
return rootNode; return rootNode;
} }
class UpdateTextOperation : public osg::Operation class UpdateTextOperation : public osg::Operation
{ {
public: public:
UpdateTextOperation(const osg::Vec3& center, float diameter, osg::Group* group): UpdateTextOperation(const osg::Vec3& center, float diameter, osg::Group* group):
Operation("UpdateTextOperation", true), Operation("UpdateTextOperation", true),
_center(center), _center(center),
_diameter(diameter), _diameter(diameter),
@ -502,13 +502,13 @@ public:
if (viewer) update(); if (viewer) update();
else load(); else load();
} }
void update() void update()
{ {
// osg::notify(osg::NOTICE)<<"*** Doing update"<<std::endl; // osg::notify(osg::NOTICE)<<"*** Doing update"<<std::endl;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (_mergeSubgraph.valid()) if (_mergeSubgraph.valid())
{ {
_group->addChild(_mergeSubgraph.get()); _group->addChild(_mergeSubgraph.get());
@ -525,14 +525,14 @@ public:
} }
_group->removeChild(0,1); _group->removeChild(0,1);
} }
_waitOnMergeBlock.release(); _waitOnMergeBlock.release();
} }
} }
void load() void load()
{ {
// osg::notify(osg::NOTICE)<<"Doing load"<<std::endl; // osg::notify(osg::NOTICE)<<"Doing load"<<std::endl;
osg::ref_ptr<osg::Geode> geode; osg::ref_ptr<osg::Geode> geode;
@ -544,7 +544,7 @@ public:
_availableSubgraph.pop_front(); _availableSubgraph.pop_front();
} }
} }
if (!geode) geode = new osg::Geode; if (!geode) geode = new osg::Geode;
for(unsigned int i=0; i<_maxNumTextPerGeode; ++i) for(unsigned int i=0; i<_maxNumTextPerGeode; ++i)
@ -560,7 +560,7 @@ public:
{ {
str.push_back(char(32.0 + (float(rand())/float(RAND_MAX))*128.0f)); str.push_back(char(32.0 + (float(rand())/float(RAND_MAX))*128.0f));
} }
osgText::Text* text = new osgText::Text; osgText::Text* text = new osgText::Text;
text->setDataVariance(osg::Object::DYNAMIC); text->setDataVariance(osg::Object::DYNAMIC);
text->setPosition(_center + position * _diameter); text->setPosition(_center + position * _diameter);
@ -568,22 +568,22 @@ public:
text->setText(str); text->setText(str);
text->setCharacterSize(0.025f * _diameter); text->setCharacterSize(0.025f * _diameter);
text->setAxisAlignment(osgText::Text::SCREEN); text->setAxisAlignment(osgText::Text::SCREEN);
geode->addDrawable(text); geode->addDrawable(text);
} }
{ {
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
_mergeSubgraph = geode; _mergeSubgraph = geode;
} }
// osg::notify(osg::NOTICE)<<"Waiting on merge"<<std::endl; // osg::notify(osg::NOTICE)<<"Waiting on merge"<<std::endl;
_waitOnMergeBlock.block(); _waitOnMergeBlock.block();
} }
virtual void release() virtual void release()
{ {
_waitOnMergeBlock.release(); _waitOnMergeBlock.release();
@ -595,13 +595,13 @@ public:
float _diameter; float _diameter;
unsigned int _maxNumChildren; unsigned int _maxNumChildren;
unsigned int _maxNumTextPerGeode; unsigned int _maxNumTextPerGeode;
OpenThreads::Mutex _mutex; OpenThreads::Mutex _mutex;
osg::ref_ptr<osg::Group> _group; osg::ref_ptr<osg::Group> _group;
osg::ref_ptr<osg::Geode> _mergeSubgraph; osg::ref_ptr<osg::Geode> _mergeSubgraph;
AvailableList _availableSubgraph; AvailableList _availableSubgraph;
OpenThreads::Block _waitOnMergeBlock; OpenThreads::Block _waitOnMergeBlock;
unsigned int _counter; unsigned int _counter;
}; };
@ -613,7 +613,7 @@ int main(int argc, char** argv)
// construct the viewer. // construct the viewer.
osgViewer::Viewer viewer(arguments); osgViewer::Viewer viewer(arguments);
typedef std::list< osg::ref_ptr<osg::OperationThread> > Threads; typedef std::list< osg::ref_ptr<osg::OperationThread> > Threads;
Threads operationThreads; Threads operationThreads;
@ -624,22 +624,22 @@ int main(int argc, char** argv)
{ {
// construct a multi-threaded text updating test. // construct a multi-threaded text updating test.
if (numThreads==0) numThreads = 1; if (numThreads==0) numThreads = 1;
// create a group to add everything into. // create a group to add everything into.
osg::Group* mainGroup = new osg::Group; osg::Group* mainGroup = new osg::Group;
osg::Vec3 center(0.5f,0.5f,0.5f); osg::Vec3 center(0.5f,0.5f,0.5f);
float diameter = 1.0f; float diameter = 1.0f;
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (loadedModel.valid()) if (loadedModel.valid())
{ {
mainGroup->addChild(loadedModel.get()); mainGroup->addChild(loadedModel.get());
center = loadedModel->getBound().center(); center = loadedModel->getBound().center();
diameter = loadedModel->getBound().radius() * 2.0f; diameter = loadedModel->getBound().radius() * 2.0f;
} }
for(unsigned int i=0; i<numThreads; ++i) for(unsigned int i=0; i<numThreads; ++i)
{ {
osg::Group* textGroup = new osg::Group; osg::Group* textGroup = new osg::Group;
@ -647,7 +647,7 @@ int main(int argc, char** argv)
// create the background thread // create the background thread
osg::OperationThread* operationThread = new osg::OperationThread; osg::OperationThread* operationThread = new osg::OperationThread;
operationThreads.push_back(operationThread); operationThreads.push_back(operationThread);
// create the operation that will run in the background and // create the operation that will run in the background and
@ -669,15 +669,15 @@ int main(int argc, char** argv)
mainGroup->addChild(geode); mainGroup->addChild(geode);
} }
viewer.setSceneData(mainGroup); viewer.setSceneData(mainGroup);
} }
else else
{ {
// prepare scene. // prepare scene.
osg::Vec3 center(0.0f,0.0f,0.0f); osg::Vec3 center(0.0f,0.0f,0.0f);
float radius = 1.0f; float radius = 1.0f;
// make sure the root node is group so we can add extra nodes to it. // make sure the root node is group so we can add extra nodes to it.
osg::Group* group = new osg::Group; osg::Group* group = new osg::Group;
@ -715,7 +715,7 @@ int main(int argc, char** argv)
viewer.addEventHandler(new osgViewer::StatsHandler()); viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.run(); viewer.run();
if (!operationThreads.empty()) if (!operationThreads.empty())
{ {
for(Threads::iterator itr = operationThreads.begin(); for(Threads::iterator itr = operationThreads.begin();

View File

@ -271,12 +271,13 @@ class OSG_EXPORT CullingSet : public Referenced
return false; return false;
} }
#ifdef OSG_USE_BOUND
inline bool isCulled(const Bound& bound) inline bool isCulled(const Bound& bound)
{ {
if (bound.bb) return isCulled(*bound.bb); if (bound.bb) return isCulled(*bound.bb);
else return isCulled(*bound.bs); else return isCulled(*bound.bs);
} }
#endif
inline void pushCurrentMask() inline void pushCurrentMask()
{ {
_frustum.pushCurrentMask(); _frustum.pushCurrentMask();

View File

@ -128,6 +128,20 @@ class OSG_EXPORT Drawable : public Node
/** Set the initial bounding volume to use when computing the overall bounding volume.*/ /** Set the initial bounding volume to use when computing the overall bounding volume.*/
const BoundingBox& getInitialBound() const { return _initialBound; } const BoundingBox& getInitialBound() const { return _initialBound; }
#ifdef OSG_USE_BOUND
virtual Bound getBound() const
{
if(!_boundingSphereComputed) getBoundingBox();
return Bound(_boundingSphere, _boundingBox);
}
#else
inline const BoundingSphere& getBound() const
{
if(!_boundingSphereComputed) getBoundingBox();
return _boundingSphere;
}
#endif
/** Get BoundingBox of Drawable. /** Get BoundingBox of Drawable.
* If the BoundingBox is not up to date then its updated via an internal call to computeBond(). * If the BoundingBox is not up to date then its updated via an internal call to computeBond().
*/ */

View File

@ -437,7 +437,7 @@ class OSG_EXPORT Node : public Object
/** Get the bounding sphere of node. /** Get the bounding sphere of node.
Using lazy evaluation computes the bounding sphere if it is 'dirty'.*/ Using lazy evaluation computes the bounding sphere if it is 'dirty'.*/
#ifdef OSG_USE_BOUND #ifdef OSG_USE_BOUND
inline Bound getBound() const virtual Bound getBound() const
{ {
if(!_boundingSphereComputed) if(!_boundingSphereComputed)
{ {
@ -452,7 +452,7 @@ class OSG_EXPORT Node : public Object
return Bound(_boundingSphere); return Bound(_boundingSphere);
} }
#else #else
inline BoundingSphere getBound() const inline const BoundingSphere& getBound() const
{ {
if(!_boundingSphereComputed) if(!_boundingSphereComputed)
{ {

View File

@ -317,7 +317,7 @@ BoundingSphere Billboard::computeBound() const
for( i = 0; i < ngsets; i++ ) for( i = 0; i < ngsets; i++ )
{ {
const Drawable *gset = _drawables[i].get(); const Drawable *gset = _drawables[i].get();
const BoundingBox& bbox = gset->getBound(); const BoundingBox& bbox = gset->getBoundingBox();
bsphere._center += bbox.center(); bsphere._center += bbox.center();
bsphere._center += _positionList[i]; bsphere._center += _positionList[i];
@ -329,7 +329,7 @@ BoundingSphere Billboard::computeBound() const
for( i = 0; i < ngsets; ++i ) for( i = 0; i < ngsets; ++i )
{ {
const Drawable *gset = _drawables[i].get(); const Drawable *gset = _drawables[i].get();
const BoundingBox& bbox = gset->getBound(); const BoundingBox& bbox = gset->getBoundingBox();
Vec3 local_center = bsphere._center-_positionList[i]; Vec3 local_center = bsphere._center-_positionList[i];
for(unsigned int c=0;c<8;++c) for(unsigned int c=0;c<8;++c)
{ {

View File

@ -77,7 +77,7 @@ void ComputeBoundsVisitor::apply(osg::Geode& geode)
void ComputeBoundsVisitor::applyDrawable(osg::Drawable* drawable) void ComputeBoundsVisitor::applyDrawable(osg::Drawable* drawable)
{ {
applyBoundingBox(drawable->getBound()); applyBoundingBox(drawable->getBoundingBox());
} }
void ComputeBoundsVisitor::applyBoundingBox(const osg::BoundingBox& bbox) void ComputeBoundsVisitor::applyBoundingBox(const osg::BoundingBox& bbox)

View File

@ -65,7 +65,7 @@ bool Geode::addDrawable( Drawable *drawable )
// fallback for handling geometry with deprecated data // fallback for handling geometry with deprecated data
osg::Geometry* geometry = drawable->asGeometry(); osg::Geometry* geometry = drawable->asGeometry();
if (geometry && geometry->containsDeprecatedData()) geometry->fixDeprecatedData(); if (geometry && geometry->containsDeprecatedData()) geometry->fixDeprecatedData();
// note ref_ptr<> automatically handles incrementing drawable's reference count. // note ref_ptr<> automatically handles incrementing drawable's reference count.
_drawables.push_back(drawable); _drawables.push_back(drawable);
@ -204,7 +204,7 @@ BoundingSphere Geode::computeBound() const
itr!=_drawables.end(); itr!=_drawables.end();
++itr) ++itr)
{ {
_bbox.expandBy((*itr)->getBound()); _bbox.expandBy((*itr)->getBoundingBox());
} }
if (_bbox.valid()) if (_bbox.valid())

View File

@ -369,7 +369,8 @@ BoundingSphere Group::computeBound() const
const osg::Transform* transform = (*itr)->asTransform(); const osg::Transform* transform = (*itr)->asTransform();
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
{ {
bb.expandBy((*itr)->getBound()); const osg::BoundingSphere& bs = (*itr)->getBound();
bb.expandBy(bs);
} }
} }

View File

@ -110,7 +110,7 @@ bool BuildKdTree::build(KdTree::BuildOptions& options, osg::Geometry* geometry)
if (vertices->size() <= options._targetNumTrianglesPerLeaf) return false; if (vertices->size() <= options._targetNumTrianglesPerLeaf) return false;
_bb = geometry->getBound(); _bb = geometry->getBoundingBox();
_kdTree.setVertices(vertices); _kdTree.setVertices(vertices);
unsigned int estimatedSize = (unsigned int)(2.0*float(vertices->size())/float(options._targetNumTrianglesPerLeaf)); unsigned int estimatedSize = (unsigned int)(2.0*float(vertices->size())/float(options._targetNumTrianglesPerLeaf));

View File

@ -196,7 +196,10 @@ BoundingSphere Switch::computeBound() const
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
{ {
if( _values[pos] == true ) if( _values[pos] == true )
bb.expandBy(_children[pos]->getBound()); {
const osg::BoundingSphere& bs = _children[pos]->getBound();
bb.expandBy(bs);
}
} }
} }
@ -213,7 +216,10 @@ BoundingSphere Switch::computeBound() const
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
{ {
if( _values[pos] == true ) if( _values[pos] == true )
bsphere.expandRadiusBy(static_cast<const BoundingSphere&>(_children[pos]->getBound())); {
const osg::BoundingSphere& bs = _children[pos]->getBound();
bsphere.expandRadiusBy(bs);
}
} }
} }
return bsphere; return bsphere;

View File

@ -654,7 +654,7 @@ protected:
{ {
for (unsigned int i=0; i<billboard->getNumDrawables(); ++i) for (unsigned int i=0; i<billboard->getNumDrawables(); ++i)
{ {
osg::BoundingBox bb = billboard->getDrawable(i)->getBound(); const osg::BoundingBox& bb = billboard->getDrawable(i)->getBoundingBox();
billboard->setPosition(i,bb.center()); billboard->setPosition(i,bb.center());
osgUtil::TransformAttributeFunctor tf(osg::Matrix::translate(-bb.center())); osgUtil::TransformAttributeFunctor tf(osg::Matrix::translate(-bb.center()));
@ -1168,7 +1168,7 @@ protected:
{ {
for (unsigned int i=0; i<billboard->getNumDrawables(); ++i) for (unsigned int i=0; i<billboard->getNumDrawables(); ++i)
{ {
osg::BoundingBox bb = billboard->getDrawable(i)->getBound(); const osg::BoundingBox& bb = billboard->getDrawable(i)->getBoundingBox();
billboard->setPosition(i,bb.center()); billboard->setPosition(i,bb.center());
osgUtil::TransformAttributeFunctor tf(osg::Matrix::translate(-bb.center())); osgUtil::TransformAttributeFunctor tf(osg::Matrix::translate(-bb.center()));

View File

@ -4,7 +4,7 @@ WriterCompareTriangle::WriterCompareTriangle(const osg::Geode& geode,
unsigned int nbVertices) unsigned int nbVertices)
: geode(geode) : geode(geode)
{ {
cutscene(nbVertices, geode.getDrawable(0)->asGeometry()->getBound()); cutscene(nbVertices, geode.getDrawable(0)->asGeometry()->getBoundingBox());
} }
bool bool

View File

@ -1074,7 +1074,7 @@ void* labelRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
{ {
osg::Group* group = new osg::Group; osg::Group* group = new osg::Group;
osg::BoundingBox box = text->getBound(); const osg::BoundingBox& box = text->getBoundingBox();
float shift = box.radius()+1.f; float shift = box.radius()+1.f;
// front // front
@ -1518,8 +1518,8 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
case trpgBillboard::Individual: case trpgBillboard::Individual:
{ {
// compute center of billboard geometry // compute center of billboard geometry
const osg::BoundingBox& bbox = geometry->getBound(); const osg::BoundingBox& bbox = geometry->getBoundingBox();
osg::Vec3 center ((bbox._min + bbox._max) * 0.5f); osg::Vec3 center (bbox.center());
// make billboard geometry coordinates relative to computed center // make billboard geometry coordinates relative to computed center
osg::Matrix matrix; osg::Matrix matrix;

View File

@ -80,7 +80,7 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
cloned_ea->setTouchData(NULL); cloned_ea->setTouchData(NULL);
// reproject mouse-coord // reproject mouse-coord
const osg::BoundingBox bb(hitr->drawable->getBound()); const osg::BoundingBox bb(hitr->drawable->getBoundingBox());
const osg::Vec3& p(hitr->localIntersectionPoint); const osg::Vec3& p(hitr->localIntersectionPoint);
float transformed_x = (p.x() - bb.xMin()) / (bb.xMax() - bb.xMin()); float transformed_x = (p.x() - bb.xMin()) / (bb.xMax() - bb.xMin());
@ -106,7 +106,7 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
// reproject touch-points // reproject touch-points
const osg::BoundingBox bb(hitr->drawable->getBound()); const osg::BoundingBox bb(hitr->drawable->getBoundingBox());
osg::Camera* camera = viewer->getCamera(); osg::Camera* camera = viewer->getCamera();
osg::Matrix matrix = osg::computeLocalToWorld(hitr->nodePath, false) * camera->getViewMatrix() * camera->getProjectionMatrix(); osg::Matrix matrix = osg::computeLocalToWorld(hitr->nodePath, false) * camera->getViewMatrix() * camera->getProjectionMatrix();

View File

@ -833,7 +833,7 @@ void SlideShowConstructor::addBullet(const std::string& bullet, PositionData& po
text->setText(bullet); text->setText(bullet);
osg::BoundingBox bb = text->getBound(); const osg::BoundingBox& bb = text->getBoundingBox();
// note, this increment is only "correct" when text is on the plane of the slide.. // note, this increment is only "correct" when text is on the plane of the slide..
// will need to make this more general later. // will need to make this more general later.
@ -882,7 +882,7 @@ void SlideShowConstructor::addParagraph(const std::string& paragraph, PositionDa
} }
text->setText(paragraph); text->setText(paragraph);
osg::BoundingBox bb = text->getBound(); const osg::BoundingBox& bb = text->getBoundingBox();
// note, this increment is only "correct" when text is on the plane of the slide.. // note, this increment is only "correct" when text is on the plane of the slide..
// will need to make this more general later. // will need to make this more general later.

View File

@ -264,7 +264,7 @@ osg::BoundingBox MinimalCullBoundsShadowMap::ViewData::ComputeRenderLeavesBounds
// Stay as long as possible in model space to minimize matrix ops // Stay as long as possible in model space to minimize matrix ops
if( rl && rl->_modelview == modelview && rl->_projection == projection ){ if( rl && rl->_modelview == modelview && rl->_projection == projection ){
bb.expandBy( rl->_drawable->getBound() ); bb.expandBy( rl->_drawable->getBoundingBox() );
} else { } else {
if( bb.valid() ) { if( bb.valid() ) {
// Conditions to avoid matrix multiplications // Conditions to avoid matrix multiplications
@ -292,7 +292,7 @@ osg::BoundingBox MinimalCullBoundsShadowMap::ViewData::ComputeRenderLeavesBounds
bbResult.expandBy( bb.corner( i ) * *ptrModelToWorld ); bbResult.expandBy( bb.corner( i ) * *ptrModelToWorld );
} }
if( !rl ) break; if( !rl ) break;
bb = rl->_drawable->getBound(); bb = rl->_drawable->getBoundingBox();
modelview = rl->_modelview; modelview = rl->_modelview;
projection = rl->_projection; projection = rl->_projection;
} }
@ -331,7 +331,7 @@ osg::BoundingBox MinimalCullBoundsShadowMap::ViewData::ComputeRenderLeavesBounds
if(rl->_modelview == NULL ) if(rl->_modelview == NULL )
rl->_drawable->dirtyBound(); rl->_drawable->dirtyBound();
bb = rl->_drawable->getBound(); bb = rl->_drawable->getBoundingBox();
if( !bb.valid() ) continue; if( !bb.valid() ) continue;
// Stay as long as possible in model space to minimize matrix ops // Stay as long as possible in model space to minimize matrix ops

View File

@ -285,7 +285,7 @@ public:
{ {
if (node.getDrawable(i)) if (node.getDrawable(i))
{ {
updateBound(node.getDrawable(i)->getBound()); updateBound(node.getDrawable(i)->getBoundingBox());
} }
} }
@ -1870,7 +1870,7 @@ struct RenderLeafBounds
// OSG_INFO<<"Reusing light_mvp "<<light_mvp<<std::endl; // OSG_INFO<<"Reusing light_mvp "<<light_mvp<<std::endl;
} }
const osg::BoundingBox& bb = renderLeaf->_drawable->getBound(); const osg::BoundingBox& bb = renderLeaf->_drawable->getBoundingBox();
if (bb.valid()) if (bb.valid())
{ {
// OSG_NOTICE<<"checked extents of "<<renderLeaf->_drawable->getName()<<std::endl; // OSG_NOTICE<<"checked extents of "<<renderLeaf->_drawable->getName()<<std::endl;

View File

@ -738,7 +738,7 @@ bool CullVisitor::updateCalculatedNearFar(const osg::Matrix& matrix,const osg::B
bool CullVisitor::updateCalculatedNearFar(const osg::Matrix& matrix,const osg::Drawable& drawable, bool isBillboard) bool CullVisitor::updateCalculatedNearFar(const osg::Matrix& matrix,const osg::Drawable& drawable, bool isBillboard)
{ {
const osg::BoundingBox& bb = drawable.getBound(); const osg::BoundingBox& bb = drawable.getBoundingBox();
value_type d_near, d_far; value_type d_near, d_far;
@ -981,7 +981,7 @@ void CullVisitor::apply(osg::Drawable& drawable)
{ {
RefMatrix& matrix = *getModelViewMatrix(); RefMatrix& matrix = *getModelViewMatrix();
const BoundingBox &bb =drawable.getBound(); const BoundingBox &bb =drawable.getBoundingBox();
if( drawable.getCullCallback() ) if( drawable.getCullCallback() )
{ {
@ -1085,7 +1085,7 @@ void CullVisitor::apply(Billboard& node)
node.computeMatrix(*billboard_matrix,eye_local,pos); node.computeMatrix(*billboard_matrix,eye_local,pos);
if (_computeNearFar && drawable->getBound().valid()) updateCalculatedNearFar(*billboard_matrix,*drawable,true); if (_computeNearFar && drawable->getBoundingBox().valid()) updateCalculatedNearFar(*billboard_matrix,*drawable,true);
float depth = distance(pos,modelview); float depth = distance(pos,modelview);
/* /*
if (_computeNearFar) if (_computeNearFar)

View File

@ -590,7 +590,7 @@ bool IntersectVisitor::intersect(Drawable& drawable)
IntersectState* cis = _intersectStateStack.back().get(); IntersectState* cis = _intersectStateStack.back().get();
const BoundingBox& bb = drawable.getBound(); const BoundingBox& bb = drawable.getBoundingBox();
for(IntersectState::LineSegmentList::iterator sitr=cis->_segList.begin(); for(IntersectState::LineSegmentList::iterator sitr=cis->_segList.begin();
sitr!=cis->_segList.end(); sitr!=cis->_segList.end();

View File

@ -312,7 +312,7 @@ void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Dr
if (reachedLimit()) return; if (reachedLimit()) return;
osg::Vec3d s(_start), e(_end); osg::Vec3d s(_start), e(_end);
if ( !intersectAndClip( s, e, drawable->getBound() ) ) return; if ( !intersectAndClip( s, e, drawable->getBoundingBox() ) ) return;
if (iv.getDoDummyTraversal()) return; if (iv.getDoDummyTraversal()) return;

View File

@ -2876,7 +2876,7 @@ bool Optimizer::SpatializeGroupsVisitor::divide(osg::Geode* geode, unsigned int
unsigned int i; unsigned int i;
for(i=0; i<geode->getNumDrawables(); ++i) for(i=0; i<geode->getNumDrawables(); ++i)
{ {
bb.expandBy(geode->getDrawable(i)->getBound().center()); bb.expandBy(geode->getDrawable(i)->getBoundingBox().center());
} }
float radius = bb.radius(); float radius = bb.radius();

View File

@ -108,7 +108,7 @@ void RayIntersector::intersect(IntersectionVisitor& iv, Drawable* drawable)
// clip ray to finite line segment // clip ray to finite line segment
Vec3d s(_start), e; Vec3d s(_start), e;
if (!intersectAndClip(s, _direction, e, drawable->getBound())) return; if (!intersectAndClip(s, _direction, e, drawable->getBoundingBox())) return;
// dummy traversal // dummy traversal
if (iv.getDoDummyTraversal()) return; if (iv.getDoDummyTraversal()) return;

View File

@ -151,7 +151,7 @@ void HelpHandler::setUpScene(osgViewer::ViewerBase* viewer)
label->setPosition(pos); label->setPosition(pos);
label->setText(_applicationUsage->getDescription()); label->setText(_applicationUsage->getDescription());
pos.x() = label->getBound().xMax(); pos.x() = label->getBoundingBox().xMax();
pos.y() -= characterSize*2.5f; pos.y() -= characterSize*2.5f;
} }

View File

@ -1149,7 +1149,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
frameRateLabel->setPosition(pos); frameRateLabel->setPosition(pos);
frameRateLabel->setText("Frame Rate: "); frameRateLabel->setText("Frame Rate: ");
pos.x() = frameRateLabel->getBound().xMax(); pos.x() = frameRateLabel->getBoundingBox().xMax();
osg::ref_ptr<osgText::Text> frameRateValue = new osgText::Text; osg::ref_ptr<osgText::Text> frameRateValue = new osgText::Text;
geode->addDrawable( frameRateValue.get() ); geode->addDrawable( frameRateValue.get() );
@ -1347,7 +1347,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
averageLabel->setPosition(pos); averageLabel->setPosition(pos);
averageLabel->setText("DatabasePager time to merge new tiles - average: "); averageLabel->setText("DatabasePager time to merge new tiles - average: ");
pos.x() = averageLabel->getBound().xMax(); pos.x() = averageLabel->getBoundingBox().xMax();
osg::ref_ptr<osgText::Text> averageValue = new osgText::Text; osg::ref_ptr<osgText::Text> averageValue = new osgText::Text;
_statsGeode->addDrawable( averageValue.get() ); _statsGeode->addDrawable( averageValue.get() );
@ -1358,7 +1358,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
averageValue->setPosition(pos); averageValue->setPosition(pos);
averageValue->setText("1000"); averageValue->setText("1000");
pos.x() = averageValue->getBound().xMax() + 2.0f*_characterSize; pos.x() = averageValue->getBoundingBox().xMax() + 2.0f*_characterSize;
osg::ref_ptr<osgText::Text> minLabel = new osgText::Text; osg::ref_ptr<osgText::Text> minLabel = new osgText::Text;
@ -1370,7 +1370,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
minLabel->setPosition(pos); minLabel->setPosition(pos);
minLabel->setText("min: "); minLabel->setText("min: ");
pos.x() = minLabel->getBound().xMax(); pos.x() = minLabel->getBoundingBox().xMax();
osg::ref_ptr<osgText::Text> minValue = new osgText::Text; osg::ref_ptr<osgText::Text> minValue = new osgText::Text;
_statsGeode->addDrawable( minValue.get() ); _statsGeode->addDrawable( minValue.get() );
@ -1381,7 +1381,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
minValue->setPosition(pos); minValue->setPosition(pos);
minValue->setText("1000"); minValue->setText("1000");
pos.x() = minValue->getBound().xMax() + 2.0f*_characterSize; pos.x() = minValue->getBoundingBox().xMax() + 2.0f*_characterSize;
osg::ref_ptr<osgText::Text> maxLabel = new osgText::Text; osg::ref_ptr<osgText::Text> maxLabel = new osgText::Text;
_statsGeode->addDrawable( maxLabel.get() ); _statsGeode->addDrawable( maxLabel.get() );
@ -1392,7 +1392,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
maxLabel->setPosition(pos); maxLabel->setPosition(pos);
maxLabel->setText("max: "); maxLabel->setText("max: ");
pos.x() = maxLabel->getBound().xMax(); pos.x() = maxLabel->getBoundingBox().xMax();
osg::ref_ptr<osgText::Text> maxValue = new osgText::Text; osg::ref_ptr<osgText::Text> maxValue = new osgText::Text;
_statsGeode->addDrawable( maxValue.get() ); _statsGeode->addDrawable( maxValue.get() );
@ -1403,7 +1403,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
maxValue->setPosition(pos); maxValue->setPosition(pos);
maxValue->setText("1000"); maxValue->setText("1000");
pos.x() = maxValue->getBound().xMax(); pos.x() = maxValue->getBoundingBox().xMax();
osg::ref_ptr<osgText::Text> requestsLabel = new osgText::Text; osg::ref_ptr<osgText::Text> requestsLabel = new osgText::Text;
_statsGeode->addDrawable( requestsLabel.get() ); _statsGeode->addDrawable( requestsLabel.get() );
@ -1414,7 +1414,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
requestsLabel->setPosition(pos); requestsLabel->setPosition(pos);
requestsLabel->setText("requests: "); requestsLabel->setText("requests: ");
pos.x() = requestsLabel->getBound().xMax(); pos.x() = requestsLabel->getBoundingBox().xMax();
osg::ref_ptr<osgText::Text> requestList = new osgText::Text; osg::ref_ptr<osgText::Text> requestList = new osgText::Text;
_statsGeode->addDrawable( requestList.get() ); _statsGeode->addDrawable( requestList.get() );
@ -1425,7 +1425,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
requestList->setPosition(pos); requestList->setPosition(pos);
requestList->setText("0"); requestList->setText("0");
pos.x() = requestList->getBound().xMax() + 2.0f*_characterSize;; pos.x() = requestList->getBoundingBox().xMax() + 2.0f*_characterSize;;
osg::ref_ptr<osgText::Text> compileLabel = new osgText::Text; osg::ref_ptr<osgText::Text> compileLabel = new osgText::Text;
_statsGeode->addDrawable( compileLabel.get() ); _statsGeode->addDrawable( compileLabel.get() );
@ -1436,7 +1436,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
compileLabel->setPosition(pos); compileLabel->setPosition(pos);
compileLabel->setText("tocompile: "); compileLabel->setText("tocompile: ");
pos.x() = compileLabel->getBound().xMax(); pos.x() = compileLabel->getBoundingBox().xMax();
osg::ref_ptr<osgText::Text> compileList = new osgText::Text; osg::ref_ptr<osgText::Text> compileList = new osgText::Text;
_statsGeode->addDrawable( compileList.get() ); _statsGeode->addDrawable( compileList.get() );
@ -1447,7 +1447,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
compileList->setPosition(pos); compileList->setPosition(pos);
compileList->setText("0"); compileList->setText("0");
pos.x() = maxLabel->getBound().xMax(); pos.x() = maxLabel->getBoundingBox().xMax();
_statsGeode->setCullCallback(new PagerCallback(dp, minValue.get(), maxValue.get(), averageValue.get(), requestList.get(), compileList.get(), 1000.0)); _statsGeode->setCullCallback(new PagerCallback(dp, minValue.get(), maxValue.get(), averageValue.get(), requestList.get(), compileList.get(), 1000.0));
} }
@ -1626,7 +1626,7 @@ void StatsHandler::createTimeStatsLine(const std::string& lineLabel,
label->setPosition(pos); label->setPosition(pos);
label->setText(lineLabel + ": "); label->setText(lineLabel + ": ");
pos.x() = label->getBound().xMax(); pos.x() = label->getBoundingBox().xMax();
osg::ref_ptr<osgText::Text> value = new osgText::Text; osg::ref_ptr<osgText::Text> value = new osgText::Text;
_statsGeode->addDrawable( value.get() ); _statsGeode->addDrawable( value.get() );

View File

@ -141,7 +141,7 @@ void Label::setShadow(point_type offset) {
} }
XYCoord Label::getTextSize() const { XYCoord Label::getTextSize() const {
osg::BoundingBox bb = _text->getBound(); const osg::BoundingBox& bb = _text->getBoundingBox();
return XYCoord( return XYCoord(
osg::round(bb.xMax() - bb.xMin()), osg::round(bb.xMax() - bb.xMin()),