OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osg::Node can not be displayed front of the Earth on the screen


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
aozdin
Newbie


Joined: 28 Feb 2018
Posts: 16

PostPosted: Fri Mar 02, 2018 12:43 pm    Post subject:
osg::Node can not be displayed front of the Earth on the screen
Reply with quote

Hi,

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
Code:
viewer.setSceneData( mainGroup );
to
Code:
viewer.setSceneData( nn.get() );

and remove these two lines
Code:
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.



Code:
osg::ref_ptr<osg::Node> createSceneGraph()
{
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
geom->setVertexArray( v.get() );

//horizontal
v->push_back( osg::Vec3( -1.f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.6f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.4f, 1.f, 0.f ) );
v->push_back( osg::Vec3( 0.f, 1.f, 0.f ) );

//vertical
v->push_back( osg::Vec3( -0.5f, 1.f, 0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, 0.1f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.1f ) );


osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
geom->setColorArray( c.get() );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
c->push_back( osg::Vec4( 1.f, 1.f, 1.f, 1.f ) );

osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
geom->setNormalArray( n.get() );
geom->setNormalBinding( osg::Geometry::BIND_OVERALL );
n->push_back( osg::Vec3( 0.f, -1.f, 0.f ) );

osg::LineWidth* linewdth = new osg::LineWidth();
linewdth->setWidth(25.0);
geom->getOrCreateStateSet()->setAttributeAndModes( linewdth, osg::StateAttribute::ON ) ;
geom->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINES, 0, 8 ) );

osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable( geom.get() );
return geode.get();
}

int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
viewer.setUpViewInWindow(100,100,500,500);
viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy( true, false );
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
manipulator = new EarthManipulator( arguments );
viewer.setCameraManipulator( manipulator );

osg::Group* mainGroup = new osg::Group();
osg::Group* group = MapNodeHelper().load(arguments, &viewer);
osg::ref_ptr<osg::Node> nn = createSceneGraph();

mainGroup->addChild(nn.get());
mainGroup->addChild(group);

viewer.setSceneData( mainGroup );
viewer.run();
}


Thank you!

Cheers,
Ali
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Fri Mar 02, 2018 2:14 pm    Post subject:
osg::Node can not be displayed front of the Earth on the screen
Reply with quote

Hi Ali,

have a look at the osghud example from the osg repo


On Fri, Mar 2, 2018 at 1:44 PM, Ali Ozdin < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

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

Code:
viewer.setSceneData( mainGroup );

 to
Code:
viewer.setSceneData( nn.get() );


and remove these two lines

Code:
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.




Code:
osg::ref_ptr<osg::Node> createSceneGraph()
{
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
geom->setVertexArray( v.get() );

//horizontal
v->push_back( osg::Vec3( -1.f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.6f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.4f, 1.f, 0.f ) );
v->push_back( osg::Vec3( 0.f, 1.f, 0.f ) );

//vertical
v->push_back( osg::Vec3( -0.5f, 1.f, 0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, 0.1f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.1f ) );


osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
geom->setColorArray( c.get() );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
c->push_back( osg::Vec4( 1.f, 1.f, 1.f, 1.f ) );

osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
geom->setNormalArray( n.get() );
geom->setNormalBinding( osg::Geometry::BIND_OVERALL );
n->push_back( osg::Vec3( 0.f, -1.f, 0.f ) );

osg::LineWidth* linewdth = new osg::LineWidth();
linewdth->setWidth(25.0);
geom->getOrCreateStateSet()->setAttributeAndModes( linewdth, osg::StateAttribute:ShockedN ) ;
geom->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINES, 0, 8 ) );

osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable( geom.get() );
return geode.get();
}

int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
viewer.setUpViewInWindow(100,100,500,500);
viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy( true, false );
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
manipulator = new EarthManipulator( arguments );
viewer.setCameraManipulator( manipulator );

osg::Group* mainGroup = new osg::Group();
osg::Group* group = MapNodeHelper().load(arguments, &viewer);
osg::ref_ptr<osg::Node> nn = createSceneGraph();

mainGroup->addChild(nn.get());
mainGroup->addChild(group);

viewer.setSceneData( mainGroup );
viewer.run();
}



Thank you!

Cheers,
Ali

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
aozdin
Newbie


Joined: 28 Feb 2018
Posts: 16

PostPosted: Fri Mar 02, 2018 3:23 pm    Post subject:
Re: osg::Node can not be displayed front of the Earth on the screen
Reply with quote

