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


[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


[osg-users] osg2.x and osgViewer

2008-07-03 Thread David Oyarzun
Hi all,

I have a problem with an ActiveX control using osg. I have it working well 
in osg 1.x but when I have migrated it to osg 2.x (changing the producer viewer 
to osgviewer), the OnPaint function of the control is never called and I can 
not update the osg graph. I think it is a problem with my configuration of the 
viewer. I have this in the main class of the control:

osg::ref_ptrosg::Referenced windata = new 
osgViewer::GraphicsWindowWin32::WindowData(GetSafeHwnd());

// Setup the traits parameters
traits-x = RectDLG.left;
traits-y = RectDLG.top;
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;

osg::GraphicsContext* gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext(gc);
camera-setViewport(new osg::Viewport(0,0, traits-width, traits-height));
GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
camera-setDrawBuffer(buffer);
camera-setReadBuffer(buffer);

m_SceneView-addSlave(camera.get());

if I comment the traits-inheritedWindowData = windata; line, all works ok, 
it is updated an all the events occurs, but the osg frame appears as a separate 
window, however, if I use this line it appears integrated in the browser but 
onPaint function is never called. I would thank you if somebody can help me.

Best regards,

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


[osg-users] Problems with osgViewer and ActiveX

2008-02-21 Thread David Oyarzun
Hi all,

I'm developing an ActiveX for a web browser using osgViewer. This is the 
configuration that I have used in order to attach the viewer to the window. It 
is included in my main activex control class:

RECT RectDLG;
GetWindowRect(RectDLG);

// Init the GraphicsContext Traits
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 = RectDLG.left;
traits-y = RectDLG.top;
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());
m_SceneView-getCamera()-setViewport(new 
osg::Viewport(0,0,traits-width,traits-height));
m_SceneView-getCamera()-setProjectionMatrixAsPerspective(30.0f, 
static_castdouble(traits-width)/static_castdouble(traits-height), 1.0f, 
1.0f);
m_SceneView-getCamera()-setGraphicsContext(gc);

m_SceneView-setThreadingModel(osgViewer::Viewer::SingleThreaded);



The update of the scene is done in the OnPaint function (with 
m_SceneView-frame()). My problem is that the OnPaint function is called but my 
scene is not visually updated.
I think my problem is due to osg doesn't know that the scene is active and i 
need a function as makeCurrent in Producer::RenderSurface. I have seen this 
function in osgViewer it is protected, is there another similar function or 
something that tells osg that the scene is active?

Thank you in advance,

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