home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume18 / mtvraytrace / part01 / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-26  |  3.2 KB  |  123 lines

  1. /***********************************************************************
  2.  * $Author: markv $
  3.  * $Revision: 1.6 $
  4.  * $Date: 88/10/31 14:33:44 $
  5.  * $Log:    main.c,v $
  6.  * Revision 1.6  88/10/31  14:33:44  markv
  7.  * Removed non-functioning antialiasing...
  8.  * 
  9.  * Revision 1.5  88/10/04  14:29:16  markv
  10.  * Added flags having to do with antialiasing, both statistically
  11.  * optimized and jittered.
  12.  * 
  13.  * Revision 1.4  88/09/13  16:08:21  markv
  14.  * Moved InitSlabs, must occur before ReadSceneFile
  15.  * 
  16.  * Revision 1.3  88/09/13  16:05:44  markv
  17.  * Usage message now prints -t flag as well.
  18.  * 
  19.  * Revision 1.2  88/09/12  12:53:11  markv
  20.  * Added printout of new statistic on shadow cache hits.
  21.  * 
  22.  * Revision 1.1  88/09/11  11:02:23  markv
  23.  * Initial revision
  24.  * 
  25.  ***********************************************************************/
  26.  
  27. #include <stdio.h>
  28. #include <sys/types.h>
  29. #include <sys/times.h>
  30. #include "defs.h"
  31. #include "extern.h"
  32.  
  33. main(argc, argv)
  34.  int argc ;
  35.  char * argv[] ;
  36. {
  37.     extern int optind ;
  38.     extern char *optarg ;
  39.     int c ;
  40.     char * infilename = NULL ;
  41.     char * outfilename = "out.pic" ;
  42.     struct tms pbuf, tbuf ;
  43.  
  44.     if ((Progname = rindex(argv[0], '/')) == NULL) 
  45.         Progname = argv[0] ;
  46.     else 
  47.         Progname ++ ;
  48.  
  49.     while ((c = getopt(argc, argv, "r:a:o:i:tfj:")) != EOF) {
  50.         switch (c) {
  51.         case 'r':
  52.             resolutionflag = atoi(optarg) ;
  53.             break ;
  54.         case 'f':
  55.             filtflag = 1 ;
  56.             break ;
  57.         case 'j':
  58.             jitterflag = 1 ;
  59.             maxsamples = atoi(optarg) ;
  60.             if (maxsamples <= 0) {
  61.                 fprintf(stderr, "%s: samples must be > 0\n",
  62.                     Progname) ;
  63.                 exit(1) ;
  64.             }
  65.             break ;
  66.         case 'o':
  67.             outfilename = optarg ;
  68.             break ;
  69.         case 'i':
  70.             infilename = optarg ;
  71.             break ;
  72.         case 't':
  73.             tickflag = 1 ;
  74.             break ;
  75.         case '?':
  76.             fprintf(stderr, "usage: %s [-i file] [-o file] [-t]\n",
  77.                 Progname) ;
  78.             exit(-1);
  79.         }
  80.     }
  81.  
  82.     InitSlabs() ;            /* Normalizes slab normals...    */
  83.     ReadSceneFile(infilename) ;
  84.     if (resolutionflag > 0) {
  85.         Xresolution = Yresolution = resolutionflag ;
  86.     }
  87.     BuildBoundingSlabs() ;
  88.     times(&pbuf) ;
  89.     Screen(&Eye, outfilename, Xresolution, Yresolution) ;
  90.     times(&tbuf) ;
  91.     tbuf.tms_utime -= pbuf.tms_utime ;
  92.     tbuf.tms_stime -= pbuf.tms_stime ;
  93.     PrintStatistics(&pbuf, &tbuf) ;
  94. }
  95.  
  96. PrintStatistics(pbuf, tbuf)
  97.  struct tms *pbuf, *tbuf ;
  98. {
  99.  
  100.     printf("preprocess time (user code)    %-6d seconds\n",
  101.             pbuf -> tms_utime / 60) ;
  102.     printf("preprocess time (system code)    %-6d seconds\n",
  103.             pbuf -> tms_stime / 60) ;
  104.     printf("tracing time (user code)    %-6d seconds\n",
  105.             tbuf -> tms_utime / 60 ) ;
  106.     printf("tracing time (system code)    %-6d seconds\n",
  107.             tbuf -> tms_stime / 60 ) ;
  108.  
  109.     printf("number of rays cast:       %-6d\n", nRays);
  110.     printf("number of shadow rays:       %-6d\n", nShadows);
  111.     printf("number of reflected rays:  %-6d\n", nReflected);
  112.     printf("number of refracted rays:  %-6d\n", nRefracted);
  113.  
  114.     printf("number of queue inserts:   %-6d\n", totalQueues) ;
  115.     printf("number of queue resets:    %-6d\n", totalQueueResets) ;
  116.     printf("avg number of queues/ray:  %-6g\n", (Flt) totalQueues /
  117.                         (Flt) totalQueueResets) ;
  118.     printf("max queue size:           %-6d\n", maxQueueSize) ;
  119.     printf("number of bound checks:       %-6d\n", nChecked) ;
  120.     printf("number of bound queued:       %-6d\n", nEnqueued) ;
  121.     printf("number of shadow hits:       %-6d\n", nShadowCacheHits) ;
  122. }
  123.