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 

How to overlap two cameras with different scenes?


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [forum]
View previous topic :: View next topic  
Author Message
Oceane
User


Joined: 02 Jul 2012
Posts: 24

PostPosted: Wed Apr 24, 2013 3:57 pm    Post subject:
How to overlap two cameras with different scenes?
Reply with quote

Hi all,

Sorry to disturb but I want to know how can I overlap two cameras with two different scenes?

Here the picture is the result I tried with CompositeViewer, but this is not exactly what I want. As you can see, the names of houses are displayed in one view while buildings in another view.

I have one scenegraph containing only buildings and another one containing only house names. Due to some specific needs, I can not put them under the same camera.

So I have one camera adding houses as children and meanwhile one camera adding house names as children. So how can I overlap them in one view?

I tried like this but failed, I don't have a good master of OSG theory part Sad

Code:

osgViewer::Viewer viewer;
//is this a right way to add houses to one camera?
viewer.getCamera()->addChild(houses);

//here I want to construct a camera, with all the parameters the same as the viewer.getCamera(), so that they can be overlaped. Is this a right way?
    osg::Camera* myCam = new osg::Camera;
    myCam->setProjectionMatrix(viewer.getCamera()->getProjectionMatrix());
    myCam->setViewMatrix(viewer.getCamera()->getViewMatrix());
    myCam->setViewport(viewer.getCamera()->getViewport());
    myCam->addChild(house names);
    myCam->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    viewer.addSlave(myCam, false);


And I don't know how to make them visualized.

I searched for answer in older posts, and I found the "Producer" example, I don't have the Producer version. Then there was suggestion of looking at osgdistortion example where there are multiple cameras. However these multiple cameras share the same scene dataset, simple by viewer.assignSceneDataToCameras(). But I don't use the same dataset.

I don't know if I make myself clear here.

So huge thanks in advance for any reply:)

Fan
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11192

PostPosted: Wed Apr 24, 2013 4:06 pm    Post subject:
How to overlap two cameras with different scenes?
Reply with quote

Hi Fan,


For HUD's like this have a look at the osghud example.  The key bit you need to add is to set the ClearMask to just clear the depth buffer of the overlaid Camera, and set the RenderOrder of the Camera's to make sure the overlay camera gets drawn second.

Robert.



On 24 April 2013 16:57, Fan ZHANG < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi all,

Sorry to disturb but I want to know how can I overlap two cameras with two different scenes?

Here the picture is the result I tried with CompositeViewer, but this is not exactly what I want. As you can see, the names of houses are displayed in one view while buildings in another view.

I have one scenegraph containing only buildings and another one containing only house names. Due to some specific needs, I can not put them under the same camera.

So I have one camera adding houses as children and meanwhile one camera adding house names as children. So how can I overlap them in one view?

I tried like this but failed, I don't have a good master of OSG theory part Sad


Code:

osgViewer::Viewer viewer;
//is this a right way to add houses to one camera?
viewer.getCamera()->addChild(houses);

//here I want to construct a camera, with all the parameters the same as the viewer.getCamera(), so that they can be overlaped. Is this a right way?
    osg::Camera* myCam = new osg::Camera;
    myCam->setProjectionMatrix(viewer.getCamera()->getProjectionMatrix());
    myCam->setViewMatrix(viewer.getCamera()->getViewMatrix());
    myCam->setViewport(viewer.getCamera()->getViewport());
    myCam->addChild(house names);
    myCam->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    viewer.addSlave(myCam, false);



And I don't know how to make them visualized.

I searched for answer in older posts, and I found the "Producer" example, I don't have the Producer version. Then there was suggestion of looking at osgdistortion example where there are multiple cameras. However these multiple cameras share the same scene dataset, simple by viewer.assignSceneDataToCameras(). But I don't use the same dataset.

I don't know if I make myself clear here.

So huge thanks in advance for any reply:)

Fan

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




Attachments:
http://forum.openscenegraph.org//files/result_155.png
http://forum.openscenegraph.org//files/result_212.png


_______________________________________________
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


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Oceane
User


Joined: 02 Jul 2012
Posts: 24

PostPosted: Wed Apr 24, 2013 4:16 pm    Post subject:
Re: How to overlap two cameras with different scenes?
Reply with quote

