Example #1
0
void draw_binorm_segment_c_and_edge_n (int ncp,	/* number of contour points */
                                       double front_contour[][3],
                                       double back_contour[][3],
                                       double front_norm[][3],
                                       double back_norm[][3],
                                       float color_last[3],
                                       float color_next[3],
                                       int inext, double len)
{
    int j;

    /* draw the tube segment */
    BGNTMESH (inext, len);
    for (j=0; j<ncp; j++) {
        C3F (color_last);
        N3F_D (front_norm[j]);
        V3F_D (front_contour[j], j, FRONT);

        C3F (color_next);
        N3F_D (back_norm[j]);
        V3F_D (back_contour[j], j, BACK);
    }

    if (__TUBE_CLOSE_CONTOUR) {
        /* connect back up to first point of contour */
        C3F (color_last);
        N3F_D (front_norm[0]);
        V3F_D (front_contour[0], 0, FRONT);

        C3F (color_next);
        N3F_D (back_norm[0]);
        V3F_D (back_contour[0], 0, BACK);
    }
    ENDTMESH ();
}
Example #2
0
void draw_segment_facet_n (int ncp,	/* number of contour points */
                           gleDouble front_contour[][3],
                           gleDouble back_contour[][3],
                           double norm_cont[][3],
                           int inext, double len)
{
    int j;

    /* draw the tube segment */
    BGNTMESH (inext, len);
    for (j=0; j<ncp-1; j++) {
        N3F_D (norm_cont[j]);
        V3F (front_contour[j], j, FRONT);
        V3F (back_contour[j], j, BACK);
        V3F (front_contour[j+1], j+1, FRONT);
        V3F (back_contour[j+1], j+1, BACK);
    }

    if (__TUBE_CLOSE_CONTOUR) {
        /* connect back up to first point of contour */
        N3F_D (norm_cont[ncp-1]);
        V3F (front_contour[ncp-1], ncp-1, FRONT);
        V3F (back_contour[ncp-1], ncp-1, BACK);
        V3F (front_contour[0], 0, FRONT);
        V3F (back_contour[0], 0, BACK);
    }

    ENDTMESH ();
}
Example #3
0
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();
    }

}
Example #4
0
void draw_binorm_segment_c_and_facet_n (int ncp,
                           double front_contour[][3],	
                           double back_contour[][3],	
                           double front_norm[][3],
                           double back_norm[][3],
                           gleColor color_last,
                           gleColor color_next,
                           int inext, double len)
{
   int j;

   /* draw the tube segment */
   BGNTMESH (inext, len);
   for (j=0; j<ncp-1; j++) {
      C3F (color_last);
      N3F_D (front_norm[j]);
      V3F_D (front_contour[j], j, FRONT);

      C3F (color_next);
      N3F_D (back_norm[j]);
      V3F_D (back_contour[j], j, BACK);

      C3F (color_last);
      N3F_D (front_norm[j]);
      V3F_D (front_contour[j+1], j+1, FRONT);

      C3F (color_next);
      N3F_D (back_norm[j]);
      V3F_D (back_contour[j+1], j+1, BACK);
   }

   if (__TUBE_CLOSE_CONTOUR) {
      /* connect back up to first point of contour */
      C3F (color_last);
      N3F_D (front_norm[ncp-1]);
      V3F_D (front_contour[ncp-1], ncp-1, FRONT);
   
      C3F (color_next);
      N3F_D (back_norm[ncp-1]);
      V3F_D (back_contour[ncp-1], ncp-1, BACK);
   
      C3F (color_last);
      N3F_D (front_norm[ncp-1]);
      V3F_D (front_contour[0], 0, FRONT);
   
      C3F (color_next);
      N3F_D (back_norm[ncp-1]);
      V3F_D (back_contour[0], 0, BACK);
   }

   ENDTMESH ();
}
Example #5
0
/*
 * This little routine draws the little idd-biddy fillet triangle with
 * the right  color, normal, etc.
 *
 * HACK ALERT -- there are two aspects to this routine/interface that
 * are "unfinished".
 * 1) the third point of the triangle should get a color thats
 *    interpolated beween the front and back color.  The interpolant
 *    is not currently being computed.  The error introduced by not
 *    doing this should be tiny and/or non-exitant in almost all
 *    expected uses of this code.
 *
 * 2) additional normal vectors should be supplied, and these should
 *    be interpolated to fit.  Currently, this is not being done.  As
 *    above, the expected error of not doing this should be tiny and/or
 *    non-existant in almost all expected uses of this code.
 */
