12 |
|
#include "copyright.h" |
13 |
|
|
14 |
|
#include <time.h> |
15 |
< |
#ifndef _WIN32 |
15 |
> |
#ifdef _WIN32 |
16 |
> |
#include <winsock.h> /* struct timeval. XXX find a replacement? */ |
17 |
> |
#else |
18 |
|
#include <sys/time.h> |
19 |
|
#endif |
20 |
|
#include <ctype.h> |
62 |
|
int gargc; /* global argc for printargs */ |
63 |
|
char **gargv; /* global argv for printargs */ |
64 |
|
|
65 |
+ |
static void setdefaults(void); |
66 |
+ |
static void setmove(struct ObjMove *om, char *ms); |
67 |
+ |
static void setrendparams(char *optf, char *qval); |
68 |
+ |
static void getradfile(char *rfargs); |
69 |
+ |
static void animate(void); |
70 |
+ |
static int countviews(void); /* XXX duplicated function */ |
71 |
+ |
static char * getobjname(struct ObjMove *om); |
72 |
+ |
static char * getxf(struct ObjMove *om, int n); |
73 |
|
|
74 |
+ |
|
75 |
|
int |
76 |
< |
main(argc, argv) |
77 |
< |
int argc; |
78 |
< |
char *argv[]; |
76 |
> |
main( |
77 |
> |
int argc, |
78 |
> |
char *argv[] |
79 |
> |
) |
80 |
|
{ |
81 |
|
int explicate = 0; |
82 |
|
char *cfname; |
109 |
|
case 'f': /* frame range */ |
110 |
|
switch (sscanf(argv[++i], "%d,%d", &fbeg, &fend)) { |
111 |
|
case 2: |
112 |
< |
if ((fbeg <= 0 | fend < fbeg)) |
112 |
> |
if ((fbeg <= 0) | (fend < fbeg)) |
113 |
|
goto userr; |
114 |
|
break; |
115 |
|
case 1: |
153 |
|
/* all done */ |
154 |
|
if (lorendoptf[0]) |
155 |
|
unlink(lorendoptf); |
156 |
< |
if (hirendoptf[0]) |
156 |
> |
if (hirendoptf[0] && strcmp(hirendoptf, lorendoptf)) |
157 |
|
unlink(hirendoptf); |
158 |
|
if (objtmpf[0]) |
159 |
|
unlink(objtmpf); |
163 |
|
"Usage: %s [-n nprocs][-f beg,end][-t sec][-d jnd][-s][-w][-e] anim_file\n", |
164 |
|
progname); |
165 |
|
quit(1); |
166 |
+ |
return 1; /* pro forma return */ |
167 |
|
} |
168 |
|
|
169 |
|
|
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
< |
void |
191 |
< |
setdefaults() /* set default values */ |
190 |
> |
static void |
191 |
> |
setdefaults(void) /* set default values */ |
192 |
|
{ |
193 |
|
int nviews; |
194 |
|
int decades; |
264 |
|
} |
265 |
|
|
266 |
|
|
267 |
< |
void |
268 |
< |
setmove(om, ms) /* assign a move object from spec. */ |
269 |
< |
struct ObjMove *om; |
270 |
< |
char *ms; |
267 |
> |
static void |
268 |
> |
setmove( /* assign a move object from spec. */ |
269 |
> |
struct ObjMove *om, |
270 |
> |
char *ms |
271 |
> |
) |
272 |
|
{ |
273 |
|
char parname[128]; |
274 |
|
char *cp; |
313 |
|
if (isflt(om->prio_file)) { |
314 |
|
om->prio = atof(om->prio_file); |
315 |
|
om->prio_file[0] = '\0'; |
316 |
< |
haveprio |= (om->prio < 0.95 | om->prio > 1.05); |
316 |
> |
haveprio |= ((om->prio < 0.95) | (om->prio > 1.05)); |
317 |
|
} else |
318 |
|
haveprio = 1; |
319 |
|
} else |
325 |
|
} |
326 |
|
|
327 |
|
|
328 |
< |
void |
329 |
< |
setrendparams(optf, qval) /* set global rendering parameters */ |
330 |
< |
char *optf; |
331 |
< |
char *qval; |
328 |
> |
static void |
329 |
> |
setrendparams( /* set global rendering parameters */ |
330 |
> |
char *optf, |
331 |
> |
char *qval |
332 |
> |
) |
333 |
|
{ |
334 |
|
char *argv[1024]; |
335 |
|
char **av = argv; |
349 |
|
if (qval != NULL && qval[0] == '-') |
350 |
|
ac += wordstring(av+ac, qval); |
351 |
|
|
352 |
< |
/* start with default parameters */ |
353 |
< |
ray_defaults(NULL); |
352 |
> |
/* restore default parameters */ |
353 |
> |
ray_restore(NULL); |
354 |
|
/* set what we have */ |
355 |
|
for (i = 0; i < ac; i++) { |
356 |
|
while ((rval = expandarg(&ac, &av, i)) > 0) |
364 |
|
continue; |
365 |
|
} |
366 |
|
rval = getrenderopt(ac-i, av+i); |
367 |
< |
if (rval >= 0) { |
368 |
< |
i += rval; |
369 |
< |
continue; |
367 |
> |
if (rval < 0) { |
368 |
> |
sprintf(errmsg, "bad render option at '%s'", av[i]); |
369 |
> |
error(USER, errmsg); |
370 |
|
} |
371 |
< |
sprintf(errmsg, "bad render option at '%s'", av[i]); |
357 |
< |
error(USER, errmsg); |
371 |
> |
i += rval; |
372 |
|
} |
373 |
|
} |
374 |
|
|
375 |
|
|
376 |
< |
void |
377 |
< |
getradfile(rfargs) /* run rad and get needed variables */ |
378 |
< |
char *rfargs; |
376 |
> |
static void |
377 |
> |
getradfile( /* run rad and get needed variables */ |
378 |
> |
char *rfargs |
379 |
> |
) |
380 |
|
{ |
381 |
|
static short mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1}; |
382 |
|
char combuf[256]; |
383 |
|
register int i; |
384 |
|
register char *cp; |
385 |
< |
char *pippt; |
385 |
> |
char *pippt = NULL; |
386 |
|
/* create rad command */ |
387 |
|
strcpy(lorendoptf, "ranim0.opt"); |
388 |
|
sprintf(combuf, |
425 |
|
} |
426 |
|
|
427 |
|
|
428 |
< |
void |
429 |
< |
animate() /* run through animation */ |
428 |
> |
static void |
429 |
> |
animate(void) /* run through animation */ |
430 |
|
{ |
431 |
|
int rpass; |
432 |
|
|
457 |
|
} |
458 |
|
|
459 |
|
|
460 |
< |
VIEW * |
461 |
< |
getview(n) /* get view number n */ |
462 |
< |
int n; |
460 |
> |
extern VIEW * |
461 |
> |
getview( /* get view number n */ |
462 |
> |
int n |
463 |
> |
) |
464 |
|
{ |
465 |
|
static FILE *viewfp = NULL; /* view file pointer */ |
466 |
|
static int viewnum = 0; /* current view number */ |
472 |
|
fclose(viewfp); |
473 |
|
viewfp = NULL; |
474 |
|
viewnum = 0; |
475 |
< |
copystruct(&curview, &stdview); |
475 |
> |
curview = stdview; |
476 |
|
} |
477 |
|
return(NULL); |
478 |
|
} |
488 |
|
perror(vval(VIEWFILE)); |
489 |
|
quit(1); |
490 |
|
} |
491 |
< |
copystruct(&curview, &stdview); |
491 |
> |
curview = stdview; |
492 |
|
viewnum = 0; |
493 |
|
} |
494 |
|
if (n < 0) { /* get next view */ |
508 |
|
} |
509 |
|
|
510 |
|
|
511 |
< |
int |
512 |
< |
countviews() /* count views in view file */ |
511 |
> |
static int |
512 |
> |
countviews(void) /* count views in view file */ |
513 |
|
{ |
514 |
|
int n; |
515 |
|
|
521 |
|
} |
522 |
|
|
523 |
|
|
524 |
< |
char * |
525 |
< |
getexp(n) /* get exposure for nth frame */ |
526 |
< |
int n; |
524 |
> |
extern char * |
525 |
> |
getexp( /* get exposure for nth frame */ |
526 |
> |
int n |
527 |
> |
) |
528 |
|
{ |
529 |
|
extern char *fskip(); |
530 |
|
static char expval[32]; |
576 |
|
sprintf(errmsg, "%s: exposure format error on line %d", |
577 |
|
vval(EXPOSURE), curfrm); |
578 |
|
error(USER, errmsg); |
579 |
+ |
return NULL; /* pro forma return */ |
580 |
|
} |
581 |
|
|
582 |
|
|
583 |
< |
double |
584 |
< |
expspec_val(s) /* get exposure value from spec. */ |
585 |
< |
char *s; |
583 |
> |
extern double |
584 |
> |
expspec_val( /* get exposure value from spec. */ |
585 |
> |
char *s |
586 |
> |
) |
587 |
|
{ |
588 |
|
double expval; |
589 |
|
|
591 |
|
return(1.0); |
592 |
|
|
593 |
|
expval = atof(s); |
594 |
< |
if ((s[0] == '+' | s[0] == '-')) |
594 |
> |
if ((s[0] == '+') | (s[0] == '-')) |
595 |
|
return(pow(2.0, expval)); |
596 |
|
return(expval); |
597 |
|
} |
598 |
|
|
599 |
|
|
600 |
< |
char * |
601 |
< |
getoctspec(n) /* get octree for the given frame */ |
602 |
< |
int n; |
600 |
> |
extern char * |
601 |
> |
getoctspec( /* get octree for the given frame */ |
602 |
> |
int n |
603 |
> |
) |
604 |
|
{ |
605 |
|
static char combuf[1024]; |
606 |
|
int cfm = 0; |
652 |
|
} |
653 |
|
|
654 |
|
|
655 |
< |
char * |
656 |
< |
getobjname(om) /* get fully qualified object name */ |
657 |
< |
register struct ObjMove *om; |
655 |
> |
static char * |
656 |
> |
getobjname( /* get fully qualified object name */ |
657 |
> |
register struct ObjMove *om |
658 |
> |
) |
659 |
|
{ |
660 |
|
static char objName[512]; |
661 |
|
register char *cp = objName; |
671 |
|
} |
672 |
|
|
673 |
|
|
674 |
< |
char * |
675 |
< |
getxf(om, n) /* get total transform for object */ |
676 |
< |
register struct ObjMove *om; |
677 |
< |
int n; |
674 |
> |
static char * |
675 |
> |
getxf( /* get total transform for object */ |
676 |
> |
register struct ObjMove *om, |
677 |
> |
int n |
678 |
> |
) |
679 |
|
{ |
680 |
|
static char xfsbuf[4096]; |
681 |
|
char *xfp; |
783 |
|
om->cprio = om->prio; |
784 |
|
} |
785 |
|
/* XXX bxfm relies on call order */ |
786 |
< |
if (framestep) |
786 |
> |
if (framestep) { |
787 |
|
if (invmat4(om->bxfm, om->cxfm)) |
788 |
|
multmat4(om->bxfm, om->bxfm, oxf.xfm); |
789 |
|
else |
790 |
|
setident4(om->bxfm); |
791 |
+ |
} |
792 |
|
/* all done */ |
793 |
|
return(xfp); |
794 |
|
} |
795 |
|
|
796 |
|
|
797 |
< |
int |
798 |
< |
getmove(obj) /* find matching move object */ |
799 |
< |
OBJECT obj; |
797 |
> |
extern int |
798 |
> |
getmove( /* find matching move object */ |
799 |
> |
OBJECT obj |
800 |
> |
) |
801 |
|
{ |
802 |
|
static int lasti; |
803 |
|
static OBJECT lasto = OVOID; |
815 |
|
objnm = obj_move[i].name; |
816 |
|
len = strlen(objnm); |
817 |
|
if (!strncmp(onm, objnm, len)) { |
818 |
< |
if ((obj_move[i].parent < 0 & onm[len] == '.')) |
818 |
> |
if ((obj_move[i].parent < 0) & (onm[len] == '.')) |
819 |
|
break; |
820 |
|
objnm = getobjname(&obj_move[i]) + len; |
821 |
|
len2 = strlen(objnm); |
828 |
|
} |
829 |
|
|
830 |
|
|
831 |
< |
double |
832 |
< |
obj_prio(obj) /* return priority for object */ |
833 |
< |
OBJECT obj; |
831 |
> |
extern double |
832 |
> |
obj_prio( /* return priority for object */ |
833 |
> |
OBJECT obj |
834 |
> |
) |
835 |
|
{ |
836 |
|
int moi; |
837 |
|
|
841 |
|
} |
842 |
|
|
843 |
|
|
844 |
< |
double |
845 |
< |
getTime() /* get current time (CPU or real) */ |
844 |
> |
extern double |
845 |
> |
getTime(void) /* get current time (CPU or real) */ |
846 |
|
{ |
847 |
|
struct timeval time_now; |
848 |
|
/* return CPU time if one process */ |