Hi,
I'm trying to integrate OpenCSG into my OSG Project since a couple of
days.
For that I need 2 compiled OpenGL Display Lists. After that the OpenCSG
rendering should be called to do some awesome stuff, like intersecting
these
two Shapes. Finally glCallList should be done.
Unfortunately Drawable::draw does compiling and list calling in one
method,
so there is no way to put call my OpenCSG::render method after the
compilation.
Then I found the compileGLObjects which does what I want. But I don't
know how
to call it (where do I get the needed RenderInfo from).
That's how I'm doing at the moment...
void Level::addCuboid(osg::Vec3 from, osg::Vec3 to)
{
osg::ShapeDrawable *s1, *s2;
osg::Vec3 center = osg::Vec3(
0.5 * (from.x() +
to.x()),
0.5 * (from.y() +
to.y()),
0.5 * (from.z() +
to.z()));
float width = fabs(from.x() - to.x());
float depth = fabs(from.y() - to.y());
float height = fabs(from.z() - to.z());
s1 = new osg::ShapeDrawable(new osg::Box(center, width, depth,
height));
s2 = new osg::ShapeDrawable(new osg::Box(center, width-10.0f, depth
+10.0f, height-1.0f));
node->addDrawable(s1);
node->addDrawable(s2);
s1->setDrawCallback(new ShapeDrawableCallback(&primitives,
OpenCSG::Intersection, 1));
s2->setDrawCallback(new ShapeDrawableCallback(&primitives,
OpenCSG::Subtraction, 1));
}
My callback:
virtual void
ShapeDrawableCallback::drawImplementation(osg::RenderInfo&
renderInfo,const osg::Drawable* drawable) const
{
primitives->push_back(new OpenCSG::DisplayListPrimitive(drawable-
>getDisplayList(renderInfo.getContextID()), operation, _c));
drawable->drawImplementation(renderInfo);
}
After compiling the shapes I'd need OpenCSG::render(primitives) to be
called. And then drawing (glCallList)
could happen. Hope, that someone could help me :(
Cheers,
Robert
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org