question about vertex ordering

View: New views
2 Messages — Rating Filter:   Alert me  

question about vertex ordering

by luca.pamparana :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

Re: question about vertex ordering

by David Doria-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Nov 6, 2009 at 11:02 AM, Luca Pamparana <luca.pamparana@...> 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

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers