Hi Dirk,
> Hi Toni,
>
> Antonio Bleile wrote:
> > Hi,
> >
> > I'd like to query some occlusions with OpenSG... I don't know
> > if there's any support for this in OpenSG. I'd like to render
> > a set of points and query their visibility using some OpenGL
> > query extension. I know how to do that in OpenGL, but I
> > don't know if I can map that somehow into OpenSG. Here's
> > a typical loop:
> >
> > Gluint queries[N];
> > GLuint pixelCount;
> > glGenOcclusionQueriesNV(N, queries);
> >
> >
> > for (i = 0; i < N; i++) {
> > glBeginOcclusionQueryNV(queries[i]);
> > // render point i
> > glEndOcclusionQueryNV();
> > }
> >
> > // evaluate visibility...
> >
> > Any hints?
>
> A query for each point? That sounds fairly expensive. In that form there
Well, I'll have to see if it's fast enough for me :-)
> is not support directly in OpenSG. You could use the OpenSG extension
> handling methods if you wanted to, but other than that I don't see what
> we could do to help. On the other hand, running through a bunch of
> points doesn't seem that hard, your code up there is pretty much it,
> unless I missed something. ;) You can use it with a PassiveWindow before
> calling swap, and it should work just fine.
What I do now i sto use a custom RenderAction where I attach a
EnterFunction. All I need is to get the right transformation matrices
when I draw the points for the occlusion test:
Here's some code:
// setup the RenderAction
rActPoints = RenderAction::create();
rActPoints->setWindow( static_cast<Window*>(gwin.getCPtr()) );
rActPoints->registerEnterFunction(OSG::Geometry::getClassType(),
osgTypedFunctionFunctor2CPtrRef<
Action::ResultE,
CNodePtr,
Action *>(renderPoints));
//And here is the implementation of renderPoints:
OSG::Action::ResultE renderPoints( OSG::CNodePtr &, OSG::Action * action )
{
RenderAction *ra = dynamic_cast<RenderAction*>(action);
OSG::NodePtr node = action->getActNode();
GeoPositions3fPtr vertices;
unsigned int nVertices = 0;
osg::GeometryPtr geo = osg::GeometryPtr::dcast(node->getCore());
if (geo!=NullFC)
{
vertices = osg::GeoPositions3fPtr::dcast(geo->getPositions());
nVertices = vertices->size();
GLuint *queries = new GLuint[nVertices];
glGenQueriesARB(nVertices, queries);
for( unsigned int i = 0; i < nVertices; ++i ){
osg::Pnt3f p = vertices->getValue(i);
glBeginQueryARB(GL_SAMPLES_PASSED_ARB, queries[i]);
glBegin(GL_POINTS);
glVertex3f( (float)p[0], (float)p[1], (float)p[2]);
glEnd();
glEndQueryARB(GL_SAMPLES_PASSED_ARB);
}
int count = 42;
for( unsigned int i = 0; i < nVertices; ++i ){
glGetQueryObjectivARB( queries[i], GL_QUERY_RESULT_ARB, &count
);
printf( "visible %d\n", count );
}
glDeleteQueriesARB(nVertices,queries);
delete queries;
}
return Action::Continue;
}
Any objections?
Regards,
Toni
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users