[vtkusers] question about vertex ordering

David Doria daviddoria+vtk at gmail.com
Fri Nov 6 11:08:34 EST 2009


On Fri, Nov 6, 2009 at 11:02 AM, Luca Pamparana <luca.pamparana at gmail.com>wrote:

> Hello,
>
> I have a question about vertex ordering. I am creating a cube where
> one of the faces is created by various polygons and they will have
> alternate colours.
>
> An example list of points are as follows:
>
> -1.5 0 -3 // point ID 0
> -1.5 4 -3 // point ID 1
> -1.5 0 -2.2 // point ID 2
> -1.5 4 -2.2 // point ID 3
>
> -1.5 0 -2.2
> -1.5 4 -2.2
> -1.5 0 -1.4
> -1.5 4 -1.4
>
> -1.5 0 -1.4
> -1.5 4 -1.4
> -1.5 0 -0.6
> -1.5 4 -0.6
>
> -1.5 0 -0.6
> -1.5 4 -0.6
> -1.5 0 0.2
> -1.5 4 0.2
>
> -1.5 0 0.2
> -1.5 4 0.2
> -1.5 0 1
> -1.5 4 1
>
> And I fill each of these polygons with various colours using a
> vtkActor As you can see they represent the left wall of a cube
> (constant in x). Now, when I arrange the points in clockwise direction
> (when viewing from inside the room) as (0, 2, 3, 1). I do not see the
> colours. The panels get drawn as black boxes. However, when I arrange
> them counterclockwise (0, 1, 3, 2), the colours show up fine.
>
> Can someone tell me why this is the case??
>
> Thanks,
>
> Luca
>

I believe this is because the lighting calculation OpenGL is doing depends
on the direction of the normal. If you specify the points in one order, the
normal of the polygon is facing one direction, but if you specify the points
in the reverse order, the normal gets flipped. If the normal is not pointing
towards the light source it will show up as black. I'm certain their is a
VTK call to say "render back faces" or something similar? Or maybe someone
can show you how to add an ambient light source / another light source?

Good luck,

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091106/fd374bf1/attachment.htm>


More information about the vtkusers mailing list