| 1 |
– |
/* Copyright (c) 1995 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* rview.c - routines and variables for interactive view generation. |
| 6 |
|
* |
| 7 |
< |
* 3/24/87 |
| 7 |
> |
* External symbols declared in rpaint.h |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
< |
#include "ray.h" |
| 10 |
> |
#include "copyright.h" |
| 11 |
|
|
| 15 |
– |
#include "rpaint.h" |
| 16 |
– |
|
| 12 |
|
#include <signal.h> |
| 18 |
– |
|
| 13 |
|
#include <ctype.h> |
| 14 |
|
|
| 15 |
< |
VIEW ourview = STDVIEW; /* viewing parameters */ |
| 16 |
< |
int hresolu, vresolu; /* image resolution */ |
| 15 |
> |
#include "platform.h" |
| 16 |
> |
#include "ray.h" |
| 17 |
> |
#include "rpaint.h" |
| 18 |
|
|
| 19 |
+ |
|
| 20 |
+ |
CUBE thescene; /* our scene */ |
| 21 |
+ |
OBJECT nsceneobjs; /* number of objects in our scene */ |
| 22 |
+ |
|
| 23 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
| 24 |
|
int ndims = 0; /* number of sampling dimensions */ |
| 25 |
|
int samplendx = 0; /* index for this sample */ |
| 26 |
|
|
| 27 |
+ |
extern void ambnotify(); |
| 28 |
+ |
void (*addobjnotify[])() = {ambnotify, NULL}; |
| 29 |
+ |
|
| 30 |
+ |
VIEW ourview = STDVIEW; /* viewing parameters */ |
| 31 |
+ |
int hresolu, vresolu; /* image resolution */ |
| 32 |
+ |
|
| 33 |
+ |
void (*trace)() = NULL; /* trace call */ |
| 34 |
+ |
|
| 35 |
+ |
int do_irrad = 0; /* compute irradiance? */ |
| 36 |
+ |
|
| 37 |
|
int psample = 8; /* pixel sample size */ |
| 38 |
|
double maxdiff = .15; /* max. sample difference */ |
| 39 |
|
|
| 48 |
|
double srcsizerat = 0.; /* maximum ratio source size/dist. */ |
| 49 |
|
|
| 50 |
|
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
| 51 |
< |
double salbedo = 0.; /* global scattering albedo */ |
| 51 |
> |
COLOR salbedo = BLKCOLOR; /* global scattering albedo */ |
| 52 |
|
double seccg = 0.; /* global scattering eccentricity */ |
| 53 |
|
double ssampdist = 0.; /* scatter sampling distance */ |
| 54 |
|
|
| 60 |
|
int maxdepth = 4; /* maximum recursion depth */ |
| 61 |
|
double minweight = 1e-2; /* minimum ray weight */ |
| 62 |
|
|
| 63 |
+ |
char *ambfile = NULL; /* ambient file name */ |
| 64 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
| 65 |
+ |
int ambvwt = 0; /* initial weight for ambient value */ |
| 66 |
|
double ambacc = 0.2; /* ambient accuracy */ |
| 67 |
|
int ambres = 8; /* ambient resolution */ |
| 68 |
|
int ambdiv = 32; /* ambient divisions */ |
| 72 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
| 73 |
|
|
| 74 |
|
int greyscale = 0; /* map colors to brightness? */ |
| 75 |
< |
char *devname = dev_default; /* output device name */ |
| 75 |
> |
char *dvcname = dev_default; /* output device name */ |
| 76 |
|
|
| 77 |
|
struct driver *dev = NULL; /* driver functions */ |
| 78 |
|
|
| 91 |
|
#define CTRL(c) ((c)-'@') |
| 92 |
|
|
| 93 |
|
|
| 94 |
+ |
void |
| 95 |
|
quit(code) /* quit program */ |
| 96 |
|
int code; |
| 97 |
|
{ |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
+ |
void |
| 108 |
|
devopen(dname) /* open device driver */ |
| 109 |
|
char *dname; |
| 110 |
|
{ |
| 121 |
|
error(USER, errmsg); |
| 122 |
|
} else |
| 123 |
|
return; |
| 111 |
– |
#ifndef NIX |
| 124 |
|
/* not there, try exec */ |
| 125 |
|
if ((dev = comm_init(dname, id)) == NULL) { |
| 126 |
|
sprintf(errmsg, "cannot start device \"%s\"", dname); |
| 127 |
|
error(USER, errmsg); |
| 128 |
|
} |
| 117 |
– |
#endif |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
|
| 132 |
+ |
void |
| 133 |
|
devclose() /* close our device */ |
| 134 |
|
{ |
| 135 |
|
if (dev != NULL) |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
+ |
void |
| 142 |
|
printdevices() /* print list of output devices */ |
| 143 |
|
{ |
| 144 |
|
register int i; |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
|
| 151 |
+ |
void |
| 152 |
|
rview() /* do a view */ |
| 153 |
|
{ |
| 154 |
|
char buf[32]; |
| 155 |
|
|
| 156 |
< |
devopen(devname); /* open device */ |
| 156 |
> |
devopen(dvcname); /* open device */ |
| 157 |
|
newimage(); /* start image (calls fillreserves) */ |
| 158 |
|
|
| 159 |
|
for ( ; ; ) { /* quit in command() */ |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
|
| 184 |
+ |
void |
| 185 |
|
fillreserves() /* fill memory reserves */ |
| 186 |
|
{ |
| 187 |
|
if (reserve_mem != NULL) |
| 188 |
|
return; |
| 189 |
< |
reserve_mem = malloc(RESERVE_AMT); |
| 189 |
> |
reserve_mem = (char *)malloc(RESERVE_AMT); |
| 190 |
|
} |
| 191 |
|
|
| 192 |
|
|
| 193 |
+ |
void |
| 194 |
|
freereserves() /* free memory reserves */ |
| 195 |
|
{ |
| 196 |
|
if (reserve_mem == NULL) |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
|
| 203 |
+ |
void |
| 204 |
|
command(prompt) /* get/execute command */ |
| 205 |
|
char *prompt; |
| 206 |
|
{ |
| 329 |
|
devclose(); |
| 330 |
|
kill(0, SIGTSTP); |
| 331 |
|
/* pc stops here */ |
| 332 |
< |
devopen(devname); |
| 332 |
> |
devopen(dvcname); |
| 333 |
|
redraw(); |
| 334 |
|
break; |
| 335 |
|
#endif |
| 349 |
|
} |
| 350 |
|
|
| 351 |
|
|
| 352 |
+ |
void |
| 353 |
|
rsample() /* sample the image */ |
| 354 |
|
{ |
| 355 |
|
int xsiz, ysiz, y; |
| 372 |
|
return; |
| 373 |
|
pl = (PNODE **)malloc(xsiz*sizeof(PNODE *)); |
| 374 |
|
if (pl == NULL) { |
| 375 |
< |
free((char *)rl); |
| 375 |
> |
free((void *)rl); |
| 376 |
|
return; |
| 377 |
|
} |
| 378 |
|
/* |
| 433 |
|
} |
| 434 |
|
} |
| 435 |
|
escape: |
| 436 |
< |
free((char *)rl); |
| 437 |
< |
free((char *)pl); |
| 436 |
> |
free((void *)rl); |
| 437 |
> |
free((void *)pl); |
| 438 |
|
} |
| 439 |
|
|
| 440 |
|
|