Problem solved. I finally understand the compositeViewer example.
2008/6/23 Jean-Baptiste Authesserre <[EMAIL PROTECTED]>:
> Hi,
>
> I would like to have simultaneously many points of view of the same scene.
> I try to obtain this by using the CompositeViewer.
> I use the following code, but it doesn't work. Nothing appear to the second
> window. And in the first, the camera properties aren't those I give in the
> code! When I don't change camera properties of the second view (ie I
> deactivate the lines after the flag "//view2 camera properties"), the view 1
> appears correctly and the view 2 also appears with camera default
> properties.
> Can somebody help me?
> I have also a question:
> Is that possible to display two views of the same scene with only one
> window (by using functions like camera->setUpViewInWindow...)?
> How can I explained to the object view2 to use the same windows as the
> object view?
>
> Best Regards,
>
> Jean-Baptiste.
>
>
> *********************************************************************************************************************************
> // Create a viewer
> osgViewer::CompositeViewer * viewer = new osgViewer::CompositeViewer;
>
>
> /***************************** View 1 ********************************/
> osgViewer::View* view = new osgViewer::View;
> //create a manipulator
> Manipulator * MyManipulator = new Manipulator(view, MyCameraHandler);
>
> view->setCameraManipulator(MyManipulator);
> view->setSceneData(root);
> viewer->addView(view);
>
> /***************************** View 2 ***********************************/
> osgViewer::View* view2 = new osgViewer::View;
> Manipulator * MyManipulator2 = new Manipulator(view2, MyCameraHandler);
> view2->setCameraManipulator(MyManipulator2);
> view2->setSceneData(root);
> viewer->addView(view2);
>
> // set graphic window properties
> view->setUpViewInWindow(0,0,200,200);
> view2->setUpViewInWindow(200,200,200,200);
> /********************************************* start the rendering
> **************************************/
>
>
> while(!viewer->done())
> {
>
>
> if(!viewer->isRealized()) //realize the graphic context and set a
> default camera
> {
> viewer->realize();
> }
>
> /**************************** Initialize the camera of the
> different views *********************************/
> if (!cam_ini)
> {
> // View 1
> osg::Camera* camera = view->getCamera();
> camera->setClearColor(osg::Vec4(0.5f,0.5f,0.5f,1.0f));
> camera->setClearMask(GL_COLOR_BUFFER_BIT |
> GL_DEPTH_BUFFER_BIT);
>
> CameraHandler::Cam * cameraprop =
> MyCameraHandler->GetCameraAtIndex(5);
> if (cameraprop != NULL)//if camera index is valid
> {
>
> MyManipulator->setHomePosition(cameraprop->Position,cameraprop->Target,cameraprop->up);
> MyManipulator->home(0);
>
>
> camera->setProjectionMatrixAsPerspective(cameraprop->Fovy,cameraprop->AspectRatio,cameraprop->Near,cameraprop->Far);
> camera->setViewport (0, 0, cameraprop->width,
> cameraprop->height);
>
> }
>
>
>
> //View 2 camera properties
>
> camera = view2->getCamera();
> camera->setClearColor(osg::Vec4(0.8f,0.0f,0.0f,1.0f));
> camera->setClearMask(GL_COLOR_BUFFER_BIT |
> GL_DEPTH_BUFFER_BIT);
>
> //select the default camera
> cameraprop = MyCameraHandler->GetCameraAtIndex(4);
> if (cameraprop != NULL)//if camera index is valid
> {
>
> MyManipulator->setHomePosition(cameraprop->Position,cameraprop->Target,cameraprop->up);
> MyManipulator->home(0);
>
>
> camera->setProjectionMatrixAsPerspective(cameraprop->Fovy,cameraprop->AspectRatio,cameraprop->Near,cameraprop->Far);
> camera->setViewport (201, 201, 200, 200);
>
> }
>
>
> cam_ini=true;
>
> }
>
> viewer->frame();
>
> }
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org