Re: [osg-users] Embedding OSG in QT 4.5.0 with QGLWidget + QGraphicsScene / drawBackground() - need a little help.
I want to re-open this discussion because it comes up regularly and I think it's important to address. Sure it's easier to avoid mixing, but combining osg with toolkits such as Qt Quick/QML can create very powerful and beautiful user interfaces. The marriage of the two can create great things. We've got a pretty good state saver now, but it apparently doesn't work perfectly to keep both toolkits happy. We're close. What I've seen is lighting is not restored completely, and there is an issue with texture coordinates. It's been suggested that for performance reasons, we let OSG handle the context and do the 3rd party toolkit drawing in pre/post callbacks. This might help with multi-threaded rendering, but doesn't address the state issue. Performance aside, is there something that can be done to insure that OSG is given an OpenGL state that it is happy with? At some point, OSG is given a virgin OpenGL state and is forced to set the state as it wishes. I'd be more than happy to sacrifice performance if multiple rendering toolkits could co-exist. John On Tue, Jun 15, 2010 at 8:13 AM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Martin, Mixing OpenGL apps/toolkits with the OSG requires one to be very careful about the state both the OSG side and the other OpenGL code side to make sure that neither interfere with each other. I've written about the issues plenty of times on osg-users so have a trawl through the archives. In general I would just recommend trying to avoid mixing is it certainly makes for an easier life alround. Robert. On Tue, Jun 15, 2010 at 2:05 PM, Martin Scheffler osgfo...@tevs.eu wrote: Some notes: The captureCurrentState command never catches any states. In OSG head, the camera does not even have a state. The push/popClientAttribute method causes problems with terra page terrain rendering. When I include it, the GUI looks good, but the terrain is screwed up. Adding glEnableClientState(GL_VERTEX_ARRAY) makes the terrain visible, but the texture coordinates seem to be broken. When I don't include the client attribute stuff then the Qt GUI becomes warped at some specific camera angles. Any ideas? Thank you! Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=28948#28948 ___ 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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Best place to update application items
This raises the question, when running in the different threading modes, ThreadPerContext, etc., is it safe to modify the graph in the update traversals or could there be a rendering thread working on the graph? I would assume the update phase is safe from conflict, but it's not clear. John On Fri, Mar 26, 2010 at 4:53 AM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Brad, On Thu, Mar 25, 2010 at 8:17 PM, Brad Colbert bcolb...@rscusa.com wrote: Where is the best place to update application level things before the frame is drawn? (ie. network reads/writes, model updates, text setting... ) The answer will depend upon your viewer/application and the scene graph you are trying to modify. The OSG has a update traversal that calls update callbacks on node, drawables, statesets and stateattributes so you could attach an update callback for this. There is also support for in osgViewer::Viewer/CompositeViewer for attaching a custom osg::Operation that called on every fame. You simply subclass form osg::Operation and implement the virtual void operator () method, then attach this via viewer.addUpdateOperation(pointerToMyOperation); Finally you have control over the frame loop in you application so outside of calling viewer.frame() you can do you updates. If you are presently using viewer.run() for the frame loop you can break it down in to it's constituent parts (have a look at the source code): viewer.run() is equivialant to : viewer.realize(); while(!viewer.done()) { viewer.frame(); } Which can be further broken down in to: viewer.realize(); while(!viewer.done()) { viewer.advance(); viewer.eventTraversal(); viewer.updateTraversal(); viewer.renderingTraversals(); } You can place you own update could into these frame loops where you find appropriate. Another possible route is to subclass from osgViewer::Viewer/CompositeViewer and override the updateTraversal() method then frame() or run() will call the you own code. Finally, in you are doing IO operations then you are typically best to put these in an separate thread than one that runs the frame loop as IO operations can be prone to high latencies that can cause frame breaks. Robert. ___ 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
Re: [osg-users] Multi Projector edge blend and bend (distortion correction)
Robert- I'm glad this topic was brought up. I am doing some work with non-linear distortion correction and have taken the code in osgViewer for doing the spherical distortion and made it more generic to accept a grid of points that represent the distortion mesh. This is just what the spherical distortion routines are doing in osgViewer, except rather than computing the points, it takes a rectangular grid. What I would like to do is integrate this distortion code into osgViewer to allow for more generic distortion grids to be used. The existing spherical distortion routines could use this by computing the appropriate distortion grid and supplying that grid to this more general distortion generator. The result would be that the existing spherical distortion would still work, and more general distortion patterns can be given too. If you think this would be useful, let me know and I'll integrate the changes and make a patch. John On Wed, Mar 11, 2009 at 4:06 AM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Bino, The OSG only currently has distortion correction built in for spherical displays with a single projector. General distortion correction can be implemented on top of osgViewer in the same way as the I implemented the spherical display distortion correction - using a series of slave cameras that to a render to texture then a second distortion correction/edge blending pass for each of the displays. Robert. On Wed, Mar 11, 2009 at 7:06 AM, Albino Rodrigues b...@vrspace.com.au wrote: Hi, I was wondering if OSG has distortion correction built in for multi projector displays so that the edges blend nicely. I vaguely recall reading that OSG has built in support for this but can’t seem to find any information on it. (other than the post: http://www.mail-archive.com/osg-us...@openscenegraph.net/msg10361.html) Thanks in advance, Bino ___ 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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Multi Projector edge blend and bend (distortion correction)
I haven't thought through how the interface would look with osgViewer. In my external implementation, I do have a class that holds on to the distortion geometry and allows new meshes to be given to change the pattern (for dynamic calibration). One thought is to have an osgViewer::DistortionManager class that could be retrieved through an osgView::getDistortionmanager() accessor method. If a distortion system is created, it would be managed by the osgViewer::DistortionManager object and manipulated by getting that object through the osgViewer object. John On Wed, Mar 11, 2009 at 10:49 AM, Robert Osfield robert.osfi...@gmail.comwrote: Hi John, I'm certainly open to this approach - it's one I've considered for a while, so please post what code you have. Are you adding an extra class to manage the distortion correction? Robert. On Wed, Mar 11, 2009 at 3:10 PM, John Aughey j...@aughey.com wrote: Robert- I'm glad this topic was brought up. I am doing some work with non-linear distortion correction and have taken the code in osgViewer for doing the spherical distortion and made it more generic to accept a grid of points that represent the distortion mesh. This is just what the spherical distortion routines are doing in osgViewer, except rather than computing the points, it takes a rectangular grid. What I would like to do is integrate this distortion code into osgViewer to allow for more generic distortion grids to be used. The existing spherical distortion routines could use this by computing the appropriate distortion grid and supplying that grid to this more general distortion generator. The result would be that the existing spherical distortion would still work, and more general distortion patterns can be given too. If you think this would be useful, let me know and I'll integrate the changes and make a patch. John On Wed, Mar 11, 2009 at 4:06 AM, Robert Osfield robert.osfi...@gmail.com wrote: Hi Bino, The OSG only currently has distortion correction built in for spherical displays with a single projector. General distortion correction can be implemented on top of osgViewer in the same way as the I implemented the spherical display distortion correction - using a series of slave cameras that to a render to texture then a second distortion correction/edge blending pass for each of the displays. Robert. On Wed, Mar 11, 2009 at 7:06 AM, Albino Rodrigues b...@vrspace.com.au wrote: Hi, I was wondering if OSG has distortion correction built in for multi projector displays so that the edges blend nicely. I vaguely recall reading that OSG has built in support for this but can’t seem to find any information on it. (other than the post: http://www.mail-archive.com/osg-us...@openscenegraph.net/msg10361.html) Thanks in advance, Bino ___ 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 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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] cast ray into scene
For my application, I use this function to extract the origin and the direction of a 2d point on the screen. My windowing system here is Qt. I can't say this is the most efficient way to get the answer, but it works. void QOpenSceneGraph::xyVector(const QPoint screenpoint, osg::Vec3d origin, osg::Vec3d direction) { osg::Matrix mat = osg::Matrix::inverse(m_SceneView-getProjectionMatrix()); osg::Matrix cameramatrix = this-getCameraMatrix(); osg::Matrix cameramatrixnotrans = cameramatrix; cameramatrixnotrans.setTrans(0,0,0); osg::Vec4d d = osg::Vec4( ((double)screenpoint.x() / (double)this-width()) * 2.0 - 1.0, -(((double)screenpoint.y() / (double)this-height()) * 2.0 - 1.0), 0.0,1.0); d = d * mat; d = d * cameramatrixnotrans; direction.set(d[0],d[1],d[2]); direction.normalize(); origin = cameramatrix.getTrans(); } On Mon, Mar 9, 2009 at 2:31 PM, Ben Axelrod baxel...@coroware.com wrote: I have been using osgUtil::PickVisitor for a while now to pick objects in my tree under the mouse. But now I need to cast a ray into the scene under the mouse and manually intersect it with an imaginary plane. Is there some helper function to do this mouse ray cast for me? Specifically, something that would take as input 2 ints for the position of the mouse, and maybe the camera or projection and view matrices, then output a vector? Thanks, -Ben ___ 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] Views 1 frame out-of-sync
I have a problem with 2 independent view windows getting out of sync in a multi-channel system. Bear with me while I explain the configuration. My current test system is one machine with 2 nVidia Quadro FX 4600 graphics cards. These cards are genlocked with the GSync2 option card. Each video card renders one half of a video frame which is then combined in the display hardware. My test scene is nothing but a spinning cube with 5 black faces and 1 white face. Each frame the cube is rotated 90 degrees showing 3 frames of black and 1 frame of white. GL is synced to VBLANK with the __GL_SYNC_TO_VBLANK environment variable. The behavior I'm seeing is when the program first starts the top and bottom half are in perfect sync. What is displayed is 3 frames of black and 1 frame of white producing a seizure-enducing strobe effect. However, after a short period of time (5-10 seconds), the bottom half (second video card) is 1 frame behind the top half. Visually you see the top half strobe slightly before the bottom half (verified with light sensors and a scope). The CPU load is very low (extremely simple scene). I am running in SIngleThreaded mode, and the threading mode doesn't seem to effect the problem. I have had this same problem where the two graphics cards were split across two different machines (2 computers, 2 graphics cards, genlocked with gsync2). In the scene, you will see the two halves looking as they should then after a while you'll see the two halves torn by 1 frame, then after a while they appear to re-sync back up (somewhat dependent on scene content). But while they are split, the system still runs at 60Hz so it is not in a constant overload condition. I believe the problem may lie in the rendering pipeline on the graphics card, and I need to figure out how to keep multiple pipelines in sync with each other. Has anyone else had this problem or knows what I can do to address this synchronization problem? Thank you John ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org