static void draw_fillet_triangle_n_norms
                          (gleDouble va[3],
                           gleDouble vb[3],
                           gleDouble vc[3],
                           int face,
                           float front_color[3],
                           float back_color[3],
                           double na[3],
                           double nb[3])
{

   if (front_color != NULL) C3F (front_color);
   BGNTMESH (-5, 0.0);
   if (__TUBE_DRAW_FACET_NORMALS) {
      N3F_D (na);
      if (face) {
         V3F (va, -1, FILLET);
         V3F (vb, -1, FILLET);
      } else {
         V3F (vb, -1, FILLET);
         V3F (va, -1, FILLET);
      }
      V3F (vc, -1, FILLET);
   } else {
      if (face) {
         N3F_D (na);
         V3F (va, -1, FILLET);
         N3F_D (nb);
         V3F (vb, -1, FILLET);
      } else {
         N3F_D (nb);
         V3F (vb, -1, FILLET);
         N3F_D (na);
         V3F (va, -1, FILLET);
         N3F_D (nb);
      }
      V3F (vc, -1, FILLET);
   }
   ENDTMESH ();

}
Example #6
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 */

}
Example #7
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 */

}
Example #8
0
void draw_segment_c_and_facet_n (int ncp,	/* number of contour points */
                                 gleDouble front_contour[][3],
                                 gleDouble back_contour[][3],
                                 double norm_cont[][3],
                                 float color_last[3],
                                 float color_next[3],
                                 int inext, double len)
{
    int j;
    /* Note about this code:
     * At first, when looking at this code, it appears to be really dumb:
     * the N3F() call appears to be repeated multiple times, for no
     * apparent purpose.  It would seem that a performance improvement
     * would be gained by stripping it out. !DONT DO IT!
     * When there are no local lights or viewers, the V3F() subroutine
     * does not trigger a recalculation of the lighting equations.
     * However, we MUST trigger lighting, since otherwise colors come out
     * wrong.  Trigger lighting by doing an N3F call.
     */

    /* draw the tube segment */
    BGNTMESH (inext, len);
    for (j=0; j<ncp-1; j++) {
        C3F (color_last);
        N3F_D (norm_cont[j]);
        V3F (front_contour[j], j, FRONT);

        C3F (color_next);
        N3F_D (norm_cont[j]);
        V3F (back_contour[j], j, BACK);

        C3F (color_last);
        N3F_D (norm_cont[j]);
        V3F (front_contour[j+1], j+1, FRONT);

        C3F (color_next);
        N3F_D (norm_cont[j]);
        V3F (back_contour[j+1], j+1, BACK);
    }

    if (__TUBE_CLOSE_CONTOUR) {
        /* connect back up to first point of contour */
        C3F (color_last);
        N3F_D (norm_cont[ncp-1]);
        V3F (front_contour[ncp-1], ncp-1, FRONT);

        C3F (color_next);
        N3F_D (norm_cont[ncp-1]);
        V3F (back_contour[ncp-1], ncp-1, BACK);

        C3F (color_last);
        N3F_D (norm_cont[ncp-1]);
        V3F (front_contour[0], 0, FRONT);

        C3F (color_next);
        N3F_D (norm_cont[ncp-1]);
        V3F (back_contour[0], 0, BACK);
    }

    ENDTMESH ();
}