home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_dos.lha / dos / sphsrc / sph_draw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-26  |  3.5 KB  |  158 lines

  1. #include "HEADERS.h"
  2. #include "sphigslocal.h"
  3.  
  4.  
  5.  
  6. /** DRAW ROUTINES
  7. The display-traverser has set the two variables "currentViewIndex" and 
  8.     "currentCompositeModxform".
  9. **/
  10.  
  11.  
  12.  
  13. srgp__point srgp_pdc_points[20], srgp_polygon_points[20];
  14.  
  15.  
  16.  
  17. /*!*/
  18. static void ChangeMCpointsToPDC3d_points 
  19.    (MAT3hvec *MCvlist, pdc_point *PDCvlist, int vertex_count)
  20. {
  21.    register i;
  22.    MAT3hvec temp_outpt;
  23.  
  24.    for (i=(vertex_count-1); i>=0; i--) {
  25.       MAT3mult_hvec (temp_outpt, MCvlist[i], currentTOTALxform, 1);
  26.       PDCvlist[i][0] = (int)temp_outpt[0];
  27.       PDCvlist[i][1] = (int)temp_outpt[1];
  28.       PDCvlist[i][2] = (int)temp_outpt[2];
  29.    }
  30. }
  31.  
  32.  
  33. /*!*/
  34. static void ChangeMCpointsToSRGP_points 
  35.    (MAT3hvec *MCvlist, srgp__point *SRGP_vlist, int vertex_count)
  36. {
  37.    register i;
  38.    MAT3hvec temp_outpt;
  39.  
  40.    for (i=(vertex_count-1); i>=0; i--) {
  41.       MAT3mult_hvec (temp_outpt, MCvlist[i], currentTOTALxform, 1);
  42.       SRGP_vlist[i].x = (int)temp_outpt[0];
  43.       SRGP_vlist[i].y = (int)temp_outpt[1];
  44.    }
  45. }
  46.  
  47.  
  48.  
  49. /*!*/
  50. void
  51. SPH__draw_polyhedron (poly, attrs)
  52. POLYHEDRON *poly;
  53. attribute_group *attrs;
  54. {
  55.    register int v, f, viindex;
  56.    pdc_point *vertptr;
  57.    vertex_index *viptr;
  58.    facet *facetptr;
  59.    obj *newobj;
  60.  
  61.    switch (currentRendermode) {
  62.  
  63.     case WIREFRAME_RAW:
  64.  
  65.       SRGP_setColor (attrs->edge_color);
  66.       SRGP_setLineWidth (attrs->edge_width);
  67.       SRGP_setLineStyle (attrs->edge_style);
  68.  
  69.       ChangeMCpointsToSRGP_points (poly->vertex_list, srgp_pdc_points,
  70.                    poly->vertex_count);
  71.  
  72.       for (f = 0, facetptr = poly->facet_list;
  73.        f < poly->facet_count;      
  74.        f++, facetptr++) {
  75.      viindex = facetptr->vertex_count;
  76.      viptr = facetptr->vertex_indices + viindex;
  77.      while (viindex--)
  78.         srgp_polygon_points[viindex] = srgp_pdc_points[*(--viptr)];
  79.      SRGP_polygon (facetptr->vertex_count, srgp_polygon_points);
  80.       }
  81.       break;
  82.  
  83.     default:
  84.       OBJECT__addPoly (currentViewSpec, poly, currentMCtoUVNxform, attrs);
  85.       break;
  86.    }
  87. }
  88.  
  89.  
  90. /*!*/
  91. void
  92. SPH__draw_fill_area (element *elptr, attribute_group *attrs)
  93. {
  94.    switch (currentRendermode) {
  95.  
  96.     case WIREFRAME_RAW:
  97.       SRGP_setColor (attrs->edge_color);
  98.       SRGP_setLineWidth (attrs->edge_width);
  99.       SRGP_setLineStyle (attrs->edge_style);
  100.       ChangeMCpointsToSRGP_points 
  101.      (elptr->data.points, srgp_pdc_points, elptr->info.count);
  102.       SRGP_polygon (elptr->info.count, srgp_pdc_points);
  103.       break;
  104.  
  105.     default:
  106.       OBJECT__addFillArea (currentViewSpec, 
  107.                elptr->data.points, elptr->info.count,
  108.                currentMCtoUVNxform, attrs);
  109.       break;
  110.    }
  111. }
  112.  
  113.  
  114.  
  115.  
  116. /*!*/
  117. void
  118. SPH__draw_lines (element *elptr, attribute_group *attrs)
  119. {
  120.    ChangeMCpointsToSRGP_points 
  121.       (elptr->data.points, srgp_pdc_points, elptr->info.count);
  122.  
  123.    SRGP_setColor (attrs->line_color);
  124.    SRGP_setLineStyle (attrs->line_style);
  125.    SRGP_setLineWidth (attrs->line_width);
  126.    SRGP_polyLine (elptr->info.count, srgp_pdc_points);
  127. }
  128.  
  129.  
  130.  
  131. /*!*/
  132. void
  133. SPH__draw_markers (element *elptr, attribute_group *attrs)
  134. {
  135.    ChangeMCpointsToSRGP_points 
  136.       (elptr->data.points, srgp_pdc_points, elptr->info.count);
  137.  
  138.    SRGP_setColor (attrs->marker_color);
  139.    SRGP_setMarkerStyle (attrs->marker_style);
  140.    SRGP_setMarkerSize (attrs->marker_size);
  141.    SRGP_polyMarker (elptr->info.count, srgp_pdc_points);
  142. }
  143.          
  144.       
  145.  
  146. /*!*/
  147. void
  148. SPH__draw_text (mc_origin, text, attrs)
  149. MAT3hvec mc_origin;
  150. char *text;
  151. attribute_group *attrs;
  152. {
  153.    ChangeMCpointsToSRGP_points ((MAT3hvec*)mc_origin, srgp_pdc_points, 1);
  154.    SRGP_setColor (attrs->text_color);
  155.    SRGP_setFont (attrs->font);
  156.    SRGP_text (srgp_pdc_points[0], text);
  157. }
  158.