home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Homebrewer's Handbook / vr.iso / avril / example2.c < prev    next >
C/C++ Source or Header  |  1996-03-19  |  971b  |  45 lines

  1. /* EXAMPLE2 -- several asteroids, sharing the same geometry */
  2.  
  3. /* Written by Bernie Roehl, April 1994 */
  4.  
  5. #include "avril.h"
  6. #include <stdlib.h>  /* needed for rand() */
  7.  
  8. void main()
  9.     {
  10.     FILE *infile;
  11.     vrl_Light *light;
  12.     vrl_Camera *camera;
  13.     vrl_Shape *asteroidshape = NULL;
  14.     int i;
  15.  
  16.     vrl_SystemStartup();
  17.     
  18.     vrl_WorldSetHorizon(0);    /* turn off horizon */
  19.     vrl_WorldSetSkyColor(0);   /* black sky */
  20.  
  21.     infile = fopen("asteroid.plg", "r");
  22.     if (infile)
  23.         {
  24.         asteroidshape = vrl_ReadPLG(infile);
  25.         fclose(infile);
  26.         }
  27.  
  28.     light = vrl_LightCreate();
  29.     vrl_LightRotY(light, float2angle(45));
  30.     vrl_LightRotX(light, float2angle(45));
  31.     vrl_LightSetIntensity(light, float2factor(0.9));
  32.  
  33.     camera = vrl_CameraCreate();
  34.     vrl_CameraMove(camera, 0, 100, -50);
  35.  
  36.     for (i = 0; i < 5; ++i)
  37.         {
  38.         vrl_Object *obj = vrl_ObjectCreate(asteroidshape);
  39.         vrl_ObjectMove(obj, rand() % 1000, rand() % 1000, rand() % 1000);
  40.         }
  41.  
  42.     vrl_SystemRun();
  43.     }
  44.  
  45.