osgUtil/CullVisitor.cpp line 644-645: // whole object behind the eye point so discard return false;
Perhaps its not called "culling" in this case but my code hits this return statement and as a result, the drawable is not added to the StateGraphList in RenderBin. OpenGL is never given a chance to clip. Frank On Fri, Nov 14, 2008 at 08:22:31PM +0000, Robert Osfield wrote: > Hi Frank, > > If culling is switched off then culling is off, the eye point will > make no difference. > > What difference you moving the eye point will be in the clipping due > to the position of near/far plane. > > Robert. > > On Fri, Nov 14, 2008 at 8:09 PM, <[EMAIL PROTECTED]> wrote: > > I think I figured it out. It looks like even with culling turned off, > > nodes that are behind the "eye point" are culled. See > > osgUtil/CullVisitor.cpp line 645. > > > > I now calculate the view matrix as follows. > > > > osg::Matrixd matrix = osg::Matrixd::translate( -center ); > > matrix.postMultRotate( osg::Quat( PI, osg::Vec3d( 1.0, 0.0, 0.0 ) ) ); > > matrix.postMultTranslate( osg::Vec3d( 0.0, 0.0, -0.5 ) ); > > > > Adding the last translation transform to push the nodes away from the > > "eye point" made the problem go away. > > > > Is this a bug? > > > > Frank > > > > On Thu, Nov 13, 2008 at 11:38:14AM -0500, [EMAIL PROTECTED] wrote: > >> Hi Robert, > >> > >> Thanks for the quick response. That was a good suggestion. However it > >> looks like that is not the problem. All of my nodes live on the z=0.0 > >> plane and my projection matrix is > >> > >> osg::Matrixd::ortho( -aspectRatio, aspectRatio, -1.0, 1.0, -1.0, 1.0 ) > >> > >> I have attached a small code sample that exhibits the problem. > >> > >> Frank > >> > >> On Thu, Nov 13, 2008 at 04:24:37PM +0000, Robert Osfield wrote: > >> > Hi Frank, > >> > > >> > My best guess is that your projection matrix isn't wide enough to > >> > encompass your scene and near/far clipping is clipping out the > >> > fragments. This may well look like culling, often users do mistake > >> > clipping with culling so chase up the wrong part of the pipeline. > >> > > >> > Robert. > >> > > >> > On Thu, Nov 13, 2008 at 4:18 PM, <[EMAIL PROTECTED]> wrote: > >> > > Greetings osg community, > >> > > > >> > > I'm have written a custom MatrixManipulator for a 2D scene and I am > >> > > experiencing a strange problem. As I pan and zoom around, some of the > >> > > nodes in the scene disappear abruptly as if they are being culled > >> > > inappropriately. However, disabling culling has no effect. > >> > > > >> > > The behavior is erratic and unpredictable which smells to me like I'm > >> > > on > >> > > the border of a floating point inequality. I have discovered two ways > >> > > that seem to make the problem go away. > >> > > > >> > > One: > >> > > > >> > > One of the transformations I use to construct the view matrix is > >> > > > >> > > osg::Matrixd::rotate( osg::Quat( PI, osg::Vec3d( 1.0, 0.0, 0.0 ) ) ) > >> > > > >> > > If I replace that with > >> > > > >> > > osg::Matrixd::scale( osg::Vec3d( 1.0, -1.0, 1.0 ) ) > >> > > > >> > > the problem seems to go away. > >> > > > >> > > Two: > >> > > > >> > > All of the nodes in my seen that exhibit this problem have a 2D > >> > > bounding box. i.e. > >> > > > >> > > osg::BoundingBox const & bb = pGeode->getBoundingBox(); > >> > > assert( bb.zMax() - bb.zMin() < 1e-5 ); > >> > > > >> > > If I give the nodes some depth so that the above assert would fail, > >> > > the problem seems to go away. > >> > > > >> > > I suspect that these are not actual solutions. In any case, I would > >> > > like > >> > > to understand what is happening under the covers. Any ideas? > >> > > > >> > > Frank > >> > > > >> > > _______________________________________________ > >> > > osg-users mailing list > >> > > [email protected] > >> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > >> > > > >> > _______________________________________________ > >> > osg-users mailing list > >> > [email protected] > >> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > >> > >> #include <osg/Geode> > >> #include <osg/Geometry> > >> #include <osgViewer/Viewer> > >> > >> #include <iostream> > >> #include <cassert> > >> > >> osg::ref_ptr< osg::Node > CreateGraph() > >> { > >> osg::ref_ptr< osg::Geode > pGeode = new osg::Geode(); > >> osg::ref_ptr< osg::Geometry > pGeometry = new osg::Geometry(); > >> pGeode->addDrawable( pGeometry.get() ); > >> > >> // Vertices > >> osg::ref_ptr< osg::Vec3Array > pVerts = new osg::Vec3Array( 4 ); > >> (*pVerts)[ 0 ] = osg::Vec3( 0.0, 0.0, 0.0 ); > >> (*pVerts)[ 1 ] = osg::Vec3( 1.0, 0.0, 0.0 ); > >> (*pVerts)[ 2 ] = osg::Vec3( 1.0, 1.0, 0.0 ); > >> (*pVerts)[ 3 ] = osg::Vec3( 0.0, 1.0, 0.0 ); // dosen't work > >> //(*pVerts)[ 3 ] = osg::Vec3( 0.0, 1.0, 0.1 ); // works as expected > >> pGeometry->setVertexArray( pVerts.get() ); > >> > >> pGeometry->addPrimitiveSet( new osg::DrawArrays( > >> osg::PrimitiveSet::QUADS, 0, 4 ) ); > >> > >> osg::ref_ptr< osg::Vec4Array > pColors = new osg::Vec4Array( 4 ); > >> (*pColors)[ 0 ] = osg::Vec4( 1.0f, 1.0f, 1.0f, 1.0f ); > >> (*pColors)[ 1 ] = osg::Vec4( 1.0f, 0.0f, 0.0f, 1.0f ); > >> (*pColors)[ 2 ] = osg::Vec4( 0.0f, 1.0f, 0.0f, 1.0f ); > >> (*pColors)[ 3 ] = osg::Vec4( 0.0f, 0.0f, 1.0f, 1.0f ); > >> pGeometry->setColorArray( pColors.get() ); > >> pGeometry->setColorBinding( osg::Geometry::BIND_PER_VERTEX ); > >> > >> osg::ref_ptr< osg::StateSet > pState = pGeode->getOrCreateStateSet(); > >> pState->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); > >> > >> osg::BoundingBox const & bb = pGeode->getBoundingBox(); > >> std::cout > >> << "BoundingBox = (" > >> << bb.xMin() << "," > >> << bb.yMin() << "," > >> << bb.zMin() << "," > >> << bb.xMax() << "," > >> << bb.yMax() << "," > >> << bb.zMax() << ")" > >> << std::endl; > >> > >> return pGeode.get(); > >> } > >> > >> int main( int argc, char * argv[] ) > >> { > >> int const x = 100; > >> int const y = 100; > >> int const w = 800; > >> int const h = 800; > >> > >> osg::ref_ptr< osg::GraphicsContext::Traits > pTraits = new > >> osg::GraphicsContext::Traits(); > >> pTraits->x = x; > >> pTraits->y = y; > >> pTraits->width = w; > >> pTraits->height = h; > >> pTraits->windowDecoration = true; > >> pTraits->doubleBuffer = true; > >> pTraits->sharedContext = 0; > >> > >> osg::ref_ptr< osg::GraphicsContext > pContext = > >> osg::GraphicsContext::createGraphicsContext( pTraits.get() ); > >> assert( pContext.valid() ); > >> > >> osgViewer::Viewer viewer; > >> > >> viewer.getCamera()->setGraphicsContext( pContext.get() ); > >> viewer.getCamera()->setClearColor( osg::Vec4( 0.0, 0.0, 0.0, 1.0 ) ); > >> viewer.getCamera()->setViewport( new osg::Viewport( 0, 0, w, h ) ); > >> viewer.getCamera()->setGraphicsContext( pContext.get() ); > >> viewer.getCamera()->setCullingMode( osg::CullSettings::NO_CULLING ); > >> > >> double const aspectRatio = double(w)/double(h); > >> //osg::Matrixd ortho = osg::Matrixd::ortho2D( -aspectRatio, aspectRatio, > >> -1.0, 1.0 ); > >> osg::Matrixd ortho = osg::Matrixd::ortho( -aspectRatio, aspectRatio, > >> -1.0, 1.0, -1.0, 1.0 ); > >> viewer.getCamera()->setProjectionMatrix( ortho ); > >> > >> osg::ref_ptr< osg::Node > pGraph = CreateGraph(); > >> > >> viewer.setSceneData( pGraph ); > >> > >> viewer.realize(); > >> > >> int n = 0; > >> int const N = 4000; // adjust for your computer speed > >> osg::Vec3d const initialCenter( 0.5, 0.5, 0.0 ); > >> > >> while ( !viewer.done() ) > >> { > >> n = ( n + 1 ) % N; > >> double d = -double(n)/double(N); > >> > >> osg::Vec3d center = initialCenter + osg::Vec3d( 0.0, d, 0.0 ); > >> //std::cout > >> // << "center = (" > >> // << center[0] << "," > >> // << center[1] << "," > >> // << center[2] << ")" > >> // << std::endl; > >> > >> osg::Matrixd matrix = osg::Matrixd::translate( -center ); > >> > >> // doesn't work > >> double const PI = 3.14159265; > >> matrix.postMultRotate( osg::Quat( PI, osg::Vec3d( 1.0, 0.0, 0.0 ) ) ); > >> > >> // works as expected, but left handed coordinate system is not desired > >> //matrix.postMultScale( osg::Vec3d( 1.0, -1.0, 1.0 ) ); > >> > >> viewer.getCamera()->setViewMatrix( matrix ); > >> > >> viewer.frame(); > >> } > >> > >> return 0; > >> } > >> > > > >> _______________________________________________ > >> osg-users mailing list > >> [email protected] > >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > > _______________________________________________ > > osg-users mailing list > > [email protected] > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

