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

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.

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

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.

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

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.

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