I could not relate the example with my question. I am using osgEarth.
Can you be more expressive what causes this?

Thanks,

Trajce Nikolov NICK wrote:
Hi Ali,

have a look at the osghud example from the osg repo


On Fri, Mar 2, 2018 at 1:44 PM, Ali Ozdin < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

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

Code:
viewer.setSceneData( mainGroup );

 to
Code:
viewer.setSceneData( nn.get() );


and remove these two lines

Code:
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.




Code:
osg::ref_ptr<osg::Node> createSceneGraph()
{
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
geom->setVertexArray( v.get() );

//horizontal
v->push_back( osg::Vec3( -1.f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.6f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.4f, 1.f, 0.f ) );
v->push_back( osg::Vec3( 0.f, 1.f, 0.f ) );

//vertical
v->push_back( osg::Vec3( -0.5f, 1.f, 0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, 0.1f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.1f ) );


osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
geom->setColorArray( c.get() );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
c->push_back( osg::Vec4( 1.f, 1.f, 1.f, 1.f ) );

osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
geom->setNormalArray( n.get() );
geom->setNormalBinding( osg::Geometry::BIND_OVERALL );
n->push_back( osg::Vec3( 0.f, -1.f, 0.f ) );

osg::LineWidth* linewdth = new osg::LineWidth();
linewdth->setWidth(25.0);
geom->getOrCreateStateSet()->setAttributeAndModes( linewdth, osg::StateAttribute:ShockedN ) ;
geom->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINES, 0, 8 ) );

osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable( geom.get() );
return geode.get();
}

int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
viewer.setUpViewInWindow(100,100,500,500);
viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy( true, false );
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
manipulator = new EarthManipulator( arguments );
viewer.setCameraManipulator( manipulator );

osg::Group* mainGroup = new osg::Group();
osg::Group* group = MapNodeHelper().load(arguments, &viewer);
osg::ref_ptr<osg::Node> nn = createSceneGraph();

mainGroup->addChild(nn.get());
mainGroup->addChild(group);

viewer.setSceneData( mainGroup );
viewer.run();
}



Thank you!

Cheers,
Ali

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Fri Mar 02, 2018 7:34 pm    Post subject:
osg::Node can not be displayed front of the Earth on the screen
Reply with quote

if you need to draw anything on the center of the screen in front of something else, then your problem is to create an ortho camera and have your geometry there - something like HUD. The osghud example shows how to do this. Just for a test, you can use the createHUD() function from that sample to create your screen geometry in front of the osgEarth globe

On Fri, Mar 2, 2018 at 4:23 PM, Ali Ozdin < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
I could not relate the example with my question. I am using osgEarth.
Can you be more expressive what causes this?

Thanks,


Trajce Nikolov NICK wrote:
Quote:
Hi Ali,

have a look at the osghud example from the osg repo


On Fri, Mar 2, 2018 at 1:44 PM, Ali Ozdin < ()> wrote:

Quote:
Hi,

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

Code:
viewer.setSceneData( mainGroup );

 to
Code:
viewer.setSceneData( nn.get() );


and remove these two lines

Code:
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.




Code:
osg::ref_ptr<osg::Node> createSceneGraph()
{
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
geom->setVertexArray( v.get() );

//horizontal
v->push_back( osg::Vec3( -1.f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.6f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.4f, 1.f, 0.f ) );
v->push_back( osg::Vec3( 0.f, 1.f, 0.f ) );

//vertical
v->push_back( osg::Vec3( -0.5f, 1.f, 0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, 0.1f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.1f ) );


osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
geom->setColorArray( c.get() );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
c->push_back( osg::Vec4( 1.f, 1.f, 1.f, 1.f ) );

osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
geom->setNormalArray( n.get() );
geom->setNormalBinding( osg::Geometry::BIND_OVERALL );
n->push_back( osg::Vec3( 0.f, -1.f, 0.f ) );

osg::LineWidth* linewdth = new osg::LineWidth();
linewdth->setWidth(25.0);
geom->getOrCreateStateSet()->setAttributeAndModes( linewdth, osg::StateAttribute:ShockedN ) ;
geom->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINES, 0, 8 ) );

osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable( geom.get() );
return geode.get();
}

int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
viewer.setUpViewInWindow(100,100,500,500);
viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy( true, false );
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
manipulator = new EarthManipulator( arguments );
viewer.setCameraManipulator( manipulator );

osg::Group* mainGroup = new osg::Group();
osg::Group* group = MapNodeHelper().load(arguments, &viewer);
osg::ref_ptr<osg::Node> nn = createSceneGraph();

