[vtkusers] (ab)using vtkRenderer in foreign scene graph - help needed

Mark Asbach mark.asbach at post.rwth-aachen.de
Tue Nov 25 05:38:44 EST 2003


Hi list,

we're using a foreign VR toolkit that implements its own scene graph, 
lighting, camera positions and lighting. Since we want to integrate vtk 
visualization, we're forced to (ab)use vtk's OponGL renderering 
facilities. Currently, when we get to the OpenGL node where we want to 
draw the vtkActors, we do the following:


bool Vista::DrawDisplayObjects ()
{
   vtkActor * actor = 0;

   // the OpenGL node doesn't push the attributes, so we do it instead...
   glPushAttrib(GL_ALL_ATTRIB_BITS);

   // it's necessary to specify GL_NORMALIZE because vtk vertices seem 
to have
   // wrong (meaning: not of length 1 and correct orientation) normals
   // which otherwise would break the lighting
   glEnable(GL_NORMALIZE);

   // render opaque props first
   this->actors->InitTraversal();
   actor = this->actors->GetNextActor();
   while (actor)
   {
     actor->RenderOpaqueGeometry (this->renderer);
     actor = this->actors->GetNextActor();
   }

   // start a second loop for translucent props (if any!)
   this->actors->InitTraversal();
   actor = this->actors->GetNextActor();
   while (actor)
   {
     actor->RenderTranslucentGeometry (this->renderer);
     actor = this->actors->GetNextActor();
   }

   // restore OpenGL state
   glPopAttrib();

   return true;
}


As you can see, I've had problems with the lighting, that I could solve 
by enabling GL_NORMALIZE. Unfortunately, this works for opaque 
geometries only. When I try to render geometries that are translucent, 
I get strange results and culling doesn't work the way I'd expect it 
to.

This might be due to the fact that vtkRenderer invokes the 
vtkFrustrumCuller before rendering the props. Unfortunately, 
vtkFrustrumCuller needs an active vtkCamera to be set - which I don't 
have because cameras are handled by the foreign scene graph that only 
lets me "plug in" a node.

What would I need to do to get the rendering done correctly from the 
foreign scene graph?

Thanks in advance,

Mark





More information about the vtkusers mailing list