Hi all,

    regarding the question yesterday about the problem with the 
compositeviewer, I attach the fragment of code that i am using. Has somebody 
any idea about where is the problem? Thank you very much.

osg::ref_ptr<osg::GraphicsContext::Traits> traits = new 
osg::GraphicsContext::Traits;

// Init the Windata Variable that holds the handle for the Window to display 
OSG in.
osg::ref_ptr<osg::Referenced> windata = new 
osgViewer::GraphicsWindowWin32::WindowData(GetSafeHwnd());

// Setup the traits parameters
traits->x = 0;
traits->y = 0;
traits->width = RectDLG.right - RectDLG.left;
traits->height = RectDLG.bottom - RectDLG.top;
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
traits->setInheritedWindowPixelFormat = true;
traits->inheritedWindowData = windata;

// Create the Graphics Context
osg::GraphicsContext* gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());

// view 1: for 3D model

/* Create the scene data */
//....

osgViewer::View* view1 = new osgViewer::View();
view1->getCamera()->setViewport(new 
osg::Viewport(traits->width/2,traits->y,traits->width/2,traits->height));
view1->getCamera()->setProjectionMatrixAsPerspective(30.0f, 
static_cast<double>(traits->width/2)/static_cast<double>(traits->height), 1.0f, 
10000.0f);
view1->getCamera()->setGraphicsContext(gc);

view1->setSceneData(BackgroundRoot);

// view 2: for Background image

/* Create the background image graph */
//....


osgViewer::View* view2 = new osgViewer::View();
view2->setSceneData(hudRoot);
view2->getCamera()->setViewport(new 
osg::Viewport(0,0,traits->width,traits->height));
view2->getCamera()->setProjectionMatrixAsPerspective(30.0f, 
static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 
10000.0f);
view2->getCamera()->setGraphicsContext(gc);

view2->setSceneData(ModelRoot);

// Attach views to CompositeViewer
sceneView->addView(view2); // Draw first?
sceneView->addView(view1);


----- Original Message ----- 
From: David Oyarzun 
To: osg-users@lists.openscenegraph.org 
Sent: Tuesday, December 02, 2008 6:09 PM
Subject: problems with CompositeViewer 


Hi all,

    I think I have a problem with the render order of the CompositeViewer.
    I am trying to program a osg-based windowed application that shows a 3D 
animated object centered in the right middle of the window. Moreover, it has a 
background image that fills all the window, including the right middle (behind 
the 3D model). I want that the application is modular, in the sense that 
depending the initial width and height fo the window, the 3D object appears 
always centered in the right middle.
    For doing that, I have created a CompositeViewer with 2 views, one of them 
setting the viewport to all the window and putting the background as SceneData, 
and the other one with the right middle size for putting the 3D object, but I 
only see the backgorund image. It seems like the backgorund image is always in 
the front, because if I delete its view, the 3D object is well positioned.
    Could be something related with the render order? If it is, how could I 
tell CompositeViewer to draw the background before the 3D model? Else, is it a 
good idea using the CompositeViewer for this kind of issue?

Thank you in advance,

David.


__________ InformaciĆ³n de ESET NOD32 Antivirus, versiĆ³n de la base de firmas de 
virus 3658 (20081202) __________

ESET NOD32 Antivirus ha comprobado este mensaje.
http://www.eset.com
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to