home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / EXAMPLES / SUNVIEW / LCUBE.C < prev    next >
C/C++ Source or Header  |  1994-04-27  |  2KB  |  113 lines

  1.  
  2. #include <stdio.h>
  3. #include "vogle.h"
  4.  
  5. #define    CUBE_SIZE    200.0
  6. #define    TRANS        25.0
  7. #define    SCAL        0.1
  8. #define FACE        1
  9. #define FILLED        2
  10. #define OUTLINE        3
  11.  
  12. extern float    tdir;
  13. extern float    scal;
  14. extern int    but, nplanes;
  15. int    i, n;
  16.  
  17. setup_lcube()
  18. {
  19.     window(-800.0, 800.0, -800.0, 800.0, -800.0, 800.0);
  20.     lookat(0.0, 0.0, 1500.0, 0.0, 0.0, 0.0, 0.0);
  21.  
  22.     /*
  23.      * Start with a very ordinary filled cube like the old demo..
  24.      */
  25.     polyhatch(0);
  26.     hatchang(45.0);
  27.     hatchpitch(40.0);
  28.  
  29.     makeobj(FACE);     /* hatched or filled polygon */
  30.         makepoly();
  31.             rect(-CUBE_SIZE, -CUBE_SIZE, CUBE_SIZE, CUBE_SIZE);
  32.         closepoly();
  33.     closeobj();
  34.  
  35.     makecube(FILLED);
  36.  
  37.     if ((nplanes = getdepth()) == 1)
  38.         makecube(OUTLINE);
  39.  
  40.     backbuffer(1);
  41.  
  42. }
  43.  
  44. makecube(obj)
  45.     int    obj;
  46. {
  47.     makeobj(obj);
  48.         if (obj == OUTLINE) {
  49.             pushattributes();
  50.             polyfill(0);
  51.             polyhatch(0);
  52.             color(BLACK);
  53.         }
  54.  
  55.         pushmatrix();
  56.             translate(0.0, 0.0, CUBE_SIZE);
  57.             if (obj == FILLED)
  58.                 color(RED);
  59.  
  60.             callobj(FACE);
  61.         popmatrix();
  62.  
  63.         pushmatrix();
  64.             translate(CUBE_SIZE, 0.0, 0.0);
  65.             rotate(90.0, 'y');
  66.             if (obj == FILLED)
  67.                 color(GREEN);
  68.  
  69.             callobj(FACE);
  70.         popmatrix();
  71.  
  72.         pushmatrix();
  73.             translate(0.0, 0.0, -CUBE_SIZE);
  74.             rotate(180.0, 'y');
  75.             if (obj == FILLED)
  76.                 color(BLUE);
  77.  
  78.             callobj(FACE);
  79.         popmatrix();
  80.  
  81.         pushmatrix();
  82.             translate(-CUBE_SIZE, 0.0, 0.0);
  83.             rotate(-90.0, 'y');
  84.             if (obj == FILLED)
  85.                 color(CYAN);
  86.  
  87.             callobj(FACE);
  88.         popmatrix();
  89.  
  90.         pushmatrix();
  91.             translate(0.0, CUBE_SIZE, 0.0);
  92.             rotate(-90.0, 'x');
  93.             if (obj == FILLED)
  94.                 color(MAGENTA);
  95.  
  96.             callobj(FACE);
  97.         popmatrix();
  98.  
  99.         pushmatrix();
  100.             translate(0.0, -CUBE_SIZE, 0.0);
  101.             rotate(90.0, 'x');
  102.             if (obj == FILLED)
  103.                 color(YELLOW);
  104.  
  105.             callobj(FACE);
  106.         popmatrix();
  107.  
  108.         if (obj == OUTLINE)
  109.             popattributes();
  110.         
  111.     closeobj();
  112. }
  113.