Re: [osg-users] problems with CompositeViewer

2008-12-03 Thread David Oyarzun
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_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;

// Init the Windata Variable that holds the handle for the Window to display 
OSG in.
osg::ref_ptrosg::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_castdouble(traits-width/2)/static_castdouble(traits-height), 1.0f, 
1.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_castdouble(traits-width)/static_castdouble(traits-height), 1.0f, 
1.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


Re: [osg-users] problems with CompositeViewer

2008-12-03 Thread Robert Osfield
HI David,

I'll stop being subtle about it then as you seem to have ignored my
previous email which told you exactly what to do.

Using two views to do what you want to do is *completely* the wrong
way to tackle the problem.   You task requires a single view, but with
either a slave Camera or a in scene graph Camera.  Please just abandon
your currently code as a lost cause, and review the osghud example and
learn about the different ways of using cameras.

Robert.

On Wed, Dec 3, 2008 at 9:25 AM, David Oyarzun [EMAIL PROTECTED] wrote:
 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_ptrosg::GraphicsContext::Traits traits = new
 osg::GraphicsContext::Traits;

 // Init the Windata Variable that holds the handle for the Window to display
 OSG in.
 osg::ref_ptrosg::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_castdouble(traits-width/2)/static_castdouble(traits-height),
 1.0f, 1.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_castdouble(traits-width)/static_castdouble(traits-height),
 1.0f, 1.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


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] problems with CompositeViewer

2008-12-02 Thread David Oyarzun
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.___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problems with CompositeViewer

2008-12-02 Thread Robert Osfield
Hi David,

The Camera::setRenderOrder(..) method is used to control order in
which the cameras on a GraphicsWindow are rendered.

In you application the wish to have a background image is not served
well by creating a separate view for it.  A far better solution would
be to insert a Camera into the scene graph that works as HUD.  See the
osghud example, this would be simpler to manage, and conceptually a
far better fit.

Robert.

On 12/2/08, David Oyarzun [EMAIL PROTECTED] wrote:
 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.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org