Hi Carl, Please download http://www.openscenegraph.org/projects/osg/attachment/wiki/Support/Tutorials/NPS_Tutorials_src.rarand test Tutorial_06 which is given link osgHud in OSG website by you. I have already tried and it is working pretty good. I think your problem was that you didn't control model's path. So you can't see any hud on the screen. Please control all path's on your system and recompile it. You will see all of them works.
Regards. Ümit Uzun 2009/12/29 Trajce Nikolov <[email protected]> > dont panic :)) > > here is your code modfied and working > > osg::ref_ptr<osg::Group> CreateHUD() > { > osg::ref_ptr<osg::Group> Root( new osg::Group ); > > // HUD > osg::ref_ptr<osgText::Text> HUD_Text( new osgText::Text ); > HUD_Text->setCharacterSize( 25 ); > HUD_Text->setFont( "fonts/arial.ttf" ); > HUD_Text->setText( "Not so good" ); > //HUD_Text->setAxisAlignment( osgText::Text::SCREEN ); > HUD_Text->setPosition( osg::Vec3( 30.0, 30.0, 0.0 ) ); > HUD_Text->setColor( osg::Vec4( 1.0, 1.0, 0.0, 1.0 ) ); > > // HUD Vertices > osg::ref_ptr<osg::Vec3Array> HUD_Vertices( new osg::Vec3Array ); > HUD_Vertices->push_back( osg::Vec3d( 0.0, 0.0, -0.1 ) ); > HUD_Vertices->push_back( osg::Vec3d( 1024.0, 0.0, -0.1 ) ); > HUD_Vertices->push_back( osg::Vec3d( 1024.0, 200.0, -0.1 ) ); > HUD_Vertices->push_back( osg::Vec3d( 0.0, 200.0, -0.1 ) ); > > // HUD Indices > osg::ref_ptr<osg::DrawElementsUInt> HUD_Indices( new osg::DrawElementsUInt( > osg::PrimitiveSet::POLYGON, 0 ) ); > HUD_Indices->push_back( 0 ); > HUD_Indices->push_back( 1 ); > HUD_Indices->push_back( 2 ); > HUD_Indices->push_back( 3 ); > > // Hud Color > osg::ref_ptr<osg::Vec4Array> HUD_Color(new osg::Vec4Array ); > HUD_Color->push_back( osg::Vec4( 0.8f, 0.8f, 0.8f, 0.8f) ); > > // HUD Normals > osg::ref_ptr<osg::Vec3Array> HUD_Normals( new osg::Vec3Array ); > HUD_Normals->push_back( osg::Vec3( 0.0f, 0.0f, -1.0f ) ); > > // HUD Geometry > osg::ref_ptr<osg::Geometry> HUD_Geometry( new osg::Geometry ); > HUD_Geometry->setNormalArray( HUD_Normals ); > HUD_Geometry->setNormalBinding( osg::Geometry::BIND_OVERALL ); > HUD_Geometry->addPrimitiveSet( HUD_Indices ); > HUD_Geometry->setVertexArray( HUD_Vertices ); > HUD_Geometry->setColorArray( HUD_Color ); > HUD_Geometry->setColorBinding( osg::Geometry::BIND_OVERALL ); > > // HUD Renderstates > osg::ref_ptr<osg::StateSet> HUD_StateSet( new osg::StateSet ); > HUD_StateSet->setMode( GL_BLEND, osg::StateAttribute::ON ); > HUD_StateSet->setMode( GL_DEPTH_TEST, osg::StateAttribute::OFF ); > HUD_StateSet->setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); > HUD_StateSet->setRenderBinDetails( 11, "DepthSortedBin"); > > // HUD Geode > osg::ref_ptr<osg::Geode> HUD_Geode( new osg::Geode ); > HUD_Geode->addDrawable( HUD_Geometry.get() ); > HUD_Geode->addDrawable( HUD_Text.get() ); > //HUD_Geode->setStateSet( HUD_StateSet.get() ); > > // HUD View > osg::ref_ptr<osg::MatrixTransform> HUD_Transform( new > osg::MatrixTransform ); > HUD_Transform->setMatrix( osg::Matrix::identity() ); > HUD_Transform->setReferenceFrame( > osg::Transform::ABSOLUTE_RF_INHERIT_VIEWPOINT ); > HUD_Transform->addChild( HUD_Geode.get() ); > > // HUD Projection > /* > osg::ref_ptr<osg::Projection> HUD_Projection( new osg::Projection ); > HUD_Projection->setMatrix( osg::Matrix::ortho2D( 0.0, 1024.0, 0.0, 768.0 > ) ); > HUD_Projection->addChild( HUD_Transform.get() ); > */ > > osg::Camera* camera = new osg::Camera; > camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024)); > camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); > camera->setViewMatrix(osg::Matrix::identity()); > camera->setClearMask(GL_DEPTH_BUFFER_BIT); > camera->setRenderOrder(osg::Camera::NESTED_RENDER); > camera->setAllowEventFocus(false); > camera->addChild( HUD_Transform.get() ); > > //Root->addChild( HUD_Projection.get() ); > Root->addChild( camera ); > > return Root; > } > int main (int argc, char* argv[]) > { > // Create a Producer-based viewer > osgViewer::Viewer viewer; > viewer.addEventHandler( new osgViewer::StatsHandler ); > viewer.setUpViewInWindow( 32, 32, 1024, 768 ); > viewer.setSceneData( CreateHUD().get() ); > viewer.setCameraManipulator(new osgGA::TrackballManipulator()); > viewer.realize(); > > while( !viewer.done() ) > { > viewer.frame(); > } > > //return viewer.run(); > return 0; > } > > Nick > > http://www.linkedin.com/in/tnick > Sent from Devlet, Ankara, Turkey > > On Tue, Dec 29, 2009 at 1:46 PM, Carl Johnson <[email protected]> wrote: > >> Hi, >> >> it is unbelievable that nobody can help. [Question] >> >> >> http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/HudsAndText >> >> This tutorial dont work :-< >> >> It looks like so easy and plausible, so i can not understand what i do >> wrong. >> >> Thank you! >> >> Cheers, >> Carl >> >> ------------------ >> Read this topic online here: >> http://forum.openscenegraph.org/viewtopic.php?p=21911#21911 >> >> >> >> >> >> _______________________________________________ >> osg-users mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

