1 |
|
#ifndef lint |
2 |
< |
static const char RCSid[] = "$Id$"; |
2 |
> |
static const char RCSid[] = "$Id"; |
3 |
|
#endif |
4 |
|
/* |
5 |
|
* Radiance object animation program |
9 |
|
* See ranimove.h and the ranimove(1) man page for details. |
10 |
|
*/ |
11 |
|
|
12 |
< |
/* ==================================================================== |
13 |
< |
* The Radiance Software License, Version 1.0 |
14 |
< |
* |
15 |
< |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
16 |
< |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
17 |
< |
* |
18 |
< |
* Redistribution and use in source and binary forms, with or without |
19 |
< |
* modification, are permitted provided that the following conditions |
20 |
< |
* are met: |
21 |
< |
* |
22 |
< |
* 1. Redistributions of source code must retain the above copyright |
23 |
< |
* notice, this list of conditions and the following disclaimer. |
24 |
< |
* |
25 |
< |
* 2. Redistributions in binary form must reproduce the above copyright |
26 |
< |
* notice, this list of conditions and the following disclaimer in |
27 |
< |
* the documentation and/or other materials provided with the |
28 |
< |
* distribution. |
29 |
< |
* |
30 |
< |
* 3. The end-user documentation included with the redistribution, |
31 |
< |
* if any, must include the following acknowledgment: |
32 |
< |
* "This product includes Radiance software |
33 |
< |
* (http://radsite.lbl.gov/) |
34 |
< |
* developed by the Lawrence Berkeley National Laboratory |
35 |
< |
* (http://www.lbl.gov/)." |
36 |
< |
* Alternately, this acknowledgment may appear in the software itself, |
37 |
< |
* if and wherever such third-party acknowledgments normally appear. |
38 |
< |
* |
39 |
< |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
40 |
< |
* and "The Regents of the University of California" must |
41 |
< |
* not be used to endorse or promote products derived from this |
42 |
< |
* software without prior written permission. For written |
43 |
< |
* permission, please contact [email protected]. |
44 |
< |
* |
45 |
< |
* 5. Products derived from this software may not be called "Radiance", |
46 |
< |
* nor may "Radiance" appear in their name, without prior written |
47 |
< |
* permission of Lawrence Berkeley National Laboratory. |
48 |
< |
* |
49 |
< |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
50 |
< |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
51 |
< |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
52 |
< |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
53 |
< |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
54 |
< |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
55 |
< |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
56 |
< |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
57 |
< |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
58 |
< |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
59 |
< |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
60 |
< |
* SUCH DAMAGE. |
61 |
< |
* ==================================================================== |
62 |
< |
* |
63 |
< |
* This software consists of voluntary contributions made by many |
64 |
< |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
65 |
< |
* information on Lawrence Berkeley National Laboratory, please see |
66 |
< |
* <http://www.lbl.gov/>. |
67 |
< |
*/ |
12 |
> |
#include "copyright.h" |
13 |
|
|
14 |
< |
#include "ranimove.h" |
15 |
< |
#include <sys/time.h> |
14 |
> |
#include <time.h> |
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> |
21 |
+ |
#include <string.h> |
22 |
|
|
23 |
+ |
#include "paths.h" |
24 |
+ |
#include "ranimove.h" |
25 |
+ |
|
26 |
|
int NVARS = NV_INIT; /* total number of variables */ |
27 |
|
|
28 |
|
VARIABLE vv[] = VV_INIT; /* variable-value pairs */ |
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 |
|
|
170 |
|
void |
171 |
< |
eputs(s) /* put string to stderr */ |
172 |
< |
register char *s; |
171 |
> |
eputs( /* put string to stderr */ |
172 |
> |
register char *s |
173 |
> |
) |
174 |
|
{ |
175 |
|
static int midline = 0; |
176 |
|
|
188 |
|
} |
189 |
|
|
190 |
|
|
191 |
< |
void |
192 |
< |
setdefaults() /* set default values */ |
191 |
> |
static void |
192 |
> |
setdefaults(void) /* set default values */ |
193 |
|
{ |
194 |
|
int nviews; |
195 |
|
int decades; |
261 |
|
setrendparams(lorendoptf, vval(LOWQ)); |
262 |
|
ray_save(&lorendparams); |
263 |
|
curparams = &lorendparams; |
264 |
< |
twolevels = bcmp(&lorendparams, &hirendparams, sizeof(RAYPARAMS)); |
264 |
> |
twolevels = memcmp(&lorendparams, &hirendparams, sizeof(RAYPARAMS)); |
265 |
|
} |
266 |
|
|
267 |
|
|
268 |
< |
void |
269 |
< |
setmove(om, ms) /* assign a move object from spec. */ |
270 |
< |
struct ObjMove *om; |
271 |
< |
char *ms; |
268 |
> |
static void |
269 |
> |
setmove( /* assign a move object from spec. */ |
270 |
> |
struct ObjMove *om, |
271 |
> |
char *ms |
272 |
> |
) |
273 |
|
{ |
274 |
|
char parname[128]; |
275 |
|
char *cp; |
314 |
|
if (isflt(om->prio_file)) { |
315 |
|
om->prio = atof(om->prio_file); |
316 |
|
om->prio_file[0] = '\0'; |
317 |
< |
haveprio |= (om->prio < 0.95 | om->prio > 1.05); |
317 |
> |
haveprio |= ((om->prio < 0.95) | (om->prio > 1.05)); |
318 |
|
} else |
319 |
|
haveprio = 1; |
320 |
|
} else |
326 |
|
} |
327 |
|
|
328 |
|
|
329 |
< |
void |
330 |
< |
setrendparams(optf, qval) /* set global rendering parameters */ |
331 |
< |
char *optf; |
332 |
< |
char *qval; |
329 |
> |
static void |
330 |
> |
setrendparams( /* set global rendering parameters */ |
331 |
> |
char *optf, |
332 |
> |
char *qval |
333 |
> |
) |
334 |
|
{ |
335 |
|
char *argv[1024]; |
336 |
|
char **av = argv; |
350 |
|
if (qval != NULL && qval[0] == '-') |
351 |
|
ac += wordstring(av+ac, qval); |
352 |
|
|
353 |
< |
/* start with default parameters */ |
354 |
< |
ray_defaults(NULL); |
353 |
> |
/* restore default parameters */ |
354 |
> |
ray_restore(NULL); |
355 |
|
/* set what we have */ |
356 |
|
for (i = 0; i < ac; i++) { |
357 |
|
while ((rval = expandarg(&ac, &av, i)) > 0) |
365 |
|
continue; |
366 |
|
} |
367 |
|
rval = getrenderopt(ac-i, av+i); |
368 |
< |
if (rval >= 0) { |
369 |
< |
i += rval; |
370 |
< |
continue; |
368 |
> |
if (rval < 0) { |
369 |
> |
sprintf(errmsg, "bad render option at '%s'", av[i]); |
370 |
> |
error(USER, errmsg); |
371 |
|
} |
372 |
< |
sprintf(errmsg, "bad render option at '%s'", av[i]); |
406 |
< |
error(USER, errmsg); |
372 |
> |
i += rval; |
373 |
|
} |
374 |
|
} |
375 |
|
|
376 |
|
|
377 |
< |
void |
378 |
< |
getradfile(rfargs) /* run rad and get needed variables */ |
379 |
< |
char *rfargs; |
377 |
> |
static void |
378 |
> |
getradfile( /* run rad and get needed variables */ |
379 |
> |
char *rfargs |
380 |
> |
) |
381 |
|
{ |
382 |
|
static short mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1}; |
383 |
|
char combuf[256]; |
384 |
|
register int i; |
385 |
|
register char *cp; |
386 |
< |
char *pippt; |
386 |
> |
char *pippt = NULL; |
387 |
|
/* create rad command */ |
388 |
|
strcpy(lorendoptf, "ranim0.opt"); |
389 |
|
sprintf(combuf, |
404 |
|
pippt = NULL; |
405 |
|
} |
406 |
|
if (pippt != NULL) |
407 |
< |
strcpy(pippt, "> /dev/null"); /* nothing to match */ |
407 |
> |
strcpy(pippt, "> " NULL_DEVICE); /* nothing to match */ |
408 |
|
else { |
409 |
|
strcpy(cp, ")[ \t]*=' > ranimove.var"); |
410 |
|
cp += 11; /* point to file name */ |
426 |
|
} |
427 |
|
|
428 |
|
|
429 |
< |
void |
430 |
< |
animate() /* run through animation */ |
429 |
> |
static void |
430 |
> |
animate(void) /* run through animation */ |
431 |
|
{ |
432 |
|
int rpass; |
433 |
|
|
458 |
|
} |
459 |
|
|
460 |
|
|
461 |
< |
VIEW * |
462 |
< |
getview(n) /* get view number n */ |
463 |
< |
int n; |
461 |
> |
extern VIEW * |
462 |
> |
getview( /* get view number n */ |
463 |
> |
int n |
464 |
> |
) |
465 |
|
{ |
466 |
|
static FILE *viewfp = NULL; /* view file pointer */ |
467 |
|
static int viewnum = 0; /* current view number */ |
473 |
|
fclose(viewfp); |
474 |
|
viewfp = NULL; |
475 |
|
viewnum = 0; |
476 |
< |
copystruct(&curview, &stdview); |
476 |
> |
curview = stdview; |
477 |
|
} |
478 |
|
return(NULL); |
479 |
|
} |
489 |
|
perror(vval(VIEWFILE)); |
490 |
|
quit(1); |
491 |
|
} |
492 |
< |
copystruct(&curview, &stdview); |
492 |
> |
curview = stdview; |
493 |
|
viewnum = 0; |
494 |
|
} |
495 |
|
if (n < 0) { /* get next view */ |
509 |
|
} |
510 |
|
|
511 |
|
|
512 |
< |
int |
513 |
< |
countviews() /* count views in view file */ |
512 |
> |
static int |
513 |
> |
countviews(void) /* count views in view file */ |
514 |
|
{ |
515 |
|
int n; |
516 |
|
|
522 |
|
} |
523 |
|
|
524 |
|
|
525 |
< |
char * |
526 |
< |
getexp(n) /* get exposure for nth frame */ |
527 |
< |
int n; |
525 |
> |
extern char * |
526 |
> |
getexp( /* get exposure for nth frame */ |
527 |
> |
int n |
528 |
> |
) |
529 |
|
{ |
530 |
|
extern char *fskip(); |
531 |
|
static char expval[32]; |
577 |
|
sprintf(errmsg, "%s: exposure format error on line %d", |
578 |
|
vval(EXPOSURE), curfrm); |
579 |
|
error(USER, errmsg); |
580 |
+ |
return NULL; /* pro forma return */ |
581 |
|
} |
582 |
|
|
583 |
|
|
584 |
< |
double |
585 |
< |
expspec_val(s) /* get exposure value from spec. */ |
586 |
< |
char *s; |
584 |
> |
extern double |
585 |
> |
expspec_val( /* get exposure value from spec. */ |
586 |
> |
char *s |
587 |
> |
) |
588 |
|
{ |
589 |
|
double expval; |
590 |
|
|
592 |
|
return(1.0); |
593 |
|
|
594 |
|
expval = atof(s); |
595 |
< |
if ((s[0] == '+' | s[0] == '-')) |
595 |
> |
if ((s[0] == '+') | (s[0] == '-')) |
596 |
|
return(pow(2.0, expval)); |
597 |
|
return(expval); |
598 |
|
} |
599 |
|
|
600 |
|
|
601 |
< |
char * |
602 |
< |
getoctspec(n) /* get octree for the given frame */ |
603 |
< |
int n; |
601 |
> |
extern char * |
602 |
> |
getoctspec( /* get octree for the given frame */ |
603 |
> |
int n |
604 |
> |
) |
605 |
|
{ |
606 |
|
static char combuf[1024]; |
607 |
|
int cfm = 0; |
653 |
|
} |
654 |
|
|
655 |
|
|
656 |
< |
char * |
657 |
< |
getobjname(om) /* get fully qualified object name */ |
658 |
< |
register struct ObjMove *om; |
656 |
> |
static char * |
657 |
> |
getobjname( /* get fully qualified object name */ |
658 |
> |
register struct ObjMove *om |
659 |
> |
) |
660 |
|
{ |
661 |
|
static char objName[512]; |
662 |
|
register char *cp = objName; |
672 |
|
} |
673 |
|
|
674 |
|
|
675 |
< |
char * |
676 |
< |
getxf(om, n) /* get total transform for object */ |
677 |
< |
register struct ObjMove *om; |
678 |
< |
int n; |
675 |
> |
static char * |
676 |
> |
getxf( /* get total transform for object */ |
677 |
> |
register struct ObjMove *om, |
678 |
> |
int n |
679 |
> |
) |
680 |
|
{ |
681 |
|
static char xfsbuf[4096]; |
682 |
|
char *xfp; |
784 |
|
om->cprio = om->prio; |
785 |
|
} |
786 |
|
/* XXX bxfm relies on call order */ |
787 |
< |
if (framestep) |
787 |
> |
if (framestep) { |
788 |
|
if (invmat4(om->bxfm, om->cxfm)) |
789 |
|
multmat4(om->bxfm, om->bxfm, oxf.xfm); |
790 |
|
else |
791 |
|
setident4(om->bxfm); |
792 |
+ |
} |
793 |
|
/* all done */ |
794 |
|
return(xfp); |
795 |
|
} |
796 |
|
|
797 |
|
|
798 |
< |
int |
799 |
< |
getmove(obj) /* find matching move object */ |
800 |
< |
OBJECT obj; |
798 |
> |
extern int |
799 |
> |
getmove( /* find matching move object */ |
800 |
> |
OBJECT obj |
801 |
> |
) |
802 |
|
{ |
803 |
|
static int lasti; |
804 |
|
static OBJECT lasto = OVOID; |
816 |
|
objnm = obj_move[i].name; |
817 |
|
len = strlen(objnm); |
818 |
|
if (!strncmp(onm, objnm, len)) { |
819 |
< |
if ((obj_move[i].parent < 0 & onm[len] == '.')) |
819 |
> |
if ((obj_move[i].parent < 0) & (onm[len] == '.')) |
820 |
|
break; |
821 |
|
objnm = getobjname(&obj_move[i]) + len; |
822 |
|
len2 = strlen(objnm); |
829 |
|
} |
830 |
|
|
831 |
|
|
832 |
< |
double |
833 |
< |
obj_prio(obj) /* return priority for object */ |
834 |
< |
OBJECT obj; |
832 |
> |
extern double |
833 |
> |
obj_prio( /* return priority for object */ |
834 |
> |
OBJECT obj |
835 |
> |
) |
836 |
|
{ |
837 |
|
int moi; |
838 |
|
|
842 |
|
} |
843 |
|
|
844 |
|
|
845 |
< |
double |
846 |
< |
getTime() /* get current time (CPU or real) */ |
845 |
> |
extern double |
846 |
> |
getTime(void) /* get current time (CPU or real) */ |
847 |
|
{ |
848 |
|
struct timeval time_now; |
849 |
|
/* return CPU time if one process */ |