| 5 |
|
* Routines to do the actual calculation for mkillum |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include <string.h> |
| 9 |
+ |
|
| 10 |
|
#include "mkillum.h" |
| 11 |
|
#include "face.h" |
| 12 |
|
#include "cone.h" |
| 13 |
|
#include "random.h" |
| 14 |
|
|
| 15 |
|
|
| 16 |
< |
o_default(ob, il, rt, nm) /* default illum action */ |
| 17 |
< |
OBJREC *ob; |
| 18 |
< |
struct illum_args *il; |
| 19 |
< |
struct rtproc *rt; |
| 20 |
< |
char *nm; |
| 16 |
> |
int o_default(FUN_ARGLIST); |
| 17 |
> |
int o_face(FUN_ARGLIST); |
| 18 |
> |
int o_sphere(FUN_ARGLIST); |
| 19 |
> |
int o_ring(FUN_ARGLIST); |
| 20 |
> |
void raysamp(float res[3], FVECT org, FVECT dir, struct rtproc *rt); |
| 21 |
> |
void rayflush(struct rtproc *rt); |
| 22 |
> |
void mkaxes(FVECT u, FVECT v, FVECT n); |
| 23 |
> |
void rounddir(FVECT dv, double alt, double azi); |
| 24 |
> |
void flatdir(FVECT dv, double alt, double azi); |
| 25 |
> |
|
| 26 |
> |
|
| 27 |
> |
int /* XXX type conflict with otypes.h */ |
| 28 |
> |
o_default( /* default illum action */ |
| 29 |
> |
OBJREC *ob, |
| 30 |
> |
struct illum_args *il, |
| 31 |
> |
struct rtproc *rt, |
| 32 |
> |
char *nm |
| 33 |
> |
) |
| 34 |
|
{ |
| 35 |
|
sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"", |
| 36 |
|
nm, ofun[ob->otype].funame, ob->oname); |
| 37 |
|
error(WARNING, errmsg); |
| 38 |
|
printobj(il->altmat, ob); |
| 39 |
+ |
return(1); |
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
|
| 43 |
< |
o_face(ob, il, rt, nm) /* make an illum face */ |
| 44 |
< |
OBJREC *ob; |
| 45 |
< |
struct illum_args *il; |
| 46 |
< |
struct rtproc *rt; |
| 47 |
< |
char *nm; |
| 43 |
> |
int |
| 44 |
> |
o_face( /* make an illum face */ |
| 45 |
> |
OBJREC *ob, |
| 46 |
> |
struct illum_args *il, |
| 47 |
> |
struct rtproc *rt, |
| 48 |
> |
char *nm |
| 49 |
> |
) |
| 50 |
|
{ |
| 51 |
|
#define MAXMISS (5*n*il->nsamps) |
| 52 |
|
int dim[3]; |
| 63 |
|
fa = getface(ob); |
| 64 |
|
if (fa->area == 0.0) { |
| 65 |
|
freeface(ob); |
| 66 |
< |
o_default(ob, il, rt, nm); |
| 49 |
< |
return; |
| 66 |
> |
return(o_default(ob, il, rt, nm)); |
| 67 |
|
} |
| 68 |
|
/* set up sampling */ |
| 69 |
|
if (il->sampdens <= 0) |
| 130 |
|
rt->nrays = 0; |
| 131 |
|
freeface(ob); |
| 132 |
|
free((void *)distarr); |
| 133 |
< |
o_default(ob, il, rt, nm); |
| 117 |
< |
return; |
| 133 |
> |
return(o_default(ob, il, rt, nm)); |
| 134 |
|
} |
| 135 |
|
for (j = 0; j < 3; j++) |
| 136 |
|
org[j] += .001*fa->norm[j]; |
| 149 |
|
freeface(ob); |
| 150 |
|
free((void *)distarr); |
| 151 |
|
#undef MAXMISS |
| 152 |
+ |
/* XXX we need to return something here. what is it? */ |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
|
| 156 |
< |
o_sphere(ob, il, rt, nm) /* make an illum sphere */ |
| 157 |
< |
register OBJREC *ob; |
| 158 |
< |
struct illum_args *il; |
| 159 |
< |
struct rtproc *rt; |
| 160 |
< |
char *nm; |
| 156 |
> |
int |
| 157 |
> |
o_sphere( /* make an illum sphere */ |
| 158 |
> |
register OBJREC *ob, |
| 159 |
> |
struct illum_args *il, |
| 160 |
> |
struct rtproc *rt, |
| 161 |
> |
char *nm |
| 162 |
> |
) |
| 163 |
|
{ |
| 164 |
|
int dim[3]; |
| 165 |
|
int n, nalt, nazi; |
| 221 |
|
printobj(il->altmat, ob); |
| 222 |
|
/* clean up */ |
| 223 |
|
free((void *)distarr); |
| 224 |
+ |
return(1); |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
|
| 228 |
< |
o_ring(ob, il, rt, nm) /* make an illum ring */ |
| 229 |
< |
OBJREC *ob; |
| 230 |
< |
struct illum_args *il; |
| 231 |
< |
struct rtproc *rt; |
| 232 |
< |
char *nm; |
| 228 |
> |
int |
| 229 |
> |
o_ring( /* make an illum ring */ |
| 230 |
> |
OBJREC *ob, |
| 231 |
> |
struct illum_args *il, |
| 232 |
> |
struct rtproc *rt, |
| 233 |
> |
char *nm |
| 234 |
> |
) |
| 235 |
|
{ |
| 236 |
|
int dim[3]; |
| 237 |
|
int n, nalt, nazi; |
| 293 |
|
/* clean up */ |
| 294 |
|
freecone(ob); |
| 295 |
|
free((void *)distarr); |
| 296 |
+ |
return(1); |
| 297 |
|
} |
| 298 |
|
|
| 299 |
|
|
| 300 |
< |
raysamp(res, org, dir, rt) /* compute a ray sample */ |
| 301 |
< |
float res[3]; |
| 302 |
< |
FVECT org, dir; |
| 303 |
< |
register struct rtproc *rt; |
| 300 |
> |
void |
| 301 |
> |
raysamp( /* compute a ray sample */ |
| 302 |
> |
float res[3], |
| 303 |
> |
FVECT org, |
| 304 |
> |
FVECT dir, |
| 305 |
> |
register struct rtproc *rt |
| 306 |
> |
) |
| 307 |
|
{ |
| 308 |
|
register float *fp; |
| 309 |
|
|
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
|
| 319 |
< |
rayflush(rt) /* flush buffered rays */ |
| 320 |
< |
register struct rtproc *rt; |
| 319 |
> |
void |
| 320 |
> |
rayflush( /* flush buffered rays */ |
| 321 |
> |
register struct rtproc *rt |
| 322 |
> |
) |
| 323 |
|
{ |
| 324 |
|
register int i; |
| 325 |
|
|
| 326 |
|
if (rt->nrays <= 0) |
| 327 |
|
return; |
| 328 |
< |
bzero(rt->buf+6*rt->nrays, 6*sizeof(float)); |
| 328 |
> |
memset(rt->buf+6*rt->nrays, '\0', 6*sizeof(float)); |
| 329 |
|
errno = 0; |
| 330 |
|
if ( process(&(rt->pd), (char *)rt->buf, (char *)rt->buf, |
| 331 |
|
3*sizeof(float)*(rt->nrays+1), |
| 342 |
|
} |
| 343 |
|
|
| 344 |
|
|
| 345 |
< |
mkaxes(u, v, n) /* compute u and v to go with n */ |
| 346 |
< |
FVECT u, v, n; |
| 345 |
> |
void |
| 346 |
> |
mkaxes( /* compute u and v to go with n */ |
| 347 |
> |
FVECT u, |
| 348 |
> |
FVECT v, |
| 349 |
> |
FVECT n |
| 350 |
> |
) |
| 351 |
|
{ |
| 352 |
|
register int i; |
| 353 |
|
|
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
|
| 365 |
< |
rounddir(dv, alt, azi) /* compute uniform spherical direction */ |
| 366 |
< |
register FVECT dv; |
| 367 |
< |
double alt, azi; |
| 365 |
> |
void |
| 366 |
> |
rounddir( /* compute uniform spherical direction */ |
| 367 |
> |
register FVECT dv, |
| 368 |
> |
double alt, |
| 369 |
> |
double azi |
| 370 |
> |
) |
| 371 |
|
{ |
| 372 |
|
double d1, d2; |
| 373 |
|
|
| 379 |
|
} |
| 380 |
|
|
| 381 |
|
|
| 382 |
< |
flatdir(dv, alt, azi) /* compute uniform hemispherical direction */ |
| 383 |
< |
register FVECT dv; |
| 384 |
< |
double alt, azi; |
| 382 |
> |
void |
| 383 |
> |
flatdir( /* compute uniform hemispherical direction */ |
| 384 |
> |
register FVECT dv, |
| 385 |
> |
double alt, |
| 386 |
> |
double azi |
| 387 |
> |
) |
| 388 |
|
{ |
| 389 |
|
double d1, d2; |
| 390 |
|
|