Пример #1
0
    /**
     * Decides if this polygon is a 'back face'. A back face is a polygon that is facing away from
     * the camera and therefore should not be drawn. If this polygon is double sided then it can not
     * be a back face. In such a case this routine has the side effect of ensuring that the normal
     * points towards the camera eye rather than away from it.
     *
     * @see Obj3d#draw(Graphics)
     */
    boolean isBackFace(final float[] eye) {

      if (dirtyNormal) {
        setNormal();
      }

      p[0] = ps[points[0]];
      p[1] = ps[points[0] + 1];
      p[2] = ps[points[0] + 2];

      Tools3d.subtract(p, eye, ray);

      if (doubleSided) {
        // flip the normal if necessary so this is NOT a backface
        if (Tools3d.dot(normal, ray) >= 0) {
          Tools3d.scaleBy(normal, -1);
        }
        return false;
      } else {
        return (Tools3d.dot(normal, ray) >= 0);
      }
    }