mainGroup->addChild(nn.get());
mainGroup->addChild(group);

viewer.setSceneData( mainGroup );
viewer.run();
}



Thank you!

Cheers,
Ali

------------------
Read this topic online here:


Quote:
Quote:
http://forum.openscenegraph.org/viewtopic.php?p=72998#72998 (http://forum.openscenegraph.org/viewtopic.php?p=72998#72998)





_______________________________________________
osg-users mailing list
  ()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)





--
trajce nikolov nick

  ------------------
Post generated by Mail2Forum


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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org






--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
aozdin
Newbie


Joined: 28 Feb 2018
Posts: 16

PostPosted: Mon Mar 05, 2018 1:37 pm    Post subject:
Re: osg::Node can not be displayed front of the Earth on the screen
Reply with quote

Thank you very much, I did it.

Trajce Nikolov NICK wrote:
if you need to draw anything on the center of the screen in front of something else, then your problem is to create an ortho camera and have your geometry there - something like HUD. The osghud example shows how to do this. Just for a test, you can use the createHUD() function from that sample to create your screen geometry in front of the osgEarth globe

On Fri, Mar 2, 2018 at 4:23 PM, Ali Ozdin < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
I could not relate the example with my question. I am using osgEarth.
Can you be more expressive what causes this?

Thanks,


Trajce Nikolov NICK wrote:
Quote:
Hi Ali,

have a look at the osghud example from the osg repo


On Fri, Mar 2, 2018 at 1:44 PM, Ali Ozdin < ()> wrote:

Quote:
Hi,

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

Code:
viewer.setSceneData( mainGroup );

 to
Code:
viewer.setSceneData( nn.get() );


and remove these two lines

Code:
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.




Code:
osg::ref_ptr<osg::Node> createSceneGraph()
{
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
geom->setVertexArray( v.get() );

//horizontal
v->push_back( osg::Vec3( -1.f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.6f, 1.f, 0.f ) );
v->push_back( osg::Vec3( -0.4f, 1.f, 0.f ) );
v->push_back( osg::Vec3( 0.f, 1.f, 0.f ) );

//vertical
v->push_back( osg::Vec3( -0.5f, 1.f, 0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, 0.1f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.5f ) );
v->push_back( osg::Vec3( -0.5f, 1.f, -0.1f ) );


osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
geom->setColorArray( c.get() );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
c->push_back( osg::Vec4( 1.f, 1.f, 1.f, 1.f ) );

osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
geom->setNormalArray( n.get() );
geom->setNormalBinding( osg::Geometry::BIND_OVERALL );
n->push_back( osg::Vec3( 0.f, -1.f, 0.f ) );

osg::LineWidth* linewdth = new osg::LineWidth();
linewdth->setWidth(25.0);
geom->getOrCreateStateSet()->setAttributeAndModes( linewdth, osg::StateAttribute:ShockedN ) ;
geom->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINES, 0, 8 ) );

osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable( geom.get() );
return geode.get();
}

int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
viewer.setUpViewInWindow(100,100,500,500);
viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy( true, false );
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
manipulator = new EarthManipulator( arguments );
viewer.setCameraManipulator( manipulator );

osg::Group* mainGroup = new osg::Group();
osg::Group* group = MapNodeHelper().load(arguments, &viewer);
osg::ref_ptr<osg::Node> nn = createSceneGraph();

mainGroup->addChild(nn.get());
mainGroup->addChild(group);

viewer.setSceneData( mainGroup );
viewer.run();
}



Thank you!

Cheers,
Ali

------------------
Read this topic online here:


Quote:
Quote:
http://forum.openscenegraph.org/viewtopic.php?p=72998#72998 (http://forum.openscenegraph.org/viewtopic.php?p=72998#72998)





_______________________________________________
osg-users mailing list
  ()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)





--
trajce nikolov nick

  ------------------
Post generated by Mail2Forum


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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org






--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Leaking memory on node removal Tini General 1 Fri May 25, 2018 6:48 pm View latest post
No new posts Leaking memory on node removal Tini General 0 Fri May 25, 2018 6:39 pm View latest post
No new posts Leaking memory on node removal Tini General 0 Fri May 25, 2018 6:30 pm View latest post
No new posts Leaking memory on node removal Tini General 0 Fri May 25, 2018 6:27 pm View latest post
No new posts EXTERNAL: Re: Getting the combined ma... Rowley, Marlin R General 0 Tue May 08, 2018 3:25 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP