| 1 |
|
#ifndef lint |
| 2 |
< |
static const char RCSid[] = "$Id"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 4 |
|
/* |
| 5 |
|
* Radiance object animation program |
| 12 |
|
#include "copyright.h" |
| 13 |
|
|
| 14 |
|
#include <time.h> |
| 15 |
< |
#ifdef _WIN32 |
| 15 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 16 |
|
#include <winsock.h> /* struct timeval. XXX find a replacement? */ |
| 17 |
|
#else |
| 18 |
|
#include <sys/time.h> |
| 20 |
|
#include <ctype.h> |
| 21 |
|
#include <string.h> |
| 22 |
|
|
| 23 |
+ |
#include "platform.h" |
| 24 |
|
#include "paths.h" |
| 25 |
|
#include "ranimove.h" |
| 26 |
+ |
#include "func.h" |
| 27 |
|
|
| 28 |
|
int NVARS = NV_INIT; /* total number of variables */ |
| 29 |
|
|
| 83 |
|
int explicate = 0; |
| 84 |
|
char *cfname; |
| 85 |
|
int i; |
| 86 |
< |
|
| 87 |
< |
progname = argv[0]; /* get arguments */ |
| 86 |
> |
/* set global progname */ |
| 87 |
> |
fixargv0(argv[0]); |
| 88 |
> |
/* initialize calcomp */ |
| 89 |
> |
initfunc(); |
| 90 |
|
gargc = argc; |
| 91 |
|
gargv = argv; |
| 92 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
| 173 |
|
|
| 174 |
|
void |
| 175 |
|
eputs( /* put string to stderr */ |
| 176 |
< |
register char *s |
| 176 |
> |
const char *s |
| 177 |
|
) |
| 178 |
|
{ |
| 179 |
|
static int midline = 0; |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
|
| 195 |
+ |
void |
| 196 |
+ |
quit(int ec) /* make sure exit is called */ |
| 197 |
+ |
{ |
| 198 |
+ |
if (ray_pnprocs > 0) /* close children if any */ |
| 199 |
+ |
ray_pclose(0); |
| 200 |
+ |
else if (ray_pnprocs < 0) |
| 201 |
+ |
_exit(ec); /* avoid flush in child */ |
| 202 |
+ |
exit(ec); |
| 203 |
+ |
} |
| 204 |
+ |
|
| 205 |
+ |
|
| 206 |
|
static void |
| 207 |
|
setdefaults(void) /* set default values */ |
| 208 |
|
{ |
| 354 |
|
av[ac=0] = NULL; |
| 355 |
|
/* load options from file, first */ |
| 356 |
|
if (optf != NULL && *optf) { |
| 357 |
< |
ac = wordfile(av, optf); |
| 357 |
> |
ac = wordfile(av, 1024, optf); |
| 358 |
|
if (ac < 0) { |
| 359 |
|
sprintf(errmsg, "cannot load options file \"%s\"", |
| 360 |
|
optf); |
| 363 |
|
} |
| 364 |
|
/* then from options string */ |
| 365 |
|
if (qval != NULL && qval[0] == '-') |
| 366 |
< |
ac += wordstring(av+ac, qval); |
| 366 |
> |
ac += wordstring(av+ac, 1024-ac, qval); |
| 367 |
|
|
| 368 |
|
/* restore default parameters */ |
| 369 |
|
ray_restore(NULL); |
| 396 |
|
{ |
| 397 |
|
static short mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1}; |
| 398 |
|
char combuf[256]; |
| 399 |
< |
register int i; |
| 400 |
< |
register char *cp; |
| 399 |
> |
int i; |
| 400 |
> |
char *cp; |
| 401 |
|
char *pippt = NULL; |
| 402 |
|
/* create rad command */ |
| 403 |
|
strcpy(lorendoptf, "ranim0.opt"); |
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
|
| 476 |
< |
extern VIEW * |
| 476 |
> |
VIEW * |
| 477 |
|
getview( /* get view number n */ |
| 478 |
|
int n |
| 479 |
|
) |
| 508 |
|
viewnum = 0; |
| 509 |
|
} |
| 510 |
|
if (n < 0) { /* get next view */ |
| 511 |
< |
register int c = getc(viewfp); |
| 511 |
> |
int c = getc(viewfp); |
| 512 |
|
if (c == EOF) |
| 513 |
|
return(NULL); /* that's it */ |
| 514 |
|
ungetc(c, viewfp); |
| 537 |
|
} |
| 538 |
|
|
| 539 |
|
|
| 540 |
< |
extern char * |
| 540 |
> |
char * |
| 541 |
|
getexp( /* get exposure for nth frame */ |
| 542 |
|
int n |
| 543 |
|
) |
| 544 |
|
{ |
| 530 |
– |
extern char *fskip(); |
| 545 |
|
static char expval[32]; |
| 546 |
|
static FILE *expfp = NULL; |
| 547 |
|
static int curfrm = 0; |
| 548 |
< |
register char *cp; |
| 548 |
> |
char *cp; |
| 549 |
|
|
| 550 |
|
if (n == 0) { /* signal to close file */ |
| 551 |
|
if (expfp != NULL) { |
| 595 |
|
} |
| 596 |
|
|
| 597 |
|
|
| 598 |
< |
extern double |
| 598 |
> |
double |
| 599 |
|
expspec_val( /* get exposure value from spec. */ |
| 600 |
|
char *s |
| 601 |
|
) |
| 612 |
|
} |
| 613 |
|
|
| 614 |
|
|
| 615 |
< |
extern char * |
| 615 |
> |
char * |
| 616 |
|
getoctspec( /* get octree for the given frame */ |
| 617 |
|
int n |
| 618 |
|
) |
| 619 |
|
{ |
| 620 |
|
static char combuf[1024]; |
| 621 |
< |
int cfm = 0; |
| 621 |
> |
static int cfm = 0; |
| 622 |
|
int uses_inline; |
| 623 |
|
FILE *fp; |
| 624 |
|
int i; |
| 625 |
|
/* is octree static? */ |
| 626 |
|
if (!vdef(MOVE)) |
| 627 |
|
return(vval(OCTREEF)); |
| 628 |
< |
/* done already */ |
| 628 |
> |
/* done already? */ |
| 629 |
|
if (n == cfm) |
| 630 |
|
return(combuf); |
| 631 |
|
/* else create object file */ |
| 632 |
< |
strcpy(objtmpf, "movinobj.rad"); |
| 619 |
< |
fp = fopen(objtmpf, "w"); |
| 632 |
> |
fp = fopen(mktemp(strcpy(objtmpf, TEMPLATE)), "w"); |
| 633 |
|
if (fp == NULL) { |
| 634 |
|
sprintf(errmsg, "cannot write to moving objects file '%s'", |
| 635 |
|
objtmpf); |
| 660 |
|
vdef(OCONV) ? vval(OCONV) : "", |
| 661 |
|
vval(OCTREEF), objtmpf); |
| 662 |
|
else |
| 663 |
< |
sprintf(combuf, "!xform -f %s | oconv -f -i '%s' -", |
| 664 |
< |
objtmpf, vval(OCTREEF)); |
| 663 |
> |
sprintf(combuf, "!xform -f %s | oconv %s -f -i '%s' -", |
| 664 |
> |
objtmpf, vdef(OCONV) ? vval(OCONV) : "", |
| 665 |
> |
vval(OCTREEF)); |
| 666 |
|
return(combuf); |
| 667 |
|
} |
| 668 |
|
|
| 669 |
|
|
| 670 |
|
static char * |
| 671 |
|
getobjname( /* get fully qualified object name */ |
| 672 |
< |
register struct ObjMove *om |
| 672 |
> |
struct ObjMove *om |
| 673 |
|
) |
| 674 |
|
{ |
| 675 |
|
static char objName[512]; |
| 676 |
< |
register char *cp = objName; |
| 676 |
> |
char *cp = objName; |
| 677 |
|
|
| 678 |
|
strcpy(cp, om->name); |
| 679 |
|
while (om->parent >= 0) { |
| 688 |
|
|
| 689 |
|
static char * |
| 690 |
|
getxf( /* get total transform for object */ |
| 691 |
< |
register struct ObjMove *om, |
| 691 |
> |
struct ObjMove *om, |
| 692 |
|
int n |
| 693 |
|
) |
| 694 |
|
{ |
| 701 |
|
char *av[64]; |
| 702 |
|
int ac; |
| 703 |
|
int i; |
| 704 |
< |
register char *cp; |
| 704 |
> |
char *cp; |
| 705 |
|
/* get parent transform, first */ |
| 706 |
|
if (om->parent >= 0) |
| 707 |
|
xfp = getxf(&obj_move[om->parent], n); |
| 809 |
|
} |
| 810 |
|
|
| 811 |
|
|
| 812 |
< |
extern int |
| 812 |
> |
int |
| 813 |
|
getmove( /* find matching move object */ |
| 814 |
|
OBJECT obj |
| 815 |
|
) |
| 818 |
|
static OBJECT lasto = OVOID; |
| 819 |
|
char *onm, *objnm; |
| 820 |
|
int len, len2; |
| 821 |
< |
register int i; |
| 821 |
> |
int i; |
| 822 |
|
|
| 823 |
|
if (obj == OVOID) |
| 824 |
|
return(-1); |
| 843 |
|
} |
| 844 |
|
|
| 845 |
|
|
| 846 |
< |
extern double |
| 846 |
> |
double |
| 847 |
|
obj_prio( /* return priority for object */ |
| 848 |
|
OBJECT obj |
| 849 |
|
) |
| 856 |
|
} |
| 857 |
|
|
| 858 |
|
|
| 859 |
< |
extern double |
| 859 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 860 |
> |
/* replacement function for Windoze */ |
| 861 |
> |
static int |
| 862 |
> |
gettimeofday(struct timeval *tp, void *dummy) |
| 863 |
> |
{ |
| 864 |
> |
FILETIME ft; |
| 865 |
> |
LARGE_INTEGER li; |
| 866 |
> |
__int64 t; |
| 867 |
> |
|
| 868 |
> |
SYSTEMTIME st; |
| 869 |
> |
FILETIME ft2; |
| 870 |
> |
LARGE_INTEGER li2; |
| 871 |
> |
__int64 t2; |
| 872 |
> |
|
| 873 |
> |
st.wYear = 1970; |
| 874 |
> |
st.wHour = 0; |
| 875 |
> |
st.wMinute = 0; |
| 876 |
> |
st.wSecond = 0; |
| 877 |
> |
st.wMilliseconds = 1; |
| 878 |
> |
|
| 879 |
> |
SystemTimeToFileTime(&st, &ft2); |
| 880 |
> |
li2.LowPart = ft2.dwLowDateTime; |
| 881 |
> |
li2.HighPart = ft2.dwHighDateTime; |
| 882 |
> |
t2 = li2.QuadPart; |
| 883 |
> |
|
| 884 |
> |
GetSystemTimeAsFileTime(&ft); |
| 885 |
> |
li.LowPart = ft.dwLowDateTime; |
| 886 |
> |
li.HighPart = ft.dwHighDateTime; |
| 887 |
> |
t = li.QuadPart; |
| 888 |
> |
t -= t2; // From 1970 |
| 889 |
> |
t /= 10; // In microseconds |
| 890 |
> |
tp->tv_sec = (long)(t / 1000000); |
| 891 |
> |
tp->tv_usec = (long)(t % 1000000); |
| 892 |
> |
return 0; |
| 893 |
> |
} |
| 894 |
> |
|
| 895 |
> |
#endif |
| 896 |
> |
|
| 897 |
> |
double |
| 898 |
|
getTime(void) /* get current time (CPU or real) */ |
| 899 |
|
{ |
| 900 |
|
struct timeval time_now; |