home *** CD-ROM | disk | FTP | other *** search
- /*
- * options.c
- *
- * Copyright (C) 1989, 1991, Craig E. Kolb
- * All rights reserved.
- *
- * This software may be freely copied, modified, and redistributed
- * provided that this copyright notice is preserved on all copies.
- *
- * You may not distribute this software, in whole or in part, as part of
- * any commercial product without the express consent of the authors.
- *
- * There is no warranty or other guarantee of fitness of this software
- * for any purpose. It is provided solely "as is".
- *
- * $Id: options.c,v 4.0 91/07/17 14:46:47 kolb Exp Locker: kolb $
- *
- * $Log: options.c,v $
- * Revision 4.0 91/07/17 14:46:47 kolb
- * Initial version.
- *
- */
- #include "rayshade.h"
- #include "options.h"
- #include "stats.h"
- #include "viewing.h"
-
- RSOptions Options;
-
- static void usage();
-
- void
- RSOptionsSet(argc, argv)
- int argc;
- char **argv;
- {
- Options.progname = strsave(argv[0]);
- Options.inputname = (char *)NULL;
-
- while (--argc) {
- argv++;
- if (argv[0][0] != '-') {
- /*
- * Must be the input file name.
- * If already given, complain and then exit.
- */
- if (Options.inputname != (char *)NULL) {
- usage();
- exit(1);
- }
- Options.inputname = strsave(argv[0]);
- continue;
- }
- /* else */
- switch(argv[0][1]) {
- case 'A':
- /*
- * First frame number
- */
- Options.startframe = atoi(argv[1]);
- argv++; argc--;
- break;
- case 'C':
- Options.cutoff.r = atof(argv[1]);
- Options.cutoff.g = atof(argv[2]);
- Options.cutoff.b = atof(argv[3]);
- Options.cutoff_set = TRUE;
- argv += 3; argc -= 3;
- break;
- case 'D':
- Options.maxdepth = atoi(argv[1]);
- Options.maxdepth_set = TRUE;
- argv++; argc--;
- break;
- case 'E':
- Options.eyesep = atof(argv[1]);
- Options.eyesep_set = TRUE;
- argc--; argv++;
- break;
- case 'F':
- Options.report_freq = atoi(argv[1]);
- if (Options.report_freq < 1)
- Options.report_freq = 1;
- Options.freq_set = TRUE;
- argv++; argc--;
- break;
- case 'f':
- Options.flipnorm = !Options.flipnorm;
- break;
- case 'G':
- Options.gamma = atof(argv[1]);
- argv++; argc--;
- break;
- case 'g':
- Options.gaussian = !Options.gaussian;
- break;
- case 'h':
- case '?':
- usage();
- exit(0);
- break;
- case 'j':
- Options.jitter = !Options.jitter;
- Options.jitter_set = TRUE;
- break;
- case 'l':
- Options.stereo = LEFT;
- break;
- case 'N':
- Options.totalframes = atof(argv[1]);
- Options.totalframes_set = TRUE;
- argv++; argc--;
- break;
- case 'n':
- Options.no_shadows = !Options.no_shadows;
- break;
- case 'O':
- Options.imgname = strsave(argv[1]);
- argv++;
- argc--;
- break;
- case 'o':
- Options.shadowtransp = !Options.shadowtransp;
- break;
- case 'p':
- /*
- * Preview-quality rendering
- * no shadows
- * max depth of 0
- * 1 jittered sample/pixel
- */
- Options.no_shadows = TRUE;
- Options.maxdepth = 0;
- Options.maxdepth_set = TRUE;
- Options.jitter = TRUE;
- Options.jitter_set = TRUE;
- Options.samples = 1;
- Options.samples_set = TRUE;
- break;
- case 'q':
- Options.quiet = TRUE;
- break;
- case 'R':
- Screen.xres = atoi(argv[1]);
- Screen.yres = atoi(argv[2]);
- Options.resolution_set = TRUE;
- argv += 2;
- argc -= 2;
- break;
- case 'r':
- Options.stereo = RIGHT;
- break;
- case 'S':
- Options.samples = atoi(argv[1]);
- if (Options.samples < 1)
- Options.samples = 1;
- Options.samples_set = TRUE;
- argv++; argc--;
- break;
- case 's':
- Options.cache = !Options.cache;
- break;
- case 'T':
- Options.contrast.r = atof(argv[1]);
- Options.contrast.g = atof(argv[2]);
- Options.contrast.b = atof(argv[3]);
- Options.contrast_set = TRUE;
- argv += 3;
- argc -= 3;
- break;
- case 'v':
- Options.verbose = TRUE;
- break;
- case 'V':
- Options.verbose = TRUE;
- if (argv[1][0] == '-') {
- /* User probably blew it, and
- * it's difficult to remove a file
- * that begins with '-'...
- */
- usage();
- exit(2);
- }
- argv++; argc--;
- break;
-
- default:
- RLerror(RL_PANIC,"Bad argument: %s\n",argv[0],0,0);
- }
- }
- }
-
- void
- RSOptionsList()
- {
- if (Options.totalframes > 1) {
- printf("Rendering frames %d through %d.\n",Options.startframe, Options.endframe);
- } else {
- printf("Rendering frame %d.\n", Options.startframe);
- }
-
- printf("Screen resolution: %d x %d\n",Screen.xres,Screen.yres);
- printf("Image window: (%d - %d), (%d - %d).\n",Screen.minx, Screen.maxx, Screen.miny, Screen.maxy);
-
- if (Options.jitter)
- printf("Using jittered sampling, ");
- printf("Max sampling rate %d %s/pixel.\n",
- Options.samples*Options.samples,
- Options.samples == 1 ? "sample" : "samples");
-
- printf("Maximum contrast: %g red, %g green, %g blue.\n",
- Options.contrast.r, Options.contrast.g,
- Options.contrast.b);
- printf("Maximum ray depth: %d. Cutoff thresh: %g %g %g.\n",
- Options.maxdepth,
- Options.cutoff.r, Options.cutoff.g, Options.cutoff.b);
- if (Options.stereo == LEFT)
- printf("Rendering image for left eye.\n");
- else if (Options.stereo == RIGHT)
- printf("Rendering image for right eye.\n");
- if (Options.no_shadows) {
- printf("No shadows are rendered.\n");
- } else if (Options.shadowtransp) {
- printf("Object opacity affects depth of shadowing.\n");
- }
- if (!Options.cache)
- printf("Shadow caching is disabled.\n");
- if (Options.totalframes != 1)
- printf("Rendering %d frames.\n",Options.totalframes);
- }
-
- static void
- usage()
- {
- printf("usage: %s [options] [filename]\n", Options.progname);
- printf("Where options include:\n");
- printf("\t-A frame\t(Begin with given frame #.)\n");
-
- printf("\t-C thresh\t(Set adaptive ray tree cutoff value.)\n");
-
- printf("\t-D depth\t(Set maximum ray tree depth.)\n");
- printf("\t-E eye_sep\t(Set eye separation in stereo pairs.)\n");
-
- printf("\t-F freq\t\t(Set frequency of status report.)\n");
- printf("\t-G gamma\t(Use given gamma correction exponent.)\n");
- printf("\t-h \t\t(Print this message.)\n");
- printf("\t-l \t\t(Render image for left eye view.)\n");
- printf("\t-N number\t(Render given number of frames.)\n");
- printf("\t-n \t\t(Do not render shadows.)\n");
- printf("\t-O outfile \t(Set output file name.)\n");
- printf("\t-o \t\t(Toggle opacity effect on shadowing.)\n");
- printf("\t-p \t\t(Preview-quality rendering.)\n");
- printf("\t-q \t\t(Run quietly.)\n");
- printf("\t-R xres yres\t(Render at given resolution.)\n");
- printf("\t-r \t\t(Render image for right eye view.)\n");
- printf("\t-S samples\t(Max density of samples^2 samples.)\n");
- printf("\t-s \t\t(Don't cache shadowing information.)\n");
- printf("\t-T r g b\t(Set contrast threshold (0. - 1.).)\n");
- printf("\t-V filename \t(Write verbose output to filename.)\n");
- printf("\t-v \t\t(Verbose output.)\n");
- }
-