Advertisement

3d Backface culling

Started by December 19, 2000 03:53 AM
0 comments, last by Theo 23 years, 11 months ago
I am stuck with this problem at the moment. I''m trying to order my vertixes so that OpenGL can do backface culling for me, I can''t specify my points in order manually because my code just doesn''t work like that. The points need to be reordered programatically automatically. For example, my GLCuboidObj can accept just two points, a width float and height float. It builds all the GLQuad3dObj ''s with their vertexes all in the right place. But what it can''t know YET, is how to order the vertexes for backface culling. This is what I''m completely stuck on. What I want is to reorder my polygons to be drawn in the clockwise order (or reverse, I forget which but its not important right now as its simple to change) when they have their front face viewed. I don''t actually have them drawn in that order at the moment, and I need to adapt the code so that I can take 2 triangles, and let the code reorder the points of both of them so that they are both drawn as opposite sides of an object. I thought I could do it with dot product, but unfortunately dot product never returns an angle bigger than 180, so I can''t tell which direction two vectors starting from the origin are winded at. Unless perhaps you know of a way to find the winding angle even if its bigger than 180? Screen coordinates don''t come into this of course. Manual culling I''ll leave to OpenGL. Thanks for your time
have a search for how to workout which way a poly is oriantated

from memory its someit like so if its under 1 then the backface is facing the camera
(polygon normal) DOTPRODUCT ( cameraposition )

http://members.xoom.com/myBollux

This topic is closed to new replies.

Advertisement