Thanks for your reply but my house names are not HUD texts.

They are 3D objects too.

And for future purpose they have to be 3D objects.

And I realize I posted to a wrong place in the forum, please move this post to the right place if you can ,thanks:)


robertosfield wrote:
Hi Fan,


For HUD's like this have a look at the osghud example.  The key bit you need to add is to set the ClearMask to just clear the depth buffer of the overlaid Camera, and set the RenderOrder of the Camera's to make sure the overlay camera gets drawn second.

Robert.



On 24 April 2013 16:57, Fan ZHANG < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi all,

Sorry to disturb but I want to know how can I overlap two cameras with two different scenes?

Here the picture is the result I tried with CompositeViewer, but this is not exactly what I want. As you can see, the names of houses are displayed in one view while buildings in another view.

I have one scenegraph containing only buildings and another one containing only house names. Due to some specific needs, I can not put them under the same camera.

So I have one camera adding houses as children and meanwhile one camera adding house names as children. So how can I overlap them in one view?

I tried like this but failed, I don't have a good master of OSG theory part Sad


Code:

osgViewer::Viewer viewer;
//is this a right way to add houses to one camera?
viewer.getCamera()->addChild(houses);

//here I want to construct a camera, with all the parameters the same as the viewer.getCamera(), so that they can be overlaped. Is this a right way?
    osg::Camera* myCam = new osg::Camera;
    myCam->setProjectionMatrix(viewer.getCamera()->getProjectionMatrix());
    myCam->setViewMatrix(viewer.getCamera()->getViewMatrix());
    myCam->setViewport(viewer.getCamera()->getViewport());
    myCam->addChild(house names);
    myCam->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    viewer.addSlave(myCam, false);



And I don't know how to make them visualized.

I searched for answer in older posts, and I found the "Producer" example, I don't have the Producer version. Then there was suggestion of looking at osgdistortion example where there are multiple cameras. However these multiple cameras share the same scene dataset, simple by viewer.assignSceneDataToCameras(). But I don't use the same dataset.

I don't know if I make myself clear here.

So huge thanks in advance for any reply:)

Fan

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




Attachments:
http://forum.openscenegraph.org//files/result_155.png
http://forum.openscenegraph.org//files/result_212.png


_______________________________________________
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


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11192

PostPosted: Wed Apr 24, 2013 4:58 pm    Post subject:
How to overlap two cameras with different scenes?
Reply with quote

On 24 April 2013 17:16, Fan ZHANG < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Thanks for your reply but my house names are not HUD texts.

They are 3D objects too.

And for future purpose they have to be 3D objects.


It doesn't matter, the same technique applies for 3D and 2D objects.

 
Quote:
And I realize I posted to a wrong place in the forum, please move this post to the right place if you can ,thanks:)



I don't use the forum, just the mailing list so have little knowledge or control over what the forum does for threads.

Robert.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Oceane
User


Joined: 02 Jul 2012
Posts: 24

PostPosted: Wed Apr 24, 2013 5:18 pm    Post subject:
Re: How to overlap two cameras with different scenes?
Reply with quote

Thanks so much for your kindly help and will try the solution tomorrow.

robertosfield wrote:
On 24 April 2013 17:16, Fan ZHANG < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Thanks for your reply but my house names are not HUD texts.

They are 3D objects too.

And for future purpose they have to be 3D objects.


It doesn't matter, the same technique applies for 3D and 2D objects.

 
Quote:
And I realize I posted to a wrong place in the forum, please move this post to the right place if you can ,thanks:)



I don't use the forum, just the mailing list so have little knowledge or control over what the forum does for threads.

Robert.

------------------
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 [forum] 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 How do cameras handle the render target? wernerM General 3 Wed Mar 15, 2017 9:59 am View latest post
No new posts Multiple cameras sharing multisample fbo ravidavi General 1 Sat Mar 11, 2017 8:17 am View latest post
No new posts How to handle cameras in the scene gr... wernerM General 7 Fri Feb 24, 2017 4:47 pm View latest post
No new posts Blurred scenes for camera in motion suraj General 0 Thu Feb 09, 2017 9:13 am View latest post
No new posts Camera Eye psotion in scenes with lar... suraj General 0 Sat Sep 24, 2016 5:03 am 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