View Full Version : backface culling.

willmoores

04-15-2002, 11:45 AM

Hi, I've been playing around with OpenGL over the past few days and have stumbled accross a problem. Backface culling. It's awfully difficult to get all your vertices to be in anti-clockwise order just to specify which direction the tri/quad is facing..are there any easier ways of doing it? (like using glNormal3f() instead? I tried this, but it didn't work. Surely, it would be much fast since OpenGL wont have to calculate dot+cross product for everything).

>> It's awfully difficult to get all your vertices to be in anti-clockwise order just to specify which direction the tri/quad is facing.

<<

u must supply the vertices in the correct order yourself

Subject 2.07: How do I find the orientation of a simple polygon?

from the comp.graphics.algorithms faq

Compute the signed area (Subject 2.01). The orientation is

counter-clockwise if this area is positive.

A slightly faster method is based on the observation that it isn't

necessary to compute the area. Find the lowest vertex (or, if

there is more than one vertex with the same lowest coordinate,

the rightmost of those vertices) and then take the cross product

of the edges fore and aft of it. Both methods are O(n) for n vertices,

but it does seem a waste to add up the total area when a single cross

product (of just the right edges) suffices. Code for this is

available at ftp://cs.smith.edu/pub/code/polyorient.C (2K).

The reason that the lowest, rightmost (or any other such extreme) point

works is that the internal angle at this vertex is necessarily convex,

strictly less than pi (even if there are several equally-lowest points).

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.