[vtkusers] Using cell colors with point normals (was: Getting vtkPolyDataRenderer to use both cell data and point data)

Ron Inbar ron at eun.co.il
Wed Jul 19 06:34:51 EDT 2000


Hello again,

I didn't get any replies to my post from a couple of days ago, so maybe it
wasn't clear enough.  I'll try to rephrase it:  I want to render a smooth
polygonal surface with certain polygons marked out in a distinct color.  If
you already know how to achieve this effect, please reply.  Otherwise, read
on.

To make the surface look smooth I need to use vertex normals rather than
polygon normals.  On the other hand, polygon colors have to be based on cell
data to give the entire polygon the same hue (only the intensity should be
interpolated).

The OpenGL display list should look like this:

glEnable(GL_COLOR_MATERIAL);

glBegin(GL_TRIANGLES);
glColor3fv(/* cell 1 color */);
glNormal(/* point 1 normal */);
glVertex3f(/* point 1 coordinates */);
glNormal(/* point 2 normal */);
glVertex3f(/* point 2 coordinates */);
glNormal(/* point 3 normal */);
glVertex3f(/* point 3 coordinates */);
glColor3fv(/* cell 2 color */);
glNormal(/* point 2 normal */);
glVertex3f(/* point 2 coordinates */);
glNormal(/* point 3 normal */);
glVertex3f(/* point 3 coordinates */);
glNormal(/* point 4 normal */);
glVertex3f(/* point 4 coordinates */);
glColor3fv(/* cell 1 color */);
....
glEnd();

I couldn't get the renderer to behave this way.  When I use
SetScalarModeToUseCellData() I get a flat-shaded image, probably because the
renderer uses cell normals in addition to cell scalars.  When I use
SetScalarModeToUsePointData() I get a Gouraud-shaded image, but the colors
are also interpolated so I don't get distinct polygon boundaries.

Is it possible to achieve the behavior I need in vtk?  If so, how?
Otherwise, how can I add it in the code?

Thanks in advance,

Ron






More information about the vtkusers mailing list