void draw_cut_style_cap_callback (int iloop,
                                  double cap[][3],
                                  float face_color[3],
                                  gleDouble cut_vector[3],
                                  gleDouble bisect_vector[3],
                                  double norms[][3],
                                  int frontwards)
{
    int i;

    if (face_color != NULL) C3F (face_color);

    if (frontwards) {

        /* if lighting is on, specify the endcap normal */
        if (cut_vector != NULL) {
            /* if normal pointing in wrong direction, flip it. */
            if (cut_vector[2] < 0.0) {
                VEC_SCALE (cut_vector, -1.0, cut_vector);
            }
            N3F_D (cut_vector);
        }
        BGNPOLYGON();
        for (i=0; i<iloop; i++) {
            V3F_D (cap[i], i, FRONT_CAP);
        }
        ENDPOLYGON();
    } else {

        /* if lighting is on, specify the endcap normal */
        if (cut_vector != NULL) {
            /* if normal pointing in wrong direction, flip it. */
            if (cut_vector[2] > 0.0)
            {
                VEC_SCALE (cut_vector, -1.0, cut_vector);
            }
            N3F_D (cut_vector);
        }
        /* the sense of the loop is reversed for backfacing culling */
        BGNPOLYGON();
        for (i=iloop-1; i>-1; i--) {
            V3F_D (cap[i], i, BACK_CAP);
        }
        ENDPOLYGON();
    }

}
void draw_angle_style_front_cap (int ncp,	/* number of contour points */
                           gleDouble bi[3],		/* biscetor */
                           gleDouble point_array[][3])	/* polyline */
{
    int	j;
#ifdef OPENGL_10
   GLUtriangulatorObj *tobj;
#endif /* OPENGL_10 */

   if (bi[2] < 0.0) {
      VEC_SCALE (bi, -1.0, bi); 
   }

#ifdef GL_32
   /* old-style gl handles concave polygons no problem, so the code is
    * simple.  New-style gl is a lot more tricky. */
   /* draw the end cap */
   BGNPOLYGON ();

   N3F (bi);
   for (j=0; j<ncp; j++) {
      V3F (point_array[j], j, FRONT_CAP);
   }
   ENDPOLYGON ();
#endif /* GL_32 */

#ifdef OPENGL_10
   N3F(bi);

   tobj = gluNewTess ();
   gluTessCallback (tobj, GLU_BEGIN, glBegin);
   gluTessCallback (tobj, GLU_VERTEX, glVertex3dv);
   gluTessCallback (tobj, GLU_END, glEnd);
   gluBeginPolygon (tobj);

   for (j=0; j<ncp; j++) {
      gluTessVertex (tobj, point_array[j], point_array[j]);
   }
   gluEndPolygon (tobj);
   gluDeleteTess (tobj);
#endif /* OPENGL_10 */
}
Exemple #3
0
static void
draw_cut_style_cap_callback (int iloop,
                                  double cap[][3],
                                  float face_color[3],
                                  gleDouble cut_vector[3],
                                  gleDouble bisect_vector[3],
                                  double norms[][3],
                                  int frontwards)
{
#ifdef DELICATE_TESSELATOR
   int i;
   int is_colinear;
   double *previous_vertex = 0x0;
   double *first_vertex = 0x0;
#endif /* DELICATE_TESSELATOR */

#ifdef OPENGL_10
   GLUtriangulatorObj *tobj;
   tobj = gluNewTess ();
   gluTessCallback (tobj, GLU_BEGIN, glBegin);
   gluTessCallback (tobj, GLU_VERTEX, glVertex3dv);
   gluTessCallback (tobj, GLU_END, glEnd);
#endif /* OPENGL_10 */

   if (face_color != NULL) C3F (face_color);

   if (frontwards) {

      /* if lighting is on, specify the endcap normal */
      if (cut_vector != NULL) {
         /* if normal pointing in wrong direction, flip it. */
         if (cut_vector[2] < 0.0) {
            VEC_SCALE (cut_vector, -1.0, cut_vector);
         }
         N3F_D (cut_vector);
      }
#ifdef GL_32
      BGNPOLYGON();
      for (i=0; i<iloop; i++) {
         V3F_D (cap[i], i, FRONT_CAP);
      }
      ENDPOLYGON();
#endif /* GL_32 */
#ifdef OPENGL_10

/* If you have a tesselator that is happy with anything,
 * including degenerate points, colinear segments, etc.
 * then define this. Otherwise, pick one of the others.
 *
 * I beleive that the stock SGI tesselator is "lenient",
 * despite explicit disclaimers in the documentation.
 * (circa 1995).
 *
 * The Mesa tesselator is not at all forgiving of
 * degenerate points.
 * (circa 1997-1998)
 */

#ifdef LENIENT_TESSELATOR
      gluBeginPolygon (tobj);
      for (i=0; i<iloop; i++) {
         gluTessVertex (tobj, cap[i], cap[i]);
      }
      gluEndPolygon (tobj);
#endif /* LENIENT_TESSELATOR */

#ifdef DELICATE_TESSELATOR
      gluBeginPolygon (tobj);

      first_vertex = 0x0;
      previous_vertex = cap[iloop-1];
      for (i=0; i<iloop-1; i++) {
         COLINEAR (is_colinear, previous_vertex, cap[i], cap[i+1]);
         if (!is_colinear) {
            gluTessVertex (tobj, cap[i], cap[i]);
            previous_vertex = cap[i];
            if (!first_vertex) first_vertex = previous_vertex;
         }
      }

      if (!first_vertex) first_vertex = cap[0];
      COLINEAR (is_colinear, previous_vertex, cap[iloop-1], first_vertex);
      if (!is_colinear) gluTessVertex (tobj, cap[iloop-1], cap[iloop-1]);

      gluEndPolygon (tobj);
#endif /* DELICATE_TESSELATOR */

#endif /* OPENGL_10 */
   } else {

      /* if lighting is on, specify the endcap normal */
      if (cut_vector != NULL) {
         /* if normal pointing in wrong direction, flip it. */
         if (cut_vector[2] > 0.0) {
            VEC_SCALE (cut_vector, -1.0, cut_vector);
         }
         N3F_D (cut_vector);
      }
      /* the sense of the loop is reversed for backfacing culling */
#ifdef GL_32
      BGNPOLYGON();
      for (i=iloop-1; i>-1; i--) {
         V3F_D (cap[i], i, BACK_CAP);
      }
      ENDPOLYGON();
#endif /* GL_32 */
#ifdef OPENGL_10

#ifdef LENIENT_TESSELATOR
      gluBeginPolygon (tobj);
      for (i=iloop-1; i>-1; i--) {
         gluTessVertex (tobj, cap[i], cap[i]);
      }
      gluEndPolygon (tobj);
#endif /* LENIENT_TESSELATOR */

#ifdef DELICATE_TESSELATOR
      gluBeginPolygon (tobj);

      first_vertex = 0x0;
      previous_vertex = cap[0];
      for (i=iloop-1; i>0; i--) {
         COLINEAR (is_colinear, previous_vertex, cap[i], cap[i-1]);
         if (!is_colinear) {
            gluTessVertex (tobj, cap[i], cap[i]);
            previous_vertex = cap[i];
            if (!first_vertex) first_vertex = previous_vertex;
         }
      }

      if (!first_vertex) first_vertex = cap[iloop-1];
      COLINEAR (is_colinear, previous_vertex, cap[0], first_vertex);
      if (!is_colinear) gluTessVertex (tobj, cap[0], cap[0]);

      gluEndPolygon (tobj);
#endif /* DELICATE_TESSELATOR */

#endif /* OPENGL_10 */
   }

#ifdef OPENGL_10
   gluDeleteTess (tobj);
#endif /* OPENGL_10 */

}
Exemple #4
0
/* ARGSUSED4 */
static void draw_cut_style_cap_callback (int iloop,
                                  double cap[][3], 
                                  float face_color[3],
                                  gleDouble cut_vector[3],
                                  gleDouble bisect_vector[3],
                                  double norms[][3], 
                                  int frontwards)
{
   int i;
#ifdef OPENGL_10
   GLUtriangulatorObj *tobj;
   tobj = gluNewTess ();
   gluTessCallback (tobj, GLU_BEGIN, (void (CALLBACK*)()) glBegin);
   gluTessCallback (tobj, GLU_VERTEX, (void (CALLBACK*)()) glVertex3dv);
   gluTessCallback (tobj, GLU_END, (void (CALLBACK*)()) glEnd);
#endif /* OPENGL_10 */

   if (face_color != NULL) C3F (face_color);

   if (frontwards) {

      /* if lighting is on, specify the endcap normal */
      if (cut_vector != NULL) {
         /* if normal pointing in wrong direction, flip it. */
         if (cut_vector[2] < 0.0) { 
            VEC_SCALE (cut_vector, -1.0, cut_vector); 
         }
         N3F_D (cut_vector);
      }
#ifdef GL_32
      BGNPOLYGON();
      for (i=0; i<iloop; i++) {
         V3F_D (cap[i], i, FRONT_CAP);
      }
      ENDPOLYGON();
#endif /* GL_32 */
#ifdef OPENGL_10
      gluBeginPolygon (tobj);
      for (i=0; i<iloop; i++) {
         gluTessVertex (tobj, cap[i], cap[i]);
      }
      gluEndPolygon (tobj);
#endif /* OPENGL_10 */
   } else {

      /* if lighting is on, specify the endcap normal */
      if (cut_vector != NULL) {
         /* if normal pointing in wrong direction, flip it. */
         if (cut_vector[2] > 0.0) {
            VEC_SCALE (cut_vector, -1.0, cut_vector); 
         }
         N3F_D (cut_vector);
      }
      /* the sense of the loop is reversed for backfacing culling */
#ifdef GL_32
      BGNPOLYGON();
      for (i=iloop-1; i>-1; i--) {
         V3F_D (cap[i], i, BACK_CAP);
      }
      ENDPOLYGON();
#endif /* GL_32 */
#ifdef OPENGL_10
      gluBeginPolygon (tobj);
      for (i=iloop-1; i>-1; i--) {
         gluTessVertex (tobj, cap[i], cap[i]);
      }
      gluEndPolygon (tobj);
#endif /* OPENGL_10 */
   }

#ifdef OPENGL_10
   gluDeleteTess (tobj);
#endif /* OPENGL_10 */

}