<div dir="ltr">Hi Ali,<div><br></div><div>have a look at the osghud example from the osg repo</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 2, 2018 at 1:44 PM, Ali Ozdin <span dir="ltr"><<a href="mailto:alinailozdin@gmail.com" target="_blank">alinailozdin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
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.<br>
<br>
If I change the line from<br>
<br>
Code:<br>
viewer.setSceneData( mainGroup );<br>
<br>
 to<br>
Code:<br>
viewer.setSceneData( nn.get() );<br>
<br>
<br>
and remove these two lines<br>
<br>
Code:<br>
manipulator = new EarthManipulator(  arguments );<br>
viewer.setCameraManipulator( manipulator );<br>
<br>
<br>
<br>
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.<br>
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.<br>
<br>
<br>
<br>
<br>
Code:<br>
osg::ref_ptr<osg::Node> createSceneGraph()<br>
{<br>
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;<br>
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;<br>
geom->setVertexArray( v.get() );<br>
<br>
//horizontal<br>
v->push_back( osg::Vec3( -1.f, 1.f, 0.f ) );<br>
v->push_back( osg::Vec3( -0.6f, 1.f, 0.f ) );<br>
v->push_back( osg::Vec3( -0.4f, 1.f, 0.f ) );<br>
v->push_back( osg::Vec3( 0.f, 1.f, 0.f ) );<br>
<br>
//vertical<br>
v->push_back( osg::Vec3( -0.5f, 1.f, 0.5f ) );<br>
v->push_back( osg::Vec3( -0.5f, 1.f, 0.1f ) );<br>
v->push_back( osg::Vec3( -0.5f, 1.f, -0.5f ) );<br>
v->push_back( osg::Vec3( -0.5f, 1.f, -0.1f ) );<br>
<br>
<br>
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;<br>
geom->setColorArray( c.get() );<br>
geom->setColorBinding( osg::Geometry::BIND_OVERALL );<br>
c->push_back( osg::Vec4( 1.f, 1.f, 1.f, 1.f ) );<br>
<br>
osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;<br>
geom->setNormalArray( n.get() );<br>
geom->setNormalBinding( osg::Geometry::BIND_OVERALL );<br>
n->push_back( osg::Vec3( 0.f, -1.f, 0.f ) );<br>
<br>
osg::LineWidth* linewdth = new osg::LineWidth();<br>
linewdth->setWidth(25.0);<br>
geom->getOrCreateStateSet()-><wbr>setAttributeAndModes( linewdth, osg::StateAttribute::ON ) ;<br>
geom->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINES, 0, 8 ) );<br>
<br>
osg::ref_ptr<osg::Geode> geode = new osg::Geode;<br>
geode->addDrawable( geom.get() );<br>
return geode.get();<br>
}<br>
<br>
int main(int argc, char** argv)<br>
{<br>
osg::ArgumentParser arguments(&argc,argv);<br>
viewer.setUpViewInWindow(100,<wbr>100,500,500);<br>
viewer.getDatabasePager()-><wbr>setUnrefImageDataAfterApplyPol<wbr>icy( true, false );<br>
osgDB::Registry::instance()-><wbr>getObjectWrapperManager()-><wbr>findWrapper("osg::Image");<br>
manipulator = new EarthManipulator( arguments );<br>
viewer.setCameraManipulator( manipulator );<br>
<br>
osg::Group* mainGroup = new osg::Group();<br>
osg::Group* group = MapNodeHelper().load(<wbr>arguments, &viewer);<br>
osg::ref_ptr<osg::Node> nn = createSceneGraph();<br>
<br>
mainGroup->addChild(nn.get());<br>
mainGroup->addChild(group);<br>
<br>
viewer.setSceneData( mainGroup );<br>
viewer.run();<br>
}<br>
<br>
<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Ali<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=72998#72998" rel="noreferrer" target="_blank">http://forum.openscenegraph.<wbr>org/viewtopic.php?p=72998#<wbr>72998</a><br>
<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.<wbr>openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">trajce nikolov nick<br></div>
</div>