Whoops, forgot to attach.
MONDAY... *sigh*
On Mon, 2008-11-03 at 09:48 -0500, Jeremy Moles wrote:
> Here's a quick example you can use to play around with RenderBin
> settings; notice how you can make one object appear "on top" of another,
> just by changing the binNum.
>
> I'm not sure if this is a worth examples addition, but perhaps.
>
> On Mon, 2008-11-03 at 15:19 +0100, Peter Wraae Marino wrote:
> > thanks, this helped.
> >
> > the nested makes perfect sense..
> > i'm on track again,
> >
> > once again thanks,
> > peter
> >
> >
> > On Mon, Nov 3, 2008 at 3:06 PM, Lionel Lagarde
> > <[EMAIL PROTECTED]> wrote:
> > Hi Peter,
> >
> >
> > Peter Wraae Marino wrote:
> > > Hi Users,
> > >
> > > trying to clarify some specs on the renderbin, perhaps
> > > someone could help:
> > >
> > > what I'm assuming:
> > > -there are two default renderbins created at startup
> > > "RenderBin" and "DepthSortedBin"
> > > -"DepthSortedBin" is always render after "RenderBin"
> > > -"DepthSortedBin" sorts objects from back to front
> > > -higher renderbin number means rendering is done later
> > > -renderbins are sorted by states
> > >
> > > what I'm asking:
> > > -if an object has a parent osg::Group that has been set to
> > > "RenderBin" with a value of 10 and the object itself uses
> > > "RenderBin" with a value of 20 then which is used?
> >
> >
> > RenderBins are nested. If a node has a bin number different
> > from the current render bin (or its StateSet render bin mode
> > is set
> > to override), a new render bin is created and is added to the
> > current render bin. It become the current render bin.
> >
> > So, if a node has a bin number of 20 and it is different from
> > the current bin number, a render bin 20 is added to the
> > current
> > render bin.
> >
> >
> > > -an .osg file can have renderbin values too? so if I load
> > > an .osg file and set it to have "RenderBin" 10 do I override
> > > the renderbin values
> > > in the file? or are they pushed relative to my given value
> > > 10? sometimes the .osg file consist of many renderbin
> > > values.
> > >
> > >
> >
> >
> > An osg file can contain render bin values. If you load an osg
> > file and set the render bin number of the root node to 10, you
> > don't
> > override the render bin numbers of the nodes (or just the
> > render bin number of the root node). Because render bins are
> > nested
> > during the scene culling, it will force the cull visitor to
> > create a specific render bin for the whole sub-graph.
> >
> > > --
> > > Regards,
> > > Peter Wraae Marino
> > >
> > > www.osghelp.com - OpenSceneGraph support site
> > >
> > >
> > > ____________________________________________________________
> > >
> > > _______________________________________________
> > > 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
> >
> >
> >
> >
> > --
> > Regards,
> > Peter Wraae Marino
> >
> > www.osghelp.com - OpenSceneGraph support site
> > _______________________________________________
> > 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 <osg/MatrixTransform>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
osg::Geometry* createGeometry(int renderBin, const osg::Vec4& color)
{
static osg::Vec3::value_type size = 1.0f;
osg::Geometry* geom = new osg::Geometry();
osg::Vec3Array* coords = new osg::Vec3Array(4);
osg::Vec4Array* colors = new osg::Vec4Array(1);
osg::Vec3Array* normals = new osg::Vec3Array(1);
(*coords)[0] = osg::Vec3(-size, 0.0f, -size);
(*coords)[1] = osg::Vec3(size, 0.0f, -size);
(*coords)[2] = osg::Vec3(size, 0.0f, size);
(*coords)[3] = osg::Vec3(-size, 0.0f, size);
(*colors)[0] = color;
(*normals)[0] = osg::Vec3(0.0f, -1.0f, 0.0f);
geom->setVertexArray(coords);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, 4));
geom->getOrCreateStateSet()->setRenderBinDetails(renderBin, "RenderBin");
size += 1.0f;
return geom;
}
int main(int argc, char** argv)
{
osgViewer::Viewer viewer;
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
osg::Group* group = new osg::Group();
osg::Geode* geode1 = new osg::Geode();
osg::Geode* geode2 = new osg::Geode();
osg::MatrixTransform* trans = new osg::MatrixTransform();
// It's important that we disable DEPTH_TEST here for our purposes.
geode1->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, false);
geode1->getOrCreateStateSet()->setRenderBinDetails(2, "RenderBin");
geode2->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, false);
geode2->getOrCreateStateSet()->setRenderBinDetails(1, "RenderBin");
// Add the drawables on the same Y plane...
geode1->addDrawable(createGeometry(3, osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f)));
geode1->addDrawable(createGeometry(2, osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f)));
geode1->addDrawable(createGeometry(1, osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f)));
geode2->addDrawable(createGeometry(3, osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f)));
geode2->addDrawable(createGeometry(2, osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f)));
geode2->addDrawable(createGeometry(1, osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f)));
trans->setMatrix(osg::Matrix::translate(8.0f, 0.0f, -8.0f));
trans->addChild(geode2);
group->addChild(geode1);
group->addChild(trans);
viewer.setSceneData(group);
return viewer.run();
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org