1
$\begingroup$

I have a series of faces that describe a 3-d solid. If I draw these faces, I've drawn the solid (my light source is at infinity). Except, for most of the solids I'm drawing (platonic solids and tetartoid so far), only half the total faces are visible from any angle. Now, I'm capturing the solid from the "front" and rotating it. The question is, how do I decide which faces are visible (and should be rendered) and which ones are behind the solid and should not be rendered. I must say, this problem has proven to be considerably harder than I imagined. I thought I'd take the cross product of two edges of the solid and see if it's positive. But, if I just reverse the order of the vectors in the cross product, the sign flips. I also tried taking the center of each face and seeing if it's z-coordinate (my camera is at infinite z) is positive or negative. This worked quite well for platonic solids where all the faces are regular. However, it didn't work for a tetartoid where the faces are irregular (see below).

enter image description here

$\endgroup$
1
$\begingroup$

What you want to do is "Back Face Culling":

https://en.m.wikipedia.org/wiki/Back-face_culling

For that to work all faces of your solid must have the same orientation. That means the vertices of each polygon must be either in clockwise order (CW) or counter clockwise order (CCW). The convention is CCW order so all normal vectors points to the "outside" of the convex polygon.

$\endgroup$
1
$\begingroup$

Here is how I solved it (Mauricio's answer was a great help). The trick was to ensure the planes had points oriented the same way (when looking from outside the solid). So, I took the corss product of the first edge with the second edge. Then, I saw if the cross product of the resulting vector with the vector connecting the center of the solid to the center of the plane was >0. If not, I flipped the order of the plane vertices. With this, things seem to work as shown below.enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.