home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / EXAMPLES / PWORLD.P < prev    next >
Text File  |  2000-02-11  |  3KB  |  167 lines

  1. program world;
  2.  
  3. #include 'Vogle.h'
  4.  
  5. const
  6.         RADIUS = 10.0;
  7.         SPHERE = 1;
  8.         PI     = 3.14159265358979;
  9. var
  10.         dev: string_t;
  11.         i, dum: integer;
  12.     r, z, a: real;
  13.  
  14.  
  15.     (*
  16.      * MakeSphere
  17.      *
  18.      *    make a sphere object
  19.      *)
  20.     procedure MakeSphere;
  21.  
  22.         var    ir, r, z, a: real;
  23.             i: integer;
  24.     begin
  25.  
  26.         MakeObj(SPHERE);
  27.  
  28.             (*
  29.              * create the latitudinal rings
  30.              *)
  31.             for i := 0 to 9 do
  32.             begin
  33.                 ir := i * 20.0;
  34.                 PushMatrix;
  35.                     Rotate(ir, 'y');
  36.                     Circle(0.0, 0.0, RADIUS);
  37.                 PopMatrix
  38.             end;
  39.             
  40.             (*
  41.              * create the longitudinal rings
  42.              *)
  43.             PushMatrix;
  44.                 Rotate(90.0, 'x');
  45.                 for i := 0 to 9 do
  46.                 begin
  47.                     a := -90.0 + i * 20.0;
  48.                     r := RADIUS * cos(a * PI / 180.0);
  49.                     z := RADIUS * sin(a * PI / 180.0);
  50.                     PushMatrix;
  51.                         Translate(0.0, 0.0, -z);
  52.                         Circle(0.0, 0.0, r);
  53.                     PopMatrix
  54.                 end;
  55.             PopMatrix;
  56.  
  57.         CloseObj
  58.     end;
  59.  
  60.     (*
  61.      * showroundtext
  62.      *
  63.      *    draw string str wrapped around a circle in 3d
  64.      *)
  65.     procedure showroundtext(str: string_t);
  66.         var    i, inc: real;
  67.             n: integer;
  68.             c: char;
  69.     begin
  70.         inc := 360.0 / length(str);
  71.  
  72.         i := 0.0;
  73.         n := 1;
  74.  
  75.         while (i < 360.0) do
  76.         begin
  77.             PushMatrix;
  78.                 (*
  79.                  * find the spot on the edge of the sphere
  80.                  * by making it (0, 0, 0) in world coordinates
  81.                  *)
  82.                 Rotate(i, 'y');
  83.                 Translate(0.0, 0.0, RADIUS);
  84.  
  85.                 Move(0.0, 0.0, 0.0);
  86.  
  87.                 c := str[n];
  88.                 n := succ(n);
  89.                 DrawChar(c);
  90.             PopMatrix;
  91.  
  92.             i := i + inc
  93.         end
  94.     end;
  95.  
  96. (*
  97.  * most of the things in this program have been done before but it has
  98.  * a certain novelty value.
  99.  *)
  100. begin
  101.  
  102.     write('Enter device: ');
  103.     readln(dev);
  104.  
  105.     Vinit(dev);
  106.     Clipping(false);
  107.     VsetFlush(false);
  108.  
  109.     Font('futura.m');
  110.  
  111.     Perspective(80.0, 1.0, 0.001, 50.0);
  112.     LookAt(13.0, 13.0, 8.0, 0.0, 0.0, 0.0, 0.0);
  113.  
  114.     Color(BLACK);
  115.     Clear;
  116.  
  117.     MakeSphere;
  118.  
  119.     (*
  120.      * draw the main one in cyan
  121.      *)
  122.     Color(CYAN);
  123.  
  124.     CallObj(SPHERE);
  125.  
  126.     (*
  127.      * draw a smaller one outside the main one in white
  128.      *)
  129.     Color(WHITE);
  130.  
  131.     PushMatrix;
  132.         Translate(0.0, -1.4 * RADIUS, 1.4 * RADIUS);
  133.         Scale(0.3, 0.3, 0.3);
  134.         CallObj(SPHERE);
  135.     PopMatrix;
  136.  
  137.     (*
  138.      * scale the text
  139.      *)
  140.     BoxFit(2.0 * PI * RADIUS, 0.25 * RADIUS, 31);
  141.  
  142.     (*
  143.      * now write the text in rings around the main sphere
  144.      *)
  145.  
  146.     Color(GREEN);
  147.     showroundtext('Around the world in eighty days ');
  148.  
  149.     Color(BLUE);
  150.     (*
  151.      * note: that software text is rotated here as
  152.      * anything else would be whether you use textang
  153.      * or rotate depends on what you are trying to do.
  154.      * Experience is the best teacher here.
  155.      *)
  156.     Rotate(90.0, 'x');
  157.     showroundtext('Around the world in eighty days ');
  158.  
  159.     Color(RED);
  160.     Rotate(90.0, 'z');
  161.     showroundtext('Around the world in eighty days ');
  162.  
  163.     dum := GetKey;
  164.  
  165.     Vexit
  166. end.
  167.