osg::Node can not be displayed front of the Earth on the screen
I drew an osg::Node and I want to put it on the center of the screen like any labelControl. How can I do that? I put a sample code below.
If I change the line from
<<viewer.setSceneData( mainGroup );>> to <<viewer.setSceneData( nn.get() );>>
remove these two lines
<<manipulator = new EarthManipulator( arguments );>>
<<viewer.setCameraManipulator( manipulator ); >>
I am only able to see the geometry which I draw. However if I setSceneData as mapNode and geometry which are in "mainGroup" and if my camera manipulator is EarthManipulator; I am only able to see the earth.
To sum up, I want to see the earth in the back and I want to put my geometry front of the earth and on the center of the screen.
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
geom->setVertexArray( v.get() );
Re: osg::Node can not be displayed front of the Earth on the screen
OSG installs a default manipulator (the code that automatically configures the OpenGL view matrix based on mouse and keyboard input) based on the geometry it finds in the scene. So when you just load your own geometry, it centers the view on that geometry.
When you load it with a MapNode, the scene contains the planet (which is centered at 0,0,0 and is about 6371000m in radius) and your tiny 1m wide geometry at the center where you cannot see it.
You probably need a HUD (heads up display) camera. Go look at the OpenSceneGraph example called "osghud" to see how to set one up. This will help you draw your node in screen space instead of in world space.