| 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 |
|
* Routines to do the actual calculation for mkillum |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
< |
#include "mkillum.h" |
| 8 |
> |
#include <string.h> |
| 9 |
|
|
| 10 |
+ |
#include "mkillum.h" |
| 11 |
|
#include "face.h" |
| 14 |
– |
|
| 12 |
|
#include "cone.h" |
| 16 |
– |
|
| 13 |
|
#include "random.h" |
| 14 |
|
|
| 15 |
+ |
//void o_default(OBJREC *ob, struct illum_args *il, struct rtproc *rt, char *nm); |
| 16 |
+ |
void o_face(OBJREC *ob, struct illum_args *il, struct rtproc *rt, char *nm); |
| 17 |
+ |
void o_sphere(OBJREC *ob, struct illum_args *il, struct rtproc *rt, char *nm); |
| 18 |
+ |
void o_ring(OBJREC *ob, struct illum_args *il, struct rtproc *rt, char *nm); |
| 19 |
+ |
void raysamp(float res[3], FVECT org, FVECT dir, struct rtproc *rt); |
| 20 |
+ |
void rayflush(struct rtproc *rt); |
| 21 |
+ |
void mkaxes(FVECT u, FVECT v, FVECT n); |
| 22 |
+ |
void rounddir(FVECT dv, double alt, double azi); |
| 23 |
+ |
void flatdir(FVECT dv, double alt, double azi); |
| 24 |
|
|
| 25 |
< |
o_default(ob, il, rt, nm) /* default illum action */ |
| 26 |
< |
OBJREC *ob; |
| 27 |
< |
struct illum_args *il; |
| 28 |
< |
struct rtproc *rt; |
| 29 |
< |
char *nm; |
| 25 |
> |
|
| 26 |
> |
int /* XXX type conflict with otypes.h */ |
| 27 |
> |
o_default( /* default illum action */ |
| 28 |
> |
OBJREC *ob, |
| 29 |
> |
struct illum_args *il, |
| 30 |
> |
struct rtproc *rt, |
| 31 |
> |
char *nm |
| 32 |
> |
) |
| 33 |
|
{ |
| 34 |
|
sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"", |
| 35 |
|
nm, ofun[ob->otype].funame, ob->oname); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
|
| 41 |
< |
o_face(ob, il, rt, nm) /* make an illum face */ |
| 42 |
< |
OBJREC *ob; |
| 43 |
< |
struct illum_args *il; |
| 44 |
< |
struct rtproc *rt; |
| 45 |
< |
char *nm; |
| 41 |
> |
void |
| 42 |
> |
o_face( /* make an illum face */ |
| 43 |
> |
OBJREC *ob, |
| 44 |
> |
struct illum_args *il, |
| 45 |
> |
struct rtproc *rt, |
| 46 |
> |
char *nm |
| 47 |
> |
) |
| 48 |
|
{ |
| 49 |
|
#define MAXMISS (5*n*il->nsamps) |
| 50 |
|
int dim[3]; |
| 128 |
|
objerror(ob, WARNING, "bad aspect"); |
| 129 |
|
rt->nrays = 0; |
| 130 |
|
freeface(ob); |
| 131 |
< |
free((char *)distarr); |
| 131 |
> |
free((void *)distarr); |
| 132 |
|
o_default(ob, il, rt, nm); |
| 133 |
|
return; |
| 134 |
|
} |
| 147 |
|
printobj(il->altmat, ob); |
| 148 |
|
/* clean up */ |
| 149 |
|
freeface(ob); |
| 150 |
< |
free((char *)distarr); |
| 150 |
> |
free((void *)distarr); |
| 151 |
|
#undef MAXMISS |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
|
| 155 |
< |
o_sphere(ob, il, rt, nm) /* make an illum sphere */ |
| 156 |
< |
register OBJREC *ob; |
| 157 |
< |
struct illum_args *il; |
| 158 |
< |
struct rtproc *rt; |
| 159 |
< |
char *nm; |
| 155 |
> |
void |
| 156 |
> |
o_sphere( /* make an illum sphere */ |
| 157 |
> |
register OBJREC *ob, |
| 158 |
> |
struct illum_args *il, |
| 159 |
> |
struct rtproc *rt, |
| 160 |
> |
char *nm |
| 161 |
> |
) |
| 162 |
|
{ |
| 163 |
|
int dim[3]; |
| 164 |
|
int n, nalt, nazi; |
| 219 |
|
} else |
| 220 |
|
printobj(il->altmat, ob); |
| 221 |
|
/* clean up */ |
| 222 |
< |
free((char *)distarr); |
| 222 |
> |
free((void *)distarr); |
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
|
| 226 |
< |
o_ring(ob, il, rt, nm) /* make an illum ring */ |
| 227 |
< |
OBJREC *ob; |
| 228 |
< |
struct illum_args *il; |
| 229 |
< |
struct rtproc *rt; |
| 230 |
< |
char *nm; |
| 226 |
> |
void |
| 227 |
> |
o_ring( /* make an illum ring */ |
| 228 |
> |
OBJREC *ob, |
| 229 |
> |
struct illum_args *il, |
| 230 |
> |
struct rtproc *rt, |
| 231 |
> |
char *nm |
| 232 |
> |
) |
| 233 |
|
{ |
| 234 |
|
int dim[3]; |
| 235 |
|
int n, nalt, nazi; |
| 290 |
|
printobj(il->altmat, ob); |
| 291 |
|
/* clean up */ |
| 292 |
|
freecone(ob); |
| 293 |
< |
free((char *)distarr); |
| 293 |
> |
free((void *)distarr); |
| 294 |
|
} |
| 295 |
|
|
| 296 |
|
|
| 297 |
< |
raysamp(res, org, dir, rt) /* compute a ray sample */ |
| 298 |
< |
float res[3]; |
| 299 |
< |
FVECT org, dir; |
| 300 |
< |
register struct rtproc *rt; |
| 297 |
> |
void |
| 298 |
> |
raysamp( /* compute a ray sample */ |
| 299 |
> |
float res[3], |
| 300 |
> |
FVECT org, |
| 301 |
> |
FVECT dir, |
| 302 |
> |
register struct rtproc *rt |
| 303 |
> |
) |
| 304 |
|
{ |
| 305 |
|
register float *fp; |
| 306 |
|
|
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
|
| 316 |
< |
rayflush(rt) /* flush buffered rays */ |
| 317 |
< |
register struct rtproc *rt; |
| 316 |
> |
void |
| 317 |
> |
rayflush( /* flush buffered rays */ |
| 318 |
> |
register struct rtproc *rt |
| 319 |
> |
) |
| 320 |
|
{ |
| 321 |
|
register int i; |
| 322 |
|
|
| 323 |
|
if (rt->nrays <= 0) |
| 324 |
|
return; |
| 325 |
< |
bzero(rt->buf+6*rt->nrays, 6*sizeof(float)); |
| 325 |
> |
memset(rt->buf+6*rt->nrays, '\0', 6*sizeof(float)); |
| 326 |
|
errno = 0; |
| 327 |
< |
if ( process(rt->pd, (char *)rt->buf, (char *)rt->buf, |
| 328 |
< |
3*sizeof(float)*rt->nrays, |
| 327 |
> |
if ( process(&(rt->pd), (char *)rt->buf, (char *)rt->buf, |
| 328 |
> |
3*sizeof(float)*(rt->nrays+1), |
| 329 |
|
6*sizeof(float)*(rt->nrays+1)) < |
| 330 |
< |
3*sizeof(float)*rt->nrays ) |
| 330 |
> |
3*sizeof(float)*(rt->nrays+1) ) |
| 331 |
|
error(SYSTEM, "error reading from rtrace process"); |
| 332 |
|
i = rt->nrays; |
| 333 |
|
while (i--) { |
| 339 |
|
} |
| 340 |
|
|
| 341 |
|
|
| 342 |
< |
mkaxes(u, v, n) /* compute u and v to go with n */ |
| 343 |
< |
FVECT u, v, n; |
| 342 |
> |
void |
| 343 |
> |
mkaxes( /* compute u and v to go with n */ |
| 344 |
> |
FVECT u, |
| 345 |
> |
FVECT v, |
| 346 |
> |
FVECT n |
| 347 |
> |
) |
| 348 |
|
{ |
| 349 |
|
register int i; |
| 350 |
|
|
| 359 |
|
} |
| 360 |
|
|
| 361 |
|
|
| 362 |
< |
rounddir(dv, alt, azi) /* compute uniform spherical direction */ |
| 363 |
< |
register FVECT dv; |
| 364 |
< |
double alt, azi; |
| 362 |
> |
void |
| 363 |
> |
rounddir( /* compute uniform spherical direction */ |
| 364 |
> |
register FVECT dv, |
| 365 |
> |
double alt, |
| 366 |
> |
double azi |
| 367 |
> |
) |
| 368 |
|
{ |
| 369 |
|
double d1, d2; |
| 370 |
|
|
| 376 |
|
} |
| 377 |
|
|
| 378 |
|
|
| 379 |
< |
flatdir(dv, alt, azi) /* compute uniform hemispherical direction */ |
| 380 |
< |
register FVECT dv; |
| 381 |
< |
double alt, azi; |
| 379 |
> |
void |
| 380 |
> |
flatdir( /* compute uniform hemispherical direction */ |
| 381 |
> |
register FVECT dv, |
| 382 |
> |
double alt, |
| 383 |
> |
double azi |
| 384 |
> |
) |
| 385 |
|
{ |
| 386 |
|
double d1, d2; |
| 387 |
|
|